Difference between revisions of "Map Script Format"

From Terranigma Wiki
Jump to navigation Jump to search
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 95: Line 98:
| 0xFC
| 0xFC
| 2  
| 2  
|
| Calls map script #0 which then plays the selected song id
|-
|-
| 0xFD
| 0xFD

Revision as of 11:11, 15 April 2012

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.

For some reason offsets are not directly read but calculated via this code: (don't ask!)

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
Offset Length (Byte) Name
0 2 Map ID


0x02 5 Play SPC data
Offset Length (Byte) Name
0 1 Unknown
1 1 Entry ID?
2 3 SPC data Offset
0x08 variable run sub command
Opcode Argument length (byte) Function
0x00 6
0xFF 0 End of script
0xFC 2 Calls map script #0 which then plays the selected song id
0xFD 4
Offset Length (Byte) Name
0 3 Offset (Unknown)
3 1 Unknown
0xFA ?
0xF9 ?
0xF8 ?
default 2 ?
0x10 4 Load data
Offset Length (Byte) Name
0 1 0x00 - Tiles

0x01 - Map Layer 0

0x02 - Map Layer 1

1 3 Offset of data
0x20 7 Load MapTile/Collision data
Offset Length (Byte) Name
0 1 Unknown
1 1 Type
0x08 0x40
Load collision data Load MapTile data
2 1 Unknown
3 1 Layer ID
4 3 Offset


0x40 6 Set palette for map
Offset Length (Byte) Name
0 1 Pal index
1 1 Unknown
2 1 Changing this value changes the colors
3 3 Offset of palette


0x80 6 Load Tile Data
Offset Length (Byte) Name
0 1 Unknown
1 1 Unknown
2 1 Unknown
3 3 Offset of Tile Data
6 2 Unknown