Music Documentation Wrong?

Share and discuss all facets of DKC ROM hacking...

Music Documentation Wrong?

Postby Cyclone » October 6th, 2022, 12:32 pm

I found this bit of documentation here on the Atlas. Most of it seems correct except the lines in bold. Changing those values did nothing.

These lines apear to be wrong?

19 Bonus Lose 0x13E2B3 0x0AB3F0
1A Level Goal 0x13E789 0x0AB38A



Any ideas?
Thanks.

Code: Select all
 Song title       Sequence position    Waveform set position

    00   Jungle Groove      0x0A9361   0x0AB286
    01   Cave Dweller Concert   0x090000   0x0AB29C
    02   Misty Menace      0x090838   0x0AB2A8
    03   Aquatic Ambiance   0x0A8000   0x0AB2B6
    04   Mine Cart Madness   0x093BBF   0x0AB2CE
    05   Northern Hemispheres   0x091CF8   0x0AB2DC
    06   Voices of the Temple   0x1F1650   0x0AB2EC
    07   Fear Factory      0x090F83   0x0AB2F8
    08   Life in the Mines   0x23CDA7   0x0AB30A
    09   Simian Segue      0x13D88C   0x0AB31C
    0A   Fanfare Theme      0x2A0000   0x0AB33A
    0B   Ice Cave Chant      0x3095BE   0x0AB33E
    0C   DK Island Swing      0x016B84   0x0AB34A
    0D   Forest Frenzy      0x050000   0x0AB356
    0E   The Credits Concerto   0x1FDBB4   0x0AB362
    0F   Game Over      0x340000   0x0AB374
    10   Bonus Room Blitz   0x1BF5D8   0x0AB37C
    11   Lost Life      0x210000   0x0AB394
    12   Bonus Win      0x2E1476   0x0AB38A
    13   Treetop Rock      0x05EBC6   0x0AB39A
    14   Funky's Fugue      0x060000   0x0AB3A4
    15   Bad Boss Boogie      0x29C6A4   0x0AB3B8
    16   Candy's Love Song   0x31BB58   0x0AB3C8
    17   Cranky's Theme      0x0A8C65   0x0AB3DA
    18   Gang-Plank Galleon   0x022ECC   0x0AB3E2
    19   Bonus Lose      0x13E2B3   0x0AB3F0
    1A   Level Goal      0x13E789   0x0AB38A
    ??            (Null)     0x0AB330
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 6th, 2022, 1:15 pm

That’s interesting, I’ll have to look into that, I created this program that tells you which lines of code are being used at any point on screen so I will see what happens. Interesting find! :thumbs: :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby rainbowsprinklez » October 7th, 2022, 4:29 am

19 is at 0xd3deab and 1a is at 0xfc5a12. Question. What are you changing about music? Just tempo?
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 7th, 2022, 4:34 am

I got the chance yesterday to play on my DKC emulator. And of course I forgot to use Screen Record :facepalm: . So of course I will be back at it soon! Hopefully, this information gets cleared up! :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby Cyclone » October 7th, 2022, 7:58 am

rainbowsprinklez wrote:19 is at 0xd3deab and 1a is at 0xfc5a12. Question. What are you changing about music? Just tempo?


Those are invalid. My hex editor won't except them? Maybe they are in a different format? And ya I am editing the tempo :)
hmm
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 7th, 2022, 9:26 am

Is the level goal music referring to exiting a level? :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby Cyclone » October 7th, 2022, 12:18 pm

^ Yes. It is played when completing a level for the first time.

I found the location of the tempo offset here...
0x3C5A29

also the Document is missing the Intro Theme offset.

How would I go about changing the pitch of the music. Any ideas things I can change besides tempo?

Any help on the music format? I don't quite understand it.

Thank You.
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 7th, 2022, 2:50 pm

I’m not an expert on this, but I do know that Rare used a compression system that has as far as I know not used by anyone else, even to this day! I can’t be much help here, other than I when I get a chance, I will see what hex codes are used in both instances. :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby Mattrizzle » October 7th, 2022, 9:06 pm

Made a reply to your post at romhacking.net without realizing that you also made a thread here, and that rainbowsprinklez wrote a reply before I did.

Anyway, these offsets are correct, but only for (U) revision 1.2. Most other documentation is for U R1.0, which also happens to match U R1.1 in this case.

The waveform set positions are wrong for 1.0 as well, but if you subtract 5 from each of them, you get the proper offset.

Here are the the offsets for the two relevant pointer tables in (U) revisions 1.0 and 1.1:
Code: Select all
0xAB159-0xAB1A9 Sequence data pointers (3 bytes per pointer, 27 pointers)
0xAB20D-0xAB244 Waveform set pointers (2 bytes per pointer, 28 pointers)
Veteran Venturer
Bananas received 222
Posts: 559
Joined: 2008

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 8th, 2022, 2:05 am

Sounds like you beat me to it! :thumbs: Great job! Well it appears to be fixed, so that’s good. :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby rainbowsprinklez » October 8th, 2022, 8:33 am

