JillPill

zelda 2 music hacking notes

Jul 26th, 2017
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.18 KB | None | 0 0
  1. zelda 2's music is stored in a data bank which is split into four sections for different areas of the game
  2. 1A010 = beginning of overworld section
  3. 1A3DA = beginning of town(?) section
  4. 1A63F = beginning of palace section
  5. 1A946 = beginning of great palace(?) section
  6.  
  7. 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
  8. (bare with me on this terminology because i am not a music person)
  9.  
  10.  
  11.  
  12. SONG POINTERS:
  13. - 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)
  14.  
  15. - the game chooses one of these 8 bytes to play a song depending on certain situations:
  16. overworld:
  17. 00 - oveworld intro
  18. 01 - overworld loop
  19. 02 - cave/encounter loop
  20. 03 - unused(?) duplicate of 02
  21. 04 - item/level-up jingle
  22. 05 - none
  23. 06 - none
  24. 07 - none
  25. town:
  26. 00 - town intro
  27. 01 - town loop
  28. 02 - interior loop
  29. 03 - unused(?) duplicate of 02
  30. 04 - item/spell acquisition jingle
  31. 05 - none
  32. 06 - none
  33. 07 - none
  34. palace:
  35. 00 - palace intro
  36. 01 - palace loop
  37. 02 - unused(?) duplicate of 01
  38. 03 - boss loop
  39. 04 - item/level-up jingle
  40. 05 - none
  41. 06 - palace clear jingle
  42. 07 - none
  43. great palace:
  44. 00 - great palace intro
  45. 01 - great palace loop
  46. 02 - ending scene loop
  47. 03 - credits loop
  48. 04 - item/level-up jingle
  49. 05 - triforce get jingle
  50. 06 - final boss loop
  51. 07 - none
  52. - 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
  53.  
  54.  
  55.  
  56. PHRASE POINTERS:
  57. - 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
  58. - phrase pointers are played in a sequence with a 00 byte at the end, which marks the end point of the song
  59. - 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)
  60.  
  61.  
  62.  
  63. NOTE POINTERS:
  64. - note pointers define the sequence of notes to be played by each channel when the phrase is played
  65. - each note pointer has 6 bytes:
  66. 1. this value affects the tempo of each channel, but i am not sure exactly how
  67. - the four sound channels will only play at matching speeds if this value is 00 or a multiple of 08
  68. 2. this value contains the rightmost two digits of the address of the first note in the phrase (square wave 1)
  69. 3. same as above, but the next two digits from the right
  70. - the address that these two values point to is assumed to be 1xxxx and not 0xxxx
  71. - 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
  72. 4. added to the address of 2+3 for square wave 2 beginning
  73. 5. added to the address of 2+3 for triangle wave beginning
  74. 6. added to the address of 2+3 for noise channel beginning
  75. - if bytes 4/5/6 have a value of 00, the respective channel will be muted instead of mimicking square wave 1
  76.  
  77.  
  78.  
  79. NOTATION:
  80. - each note's pitch and duration values are added together and stored in a single byte. the following breakdown was compiled by Optomon:
  81.  
  82. 02- REST
  83. 04- E
  84. 06- F
  85. 08- F#
  86. 0A- G
  87. 0C- G#
  88. 0E- A
  89. 10- A#
  90. 12- B
  91. 14- C
  92. 16- C#
  93. 18- D
  94. 1A- D#
  95. 1C- E
  96. 1E- F
  97. 20- G#
  98. 22- A
  99. 24- A#
  100. 26- B
  101. 28- C
  102. 2A- C#
  103. 2C- D
  104. 2E- D#
  105. 30- E
  106. 32- F
  107. 34- F#
  108. 36- G
  109. 38- G#
  110. 3A- A
  111. 3C- A#
  112. 3E- B
  113.  
  114. add 00 : 1/16
  115. add 81 : 3/32
  116. add 80 : 1/8
  117. add 40 : 3/16
  118. add C0 : 1/4
  119. add c1 : 3/8
  120. add 41 : 1/2
  121. add 01 : ???
  122.  
  123. - 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
  124. - 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!
  125.  
  126. MISC. NOTES:
  127. - 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
  128. -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)
  129. - the duration of the level up jingle directly determines how long the prompt stays up after choosing a stat to level up
  130. - 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