Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- zelda 2's music is stored in a data bank which is split into four sections for different areas of the game
- 1A010 = beginning of overworld section
- 1A3DA = beginning of town(?) section
- 1A63F = beginning of palace section
- 1A946 = beginning of great palace(?) section
- the data structure of each section consists of song pointers that point to phrase pointers that point to note pointers that point to note sequences
- (bare with me on this terminology because i am not a music person)
- SONG POINTERS:
- - each section begins with 8 bytes that represent the starting point for each song in the section. the value of each byte is used as an offset from the beginning of the section to point to a sequence of phrase pointers (see next section)
- - the game chooses one of these 8 bytes to play a song depending on certain situations:
- overworld:
- 00 - oveworld intro
- 01 - overworld loop
- 02 - cave/encounter loop
- 03 - unused(?) duplicate of 02
- 04 - item/level-up jingle
- 05 - none
- 06 - none
- 07 - none
- town:
- 00 - town intro
- 01 - town loop
- 02 - interior loop
- 03 - unused(?) duplicate of 02
- 04 - item/spell acquisition jingle
- 05 - none
- 06 - none
- 07 - none
- palace:
- 00 - palace intro
- 01 - palace loop
- 02 - unused(?) duplicate of 01
- 03 - boss loop
- 04 - item/level-up jingle
- 05 - none
- 06 - palace clear jingle
- 07 - none
- great palace:
- 00 - great palace intro
- 01 - great palace loop
- 02 - ending scene loop
- 03 - credits loop
- 04 - item/level-up jingle
- 05 - triforce get jingle
- 06 - final boss loop
- 07 - none
- - since there are always exactly 8 song pointers (whether they're used or not), the first byte in each section will always be 08, which is where the first phrase pointer is located
- PHRASE POINTERS:
- - phrase pointers are used to arrange each phrase of a song. they point to note pointers in the same way that song pointers point to phrase pointers: their values are added to the offset of the first (08) byte in the section
- - phrase pointers are played in a sequence with a 00 byte at the end, which marks the end point of the song
- - the end of the phrase pointer table is usually marked with an extra 00 byte after the last pointer sequence (this byte seems to be a redundant byproduct of unused song pointers)
- NOTE POINTERS:
- - note pointers define the sequence of notes to be played by each channel when the phrase is played
- - each note pointer has 6 bytes:
- 1. this value affects the tempo of each channel, but i am not sure exactly how
- - the four sound channels will only play at matching speeds if this value is 00 or a multiple of 08
- 2. this value contains the rightmost two digits of the address of the first note in the phrase (square wave 1)
- 3. same as above, but the next two digits from the right
- - the address that these two values point to is assumed to be 1xxxx and not 0xxxx
- - note that the ROM header will offset the above two values by 10, so a value of 73 A0 actually points to the offset 1A083 as it shows up in hex editors
- 4. added to the address of 2+3 for square wave 2 beginning
- 5. added to the address of 2+3 for triangle wave beginning
- 6. added to the address of 2+3 for noise channel beginning
- - if bytes 4/5/6 have a value of 00, the respective channel will be muted instead of mimicking square wave 1
- NOTATION:
- - each note's pitch and duration values are added together and stored in a single byte. the following breakdown was compiled by Optomon:
- 02- REST
- 04- E
- 06- F
- 08- F#
- 0A- G
- 0C- G#
- 0E- A
- 10- A#
- 12- B
- 14- C
- 16- C#
- 18- D
- 1A- D#
- 1C- E
- 1E- F
- 20- G#
- 22- A
- 24- A#
- 26- B
- 28- C
- 2A- C#
- 2C- D
- 2E- D#
- 30- E
- 32- F
- 34- F#
- 36- G
- 38- G#
- 3A- A
- 3C- A#
- 3E- B
- add 00 : 1/16
- add 81 : 3/32
- add 80 : 1/8
- add 40 : 3/16
- add C0 : 1/4
- add c1 : 3/8
- add 41 : 1/2
- add 01 : ???
- - as with phrase pointers, 00 is used to mark the end point of a note sequence. the phrase itself will only end when all 4 channels have reached their end point
- - pointing an entire phrase to an instance of 00 will usually just skip it and continue on to the next phrase, but the game will freeze if it gets stuck looping phrase endings without any notes to play between them!
- MISC. NOTES:
- - the game will constantly attempt to play music barring the file select and continue screens. this means it is generally not safe to point directly to 00 bytes (whether they're notes or phrases) unless the song in question does not loop, because otherwise the game will freeze while it tries to loop a blank song over and over
- -in order to mute the game's music safely, you can overwrite every song pointer with a value of 08, then overwrite the first note pointer to point to any instance of a REST note followed by 00 (such as the one at 1A354 by using the note pointer 00 44 A3 00 00 00)
- - the duration of the level up jingle directly determines how long the prompt stays up after choosing a stat to level up
- - this is probably also true for the jingle that plays between placing a gem in a palace statue and your life/magic/exp filling up
Add Comment
Please, Sign In to add comment