User Tools

Site Tools


super:technical_information:data_structures

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
super:technical_information:data_structures [2018/12/02 21:49] – [Library background] So the bot doesn't see this smileuser96super:technical_information:data_structures [2024/03/22 16:09] (current) – [Door header] p.jboy
Line 1: Line 1:
 ====== Room header ====== ====== Room header ======
-   _______________________________________ Room index +   ____________________________________ Room index 
-  |   ____________________________________ Area index +  |   _________________________________ Area index 
-  |  |   _________________________________ X position (of top left corner) on the map +  |  |   ______________________________ X position (of top left corner) on the map 
-  |  |  |   ______________________________ Y 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 width (in units of screens = 16 blocks = 256 pixels) 
-  |  |  |  |  |   ________________________ Room height (in units of screens = 16 blocks = 256 pixels) +  |  |  |  |  |   _____________________ Room height (in units of screens = 16 blocks = 256 pixels) 
-  |  |  |  |  |  |   _____________________ Up scroller +  |  |  |  |  |  |   __________________ Up scroller 
-  |  |  |  |  |  |  |   __________________ Down scroller +  |  |  |  |  |  |  |   _______________ Down scroller 
-  |  |  |  |  |  |  |  |   _______________ CRE bitset +  |  |  |  |  |  |  |  |   ____________ CRE bitset 
-  |  |  |  |  |  |  |  |  |   ____________ Door list pointer +  |  |  |  |  |  |  |  |  |   _________ Door list pointer 
-  |  |  |  |  |  |  |  |  |  |     _______ Optional event headers +  |  |  |  |  |  |  |  |  |  |     ____ State conditions list 
-  |  |  |  |  |  |  |  |  |  |    |      _ Mandatory event header, specifies that the default state follows this room header +  |  |  |  |  |  |  |  |  |  |    | 
-  |  |  |  |  |  |  |  |  |  |    |     +  |  |  |  |  |  |  |  |  |  |    | 
-  ii aa xx yy ww hh uu dd cc dddd [...] E5E6+  ii aa xx yy ww hh uu dd cc dddd [...]
  
 Room headers define rooms, they exist in bank $8F and room header pointers are what SMILE displays as a dropdown box for room selection. 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.+They are variable length (due to the event header list) with ''E5E6'' as 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. +The **state conditions list** defines conditions to load alternative state headers, they are checked //in order// and the first state condition whose check passes determines the state header to load. 
-Due to this, event headers must be specified in backwards chronological order.+Due to this, state conditions must be specified in backwards chronological order.
  
 <hidden **Area indices**> <hidden **Area indices**>
Line 31: Line 31:
 | 7 | Debug | | 7 | Debug |
 </hidden> </hidden>
 + 
  
 Notes: Notes:
   * The **room index** is almost unused, aside from some specific checks to do with atmospheric graphics in some areas.   * The **room index** is almost unused, aside from some specific checks to do with atmospheric graphics in some areas.
   * The **room width** may not exceed 15 due to the way block collision calculations are implemented   * The **room width** may not exceed 15 due to the way block collision calculations are implemented
-  * **Room width** * **room height** may not exceed 0x50 due to memory constraints +  * **Room width** * **room height** may not exceed 50 due to memory constraints 
-  * The **up scroller** defines the threshold Y position that Samus needs to exceed (relative to the screen) for the screen to start scolling downwards when the camera is at the top of the room +  * The **up scroller** defines the threshold Y position that Samus needs to exceed (relative to the screen) for the screen to start scrolling downwards when the camera is at the top of the room 
-  * The **down scroller** defines the threshold Y position that Samus needs to exceed (relative to the screen) for the screen to start scolling upwards when the camera is at the bottom of the room+  * The **down scroller** defines the threshold Y position that Samus needs to exceed (relative to the screen) for the screen to start scrolling upwards when the camera is at the bottom of the room
   * The **CRE bitset** defines some flags that affect how the CRE is loaded during door transitions:   * The **CRE bitset** defines some flags that affect how the CRE is loaded during door transitions:
  
Line 44: Line 45:
 | 4 | Load extra large tileset | | 4 | Load extra large tileset |
  
-===== Event header ===== +===== State conditions list ===== 
-   ____________ Event +   ______________ State condition 
-  |     _______ Event parameters +  |     _________ State condition parameters 
-  |    |      State header pointer+  |    |      ___ State header pointer
   |    |     |   |    |     |
