Difference between revisions of "Map Script Format"
Jump to navigation
Jump to search
m (command 0x04 updated) |
|||
(6 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
There seem to be 1314(check) entries. | 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). | i.e. when loading map id 0 the first offset is 0x83FF05 which after the code is run turns into 0xA5FF83 (0x25FF83 ROM). | ||
Line 26: | Line 26: | ||
return (AdrHigh<<8)|AdrLow; | 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 == | == Commands == | ||
Line 68: | Line 71: | ||
| 1 | | 1 | ||
| 1 | | 1 | ||
| | | Track ID | ||
|- | |- | ||
| 2 | | 2 | ||
Line 74: | Line 77: | ||
| SPC data Offset | | SPC data Offset | ||
|} | |} | ||
|- | |- | ||
| | | 0x04 | ||
| | | 5 | ||
| Load background using 2Bit format. Only used by map ID 0x106. | |||
| | |||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 108: | Line 91: | ||
| 0 | | 0 | ||
| 3 | | 3 | ||
| Offset | | Offset | ||
|- | |- | ||
| 3 | | 3 | ||
| 1 | | 1 | ||
| Unknown | | Unknown | ||
|- | |||
| 4 | |||
| 1 | |||
| Layer | |||
|} | |} | ||
|- | |||
| 0x08 | |||
| variable | |||
| Run sub command | |||
{| class="wikitable" | |||
|- | |||
! Opcode | |||
! Argument length (byte) | |||
! Function | |||
|- | |||
| 0xF8 | |||
| 1 | |||
| Return from sub function | |||
|- | |||
| 0xF9 | |||
| 2 | |||
| Call map script | |||
|- | |- | ||
| 0xFA | | 0xFA | ||
| | | 2 | ||
| | | Push map script address | ||
|- | |||
| 0xFC | |||
| 2 | |||
| Calls map script #0 which then plays the selected song id | |||
|- | |- | ||
| | | 0xFD | ||
| | | 4 | ||
| | | Call map script when flag is true | ||
|- | |- | ||
| | | 0xFE | ||
| | | 2 | ||
| | | Return from script | ||
|- | |- | ||
| | | 0xFF | ||
| | | 0 | ||
| | | End of script | ||
|- | |- | ||
|} | |} | ||
Line 136: | Line 145: | ||
| 0x10 | | 0x10 | ||
| 4 | | 4 | ||
| Load data | | Load map data | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 145: | Line 154: | ||
| 0 | | 0 | ||
| 1 | | 1 | ||
| | | 0x01 - Map layer 0 | ||
0x02 - Map layer 1 | |||
0x02 - Map | |||
|- | |- | ||
| 1 | | 1 | ||
| 3 | | 3 | ||
| | | Address | ||
|} | |} | ||
Line 159: | Line 166: | ||
| 0x20 | | 0x20 | ||
| 7 | | 7 | ||
| Load | | Load collision data or tile maps | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 168: | Line 175: | ||
| 0 | | 0 | ||
| 1 | | 1 | ||
| | | Seek | ||
|- | |||
| 1 | |||
| 1 | |||
| Size | |||
|- | |- | ||
| 2 | |||
| 1 | | 1 | ||
| Offset | |||
|- | |||
| 3 | |||
| 1 | | 1 | ||
| | | Layer ID | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
! | ! 0x80 set | ||
! | ! 0x80 clear | ||
|- | |- | ||
| | | Collision data | ||
| | | Map tiles | ||
|} | |} | ||
|- | |- | ||
| 4 | | 4 | ||
| 3 | | 3 | ||
| | | Address | ||
|} | |} | ||
Line 201: | Line 207: | ||
| 0x40 | | 0x40 | ||
| 6 | | 6 | ||
| | | Load palette | ||
{| class="wikitable" | {| class="wikitable" | ||
Line 215: | Line 221: | ||
| 1 | | 1 | ||
| 1 | | 1 | ||
| | | Pal size | ||
|- | |- | ||
| 2 | | 2 | ||
| 1 | | 1 | ||
| | | Pal offset | ||
|- | |- | ||
| 3 | | 3 | ||
| 3 | | 3 | ||
| | | Address | ||
|} | |} | ||
Line 229: | Line 235: | ||
|- | |- | ||
| 0x80 | | 0x80 | ||
| | | 9 | ||
| Load | | Load tile data | ||
{| class="wikitable" | {| class="wikitable" | ||
|- | |- | ||
Line 240: | Line 245: | ||
| 0 | | 0 | ||
| 1 | | 1 | ||
| | | Seek | ||
|- | |- | ||
| 1 | | 1 | ||
| 1 | | 1 | ||
| | | Size | ||
|- | |- | ||
| 2 | | 2 | ||
| 1 | | 1 | ||
| | | Tile mode | ||
|- | |- | ||
| 3 | | 3 | ||
| 3 | | 3 | ||
| | | Address | ||
|- | |- | ||
| 6 | | 6 | ||
| 2 | | 2 | ||
| Bank | |||
|- | |||
| 7 | |||
| 1 | |||
| Unknown | | Unknown | ||
|- | |- |
Latest revision as of 18:27, 23 February 2016
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
|