This is an old revision of the document!
_______________________________________ Room index | ____________________________________ Area index | | _________________________________ X position (of top left corner) on the map | | | ______________________________ Y position (of top left corner) on the map | | | | ___________________________ Room width (in units of screens = 16 blocks = 256 pixels) | | | | | ________________________ Room height (in units of screens = 16 blocks = 256 pixels) | | | | | | _____________________ Up scroller | | | | | | | __________________ Down scroller | | | | | | | | _______________ CRE bitset | | | | | | | | | ____________ Door list pointer | | | | | | | | | | _______ Optional event headers | | | | | | | | | | | _ Mandatory event header, specifies that the default state follows this room header | | | | | | | | | | | | ii aa xx yy ww hh uu dd cc dddd [...] E5E6
Room headers define rooms, they exist in bank $8F and room header pointers are what SMILE displays as a dropdown box for room selection.
They are variable length (due to the optional event headers) with E5E6
as an effective terminator.
The event headers define conditions to load alternative state headers, they are checked in order and the first event header whose check passes is to determine the state header to load. Due to this, event headers must be specified in backwards chronological order.
Notes:
1 | Disable layer 1 during door transitions into and out of the room |
2 | Reload the CRE |
4 | Load extra large tileset |
____________ Event | _______ Event parameters | | _ State header pointer | | | eeee [...] ssss
Events are two-byte pointers to code in bank $8F that may have parameters depending on the event in question. If the check defined in the event is passed, the state header pointer for that event is used to load the room. The only exception is event $E5E6, the default event, which doesn't have a state header pointer (the default state header simply follows this event header instead).
_________________ First door pointer (door BTS 0) | ____________ Second door pointer (door BTS 1) | | _______ Other door pointerd (door BTS 2+) | | | aaaa bbbb [...]
Door lists are a list of door pointers that can be used in a room, they exist in bank $8F. They are variable length with no terminator, and are indexed by door BTS (thus, there is an effective maximum of 128 door pointers).
The door pointers themselves are two-byte pointers to door headers in bank $83.
_____________________________ Destination room header pointer (bank $8F) | ________________________ Elevator properties | | _____________________ Orientation | | | __________________ X position low byte | | | | _______________ Y position low byte | | | | | ____________ X position high byte | | | | | | _________ Y position high byte | | | | | | | ______ Distance from door to spawn Samus | | | | | | | | _ Custom door ASM to execute (bank $8F) | | | | | | | | | rrrr ee oo xx yy XX YY dddd aaaa
Door headers define doors, they exist in bank $83 and have a fixed length of 12 bytes. The door ASM can execute any arbitrary ASM and is often used to set scroll values for the new room where the door would normally be hidden inside a red scroll.
The elevator properties are as follows:
0x80 | Door is an elevator |
0x40 | Switch map to new area |
0x0i | Marks elevator i as used |
The orientation values are as follows:
0 | Right |
1 | Left |
2 | Down |
3 | Up |
4+ | Door spawns a closing door cap |
_______________________________________________________________ Level data | ________________________________________________________ Tileset | | _____________________________________________________ Music data index | | | __________________________________________________ Music track | | | | _______________________________________________ FX ($83) | | | | | __________________________________________ Enemy population ($A1) | | | | | | _____________________________________ Enemy set ($B4) | | | | | | | ________________________________ Layer 2 scroll X | | | | | | | | _____________________________ Layer 2 scroll Y | | | | | | | | | ________________________ Scroll | | | | | | | | | | __________________ Special x-ray blocks | | | | | | | | | | | ______________ Main ASM | | | | | | | | | | | | _________ PLM population | | | | | | | | | | | | | ____ Library background | | | | | | | | | | | | | | _ Setup ASM | | | | | | | | | | | | | | | llllll tt MM mm ffff eeee EEEE xx yy ssss xxxx AAAA pppp bbbb aaaa
State headers define the parts of rooms that can change due to different events.
Notes:
sssssssb
b
= 1, then the library background is used, otherwise custom layer 2 (defined in level data) is useds
= 0 is a special case that depends on b
b
= 0 (custom layer 2), then layer 2 and layer 1 scroll together at the same speed (like an extension of layer 1)b
= 1 (library background), then layer 2 does not scroll at all (static image background)s
!= 0), layer 2 scroll speed = (layer 1 scroll speed) * (s
/ 0x80)_______ Block type | ___ Y flip | | __ X flip | || _ Block number | ||| ttttyxnnnnnnnnnn ; First block ttttyxnnnnnnnnnn ; Second block [...] ; Other blocks ttttyxnnnnnnnnnn ; Last block bbbbbbbb ; First block BTS bbbbbbbb ; Second block BTS [...] bbbbbbbb ; Last block BTS Optional: 0000yxnnnnnnnnnn ; First block layer 2 0000yxnnnnnnnnnn ; Second block layer 2 [...] ; Other blocks layer 2 0000yxnnnnnnnnnn ; Last block layer 2
Level data is defined by specifying data for each 16px x 16px block for every block in the room. This data is split into layer 1 blocks, BTS and optionally layer 2 blocks. Layer 1/2 are two bytes per block and BTS is one byte per block; layer 1 data is followed by BTS, followed by layer 2 (if used) in that order. Level data is compressed in ROM.
Layer 1 blocks uses the binary format shown above where:
Layer 2 blocks use the same format, except that they have no block type (they are padded with zeros instead).
BTS data further specifies the type of a block, depending on the primary block type used, e.g. different slope types.
__________________________________________ Door pointer | _____________________________________ Base Y position | | ________________________________ Target Y position | | | ___________________________ Y velocity | | | | ______________________ Timer | | | | | ___________________ Type (foreground layer 3) | | | | | | ________________ A | | | | | | | _____________ B | | | | | | | | __________ C | | | | | | | | | _______ Palette FX bitset | | | | | | | | | | ____ Animated tiles bitset | | | | | | | | | | | _ Palette blend | | | | | | | | | | | | dddd,bbbb,tttt,vvvv,tt,ff,AA,BB,CC,pp,aa,bb ; First FX entry dddd,bbbb,tttt,vvvv,tt,ff,AA,BB,CC,pp,aa,bb ; Second FX entry [...] ; Other FX entries 0000,bbbb,tttt,vvvv,tt,ff,AA,BB,CC,pp,aa,bb ; Last FX entry
OR
FFFF ; No FX
____________________________________ Enemy ID | _______________________________ X position | | __________________________ Y position | | | _____________________ Initialisation parameter (orientation in SMILE) | | | | ________________ Properties (special in SMILE) | | | | | ___________ Extra properties (special graphics bitset in SMILE) | | | | | | ______ General purpose parameter (speed in SMILE) | | | | | | | _ General purpose parameter (speed2 in SMILE) | | | | | | | | iiii xxxx yyyy oooo pppp gggg aaaa bbbb ; First enemy iiii xxxx yyyy oooo pppp gggg aaaa bbbb ; Second enemy [...] ; Other enemies FFFF ; Terminator nnnn ; Number of enemy deaths needed to clear current room
______ Enemy ID | _ Palette index | | iiii pppp ; First enemy iiii pppp ; Second enemy [...] ; Other enemies FFFF ; Terminator
_______ First scroll | ____ Second scroll | | _ Other scrolls | | | aa bb [...]
_______ X position | ____ Y position | | _ Block number | | | xx yy nnnn ; First x-ray block xx yy nnnn ; Second x-ray block [...] ; Other x-ray blocks 0000 ; Terminator
____________ PLM ID | _______ X position | | ____ Y position | | | _ Parameter | | | | iiii xx yy pppp ; First PLM iiii xx yy pppp ; Second PLM [...] ; Other PLMs 0000 ; Terminator
______ Type | _ Parameters | | tttt [...] ; First background command tttt [...] ; Second background command [...] ; Other background commands 0000 ; Terminator
The list of types used in Super Metroid is as follows:
Type | Parameters | Description |
---|---|---|
2 | ssssss dddd nnnn | Transfer n bytes from s to d in VRAM |
4 | ssssss dddd | Decompress s to d in bank $7E |
6 | Clear layer 3 | |
8 | ssssss dddd nnnn | Transfer n bytes from s to d in VRAM and set BG3 tiles base address = $2000 |
Ah | Clear layer 2 | |
Ch | Clear Kraid's layer 2 | |
Eh | DDDD ssssss dddd nnnn | Transfer n bytes from s to d in VRAM if the current door pointer = D |