Mattrizzle wrote:The waveform set positions are wrong for 1.0 as well, but if you subtract 5 from each of them, you get the proper offset.

Here are the the offsets for the two relevant pointer tables in (U) revisions 1.0 and 1.1:
Code: Select all
0xAB159-0xAB1A9 Sequence data pointers (3 bytes per pointer, 27 pointers)
0xAB20D-0xAB244 Waveform set pointers (2 bytes per pointer, 28 pointers)


Sorry,, Matt. I'm ignorant. Can you please explain what the wave form is?

Mattrizzle
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: Music Documentation Wrong?

Postby rainbowsprinklez » October 8th, 2022, 8:36 am

Cyclone https://loveemu.hatenablog.com/entry/20 ... Music_Spec

I studied the above guide in making the music hacks I did.

Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: Music Documentation Wrong?

Postby Cyclone » October 8th, 2022, 12:39 pm

^ Thanks so much for the link. Looks interesting.
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby Mattrizzle » October 8th, 2022, 3:32 pm

rainbowsprinklez wrote:Sorry,, Matt. I'm ignorant. Can you please explain what the wave form is?


'Waveforms' here refers to the raw bit-rate reduced (BRR) Adaptive Differential Pulse Code Modulation (ADPCM) sound "files" used in the music and sound effect sequences. I wrote "files" in quotes because Super NES games have no actual file system, but I don't know of a better way to describe them. You could also refer to them as blocks of data

Each of the waveform sets is made of multiple 16-bit values. These values, when multiplied by 3, are each used as an index into the waveform pointer table at PC offsets 0x09FF00-0x09FFD1 (SNES addresses $89:FF00-$89:FFD1). Each of the pointers is 24-bits, or 3 bytes long.

The value #$FFFF is a special case which signifies the end of the waveform set.

EDIT: I posted a corrected version of the table with less ambiguous track names here.
Veteran Venturer
Bananas received 222
Posts: 559
Joined: 2008

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 8th, 2022, 3:48 pm

Which at some point Dave Wise referred to them as cyclical waveforms, which is essentially what you’re describing. Dave Wise encoded all of the waveforms into hexadecimal by hand. It’s quite a feat what he did! :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby Cyclone » October 15th, 2022, 4:53 pm

Hi,
Could someone explain how to use the doc found here
https://loveemu.hatenablog.com/entry/20 ... Music_Spec

to for example change the volume of the music.

The document said the...

Song Header Start Address
Donkey Kong Country = $12a0


Under Common Events it says 02 xx yy - Set L/R Volume
and under Donkey Kong Country Presets it says 1C xx yy zz ww - Set Volume L/R & ADSR Preset 1

Where in my Hex Editor do I change the values? I'm just trying to get my bearings in my Hex Editor.
See screenshot.

Thanks in advance.

Edit...
It appears that changing the 22nd and 23rd bytes after the header will change the master volume?

I guess what I'm trying to figure out is how this all relates to the document.
Attachments
music.jpg
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 15th, 2022, 5:12 pm

I’m going to tinker around with that and see what I can find out! Very interesting! :thumbs: :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby rainbowsprinklez » October 15th, 2022, 10:23 pm

Cyclone wrote:and under Donkey Kong Country Presets it says 1C xx yy zz ww - Set Volume L/R & ADSR Preset 1


Do not worry about command 1c. You only want to worry about command 11.

Idk how you found that A0 12 byte pair, but there's 2 bytes before it in the rom header.
Code: Select all
    14   Funky's Fugue      0x060000   0x0AB3A4

12a0 is the

The header consists of:
2 bytes for data size
2 bytes for SPC destination
16 bytes (2 for each channel) for the channel address in the SPC
1 byte for tempo
1 byte for effect tempo

There's actually 2 headers to consider! The ROM header which holds all of the above, and SPC header, which starts at the address for channel 1! For your purposes, you should never worry about the SPC header.

In the SPC, the starting address for all tracks is 12a0. This is where the SPC header starts. Look at love emu's doc for more info.


It is VASTLY easier to extract the track to its own file so things are 0-based. Easier still is to pad said file with 0x12a0 - 4 00s so everything lines up. '-4' because that data is never sent to the SPC. Only the main CPU uses it.

I'll assume you did the latter to explain this. A lot of stuff is in little-endian natively. So best to think of pointers in this way. Eg. a0 12 is 12a0, b2 12 is 12b2. So this is saying channel 1 starts at 12b2. Channel 2 starts at 1342. So we go to offset 12b2. This is a sequential list of commands/values. We see 2a. According to loveemu's guide, 2a has 1 param (the 64). Our next byte is 11. According to the guide, that is master volume (exactly what you want) and it takes 2 params. After that is command 4. That takes 3 bytes. Rinse and repeat. The first box in your image is part of the header and shouldn't be changed. The last box in your image is part of command 15 (echo). The second box is right :)

Side note, on command 11 above, those are L/R values. So you can play with those numbers. Challenge: Get Funky's track to play in the left ear only.

