-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddressConverter.js
65 lines (62 loc) · 2.64 KB
/
addressConverter.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
function AddressSectionMapper(sections) {
this.sections = sections;
this.sectionContainsAddress = function(section, address) {
if(section.off_beg <= address && address <= section.off_end) {
return true;
}
return false;
};
this.map = function(address) {
for (let section of sections) {
if(this.sectionContainsAddress(section, address)) {
return address - section.delta;
}
}
return null;
};
this.inverseMap = function(address) {
for (let section of sections) {
mappedAddress = address + section.delta
if(this.sectionContainsAddress(section, mappedAddress)) {
return mappedAddress;
}
}
return null;
};
}
// Fortune Street Virtual to Fortune Street File
const fsvirt_to_fsfile = new AddressSectionMapper([
{off_beg: 0x80004000, off_end: 0x80006720, delta: 0x80003f00},
{off_beg: 0x80006720, off_end: 0x80006c80, delta: 0x7fbfda40},
{off_beg: 0x80006c80, off_end: 0x80007480, delta: 0x7fbfda40},
{off_beg: 0x80007480, off_end: 0x8040d940, delta: 0x80004c60},
{off_beg: 0x8040d940, off_end: 0x8040de80, delta: 0x80003f00},
{off_beg: 0x8040de80, off_end: 0x8040dea0, delta: 0x80003f00},
{off_beg: 0x8040dec0, off_end: 0x8044ea60, delta: 0x80003f20},
{off_beg: 0x8044ea60, off_end: 0x804ac680, delta: 0x80003f20},
{off_beg: 0x80814a80, off_end: 0x808171c0, delta: 0x8036c320},
{off_beg: 0x80818da0, off_end: 0x8081ede0, delta: 0x8036df00}
]);
// Boom Street Virtual to Boom Street File
const bsvirt_to_bsfile = new AddressSectionMapper([
{off_beg: 0x80004000, off_end: 0x80006720, delta: 0x80003f00},
{off_beg: 0x80006720, off_end: 0x80006c80, delta: 0x7fbfda00},
{off_beg: 0x80006c80, off_end: 0x80007480, delta: 0x7fbfda00},
{off_beg: 0x80007480, off_end: 0x8040d980, delta: 0x80004c60},
{off_beg: 0x8040d980, off_end: 0x8040dec0, delta: 0x80003f00},
{off_beg: 0x8040dec0, off_end: 0x8040dee0, delta: 0x80003f00},
{off_beg: 0x8040df00, off_end: 0x8044ec00, delta: 0x80003f20},
{off_beg: 0x8044ec00, off_end: 0x804ac820, delta: 0x80003f20},
{off_beg: 0x80814c80, off_end: 0x808173c0, delta: 0x8036c380},
{off_beg: 0x80818fa0, off_end: 0x8081efe0, delta: 0x8036df60}
]);
// Boom Street Virtual to Fortune Street Virtual
const bsvirt_to_fsvirt = new AddressSectionMapper([
{off_beg: 0x80000100, off_end: 0x8007a283, delta: 0x0},
{off_beg: 0x8007a2f4, off_end: 0x80268717, delta: 0x54},
{off_beg: 0x80268720, off_end: 0x8040d97b, delta: 0x50},
{off_beg: 0x8040d980, off_end: 0x8041027f, delta: 0x40},
{off_beg: 0x804105f0, off_end: 0x8044ebe7, delta: 0x188},
{off_beg: 0x8044ec00, off_end: 0x804ac804, delta: 0x1A0},
{off_beg: 0x804ac880, off_end: 0x8081f013, delta: 0x200}
]);