The current URL is datacrystal.tcrf.net.
Metroid/Music data format: Difference between revisions
Line 60: | Line 60: | ||
== Note lengths tables == | == Note lengths tables == | ||
These | These tables are present in every bank with music. The first table is located at $BEF7, with the other two immediately following. | ||
This is where the music format gets a bit annoying. :) Metroid doesn't define things like quarter notes and eighth notes, nor does it specify a number of frames to hold a note. Instead, the number of frames is stored in a table, and which table is used depends on the song (see Init Music Table). | This is where the music format gets a bit annoying. :) Metroid doesn't define things like quarter notes and eighth notes, nor does it specify a number of frames to hold a note. Instead, the number of frames is stored in a table, and which table is used depends on the song (see Init Music Table). |
Revision as of 14:58, 22 March 2011
The Metroid music format was likely decoded by Dirty McDingus, as a complete description of it appears in his disassembly of the game.
Init music index table
This table appears at BBFA in every ROM bank with music (every bank except the graphics and engine banks). It translates song IDs into offsets (given as one byte) into the Init Music Table. Curiously, the songs are not in the same order in the two tables.
The song order is:
- 0: Ridley
- 1: Tourian
- 2: Item room
- 3: Kraid
- 4: Norfair
- 5: Escape
- 6: Mother Brain
- 7: Brinstar
- 8: Game start
- 9: Power up (i.e. received item or beat boss)
- A: Ending
- B: Title screen
Init Music Table
This table is present in every ROM bank with music. It is located at $BD31 in each bank.
The order (as defined by the Init Music Index table) is:
- 0: Mother Brain
- 1: Escape
- 2: Norfair
- 3: Kraid
- 4: Item room
- 5: Ridley
- 6: Ending
- 7: Title screen
- 8: Game start
- 9: Power up
- A: Brinstar
- B: Tourian
The format is:
- Index into note length table (will be $00, $0B, or $17)
- Does song loop at end? (zero = no, nonzero = yes)
- Length counter for triangle channel
- Instrument ID for square 1
- Instrument ID for square 2
- Address of square 1 music data
- Address of square 2 music data
- Address of triangle music data
- Address of noise music data
All of these are one byte except for the addresses, which take two.
If a song is not used in the current bank, its offsets are given as $0100, $0300, $0500, $0700.
Music data
- $00 - Ends or loops the song. Affects all channels.
- $Bx - Sets length of subsequent notes to x (as defined by the song's note lengths table)
- %11xxxxxx - start of local loop; loop x times
- $FF - end of local loop
- $01 - plays an A-1 note
- $02 - play a rest [i.e. a silent note]
- $04-7E = plays C#2, D-2, D#2 ... F-7.
Note lengths tables
These tables are present in every bank with music. The first table is located at $BEF7, with the other two immediately following.
This is where the music format gets a bit annoying. :) Metroid doesn't define things like quarter notes and eighth notes, nor does it specify a number of frames to hold a note. Instead, the number of frames is stored in a table, and which table is used depends on the song (see Init Music Table).
The number of frames a note is held is as follows (in decimal):
Table 0 (index of $00) - used by Power Up and Kraid
- 0: 4
- 1: 8
- 2: 16
- 3: 32
- 4: 64
- 5: 24
- 6: 48
- 7: 12
- 8: 11
- 9: 5
- A: 2
Table 1 (index of $0B) - used by all music that doesn't use tables 0 or 2
- 0: 6
- 1: 12
- 2: 24
- 3: 48
- 4: 96
- 5: 36
- 6: 72
- 7: 18
- 8: 16
- 9: 8
- A: 3
Table 2 (index of $17) - used by title screen and ending
- 0: 16
- 1: 7
- 2: 14
- 3: 28
- 4: 56
- 5: 112
- 6: 42
- 7: 21
- 8: 18
- 9: 2
- A: 3