1
|
|
|
import { SaveFileService } from './../../savefile.service'; |
2
|
|
|
|
3
|
|
|
export class MapConnData { |
4
|
|
|
constructor(saveFile?: SaveFileService, offset?: number) { |
5
|
|
|
if (saveFile !== undefined) |
6
|
|
|
this.load(saveFile as SaveFileService, offset as number); |
7
|
|
|
} |
8
|
|
|
|
9
|
|
|
public load(saveFile: SaveFileService, offset: number) { |
10
|
|
|
const it = saveFile.iterator.offsetTo(offset); |
11
|
|
|
|
12
|
|
|
const mapPtr = it.getByte(); |
13
|
|
|
this.stripSrc = it.getWord(); |
14
|
|
|
this.stripDest = it.getWord(); |
15
|
|
|
this.stripWidth = it.getByte(); |
16
|
|
|
const width = it.getByte(); |
17
|
|
|
this.yAlign = it.getByte(); |
18
|
|
|
this.xAlign = it.getByte(); |
19
|
|
|
this.viewPtr = it.getWord(0, true); |
20
|
|
|
|
21
|
|
|
this.map = `${mapPtr.toString(16).padStart(2, "0").toUpperCase()}_${width}`; |
22
|
|
|
} |
23
|
|
|
|
24
|
|
|
public save(saveFile: SaveFileService, offset: number) { |
25
|
|
|
const it = saveFile.iterator.offsetTo(offset); |
26
|
|
|
const map = this.map.split("_"); |
27
|
|
|
|
28
|
|
|
it.setByte(parseInt(map[0], 16)); |
29
|
|
|
it.setWord(this.stripSrc); |
30
|
|
|
it.setWord(this.stripDest); |
31
|
|
|
it.setByte(this.stripWidth); |
32
|
|
|
it.setByte(parseInt(map[1])); |
33
|
|
|
it.setByte(this.yAlign); |
34
|
|
|
it.setByte(this.xAlign); |
35
|
|
|
it.setWord(this.viewPtr, 0, true); |
36
|
|
|
} |
37
|
|
|
|
38
|
|
|
// Connected Map |
39
|
|
|
public map: string = ""; |
40
|
|
|
|
41
|
|
|
// Pointer to upper left corner of map without adjustment for X position |
42
|
|
|
public viewPtr: number = 0; |
43
|
|
|
|
44
|
|
|
// Strip |
45
|
|
|
public stripSrc: number = 0; |
46
|
|
|
public stripDest: number = 0; |
47
|
|
|
public stripWidth: number = 0; |
48
|
|
|
|
49
|
|
|
// Strip Alignment |
50
|
|
|
public yAlign: number = 0; |
51
|
|
|
public xAlign: number = 0; |
52
|
|
|
} |
53
|
|
|
|