-  eeee [...] ssss+  eeee [...] ssss ; First state condition 
 +  eeee [...] ssss ; Second state condition 
 +  [...]           ; Other state conditions 
 +  E5E6            ; Default state condition (terminator)
  
-**Events** are two-byte pointers to code in bank $8F that may have parameters depending on the event in question+**State conditions** are two-byte pointers to code in bank $8F that may have parameters. 
-If the check defined in the event is passed, the state header pointer for that event is used to load the room. +If the check defined in the **state conditions** is passed, the **state header pointer** in that state condition header 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).+The only exception is state condition $E5E6, the default, which doesn't have a **state header pointer** (the default state header simply follows this state condition header instead).
  
-<hidden List of events used in Super Metroid> +<hidden List of state conditions used in Super Metroid> 
-Event Event parameters ^ Description ^+Condition Parameters ^ Description ^
 | $E5E6 | | Default | | $E5E6 | | Default |
 | $E5EB | ''dddd'' | Check passes if the current door pointer = ''d'' | | $E5EB | ''dddd'' | Check passes if the current door pointer = ''d'' |
Line 69: Line 73:
 Event numbers are given as follows: Event numbers are given as follows:
  
-| 00 | Zebes is awake | +| 0 | Zebes is awake | 
-| 01 | Shitroid ate sidehopper | +| 1 | Shitroid ate sidehopper | 
-| 02 | Mother Brain's glass is broken | +| 2 | Mother Brain's glass is broken | 
-| 03 | Zebetite 1 is destroyed | +| 3 | Zebetite 1 is destroyed | 
-| 04 | Zebetite 2 is destroyed | +| 4 | Zebetite 2 is destroyed | 
-| 05 | Zebetite 3 is destroyed | +| 5 | Zebetite 3 is destroyed | 
-| 06 | Phantoon statue is grey | +| 6 | Phantoon statue is grey | 
-| 07 | Ridley statue is grey | +| 7 | Ridley statue is grey | 
-| 08 | Draygon statue is grey | +| 8 | Draygon statue is grey | 
-| 09 | Kraid statue is grey | +| 9 | Kraid statue is grey | 
-0A | Entrance to Tourian is unlocked | +Ah | Entrance to Tourian is unlocked | 
-0B | Maridia noobtube is broken | +Bh | Maridia noobtube is broken | 
-0C | Lower Norfair chozo has lowered the acid | +Ch | Lower Norfair chozo has lowered the acid | 
-0D | Shaktool cleared a path | +Dh | Shaktool cleared a path | 
-0E | Zebes timebomb set | +Eh | Zebes timebomb set | 
-0F | Critters escaped | +Fh | Critters escaped | 
-10 | 1st Metroid hall cleared | +10h | 1st Metroid hall cleared | 
-11 | 1st Metroid shaft cleared | +11h | 1st Metroid shaft cleared | 
-12 | 2nd Metroid hall cleared | +12h | 2nd Metroid hall cleared | 
-13 | 2nd Metroid shaft cleared | +13h | 2nd Metroid shaft cleared | 
-14 | //Unused// | +14h | //Unused// | 
-15 | Outran speed booster lavaquake |+15h | Outran speed booster lavaquake |
  
 Boss bits are given as follows: Boss bits are given as follows:
Line 98: Line 102:
 | 4 | Area torizo (Bomb Torizo, Golden Torizo) | | 4 | Area torizo (Bomb Torizo, Golden Torizo) |
 </hidden> </hidden>
 + 
 ===== Door list ===== ===== Door list =====
    _________________ First door pointer (door BTS 0)    _________________ First door pointer (door BTS 0)
   |     ____________ Second door pointer (door BTS 1)   |     ____________ Second door pointer (door BTS 1)
-  |    |     _______ Other door pointerd (door BTS 2+)+  |    |     _______ Other door pointers (door BTS 2+)
   |    |    |   |    |    |
   aaaa bbbb [...]   aaaa bbbb [...]
Line 115: Line 119:
    _____________________________ Destination room header pointer (bank $8F)    _____________________________ Destination room header pointer (bank $8F)
   |     ________________________ Elevator properties   |     ________________________ Elevator properties
