How to change music pointers in Donkey Kong Country?

Started by Cyclone, June 21, 2022, 12:37:03 AM

Previous topic - Next topic

Cyclone

Hi, I would like to change the music in this game. I found this bit of info on another forum.
Quote
In addition to this, the waveform set system is used.
    This is the one that reads the specified waveform into ARAM.
    There is one waveform set for each song.
    The pointer to the waveform set starts at 0x0AB212. It is specified only in the lower 2 bytes.
    The most significant byte is fixed at 0x0A.
    For song number 00, it is "0xB286", in which case the waveform set starts at 0x0AB286.

Quote
  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
    0x0AB3F0 1A Level Goal 0x13E789 0x0AB38A            (Null) 0x0AB330

Question is how can I for example change the Map Screen music with a different song?

Thanks in advance.

Cyneprepou4uk

Search for B2 86 or 86 B2 bytes for example, and replace them with pointer for another song, I guess.

The best way would be replacing song ID for a particular game scenario, instead of changing pointers.

Cyclone

Thanks for your suggestion. I already tried that. I changed all the values around and searched for those bytes. The game didn't do anything and the music didn't change.

How do I find the those song ids?

Cyneprepou4uk

I would start with adding a read breakpoint at pointers in debugger, to find out how the game chooses one of them.

Are you positive all that info from another forum is correct? And did you actuallly find correct pointers? If you go to the addresses from the list and start replacing values with 00 or something, will it affect the song in any way?

Cyclone

#4
Here is a bit of code that MAttrizle put together from a Japanese reference. I was able to change the tempo of the music with the info in that text.

This was translated but contains more info.

Quote
Where is it in the ROM?
 
    The following information is for those without headers, ver1.0, and NOINTERLEAVE(NORMAL).

    Super Donkey Kong has a lot of roundabout ways of specifying songs.
    Indirect addressing is used a lot.
    The pointer to the sequence starts at 0x0AB15E.
    The waveform offset starts at 0x09FF00.
   
    Also, Super Donkey Kong has a resident waveform that is always placed in ARAM.
    The resident waveforms are waveform numbers 0x01, 0x02, 0x03, 0x06, 0x07, 0x08, 0x09, 0x0A, 0x0B, 0x0E,
                       0x0F, 0x11, 0x16, 0x1D, 0x1F, 0x20, 0x21, 0x22, 0x23, 0x24,
                       0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B, 0x36, 0x44,
    The number of waveforms and their tones are stored in this txt file.
    See the bottom of this txt for waveform numbers and their tones.
   
   
    In addition to this, the waveform set system is also used.
    This is the thing that loads the specified waveforms into ARAM.
    There is one waveform set per song.
    The pointer to the waveform set starts at 0x0AB212. Only the lower two bytes are used to specify the waveform.
    The most significant byte is fixed at 0x0A.
    For song number 00, it is "0xB286", in this case the waveform set starts at 0x0AB286.

Translated with www.DeepL.com/Translator (free version)

Quote
Header of music data:
Bytes 0x00-0x01 Length of data, not including this or the next two bytes (DKC1)/SPC RAM Destination (DKC2 & 3; Always 1300)
Bytes 0x02-0x03 SPC RAM Destination (DKC1, always 12A0)/ Length of data divided by two (DKC2 & 3)
0x04-0x13   SPC RAM Pointers to each instrument track's data for (2 bytes per pointer, 8 tracks per song)(this for song 0x00 in a set in DKC2 & 3)
0x14      Music Tempo
0x15      Sound Effect Tempo (Always A0 in DKC1; FF in DKC2 & 3)

DKC2 & 3 only:
0x16-0x??   Pointers to each song's instrument track pointer table (2 bytes per song; length varies depending on how many songs are in the set)
0x??-0x??   SPC RAM Pointers to each instrument track's data for song 0x01, followed by music and sound effect tempo (if the song exists)
0x??-0x??   SPC RAM Pointers to each instrument track's data for song 0x02, followed by music and sound effect tempo (if the song exists)
...etc.

The actual instrument track data comes after this, and can include the following control codes:

Control Codes (documentation is still incomplete):
00               End of sound data
01 II               Set Instrument sample (Valid values: 00-45(DKC1)
02 LL RR            Volume Levels (separate values for left and right speakers)
03 yy XX            Play sound data at SPC RAM address XXyy
04 NN yy XX         Play sound data at SPC RAM address XXyy NN times, then return
05               ????? (sometimes used at the end of sound data instead of 00)
06 ??               Global note length (if not set, must specify a note length after each note value)
08 ?? ?? ?? ??           ????? (DKC1)
0B ??               ????? (DKC1)
10 ?? ??            Attack/Decay/Sustain/Release(ADSR) of current instrument?
11 LL RR            Master Level (LL = left, RR = right; valid range: #$00-#$7F)
12 ??               ?????
13 PP            Set Instrument Pitch (signed)
14 PP            Increase/Decrease Instrument Pitch (signed)
15 KK LL RR         Echo of entire song (KK = feedback, LL = left echo level, RR = right echo level)
16 ?? ??            ?????
17               ????? (DKC1)
18 ?? ?? ?? ?? ?? ?? ?? ??      Finite Impulse Response(FIR) Filter for whole song
21 yy XX            Play sound data at SPC RAM address XXyy, different from 03? (DKC2 & 3 only)
23 VV            Volume Levels (same value for both speakers, DKC2 & 3 only)
28 II LL RR         Set instrument and left/right levels (DKC1 only?)
2A ??               ????? (DKC1 only?, Usually #$64)
80               Rest
81-??               Music Note Scale

I tried using the break point editor. added a value when a level is loaded. the image below is the info it gave me. Where is the address I need? Thanks

https://imgur.com/a/X3tOsny

Cyneprepou4uk

Now you need to set write breakpoints to $4C and $4D, to track down where 61 and 93 are written. There probably will be a lot of breakpoint hits, so keep an eye on values in AXY registers (depending on via which one the value will be written) to find a correct hit, or specify a breakpoint condition.

Cyclone

#6
You are correct. I got lots of $4C hits.

Here is a line from the breakpoint info.

Breakpoint 0 hit (34).
8ab1d8 sta $4c       [00004c] A:8c65 X:0045 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 33 H:234 F:39


8c65 is The Cranky Theme addrress from that reference I posted.

What do I do with this info?

I did a trace with the breakpoint. here is a samll part of the log.

Quote
b99035 rts                    A:0401 X:05df Y:00ff S:01f8 D:0000 DB:80 nvmxdIzC V: 45 H:208 F:38
b9905b pla                    A:0401 X:05df Y:00ff S:01fa D:0000 DB:80 nvmxdIzC V: 45 H:218 F:38
b9905c jsl $b990ce   [b990ce] A:0017 X:05df Y:00ff S:01fc D:0000 DB:80 nvmxdIzC V: 45 H:227 F:38
b990ce sta $0523     [800523] A:0017 X:05df Y:00ff S:01f9 D:0000 DB:80 nvmxdIzC V: 45 H:240 F:38
b990d1 jsl $8ab1c6   [8ab1c6] A:0017 X:05df Y:00ff S:01f9 D:0000 DB:80 nvmxdIzC V: 45 H:249 F:38
8ab1c6 rep #$30               A:0017 X:05df Y:00ff S:01f6 D:0000 DB:80 nvmxdIzC V: 45 H:262 F:38
8ab1c8 php                    A:0017 X:05df Y:00ff S:01f6 D:0000 DB:80 nvmxdIzC V: 45 H:267 F:38
8ab1c9 pha                    A:0017 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 45 H:272 F:38
8ab1ca rep #$30               A:0017 X:05df Y:00ff S:01f3 D:0000 DB:80 nvmxdIzC V: 45 H:279 F:38
8ab1cc pla                    A:0017 X:05df Y:00ff S:01f3 D:0000 DB:80 nvmxdIzC V: 45 H:283 F:38
8ab1cd sta $4c       [00004c] A:0017 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 45 H:292 F:38
8ab1cf asl a                  A:0017 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 45 H:299 F:38
8ab1d0 clc                    A:002e X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 45 H:302 F:38
8ab1d1 adc $4c       [00004c] A:002e X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 45 H:305 F:38
8ab1d3 tax                    A:0045 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 45 H:312 F:38
8ab1d4 lda $8ab159,x [8ab19e] A:0045 X:0045 Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 45 H:315 F:38
8ab1d8 sta $4c       [00004c] A:8c65 X:0045 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 45 H:323 F:38
8ab1da lda $8ab15b,x [8ab1a0] A:8c65 X:0045 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 45 H:330 F:38
8ab1de and #$00ff             A:cc8a X:0045 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 45 H:339 F:38
8ab1e1 sta $4e       [00004e] A:008a X:0045 Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 46 H:  3 F:38
8ab1e3 ldx $4c       [00004c] A:008a X:0045 Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 46 H: 10 F:38
8ab1e5 jsr $b4e6     [8ab4e6] A:008a X:8c65 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 46 H: 17 F:38
8ab4e6 php                    A:008a X:8c65 Y:00ff S:01f3 D:0000 DB:80 NvmxdIzc V: 46 H: 27 F:38
8ab4e7 sep #$20               A:008a X:8c65 Y:00ff S:01f2 D:0000 DB:80 NvmxdIzc V: 46 H: 32 F:38
8ab4e9 rep #$10               A:008a X:8c65 Y:00ff S:01f2 D:0000 DB:80 NvMxdIzc V: 46 H: 37 F:38
8ab4eb ldy #$0000             A:008a X:8c65 Y:00ff S:01f2 D:0000 DB:80 NvMxdIzc V: 46 H: 41 F:38
8ab4ee lda [$4c],y   [8a8c65] A:008a X:8c65 Y:0000 S:01f2 D:0000 DB:80 nvMxdIZc V: 46 H: 46 F:38
8ab4f0 sta $4f       [00004f] A:00f8 X:8c65 Y:0000 S:01f2 D:0000 DB:80 NvMxdIzc V: 46 H: 56 F:38
8ab4f2 iny                    A:00f8 X:8c65 Y:0000 S:01f2 D:0000 DB:80 NvMxdIzc V: 46 H: 61 F:38
8ab4f3 lda [$4c],y   [8a8c66] A:00f8 X:8c65 Y:0001 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H: 64 F:38
8ab4f5 sta $50       [000050] A:0006 X:8c65 Y:0001 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H: 75 F:38
8ab4f7 iny                    A:0006 X:8c65 Y:0001 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H: 80 F:38
8ab4f8 lda [$4c],y   [8a8c67] A:0006 X:8c65 Y:0002 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H: 83 F:38
8ab4fa xba                    A:00a0 X:8c65 Y:0002 S:01f2 D:0000 DB:80 NvMxdIzc V: 46 H: 93 F:38
8ab4fb iny                    A:a000 X:8c65 Y:0002 S:01f2 D:0000 DB:80 nvMxdIZc V: 46 H: 98 F:38
8ab4fc lda [$4c],y   [8a8c68] A:a000 X:8c65 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H:101 F:38
8ab4fe plp                    A:a012 X:8c65 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H:111 F:38
8ab4ff php                    A:a012 X:8c65 Y:0003 S:01f3 D:0000 DB:80 NvmxdIzc V: 46 H:118 F:38
8ab500 sep #$20               A:a012 X:8c65 Y:0003 S:01f2 D:0000 DB:80 NvmxdIzc V: 46 H:123 F:38
8ab502 xba                    A:a012 X:8c65 Y:0003 S:01f2 D:0000 DB:80 NvMxdIzc V: 46 H:127 F:38
8ab503 tax                    A:12a0 X:8c65 Y:0003 S:01f2 D:0000 DB:80 NvMxdIzc V: 46 H:132 F:38
8ab504 lda #$04               A:12a0 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H:145 F:38
8ab506 clc                    A:1204 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H:148 F:38
8ab507 adc $4c       [00004c] A:1204 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H:151 F:38
8ab509 sta $4c       [00004c] A:1269 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H:156 F:38
8ab50b bcc $b50f     [8ab50f] A:1269 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 46 H:161 F:38

I am trying to backtrack from the break point to try to understand how the code works.

Cyneprepou4uk

Seems you've found the right place. There's index 0017 for this song is pulling out from stack at line 2, you can see its value A at line 3.

The log is not big enough, you need to trace further back. You can also switch to execute breakpoints at code locations since you know where code is now.

Cyclone

#8
Quote
You can also switch to execute breakpoints at code locations since you know where code is now.

It didn't find the execute breakpoint.

More of the log. Not sure how far back to go.

8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:102 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:108 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:113 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:118 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:124 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:129 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:133 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:149 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:154 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:159 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:165 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:170 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:174 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:180 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:185 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:190 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:196 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:201 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:205 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:211 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:216 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:221 F: 4
8ab515 eor $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:227 F: 4
8ab517 bne $b512     [8ab512] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:232 F: 4
8ab512 lda $2140     [802140] A:0480 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:236 F: 4
8ab515 eor $00       [000000] A:0401 X:05de Y:00fe S:01f0 D:0000 DB:80 nvMxdIzc V: 28 H:242 F: 4
8ab517 bne $b512     [8ab512] A:0400 X:05de Y:00fe S:01f0 D:0000 DB:80 nvMxdIZc V: 28 H:247 F: 4
8ab519 lda [$4c],y   [7e70fe] A:0400 X:05de Y:00fe S:01f0 D:0000 DB:80 nvMxdIZc V: 28 H:250 F: 4
8ab51b sta $2141     [802141] A:0400 X:05de Y:00fe S:01f0 D:0000 DB:80 nvMxdIZc V: 28 H:261 F: 4
8ab51e stx $2142     [802142] A:0400 X:05de Y:00fe S:01f0 D:0000 DB:80 nvMxdIZc V: 28 H:267 F: 4
8ab521 lda $00       [000000] A:0400 X:05de Y:00fe S:01f0 D:0000 DB:80 nvMxdIZc V: 28 H:275 F: 4
8ab523 eor #$80               A:0401 X:05de Y:00fe S:01f0 D:0000 DB:80 nvMxdIzc V: 28 H:280 F: 4
8ab525 ora #$01               A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:283 F: 4
8ab527 sta $00       [000000] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:286 F: 4
8ab529 sta $2140     [802140] A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:291 F: 4
8ab52c inx                    A:0481 X:05de Y:00fe S:01f0 D:0000 DB:80 NvMxdIzc V: 28 H:297 F: 4
8ab52d iny                    A:0481 X:05df Y:00fe S:01f0 D:0000 DB:80 nvMxdIzc V: 28 H:300 F: 4
8ab52e cpy $4f       [00004f] A:0481 X:05df Y:00ff S:01f0 D:0000 DB:80 nvMxdIzc V: 28 H:303 F: 4
8ab530 bne $b512     [8ab512] A:0481 X:05df Y:00ff S:01f0 D:0000 DB:80 nvMxdIZC V: 28 H:310 F: 4
8ab532 plp                    A:0481 X:05df Y:00ff S:01f0 D:0000 DB:80 nvMxdIZC V: 28 H:313 F: 4
8ab533 rts                    A:0481 X:05df Y:00ff S:01f1 D:0000 DB:80 nvMxdIzC V: 28 H:319 F: 4
8ab4e3 rep #$20               A:0481 X:05df Y:00ff S:01f3 D:0000 DB:80 nvMxdIzC V: 28 H:328 F: 4
8ab4e5 rts                    A:0481 X:05df Y:00ff S:01f3 D:0000 DB:80 nvmxdIzC V: 28 H:333 F: 4
8ab421 rep #$20               A:0481 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 29 H:  3 F: 4
8ab423 rtl                    A:0481 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 29 H:  7 F: 4
b99035 rts                    A:0481 X:05df Y:00ff S:01f8 D:0000 DB:80 nvmxdIzC V: 29 H: 18 F: 4
b9905b pla                    A:0481 X:05df Y:00ff S:01fa D:0000 DB:80 nvmxdIzC V: 29 H: 28 F: 4
b9905c jsl $b990ce   [b990ce] A:0017 X:05df Y:00ff S:01fc D:0000 DB:80 nvmxdIzC V: 29 H: 36 F: 4
b990ce sta $0523     [800523] A:0017 X:05df Y:00ff S:01f9 D:0000 DB:80 nvmxdIzC V: 29 H: 50 F: 4
b990d1 jsl $8ab1c6   [8ab1c6] A:0017 X:05df Y:00ff S:01f9 D:0000 DB:80 nvmxdIzC V: 29 H: 58 F: 4
8ab1c6 rep #$30               A:0017 X:05df Y:00ff S:01f6 D:0000 DB:80 nvmxdIzC V: 29 H: 72 F: 4
8ab1c8 php                    A:0017 X:05df Y:00ff S:01f6 D:0000 DB:80 nvmxdIzC V: 29 H: 76 F: 4
8ab1c9 pha                    A:0017 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 29 H: 81 F: 4
8ab1ca rep #$30               A:0017 X:05df Y:00ff S:01f3 D:0000 DB:80 nvmxdIzC V: 29 H: 88 F: 4
8ab1cc pla                    A:0017 X:05df Y:00ff S:01f3 D:0000 DB:80 nvmxdIzC V: 29 H: 93 F: 4
8ab1cd sta $4c       [00004c] A:0017 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 29 H:101 F: 4
8ab1cf asl a                  A:0017 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzC V: 29 H:108 F: 4
8ab1d0 clc                    A:002e X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 29 H:111 F: 4
8ab1d1 adc $4c       [00004c] A:002e X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 29 H:114 F: 4
8ab1d3 tax                    A:0045 X:05df Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 29 H:121 F: 4
8ab1d4 lda $8ab159,x [8ab19e] A:0045 X:0045 Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 29 H:124 F: 4
8ab1d8 sta $4c       [00004c] A:8c65 X:0045 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 29 H:143 F: 4
8ab1da lda $8ab15b,x [8ab1a0] A:8c65 X:0045 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 29 H:150 F: 4
8ab1de and #$00ff             A:cc8a X:0045 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 29 H:159 F: 4
8ab1e1 sta $4e       [00004e] A:008a X:0045 Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 29 H:164 F: 4
8ab1e3 ldx $4c       [00004c] A:008a X:0045 Y:00ff S:01f5 D:0000 DB:80 nvmxdIzc V: 29 H:171 F: 4
8ab1e5 jsr $b4e6     [8ab4e6] A:008a X:8c65 Y:00ff S:01f5 D:0000 DB:80 NvmxdIzc V: 29 H:178 F: 4
8ab4e6 php                    A:008a X:8c65 Y:00ff S:01f3 D:0000 DB:80 NvmxdIzc V: 29 H:188 F: 4
8ab4e7 sep #$20               A:008a X:8c65 Y:00ff S:01f2 D:0000 DB:80 NvmxdIzc V: 29 H:193 F: 4
8ab4e9 rep #$10               A:008a X:8c65 Y:00ff S:01f2 D:0000 DB:80 NvMxdIzc V: 29 H:197 F: 4
8ab4eb ldy #$0000             A:008a X:8c65 Y:00ff S:01f2 D:0000 DB:80 NvMxdIzc V: 29 H:202 F: 4
8ab4ee lda [$4c],y   [8a8c65] A:008a X:8c65 Y:0000 S:01f2 D:0000 DB:80 nvMxdIZc V: 29 H:206 F: 4
8ab4f0 sta $4f       [00004f] A:00f8 X:8c65 Y:0000 S:01f2 D:0000 DB:80 NvMxdIzc V: 29 H:217 F: 4
8ab4f2 iny                    A:00f8 X:8c65 Y:0000 S:01f2 D:0000 DB:80 NvMxdIzc V: 29 H:222 F: 4
8ab4f3 lda [$4c],y   [8a8c66] A:00f8 X:8c65 Y:0001 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:225 F: 4
8ab4f5 sta $50       [000050] A:0006 X:8c65 Y:0001 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:235 F: 4
8ab4f7 iny                    A:0006 X:8c65 Y:0001 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:240 F: 4
8ab4f8 lda [$4c],y   [8a8c67] A:0006 X:8c65 Y:0002 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:243 F: 4
8ab4fa xba                    A:00a0 X:8c65 Y:0002 S:01f2 D:0000 DB:80 NvMxdIzc V: 29 H:254 F: 4
8ab4fb iny                    A:a000 X:8c65 Y:0002 S:01f2 D:0000 DB:80 nvMxdIZc V: 29 H:258 F: 4
8ab4fc lda [$4c],y   [8a8c68] A:a000 X:8c65 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:261 F: 4
8ab4fe plp                    A:a012 X:8c65 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:272 F: 4
8ab4ff php                    A:a012 X:8c65 Y:0003 S:01f3 D:0000 DB:80 NvmxdIzc V: 29 H:278 F: 4
8ab500 sep #$20               A:a012 X:8c65 Y:0003 S:01f2 D:0000 DB:80 NvmxdIzc V: 29 H:283 F: 4
8ab502 xba                    A:a012 X:8c65 Y:0003 S:01f2 D:0000 DB:80 NvMxdIzc V: 29 H:288 F: 4
8ab503 tax                    A:12a0 X:8c65 Y:0003 S:01f2 D:0000 DB:80 NvMxdIzc V: 29 H:292 F: 4
8ab504 lda #$04               A:12a0 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:295 F: 4
8ab506 clc                    A:1204 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:298 F: 4
8ab507 adc $4c       [00004c] A:1204 X:12a0 Y:0003 S:01f2 D:0000 DB:80 nvMxdIzc V: 29 H:301 F: 4


Edit
this value jmp ( $83b6, X) at address B9801B changes some of the music when loading the first level. Just don't know how to change the Music when visiting Cranky. Also its guess work when changing that value in the screen shot I posted.




June 24, 2022, 01:31:59 AM - (Auto Merged - Double Posts are not allowed before 7 days.)

https://imgur.com/a/DQVEIXk

Mattrizzle

There are a few different subroutines/entry points having to do with music.  All of these are in bank $B9. For the first three, the accumulator (A) should contain the 16-bit value of the music track to play prior to jumping to the subroutine. The values to load into A match the list in the second quote block in your original post.

  • $B99023 jumps to $9027, which loads a music track (sequence data, BRR waveforms, etc.), but doesn't play it. Both of the routines following this one jsr to $9027 as well.
  • $B99036 loads a music track and plays it no matter what.
  • $B99049 checks the value of the music track which is playing, and only switches to the new track if the value in A doesn't match this.
  • $B990CE starts or restarts the loaded music track. $B99036 and $B99049 both call this subroutine.
  • $B990E7 stops the track. (I could be wrong on this one.)

Sometimes these routines are JSL'd into, while other times they are JML'd into.

For instance, code at $80EAA9 loads and plays Cranky's Theme when it is heard at Cranky's Cabin, calling $B99049 using a JSL:
org $80EAA9
lda #$0017
jsl $B99049


In another example, code at $B99015 loads and plays the same music track when it is heard in D.K.'s treehouse, but calls the subroutine $B99036 using a JML:
org $B99015
lda #$0017
jml $B99036


The last code snippet you posted seems to be part of the subroutine $8AB40F, which is called by $B99027. Stepping out of that should put you at $B99035. Stepping out again should put you at either $B99043 (in the middle of $B99036) or $B9905B (in the middle of $B99049).

Cyneprepou4uk

#10
QuoteMore of the log

That's still not enough. You need to locate 0017 value. Mattrizzle mentions 2 locations.

QuoteIt didn't find the execute breakpoint.

It could be called differently. It's neither read nor write.

Cyclone

Thank you for the help. Got it working  now. I was able to use the same method to change Funky's music as well... Mattrizzle thank you very much for taking the time to help me. much appreciated. Same to you Cyneprepou4uk

Btw what does org mean? I can't find that op code in the snes doc.

Cyneprepou4uk

That's not an opcode, it's assembler's control command, which means something like "place code here"

bogaabogaa



Changing the pointer around seems also the way to go since the index is used for multiple things in the level. 

Also "org" is a directive of some assemblers. Best practice is to look up the documentation of the assembler to know what they do. For all injection assembler I found it will tell the assembler the current offset to start assembling. The number also seems represents the CPU bus offset of the mounted ROM what helps to look things up in the debugger and doing your changes in a asm file you then use to patch the ROM with.   
CV ROM DiscordServer
https://discord.gg/PvFgxRg