I've gotten about as far with Donkey Kong's music engine as I care to.
Here's my findings:
Offset 0x3E72 is the start of the song list. There are 9 songs, each song has 5 bytes in this list:
- byte 0 = "control byte"???? I haven't fully deciphered this, but it seems to be factored in when determining note length and pulse volume. The value is used for a lookup table, so you probably should only use values that currently exist in the game (0, 8, or F), other values just jumble up the music something fierce
- bytes 1,2 = pointer to the start of the score data. Little endian. To convert to an offset, swap the bytes, subtract $C000, then add $10. So "20 FF" points to offset 3F30
- byte 3 = offset to start of triangle's music data
- byte 4 = offset to start of pulse 2's music data.
Example... the game has these bytes at offset 3E72:
00 8F FE 1B 00 <- song 0
08 B0 FE 00 0C <- song 1
00 CF FE 00 1A
08 05 FF 00 0B
00 AD FF 00 03
00 BE FF 00 00
00 C4 FF 00 00
0F 20 FF 21 3E <- song 7
00 A1 FF 08 00
Song 7 is the song played at the title screen.
It has a control byte of $0F
The score starts at $FF20 (offset 0x3F30)
Triangle offset is $21
Pulse 2 offset is $3E
So with your 3 audio channels (pulse 1, pulse 2, and triangle), the score for each starts at these addresses:
Pulse 1 @ 0x3F30
Pulse 2 @ 0x3F30 + $3E = 0x3F6E
Triangle @ 0x3F30 + $21 = 0x3F51
Each byte in the score specifies a tone (or a rest) and a length. Note that for the below I only looked at the score for the pulse channels. I assume Triangle works the same way but I didn't check so it might be different.
The first few bytes of Pulse 1's score for the title screen (offset 0x3F30) is below:
56 56 E0 42 5A 5E 5C 99 58 58 E2 ...
Here's the ugly part... this score is super
Bits 1-5 select the pitch, and bits 6,7,0 select everything else. So to edit this, you pretty much have to convert each byte to binary to see what it's doing:
$56 = %0101 0110
|| tone |
So $56 and $57 will play the same tone, but with a different length/volume
Whereas $56 and $58 will play different tones, but with the same length/volume
Good luck with this.
This does not seem like it would be fun to edit.