-  |    |   _____________________ Orientation +  |    |   _____________________ Direction 
-  |    |  |   __________________ X position low byte +  |    |  |   __________________ Doorcap X position in blocks 
-  |    |  |  |   _______________ Y position low byte +  |    |  |  |   _______________ Doorcap Y position in blocks 
-  |    |  |  |  |   ____________ X position high byte +  |    |  |  |  |   ____________ X screen 
-  |    |  |  |  |  |   _________ Y position high byte+  |    |  |  |  |  |   _________ Y screen
   |    |  |  |  |  |  |   ______ Distance from door to spawn Samus   |    |  |  |  |  |  |   ______ Distance from door to spawn Samus
   |    |  |  |  |  |  |  |     _ Custom door ASM to execute (bank $8F)   |    |  |  |  |  |  |  |     _ Custom door ASM to execute (bank $8F)
Line 127: Line 131:
 Door headers define doors, they exist in bank $83 and have a fixed length of 12 bytes. 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 **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.
 +If the **distance from door to spawn Samus** is negative (8000h..FFFFh), the standard value of 0x00C8 is used for horizontal doors or 0x0180 for vertical doors.
  
 The **elevator properties** are as follows: The **elevator properties** are as follows:
Line 132: Line 137:
 | 0x80 | Door is an elevator | | 0x80 | Door is an elevator |
 | 0x40 | Switch map to new area | | 0x40 | Switch map to new area |
-| 0x0i | Marks elevator i as used |+| 0x0i | Marks elevator index i as used (for debug mode) |
  
 The **orientation** values are as follows: The **orientation** values are as follows:
Line 152: Line 157:
   |      |  |  |  |    |    |     ________________________________ Layer 2 scroll X   |      |  |  |  |    |    |     ________________________________ Layer 2 scroll X
   |      |  |  |  |    |    |    |   _____________________________ Layer 2 scroll Y   |      |  |  |  |    |    |    |   _____________________________ Layer 2 scroll Y
-  |      |  |  |  |    |    |    |  |     ________________________ Scroll +  |      |  |  |  |    |    |    |  |   __________________________ Scroll 
-  |      |  |  |  |    |    |    |  |         __________________ Special x-ray blocks +  |      |  |  |  |    |    |    |  |      _____________________ Special x-ray blocks 
-  |      |  |  |  |    |    |    |  |    |    |     ______________ Main ASM (FX2 in old SMILE) +  |      |  |  |  |    |    |    |  |  |    |     ________________ Main ASM (FX2 in old SMILE) 
-  |      |  |  |  |    |    |    |  |    |    |    |     _________ PLM population +  |      |  |  |  |    |    |    |  |  |    |    |     ___________ PLM population 
-  |      |  |  |  |    |    |    |  |    |    |    |    |     ____ Library background +  |      |  |  |  |    |    |    |  |  |    |    |    |     ______ Library background 
-  |      |  |  |  |    |    |    |  |    |    |    |    |    |   _ Setup ASM (Layer1_2 in old SMILE) +  |      |  |  |  |    |    |    |  |  |    |    |    |    |     _ Setup ASM (Layer1_2 in old SMILE) 
-  |      |  |  |  |    |    |    |  |    |    |    |    |    |  |+  |      |  |  |  |    |    |    |  |  |    |    |    |    |    |
   llllll tt MM mm ffff eeee EEEE xx yy ssss xxxx AAAA pppp bbbb aaaa   llllll tt MM mm ffff eeee EEEE xx yy ssss xxxx AAAA pppp bbbb aaaa
  
Line 233: Line 238:
 | 7 | Song 2 | | 7 | Song 2 |
 </hidden> </hidden>
 + 
  
 Notes: Notes:
Line 260: Line 266:
 ==== Level data ==== ==== Level data ====
   ssssssssssssssss ; Size of decompressed layer 1 data (2 x the number of blocks)   ssssssssssssssss ; Size of decompressed layer 1 data (2 x the number of blocks)
 +  
    _______ Block type    _______ Block type
   |    ___ Y flip   |    ___ Y flip
Line 269: Line 275:
   ttttyxnnnnnnnnnn ; Second block   ttttyxnnnnnnnnnn ; Second block
   [...]            ; Other blocks   [...]            ; Other blocks