Also, your image is VERY painful to look at. I believe I mentioned always putting hex viewers at 16 or 32 bytes per line. This makes it easier to jump a certain amount of bytes, as those numbers are regular with how addressing works. Hex is base 16. Kingizor can no doubt explain this point better :)
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: Music Documentation Wrong?

Postby Cyclone » October 16th, 2022, 11:04 am

rainbowsprinklez wrote:Idk how you found that A0 12 byte pair, but there's 2 bytes before it in the rom header.


In the document it says...

"Song Header Start Address
Donkey Kong Country = $12a0"


That is where I got the A0 12 from. I thought that is where the header starts.

Anyways I think I got the basic understanding now on how to use the Document.
Thank you so much. rainbowsprinklez! for the time to make that reply. Much Appreciated. :thumbs:

I do have one more thing. Where is the actual sound track data stored. Like if I wanted to play around with the instruments/waveforms or what ever.
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby rainbowsprinklez » October 16th, 2022, 11:41 am

Cyclone wrote:
rainbowsprinklez wrote:Idk how you found that A0 12 byte pair, but there's 2 bytes before it in the rom header.


In the document it says...

"Song Header Start Address
Donkey Kong Country = $12a0"


That is where I got the A0 12 from. I thought that is where the header starts.


That is saying which address IN THE SPC the header is located. Not the ROM. I attached an example SPC. This will no doubt help. Open the SPC in a hex editor and go to 12a0. Just do it for practice, if nothing else and try to follow along.


Cyclone wrote:I do have one more thing. Where is the actual sound track data stored. Like if I wanted to play around with the instruments/waveforms or what ever.


That.... is a question for Mattrizzle. I never looked into. I'm pretty sure that's what Mattrizzle discusses here
Mattrizzle wrote:'Waveforms' here refers to the raw bit-rate reduced (BRR) Adaptive Differential Pulse Code Modulation (ADPCM) sound "files" used in the music and sound effect sequences. I wrote "files" in quotes because Super NES games have no actual file system, but I don't know of a better way to describe them. You could also refer to them as blocks of data


EDIT!!!
Oops. those SPC files have a 0x100 byte header, so add 0x100 to every address. So track starts at 13a0 instead of 12a0 like i previously noted

More
Code: Select all
SRCN Table Address
Donkey Kong Country = $04e0

This is likely important for instruments, but I haven't investigated it myself. Maybe Matt has?
Attachments
15 Funky's Fugue.spc
(64.55 KiB) Downloaded 1485 times
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: Music Documentation Wrong?

Postby Cyclone » October 16th, 2022, 2:36 pm

By playing around I noticed if I change the 21st byte from the header address it will Mute the music and the sound effects still play. That's what I wanted.
The thing is I can't find the control code in the Document. I attached a screen shot of the highlighted bytes. The last highlighted byte is what I changed to 00 to Mute the music.


Nevermind! I'm not thinking. That byte is part of the Header and controls the tempo. Sorry.
:oops:


I will check that sample spc.

Thanks again.
Attachments
No_Music.jpg
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby WesternTanager794 » October 16th, 2022, 3:17 pm

The customization of DKC music is advancing further and further! It’s exciting! Good job Cyclone and RainbowSprinklez for advancing this field! :thumbs: :parry:
Sage of Discovery
Bananas received 128
Posts: 2393
Joined: 2022

Re: Music Documentation Wrong?

Postby rainbowsprinklez » October 17th, 2022, 4:14 am

Cyclone wrote:By playing around I noticed if I change the 21st byte


At the risk of sounding snobby, I have a favor to ask you. Can you please convert every value you give me to hexadecimal? I work so much in hex that I am used to counting like that. So when you said
21st byte
my first thought was 0x21, which is 33 bytes. Hex is actually easy, and you need to become familiar with it to work on Donkey

And I saw you followed my advice about adjusting the width. Thank you. I would've preferred 16 as that is easier, but this works. Thanks!
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: Music Documentation Wrong?

Postby Cyclone » October 18th, 2022, 7:24 am

That’s alright. I can do that. I am already familiar with hex.

What I meant by the 21st byte was the number of bytes from the start of the header to the address of for example the tempo address.
Expedition Leader
Bananas received 559
Posts: 1253
Joined: 2008

Re: Music Documentation Wrong?

Postby rainbowsprinklez » October 18th, 2022, 7:56 am

Cyclone wrote:What I meant by the 21st byte was the number of bytes from the start of the header to the address of for example the tempo address.


Thanks, although I figured it out quickly when I remember 'normal' people use the decimal system :D
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016

Re: Music Documentation Wrong?

Postby rainbowsprinklez » November 15th, 2023, 10:44 am

Hey, Cyclone or anybody else.... does anybody have a list of what each waveform represents? I have a list... but it is incomplete. Thanks!
Veteran Venturer
Bananas received 110
Posts: 596
Joined: 2016


Return to ROM Hacking

Who is online

Users browsing this forum: No registered users and 6 guests