Map Script Format
Jump to navigation
Jump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.
When the game loads a map it looks at a pointer table at 0x06959C and runs a some kind of script to load the map parts.
There seem to be 1314(check) entries.
This code below is used to convert the ROM to a RAM address.
i.e. when loading map id 0 the first offset is 0x83FF05 which after the code is run turns into 0xA5FF83 (0x25FF83 ROM).
u32 Background::GetAddress() { u32 AdrLow = GetBytei(); u16 AdrHigh = GetWordi(); u8 push = AdrHigh & 0x7F; AdrHigh = push ^ AdrHigh; AdrHigh<<= 1; AdrHigh |= 0x80; AdrHigh |= push; AdrHigh += (((ROMOffset|(1<<23)) & 0xFF0000) >> 8); if( (AdrHigh & 0xFF00) >= 0xC000 ) AdrHigh &= 0xFF7F; return (AdrHigh<<8)|AdrLow; }
Map script #0
This map script is used to select a song to be played by the 08 FC command
Commands
Opcode | Argument length (byte) | Function | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
0x00 | 2 | Run map script
| ||||||||||||||||||||||||
0x02 | 5 | Play SPC data
| ||||||||||||||||||||||||
0x04 | 5 | Load background using 2Bit format. Only used by map ID 0x106.
| ||||||||||||||||||||||||
0x08 | variable | Run sub command
| ||||||||||||||||||||||||
0x10 | 4 | Load map data
| ||||||||||||||||||||||||
0x20 | 7 | Load collision data or tile maps
| ||||||||||||||||||||||||
0x40 | 6 | Load palette
| ||||||||||||||||||||||||
0x80 | 9 | Load tile data
|