-  ttttyxnnnnnnnnnn ; Last block +  
   bbbbbbbb         ; First block BTS   bbbbbbbb         ; First block BTS
   bbbbbbbb         ; Second block BTS   bbbbbbbb         ; Second block BTS
   [...]   [...]
-  bbbbbbbb         ; Last block BTS +  
   Optional:   Optional:
   0000yxnnnnnnnnnn ; First block layer 2   0000yxnnnnnnnnnn ; First block layer 2
   0000yxnnnnnnnnnn ; Second block layer 2   0000yxnnnnnnnnnn ; Second block layer 2
   [...]            ; Other blocks layer 2   [...]            ; Other blocks layer 2
-  0000yxnnnnnnnnnn ; Last block layer 2 
  
 Level data is defined by specifying data for each 16px x 16px block in the room. Level data is defined by specifying data for each 16px x 16px block in the room.
Line 313: Line 316:
 | ::: | ::: | 2 || Air only. Air spike (10h damage) | | ::: | ::: | 2 || Air only. Air spike (10h damage) |
 | ::: | ::: | 3 || Solid only. Draygon's broken turret (10h damage) | | ::: | ::: | 3 || Solid only. Draygon's broken turret (10h damage) |
 +| ::: | ::: | Eh || Solid only. X-rayable block (used in Blue Brinstar boulder room) |
 | ::: | ::: | Fh || Solid only. Enemy breakable block (used in Shaktool's room) | | ::: | ::: | Fh || Solid only. Enemy breakable block (used in Shaktool's room) |
 | 3 / Bh | Special | 0 || 1x1 respawning crumble block | | 3 / Bh | Special | 0 || 1x1 respawning crumble block |
Line 343: Line 347:
 | ::: | ::: | ::: | 82h | Respawning speed block, slower crumble animation | | ::: | ::: | ::: | 82h | Respawning speed block, slower crumble animation |
 | ::: | ::: | ::: | 83h | Speed block, slower crumble animation | | ::: | ::: | ::: | 83h | Speed block, slower crumble animation |
-| ::: | ::: | ::: | 84h | Respawning speed block (used by dechora pit) |+| ::: | ::: | ::: | 84h | Respawning speed block (used by dachora pit) |
 | ::: | ::: | ::: | 85h | Speed boost block | | ::: | ::: | ::: | 85h | Speed boost block |
 | ::: | ::: | Norfair | 83h | Lower Norfair chozo hand trigger | | ::: | ::: | Norfair | 83h | Lower Norfair chozo hand trigger |
Line 372: Line 376:
 | ::: | ::: | 9 || Power bomb block | | ::: | ::: | 9 || Power bomb block |
 | ::: | ::: | Ah || Respawning super missile block | | ::: | ::: | Ah || Respawning super missile block |
-| ::: | ::: | Bh || Super missile block  |+| ::: | ::: | Bh || Super missile block 
 +| ::: | ::: | Ch || Fake super missile block (solid block but shows super missile block when x-rayed) | 
 +| ::: | ::: | Dh || Fake super missile block | 
 +| ::: | ::: | Eh || Fake super missile block | 
 +| ::: | ::: | Fh || Fake super missile block |
 | ::: | ::: | 10h || Gate blocks | | ::: | ::: | 10h || Gate blocks |
 | ::: | ::: | 40h || Blue door facing left | | ::: | ::: | 40h || Blue door facing left |
Line 389: Line 397:
 | ::: | ::: | 4Dh || Right orange gate trigger | | ::: | ::: | 4Dh || Right orange gate trigger |
 | ::: | ::: | 4Fh || Critters escape block | | ::: | ::: | 4Fh || Critters escape block |
 +| Eh | Grapple block | 0 || Generic grapple block |
 +| ::: | ::: | 1 || Respawning crumbling grapple block |
 +| ::: | ::: | 2 || Non-respawning crumbling grapple block |
 +| ::: | ::: | 80h+ || Grapple-through block |
 </hidden> </hidden>
 + 
 ==== FX ==== ==== FX ====
    __________________________________________ Door pointer    __________________________________________ Door pointer
Line 465: Line 477:
 | 80h | Small tide (liquid fluctuates up and down) | | 80h | Small tide (liquid fluctuates up and down) |
 </hidden> </hidden>
 + 
 ==== Enemy population ==== ==== Enemy population ====
    ____________________________________ Enemy ID    ____________________________________ Enemy ID
   |     _______________________________ X position   |     _______________________________ X position
   |    |     __________________________ Y position   |    |     __________________________ Y position
