Welcome to Data Crystal's new home! Data Crystal is now part of the TCRF family (sort of).
The wiki has recently moved; please report any issues in Discord. Pardon the dust.

Metroid/Item data format: Difference between revisions

From Data Crystal
Jump to navigation Jump to search
No edit summary
No edit summary
 
(10 intermediate revisions by 7 users not shown)
Line 1: Line 1:
{{game=Metroid}}
{{subpage}}
 
{{Infobox table|name=Item data format
{{Infobox table|name=Item data format
|game=Metroid
|game=Metroid
Line 9: Line 10:
|totallength=Varies. See [[Metroid:ROM map|ROM Map]]
|totallength=Varies. See [[Metroid:ROM map|ROM Map]]
}}
}}
The following describes the format of the data for items in the Metroid ROM. Some aspects of the game's behavior in regards to items (for example, how items work with passwords) may not be documented here.
The following describes the format of the data for items in the Metroid ROM. For each level there is a '''set''' of entries. Each entry defines all of the items on a single horizontal row of the map. Each entry can define any number of items.
 
In this article, the term "item" is used as a generic term to refer to a variety of in-game objects such as elevators, enemies, and power-ups. This article contains a mixture of formal and informal information to compromise between clarity, brevity, and ease of understanding.
 
== About Item Data ==
Item data is defined for each level. Item data is in the form of a linked list of "item data entries," each of which define all of the items on a single horizontal map row for a single level. Each item data entry contains a number of screen entries, each of which contains zero or more (usually one) item entries that define all of the items in that screen.
 
When a level is loaded into RAM, the location of the item data varies, but the offset of the item table can always be found at the RAM address 0x9598. To calculate the ROM address, see [[Metroid:Pointer format|Pointer Format]].
 
== Item Data Entries ==
 