-  |    |    |     _____________________ Initialisation parameter (orientation in SMILE)+  |    |    |     _____________________ Initialisation parameter (orientation in old SMILE, tilemaps in SMILE RF)
   |    |    |    |     ________________ Properties (special in SMILE)   |    |    |    |     ________________ Properties (special in SMILE)
-  |    |    |    |    |     ___________ Extra properties (special graphics bitset in SMILE)+  |    |    |    |    |     ___________ Extra properties (special GFX bitset in SMILE, graphics in SMILE RF)
   |    |    |    |    |    |     ______ General purpose parameter (speed in SMILE)   |    |    |    |    |    |     ______ General purpose parameter (speed in SMILE)
-  |    |    |    |    |    |    |     _ General purpose parameter (speed2 in SMILE)+  |    |    |    |    |    |    |     _ General purpose parameter (speed 2 in SMILE)
   |    |    |    |    |    |    |    |   |    |    |    |    |    |    |    |
   iiii xxxx yyyy oooo pppp gggg aaaa bbbb ; First enemy   iiii xxxx yyyy oooo pppp gggg aaaa bbbb ; First enemy
Line 480: Line 492:
   [...]                                   ; Other enemies   [...]                                   ; Other enemies
   FFFF                                    ; Terminator   FFFF                                    ; Terminator
-  nnnn                                    ; Number of enemy deaths needed to clear current room+  nn                                      ; Number of enemy deaths needed to clear current room 
 + 
 +Enemy population defines the placement of enemies, as well as some generic and enemy specific properties. 
 +They're stored in bank $A1 with each enemy being 16 bytes, plus a 3 byte overhead. 
 +The **initialisation parameter** is overwritten by generic enemy routines and so is often only used during enemy initialisation, the other two **general purpose parameters** do not have this restriction. 
 + 
 +The **properties** are as follows: 
 + 
 +| 8000h | Hitbox solid to Samus | 
 +| 4000h | Respawns if killed | 
 +| 2000h | Process instructions | 
 +| 1000h | Block plasma beam | 
 +| 800h | Process whilst off-screen | 
 +| 400h | Intangible | 
 +| 200h | Delete | 
 +| 100h | Invisible | 
 + 
 +The **extra properties** are as follows: 
 +| 4 | Enable extended spritemap format | 
 +| 1 | Disable enemy AI. Isn't disabled if intangible |
  
 ==== Enemy set ==== ==== Enemy set ====
Line 490: Line 521:
   [...]     ; Other enemies   [...]     ; Other enemies
   FFFF      ; Terminator   FFFF      ; Terminator
 +
 +Enemy set defines which enemies are allowed inside the room and which palette slot to use.
 +They're stored in bank $B4 with each enemy being 4 bytes, plus the 2 byte terminator.
 +Enemies that use the same palette may share the same palette index.
 +Valid palette indices are 1, 2, 3 and 7; note that only palette 7 is affected by colour math.
  
 ==== Scroll ==== ==== Scroll ====
Line 497: Line 533:
   |  |  |   |  |  |
   aa bb [...]   aa bb [...]
 +
 +Scrolls define how the camera works for each 16x16 block (256px x 256px) area in left-to-right, top-down order (reading order).
 +They're stored in bank $8F and are one byte per scroll.
 +
 +Scroll values are as follows:
 +
 +| 0 | Red. Cannot scroll into this area |
 +| 1 | Blue. Hides the bottom 2 rows of the area |
 +| 2 | Green. Unrestricted |
  
 ==== Special x-ray blocks ==== ==== Special x-ray blocks ====
    _______ X position    _______ X position
   |   ____ Y position   |   ____ Y position
-  |  |   _ Block number+  |  |   _ Block
   |  |  |   |  |  |
   xx yy nnnn ; First x-ray block   xx yy nnnn ; First x-ray block
Line 507: Line 552:
   [...]      ; Other x-ray blocks   [...]      ; Other x-ray blocks
   0000       ; Terminator   0000       ; Terminator
 +
 +Special x-ray blocks display custom x-ray graphics for blocks at given positions in the room.
 +They're stored in bank $8F with each block being 4 bytes, plus the 2 byte terminator.
 +
 +Special x-ray blocks are used in exactly one place in vanilla Super Metroid: the Bomb Torizo room during the escape sequence.
 +It's a hacky way of allowing Samus to x-ray the shootable block in the bottom-right corner of the screen.
 +Note that even after you've shot the shootable block, x-ray will still show the shootable block graphics.
 +
 +The **X/Y position** is specified in (16px x 16px) block units.
 +The **block** uses the level data block format, except that the block type is ignored.
 +
 +Note that [[http://metroidconstruction.com/resource.php?id=54|flexglow]] uses this pointer for the flexglow table instead.
  
 ==== PLM population ==== ==== PLM population ====
Line 518: Line 575:
   [...]           ; Other PLMs   [...]           ; Other PLMs
   0000            ; Terminator   0000            ; Terminator
 +
 +PLM population defines the placement of PLMs, as well as some PLM specific properties.
 +They're stored in bank $8F with each PLM being 6 bytes, plus the 2 byte terminator.
 +
 +PLMs with **PLM ID** >= $DF89 are considered to be "item PLMs", meaning the PLM argument specified in the PLM populations will be used as a unique ID and cannot be negative.
  
 ==== Library background ==== ==== Library background ====
Line 537: Line 599:
 | Ah | | Clear layer 2 | | Ah | | Clear layer 2 |
 | Ch | | Clear Kraid's 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''// |+| Eh | DDDD ssssss dddd nnnn | Transfer ''n'' bytes from ''s'' to ''d'' in VRAM //if the current door pointer = ''D''// | 
 + 
 + 
 +====== Object formats ====== 
 +Super Metroid has lots of specialised **object formats**, which are defined with an **instruction list** possibly combined with an "initialisation ASM"
 +In general, **object formats** have a handler that, for each object, executes a **pre-instruction** and then interprets the **instruction list**. 
 + 
 +The **instruction list** is a list of **ASM instructions** and **special instructions**. 
 +**ASM instructions** have a negative value (meaning $8000..FFFF), which is a pointer to a function to be executed, followed by any parameter values that the function requires. 
 +**Special instructions** (usually graphical in nature) have a positive value (meaning $0000..7FFF), usually a timer value, followed by any parameter values. 
 + 
 +Common **ASM instructions** include looping, conditional execution, setting the pre-instruction, deleting the object and sleeping. 
 +The pre-instruction is a function that's executed before the object's instruction list is processed for the current frame. 
 +Objects that are sleeping are suspended from handling until they are awakened (usually by a pre-instruction set earlier in the object instruction list). 
 + 
 +===== PLMs ===== 
 +PLMs (post-load modifications) are objects that modify level data blocks in real-time. 
 +They exist in bank $84 and are typically loaded with a room from a room header (e.g. items, doors) or spawned as part of a block interaction (e.g. shot block crumbling). 
 + 
 +PLM header: 
 +   ______ Initialisation ASM pointer 
 +  |     _ Instruction list pointer 
 +  |    | 
 +  aaaa iiii 
 + 
 +Door PLM header: 
 +   ___________ Initialisation ASM pointer 
 +  |     ______ Instruction list pointer 
 +  |    |     _ Instruction list pointer - door closing 
 +  |    |    | 
 +  aaaa iiii dddd 
 + 
 +The third pointer for door PLMs is used instead of the second pointer when the PLM is placed where a blue door would normally be closing when Samus enters a room. 
 + 
 +The **special instructions** for PLMs have the format: 
 +   ______ Draw timer 
 +  |     _ Pointer to draw instruction 
 +  |    | 
 +  tttt dddd 
 + 
 +The **draw timer** is how many frames to wait until the next instruction in the instruction list is proceeded to. 
 + 
 +The **draw instruction** format is a list of: 
 +  nnnn       ; Number of blocks 
 +  bbbb [...] ; Blocks 
 +  xx yy      ; X and Y offsets from origin to start drawing from 
 + 
 +where the list is terminated by ''xx yy = 00 00''
 + 
 +Blocks are drawn from the PLM's position, the direction they're drawn in is given by the most significant bit of ''n''
 +If ''n'' < 8000h, the blocks are drawn in a horizontal line to the right. 
 +If ''n'' >= 8000h, ''n'' & 7FFFh blocks are drawn in a vertical line downwards. 
 + 
 +===== Enemy projectiles ===== 
 +Enemy projectiles exist in bank $86 and are typically spawned by enemies and can use their graphics and palette. 
 + 
 +Enemy projectile header: 
 +   __________________________________ Initialisation AI 
 +  |     _____________________________ (Initial) pre-instruction 
 +  |    |     ________________________ Instruction list pointer 
 +  |    |    |     ___________________ X radius 
 +  |    |    |    |   ________________ Y radius 
 +  |    |    |    |  |   _____________ Damage/properties 
 +  |    |    |    |  |  |     ________ Touch AI 
 +  |    |    |    |  |  |    |     ___ Shot AI 
 +  |    |    |    |  |  |    |    | 
 +  iiii pppp IIII xx yy Pddd tttt ssss 
 + 
 +The **properties** are as follows: 
 + 
 +| 8000h | Detect collisions with projectiles | 
 +| 4000h | Don't die on contact | 
 +| 2000h | Disable collisions with Samus | 
 +| 1000h | Low priority (drawn under enemies/Samus/projectiles) | 
 + 
 +The **special instructions** for enemy projectiles have the format: 
 +   ______ Spritemap timer 
 +  |     _ Pointer to spritemap 
 +  |    | 
 +  tttt ssss 
 + 
 +The **spritemap timer** is how many frames to wait until the next instruction in the instruction list is proceeded to. 
 +Within the spritemap, the tile numbers added to the base tile number set when the enemy projectile was spawned (so the projectile can access enemy graphics). 
 + 
 +===== Animated tiles objects ===== 
 +Animated tiles objects are objects that modify tile graphics in real-time. 
 +They exist in bank $87 and are loaded with a room from an FX header. 
 + 
 +Animated tiles object header format: 
 +   ___________ Instruction list pointer 
 +  |     ______ Size 
 +  |    |     _ VRAM address 
 +  |    |    | 
 +  iiii ssss vvvv 
 + 
 +The **special instructions** for animated tiles objects have the format: 
 +   ______ Animation timer 
 +  |     _ Pointer to tile graphics 
 +  |    | 
 +  tttt ssss 
 + 
 +The **animation timer** is how many frames to wait until the next instruction in the instruction list is proceeded to. 
 + 
 +===== HDMA objects ===== 
 +HDMA objects exist in bank $88 and are typically loaded with a room as part of FX or spawned by power bombs / x-ray. 
 + 
 +HDMA object header format: 
 +   _______ HDMA options 
 +  |   ____ PPU register index 
 +  |  |   _ Instruction list pointer 
 +  |  |  | 
 +  dd pp iiii 
 + 
 +The **special instructions** for HDMA objects have the format: 
 +   ______ Table timer 
 +  |     _ Pointer to HDMA table 
 +  |    | 
 +  tttt ssss 
 + 
 +The **table timer** is how many frames to wait until the next instruction in the instruction list is proceeded to. 
 + 
 +===== Palette FX objects ===== 
 +Palette FX objects are objects that modify palette data in real-time. 
 +They exist in bank $8D and are loaded with a room from an FX header. 
 + 
 +Palette FX object header format: 
 +   ______ Initialisation ASM pointer 
 +  |     _ Instruction list pointer 
 +  |    | 
 +  aaaa iiii 
 + 
 +The **special instructions** for palette FX objects have the format: 
 +   ______ Palette timer 
 +  |     _ Palette instruction list 
 +  |    | 
 +  tttt [...] 
 + 
 +The **palette timer** is how many frames to wait until the next instruction in the instruction list is proceeded to. 
 + 
 +The ASM instructions are usually used for setting the initial colour index, 
 +which is an index into CGRAM equal to ''(p * 10h + c) * 2'' where ''p'' is the palette number and ''c'' is the colour index within the palette. 
 + 
 +**Palette instructions** are a mix of colours (which are positive values) and ASM instructions (negative values). 
 +Colours are written to successive positions in CGRAM starting from initial colour index. 
 +ASM instructions can modify the colour index between listed colour values, 
 +and the instruction $C595 is used to terminate the palette instruction list.
  
super/technical_information/data_structures.1543787391.txt.gz · Last modified: 2018/12/02 21:49 by smileuser96