Each item entry can define multiple items in multiple screens. The linked list of item data entries must be logically ordered by their vertical map coordinate (though they aren't required to appear in order in memory).
 
The binary format of an "item data entry" (not to be confused with a simple "item entry") is defined below. Italicized words refer to data where the format is defined elsewhere. Each pair of letters represents a byte, where the first letter represents the high nibble and the second letter represents the low nibble.
 
The following is the formal definition of an item data entry.
 
''itemDataEntry'' := YY ''pointer'' ''screenEntries''
:* YY: Map Y coordinate for all items in the item data entry.
:* ''pointer'': This is a pointer to the RAM address of the next item data entry. To convert to a ROM pointer, see [[Metroid:Pointer format]]. The pointer is a two byte pointer, ''low byte first''. A hexadecimal value of FFFF denotes the end of a level's item data. The formal definition for the pointer is:
::* <tt>pointer := BB AA</tt>
:* ''screenEntries'': zero or more entries that define item data for screens. See Screen Entries below for the format of this information.
 
== Screen Entries ==
 
Item data entries tend to contain multiple screen entries, although they do sometimes contain only one and it would be valid for them to contain zero. A screen entry can define multiple items in the same map screen, but they typically contain one. Screen entries must be ordered by horizontal map position.
 
The formal definition of a screen entry is as follows:
''screenEntry'' := XX SS ''itemEntries'' 00
:*XX: The map x-coordinate of the screen.
:*SS: The size, in bytes, of this screen entry, or the value of FF (hexadecimal) to indicate that this is the last screen entry in the containing item data entry.
:*''itemEntries'': zero or more item entries defining the items in this room.
:*00: Literal value (zero). Terminates this screen data.
 
== Item Entries ==
An item entry defines a single item. The format and size of an item entry depends on the type of item being defined (i.e. elevator, power-up, enemy, etc.). The type of item is defined by the lower nibble of the first byte of the item entry. This value corresponds to the following types (hexadecimal is used). Values not listed are '''undefined''' (not to be confused with unknown).
 
:*0 - This value is reserved as a terminator for a screen entry.
:*1 - Some Squeepts. The ones next to tall walls. Behind the high jump boots, for example. (These are enemies that jump out of the lava in Norfair)
:*2 - Power up items
:*3 - Mellows, Melias and Memus (small flying enemies)
:*4 - Elevators
:*5 - Mother brain room cannons
:*6 - Mother brain
:*7 - Zeebetites (Column-like structures in mother brain's room)
:*8 - Rinkas (Cheerio-like enemies from Tourain)
:*9 - Some doors
:*A - Palette switch
 
The mella (3), palette switch (A), and rinkas (8) are single-byte items, requiring only the byte that specifies the item type and no other data.
 
==== Elevator Entry ====
 
An elevator item entry is two bytes: the item type and a byte indicating which elevator is being defined. The formal definition is:
 
''elevatorEntry'' := TT EE
:*TT: Item type (4), specifies an elevator
:*EE: Elevator type.
 
The elevator type can have the following values (hexadecimal):
 
:*1: to Norfair
:*2: to Kraid
:*3: to Tourain
:*4: to Ridley
:*80: Norfair exit (to Brinstar)
:*81: Kraid exit (to Brinstar)
:*82: Tourain exit (to Brinstar)
:*83: Ridley exit (to Norfair)
:*8F: Game end
 
==== Enemy Entry ====
 
An enemy entry is three bytes. The format is as follows:


There are five sets of entries: one for each level. Each entry can contain multiple items. All items in a single entry will appear in a single horizontal row of the map.
  ''enemyEntry'' := SI DT YX
== Entry Format ==
:*S: "Sprite Slot" (en enemy will not be loaded if there is already another enemy loaded into the same sprite slot)
The following is the binary format for a single item data entry. Each pair of letters represents a byte, where the first letter represents the high nibble and the second letter represents the low nibble. Each entry can contain multiple items. The brackets indicate data that may or may not be present, depending on the types of objects represented and the number of items defined in the entry.
:*I: Item type (1), specifies an enemy
  YY BB AA XX CC FT [II [yx]] 00 [ XX CC FT [II [yx]] 00 [XX CC FT [II [yx]] 00 [...]]]
:*D: Difficulty. Has a value of 8 (adding 0x80 to the total value of the byte) if the enemy is of a harder difficulty than normal, otherwise 0.
:* <tt>XX</tt>: Map X coordinate for single item.
:*T: Enemy type. The types available vary between levels.
:* <tt>YY</tt>: Map Y coordinate for all items in this entry.
:*Y: Screen y-coordinate of the enemy.
:* <tt>AA BB</tt>: Memory address (RAM) of next item data entry.
:*X: Screen x-coordinate of the enemy.
:* <tt>CC</tt>: Size of a "screen entry" (see ''Terminator'' below), or bytes between '''CC''' value for this item and that of the next item. A value of <code>0xFF</code> indicates that this is the last item in the entry.
:* <tt>F</tt>: "Sprite Slot" value for enemy data. Disregarded for item data.
:* <tt>T</tt>: Item type (see below).
:* <tt>II</tt>: Power-up type (see below) or elevator destination. This data is not present for palette switches.
:* <tt>x</tt>: Screen x coordinate. Not present for palette switches or elevators.
:* <tt>y</tt>: Screen y coordinate. Not present for palette switches or elevators.
:* <tt>00</tt>: Terminator. Always has a value of zero. Indicates end of data for an item.


The first three bytes (<tt>YY BB AA</TT>) are defined once per row of items. The remaining data (<tt>XX CC FT II yx 00</tt>) is repeated for each item. The<tt> II </tt>and<tt> yx </tt>values may not necessarily be present, depending on what type of item is being defined. There are some interesting things to note about item data, though they may not be necessary or relevant to ROM hacking.
Note that enemy data is generally incorporated into Metroid's screen data rather than item data. Adding enemies via item data is only used in unusual circumstances.


The<tt> '''FT II yx''' </tt>data is the same exact format as used in Room data (see [[Metroid:Room_data_format|Room Format]]) for enemies (and is interpreted by the same exact program code). It is entirely possible to add items to a room in that room's enemy data, and even add enemies into the level's item data. Apparently, however, the programmers saw fit to make item data independent from room data, which allows the same screen to appear with different items or without items at all. 
==== Power-Up Entry ====


It would also probably be possible to place multiple items in the same room (see ''Terminator'' below).
A power-up entry has three bytes. The format is as follows:
====Map Coordinates (<tt>YY, XX</tt>)====
 
The y-coordinate is specified only once and applies to all items in the entry, hence all items in an entry must appear in the same row of the map. The x-coordinate is specified for each item.
''powerupEntry'' := II TT YX
====Memory Address (<tt>AA BB</tt>)====
:*II: Item type (2), specifies a power-up.
This value specifies the memory address for the next item data entry. The memory address specified is a RAM address, which is offset from the ROM address. See [[Metroid:Pointer_format|Pointer Format]]. A value of <code>0xFFFF</code> indicates that this is the last entry for the level.
:*TT: Power-up type. See below:
====Special Items====
:*Y: Screen y-coordinate.
Special items, such as elevators and palette switches, have less data. Elevators are missing the last byte of data (screen coordinates). Palette swaps are missing the last two bytes (type and screen coordinates). There may be other special object types.
:*X: Screen x-coordinate.
====Item Types (<tt>T</tt>)====
 
This specifies what type of object the data represents. The following are known possibilities. Other values are unknown or undefined. Hexadecimal values are used.
The following are defined power-up types (using hexadecimal):
:*0: Nothing
:*0: Bombs
:*1: Enemy
:*2: Power-up
:*4: Elevator
:*6: Tourain Access Bridge
:*7: Respawning Enemy
:*A: Palette Switch
====Power-up Type (II)====
This specifies what item the data represents. Values marked "Nothing" don't seem to manifest in the game. Values in parentheses aren't used in the game. Hexadecimal values are used.
:*0: Maru Mari Bombs
:*1: High Jump Boots
:*1: High Jump Boots
:*2: Long Beam
:*2: Long Beam
Line 58: Line 116:
:*8: Energy Tank
:*8: Energy Tank
:*9: Missile
:*9: Missile
:*A: (Dot Missile)
:*A: "Dot missile": Appears as a dot. Gives the player five missiles, but this item won't be saved in the password.
:*B: (Arrow Missile)
:*B: "Arrow Missile": Appears as an arrow. Behaves just like the "dot missile."
:*C: (Nothing)
 
:*D: (Nothing)
== Passwords ==
:*E: (Nothing)
 
:*F: (nothing)
The way that inventory is saved to the password is unusual and un-intuitive, and employs highly redundant data. See [[Metroid:Password data]].
====Terminator (<tt>00</tt>)====
 
This byte has a value of zero and must be present for the Metroid game program to run properly. It is probably possible to add data for a second item (or more) that will appear in the same screen by providing more <tt>FT II yx</tt> entries preceding the <tt>00</tt> terminator. In light of this understanding, it might be more appropriate to think of the data<tt> XX CC FT II yx</tt>, where the last three bytes can be repeated, as a screen entry rather than a simple item entry.
== Examples ==
==Examples==
 
====Long Beam/Bombs====
==== Long Beam/Bombs ====
The following defines the long beam and bombs from Brinstar.
The following data defines the long beam and bombs found in Brinstar.
YY BB AA  XX CC FT II yx 00  XX CC FT II yx 00
 
  05 02 A4  07 06 02 02 37 00   19 FF 02 00 37 00
  | 05 02 A4  07 06 02 02 37     00   19 FF 02 00 37     00
:*'''05''': Map Y position is 5
|
:*'''02 A4''': RAM address of next entry is <tt>A402</tt>.
| --''itemDataEntry''------------------------------------------
:*'''07''': Map X position is 7
|            --''screenEntry1''-------    --''screenEntry2''-------
:*'''06''': Six bytes until next <tt>CC</tt> value.
|                  -''itemEntry1''-            -''itemEntry2''-
:*'''02''': Object type 2: Power-up.
|
:*'''02''': Power-up type 2: Long beam.
|
:*'''37''': Screen position is three down and seven over.
| ''itemDataEntry''
:*'''00''': End of this item's data.
|    '''05''': Map Y position is 5
:*'''19''': Map X position for second item is 19 (hex).
|    '''02 A4''': RAM address of next entry is A402.
:*'''FF''': This is the last item in the entry.
|    ''screenEntry1''
:*'''02''': Object type 2: Item.
|        '''07''': Map X position is 7
:*'''00''': Item type 2: Bombs.
|        '''06''': Six bytes in screen entry.
:*'''37''': Screen position is three down and seven over.
|        ''itemEntry1''
:*'''00''': End of this item's data.
|            '''02''': Item type 2: Power-up.
====Elevator====
|            '''02''': Power-up type 2: Long beam.
The following data defines the elevator to Kraid's hideout from Brinstar.
|            '''37''': Screen position is three down and seven over.
  YY BB AA  XX CC FT II 00
|        '''00''': End of this screen's data.
12 FF FF  07 FF 04 02 00
|    ''screenEntry2''
:*'''12''': Map Y position is 12 (hex).
|        '''19''': Map X position for second item is 19 (hex).
:*'''FFFF''': This is the last entry for Brinstar item data.
|        '''FF''': This is the last item in the entry.
:*'''07''': Map X position is 7.
|        ''itemEntry2''
:*'''FF''': This is the last item in this entry.
|            '''02''': Item type 2: Item.
:*'''04''': Object type 4: Elevator.
|            '''00''': Power-up type 0: Bombs.
:*'''02''': Destination is level 2: Kraid's hideout.
|            '''37''': Screen position is three down and seven over.
:*'''00''': The end.
|        '''00''': End of this screen's data.  
 
==== Elevator ====
The following defines the elevator from Brinstar to Kraid.
  | 12 FF FF  07 FF   04 02       00
|
| -''itemDataEntry''-------------------
|            -''screenEntry''----------
|                    -''itemEntry''-
|
| ''itemDataEntry''
|    '''12''': Map Y position is 12 (hex).
|    '''FF FF''': This is the last entry for Brinstar item data.
|    ''screenEntry''
|        '''07''': Map X position is 7.
|        '''FF''': This is the last screen in this item data entry.
|        ''itemEntry''
|            '''04''': Object type 4: Elevator.
|            '''02''': Destination is level 2: Kraid's hideout.
|        '''00''': The end.




=See Also=
=See Also=


[[Category:Metroid|Room data format]]
*[[Metroid:Password data|Password Data]]
*[[Metroid:ROM map|Metroid Rom Map]]
*[[Metroid]]

Latest revision as of 14:59, 24 January 2024

This is a sub-page of Metroid.

Item data format
Game Metroid
Start Address Varies by bank. See ROM Map
End Address Varies by bank. See ROM Map
# of Entries Varies by bank. See ROM Map
Entry Length Varies.
Total Length Varies. See ROM Map
Back to the ROM map

The following describes the format of the data for items in the Metroid ROM. For each level there is a set of entries. Each entry defines all of the items on a single horizontal row of the map. Each entry can define any number of items.

In this article, the term "item" is used as a generic term to refer to a variety of in-game objects such as elevators, enemies, and power-ups. This article contains a mixture of formal and informal information to compromise between clarity, brevity, and ease of understanding.

About Item Data

Item data is defined for each level. Item data is in the form of a linked list of "item data entries," each of which define all of the items on a single horizontal map row for a single level. Each item data entry contains a number of screen entries, each of which contains zero or more (usually one) item entries that define all of the items in that screen.

When a level is loaded into RAM, the location of the item data varies, but the offset of the item table can always be found at the RAM address 0x9598. To calculate the ROM address, see Pointer Format.

Item Data Entries

Each item entry can define multiple items in multiple screens. The linked list of item data entries must be logically ordered by their vertical map coordinate (though they aren't required to appear in order in memory).

The binary format of an "item data entry" (not to be confused with a simple "item entry") is defined below. Italicized words refer to data where the format is defined elsewhere. Each pair of letters represents a byte, where the first letter represents the high nibble and the second letter represents the low nibble.

The following is the formal definition of an item data entry.

itemDataEntry := YY pointer screenEntries
  • YY: Map Y coordinate for all items in the item data entry.
  • pointer: This is a pointer to the RAM address of the next item data entry. To convert to a ROM pointer, see Metroid:Pointer format. The pointer is a two byte pointer, low byte first. A hexadecimal value of FFFF denotes the end of a level's item data. The formal definition for the pointer is:
  • pointer := BB AA
  • screenEntries: zero or more entries that define item data for screens. See Screen Entries below for the format of this information.

Screen Entries

Item data entries tend to contain multiple screen entries, although they do sometimes contain only one and it would be valid for them to contain zero. A screen entry can define multiple items in the same map screen, but they typically contain one. Screen entries must be ordered by horizontal map position.

The formal definition of a screen entry is as follows:

screenEntry := XX SS itemEntries 00
  • XX: The map x-coordinate of the screen.
  • SS: The size, in bytes, of this screen entry, or the value of FF (hexadecimal) to indicate that this is the last screen entry in the containing item data entry.
  • itemEntries: zero or more item entries defining the items in this room.
  • 00: Literal value (zero). Terminates this screen data.

Item Entries

An item entry defines a single item. The format and size of an item entry depends on the type of item being defined (i.e. elevator, power-up, enemy, etc.). The type of item is defined by the lower nibble of the first byte of the item entry. This value corresponds to the following types (hexadecimal is used). Values not listed are undefined (not to be confused with unknown).

  • 0 - This value is reserved as a terminator for a screen entry.
  • 1 - Some Squeepts. The ones next to tall walls. Behind the high jump boots, for example. (These are enemies that jump out of the lava in Norfair)
  • 2 - Power up items
  • 3 - Mellows, Melias and Memus (small flying enemies)
  • 4 - Elevators
  • 5 - Mother brain room cannons
  • 6 - Mother brain
  • 7 - Zeebetites (Column-like structures in mother brain's room)
  • 8 - Rinkas (Cheerio-like enemies from Tourain)
  • 9 - Some doors
  • A - Palette switch

The mella (3), palette switch (A), and rinkas (8) are single-byte items, requiring only the byte that specifies the item type and no other data.

Elevator Entry

An elevator item entry is two bytes: the item type and a byte indicating which elevator is being defined. The formal definition is:

elevatorEntry := TT EE
  • TT: Item type (4), specifies an elevator
  • EE: Elevator type.

The elevator type can have the following values (hexadecimal):

  • 1: to Norfair
  • 2: to Kraid
  • 3: to Tourain
  • 4: to Ridley
  • 80: Norfair exit (to Brinstar)
  • 81: Kraid exit (to Brinstar)
  • 82: Tourain exit (to Brinstar)
  • 83: Ridley exit (to Norfair)
  • 8F: Game end

Enemy Entry

An enemy entry is three bytes. The format is as follows:

enemyEntry := SI DT YX
  • S: "Sprite Slot" (en enemy will not be loaded if there is already another enemy loaded into the same sprite slot)
  • I: Item type (1), specifies an enemy
  • D: Difficulty. Has a value of 8 (adding 0x80 to the total value of the byte) if the enemy is of a harder difficulty than normal, otherwise 0.
  • T: Enemy type. The types available vary between levels.
  • Y: Screen y-coordinate of the enemy.
  • X: Screen x-coordinate of the enemy.

Note that enemy data is generally incorporated into Metroid's screen data rather than item data. Adding enemies via item data is only used in unusual circumstances.

Power-Up Entry

A power-up entry has three bytes. The format is as follows:

powerupEntry := II TT YX
  • II: Item type (2), specifies a power-up.
  • TT: Power-up type. See below:
  • Y: Screen y-coordinate.
  • X: Screen x-coordinate.

The following are defined power-up types (using hexadecimal):

  • 0: Bombs
  • 1: High Jump Boots
  • 2: Long Beam
  • 3: Screw Attack
  • 4: Maru Mari
  • 5: Varia
  • 6: Wave Beam
  • 7: Ice Beam
  • 8: Energy Tank
  • 9: Missile
  • A: "Dot missile": Appears as a dot. Gives the player five missiles, but this item won't be saved in the password.
  • B: "Arrow Missile": Appears as an arrow. Behaves just like the "dot missile."

Passwords

The way that inventory is saved to the password is unusual and un-intuitive, and employs highly redundant data. See Metroid:Password data.

Examples

Long Beam/Bombs

The following data defines the long beam and bombs found in Brinstar.

| 05 02 A4   07 06 02 02 37     00    19 FF 02 00 37     00
| 
| --itemDataEntry------------------------------------------
|            --screenEntry1-------    --screenEntry2-------
|                  -itemEntry1-             -itemEntry2-
| 
| 
| itemDataEntry
|     05: Map Y position is 5
|     02 A4: RAM address of next entry is A402.
|     screenEntry1
|         07: Map X position is 7
|         06: Six bytes in screen entry.
|         itemEntry1
|             02: Item type 2: Power-up.
|             02: Power-up type 2: Long beam.
|             37: Screen position is three down and seven over.
|         00: End of this screen's data.
|     screenEntry2
|         19: Map X position for second item is 19 (hex).
|         FF: This is the last item in the entry.
|         itemEntry2
|             02: Item type 2: Item.
|             00: Power-up type 0: Bombs.
|             37: Screen position is three down and seven over.
|         00: End of this screen's data. 

Elevator

The following defines the elevator from Brinstar to Kraid.

| 12 FF FF   07 FF   04 02       00
| 
| -itemDataEntry-------------------
|            -screenEntry----------
|                    -itemEntry-
| 
| itemDataEntry
|     12: Map Y position is 12 (hex).
|     FF FF: This is the last entry for Brinstar item data.
|     screenEntry
|         07: Map X position is 7.
|         FF: This is the last screen in this item data entry.
|         itemEntry
|             04: Object type 4: Elevator.
|             02: Destination is level 2: Kraid's hideout.
|         00: The end.


See Also