Puzzle Bobble / Bust-A-Move

Page 1 of 2 1, 2  Next

Go down

 Puzzle Bobble / Bust-A-Move Empty Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Fri 26 Aug 2022 - 19:08

Project finished:
https://www.zeldix.net/t2534-puzzle-bobble-bust-a-move

Hey, I'm trying to research how Puzzle Bobble for the Super NES uses the SPC so that I can mute the music in order to create an MSU-1 patch, but I'm not sure how the game's sound driver works. I tried NOPing out some APUIO addresses but it seems to mute the sound effects as well, is anyone smart enough to get into the game's ROM and tell me how I should mute the SPC music in the game?

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Conn Sat 27 Aug 2022 - 11:36

The rom seems to have 2 soundbanks, to mute the spc I'd try this:

unheadered rom, ENGLISH version (didn't find a US):
0x29213: 10 f8 -> 00 00 (Soundbank 1)
0x58d07: 10 f8 -> 00 00 (Soundbank 2)

 Puzzle Bobble / Bust-A-Move Image258

This is a hard mute, so spc fallback isn't possible
Conn
Conn

 Puzzle Bobble / Bust-A-Move Image212

Since : 2013-06-30

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 13:22

To stop music, the game sends #$00 to $2140, $2142, $2143.

Looks like track numbers come across via $2143 at instruction $85B93B in the USA rom. #$20 and above seems to be music with some signals to filter out in the #$7F-FF range.

if you detect #$20 and above and replace it with #$00, the game's music will mute.

@Conn, this game launched under a different name in the US, as Bust-A-Move.

for some easy initial testing, consider using this to access the sound test (USA rom only)

The Pro Action Replay (PAR) codes 8081BC7F + 8081BD82 + 8081BE8B (US version) will cause the sound test to replace the main menu.
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Quick proof of concept

Post by zdrmonstera Sat 27 Aug 2022 - 14:31

Made a quick and dirty asar patch that uses what @Cubear said about doing a soft mute, but it seems to crash before the TAITO logo shows up and I haven't implemented the MSU stuff yet. (This is intended for the PAL ROM, which I did the initial research with. You likely need to expand the ROM with Lunar Expander or something similar.) Is there some checksum check I need to get around for this patch to work better?

lorom

org $05B938
nop
autoclean JSL spc_mute

freedata
spc_mute:
;LDA $19
;BEQ .small
LDA $0512,X
SEC ; Set Carry Flag
SBC #$20
BCC .not_music ; If sound value is less than 20, branch to a duplicate of the original code.
LDA #$00
STA $2143 ; Otherwise...
RTL

.not_music
LDA $0512,X
STA $2143
RTL

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 16:49

what is likely happening there is you're not filtering out the mute code for the instructions that are above #$20.

the game sends multiple #$FF and #$7F to 2143, and your code will be sending #$00 for all of those instructions as well

in the sound test, the highest track number is #$28, so you should also break off into native code if the signal being sent to 2143 is above that number
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Conn Sat 27 Aug 2022 - 17:50

Seeing your code fragement and reading cubears message, he said "sends #$00 to $2140, $2142, $2143", and your code only covers $2143. Maybe that's the reason?
Conn
Conn

 Puzzle Bobble / Bust-A-Move Image212

Since : 2013-06-30

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Not that good at SNES assembly

Post by zdrmonstera Sat 27 Aug 2022 - 18:10

lorom

org $05B938
nop
autoclean JSL spc_mute

freedata
spc_mute:
;LDA $19
;BEQ .small
LDA $0512,X
SEC ; Set Carry Flag
SBC #$29
BCS .not_music
LDA $0512,X
SEC ; Set Carry Flag
SBC #$20
BCC .not_music ; If sound value is less than 20, branch to a duplicate of the original code.
LDA #$00
STA $2140
STA $2142
STA $2143 ; Otherwise...
RTL

.not_music
LDA $0512,X
STA $2143
RTL

This still crashes the game at startup, IDK what else to do.

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 18:13

here's what i've done to solve it. you needed an extra NOP in your hook.

lda 0512,x 
sta 2143 

is 6 bytes of instructions, jsl and nop is only 5, so when it returns from your code it runs arbitrary data as code

Code:
lorom

org $05B938
JSL spc_mute
nop
nop

org $108000
spc_mute:
;LDA $19
;BEQ .small
LDA $0512,X
cmp #$29          ;is it above the normal range for music??
bcs .not_music    ;branches at every value $29 and greater (not music)
SEC ; Set Carry Flag
SBC #$20
BCC .not_music ; If sound value is less than 20, branch to a duplicate of the original code.
LDA #$00
STA $2143 ; Otherwise...
RTL

.not_music
LDA $0512,X
STA $2143
RTL
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sat 27 Aug 2022 - 18:29

I have a question about this @Cubear, why did you change it so that the new code is at $108000 rather than freespace given by Lunar Expander? Is it just so that you can apply the patch without worrying about using Lunar Expander?

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 18:31

i build with asar and freecode autoclean etc has just never worked for me, it never assembles. lol

if it assembles for you, use it.


a reason i don't really mind just hard coding addresses is that it's really easy to breakpoint execution of your code since you know exactly where it is
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sat 27 Aug 2022 - 19:46

Code:
lorom

macro CheckNoMSU(labelToJump)
   LDA $2002  ; Stolen from the MSU-1 port of Super Mario World (Plus), sue me.
   CMP #$53
   BNE <labelToJump>
endmacro

org $05B938
autoclean JSL spc_mute
nop
nop

;org $108000 Might work, might not work.
freedata
spc_mute:
    LDA $0512,X
    cmp #$29
    bcs .not_music
    SEC ; Set Carry Flag
    SBC #$20
    BCC .not_music ; If sound value is less than 20, branch to a duplicate of the original code.
    %CheckNoMSU(.not_music) ; Same thing for if there is no MSU1 "chip".
    LDA #$00
    STA $2143 ; Otherwise...
    lda #$FF
   sta $2006
    lda $0512,X
    SEC ; Set Carry Flag
    SBC #$1F
   sta $2004
    STZ $2005
   lda #$01   ; Set audio state to play, no repeat.
   sta $2007
RTL

.not_music
    LDA $0512,X
    STA $2143
RTL

Here is a Puzzle Bobble (PAL version) MSU-1 asar patch I made, still pretty incomplete as no music loops and it can't pause the music yet but it seems to work fine within bsnes. I tested this with a pcm pack intended for Super Mario World, so the music was pretty unfitting from what I heard from the testing. I'm thinking about adding a cmp so that the background music loops and jingles like the game over and clear ones don't loop.

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 20:04

for MSU playing i mostly just steal some example code that Conn gave me when i was starting out. it looks like this:

Code:
Sta $2004 ;store incoming track to MSU1
Stz $2005 ;zero to msu1 high byte. looks like 00XX for track number
STZ $2006 ;zero to 2006.stops static/noise from msu during track loading on console.

loop:
Bit $2000 ;checking MSU1 state
BVS loop

LDA $2000;
AND #$08 ; is the track found?
BEQ $02 ;if yes, don't play spc.
bra spcfallback
;noloop tracks here
 cmp #$XX ;noloop 1
 beq noloop
 cmp #$XX ;noloop2
 beq noloop
 LDA #$03 ;everything else loops
 bra $02
 noloop:
 LDA #$01
 STA $2007 ; sets MSU play
 LDA #$FF ;\raises volume
 STA $2006;/

you'll need to do your own mute/fallback/whatever on top of this code, but it's good code. no need to reinvent the wheel, i say.


Last edited by Cubear on Sat 27 Aug 2022 - 20:49; edited 1 time in total
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sat 27 Aug 2022 - 20:32

Cubear wrote:for MSU playing i mostly just steal some example code that Conn gave me when i was starting out. it looks like this:

Code:
Sta $2004 ;store incoming track to MSU1
Stz $2005 ;zero to msu1 high byte. looks like 00XX for track number
STZ $2006 ;zero to 2006.stops static/noise from msu during track loading on console.

loop:
Bit $2000 ;checking MSU1 state
BVS loop

LDA $2000;
AND #$08 ; is the track found?
BEQ $02 ;if yes, don't play spc.
bra spcfallback
pla
;noloop tracks here
 cmp #$XX ;noloop 1
 beq noloop
 cmp #$XX ;noloop2
 beq noloop
 LDA #$03 ;everything else loops
 bra $02
 noloop:
 LDA #$01
 STA $2007 ; sets MSU play
 LDA #$FF ;\raises volume
 STA $2006;/

you'll need to do your own mute/fallback/whatever on top of this code, but it's good code. no need to reinvent the wheel, i say.

It seems like the MSU1 checking loop causes the game to freeze itself, how do I fix it aside from removing it (Which must be important for something)?

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Conn Sat 27 Aug 2022 - 20:38

Can you send your source how you implemented above code cubear sent?
You mean it freezes at the bit $2000 - bvs loop?
Conn
Conn

 Puzzle Bobble / Bust-A-Move Image212

Since : 2013-06-30

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sat 27 Aug 2022 - 20:39

Code:

lorom

macro CheckNoMSU(labelToJump)
   LDA $2002  ; Stolen from the MSU-1 port of Super Mario World (Plus), sue me.
   CMP #$53
   BNE <labelToJump>
endmacro

org $05B938
autoclean JSL spc_mute
nop
nop

;org $108000 Might work, might not work.
freedata
spc_mute:
    LDA $0512,X
    cmp #$29
    bcs not_music
    SEC ; Set Carry Flag
    SBC #$20
    BCC not_music ; If sound value is less than 20, branch to a duplicate of the original code.
    %CheckNoMSU(not_music) ; Same thing for if there is no MSU1 "chip".
    LDA #$00
    STA $2143 ; Otherwise...
    lda $0512,X
    SEC ; Set Carry Flag
    SBC #$1F
   Sta $2004 ;store incoming track to MSU1
    Stz $2005 ;zero to msu1 high byte. looks like 00XX for track number
    STZ $2006 ;zero to 2006.stops static/noise from msu during track loading on console.

loop:
    Bit $2000 ;checking MSU1 state
    BVS loop

    LDA $2000;
    AND #$08 ; is the track found?
    BEQ $02 ;if yes, don't play spc.
    bra not_music
    pla
;noloop tracks here
    cmp #$02 ;noloop 1
    beq noloop
    cmp #$03 ;noloop2
    beq noloop
    cmp #$04 ;noloop2
    beq noloop
    cmp #$06 ;noloop2
    beq noloop
    LDA #$03 ;everything else loops
    bra $02
noloop:
    LDA #$01
    STA $2007 ; sets MSU play
    LDA #$FF ;\raises volume
    STA $2006;/
RTL

not_music:
    LDA $0512,X
    STA $2143
RTL

Yeah, I believe so.

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Conn Sat 27 Aug 2022 - 20:42

The pla seems to be the culprit at a first glimpse
Conn
Conn

 Puzzle Bobble / Bust-A-Move Image212

Since : 2013-06-30

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sat 27 Aug 2022 - 20:45

Conn wrote:The pla seems to be the culprit at a first glimpse

I thought you might be wrong, but commenting out the pla instruction seems to make the game work again? Not sure what it does but it might be related to the looping stuff.

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 20:48

oh, i forgot to clean it out of the code. pla affects the stack, stack errors will absolutely crash the game lol
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 20:50

you'll need to get your track number back around that point though, so i'd recommend fixing it with a PHA on entry to your MSU1 code
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sat 27 Aug 2022 - 20:58

Not sure where to put the PHA, so I just copy and pasted the code for loading in the track number to put into the MSU1 track register instead.

Code:

lorom

macro CheckNoMSU(labelToJump)
   LDA $2002  ; Stolen from the MSU-1 port of Super Mario World (Plus), sue me.
   CMP #$53
   BNE <labelToJump>
endmacro

org $05B938
autoclean JSL spc_mute
nop
nop

;org $108000 Might work, might not work.
freedata
spc_mute:
    LDA $0512,X
    cmp #$29
    bcs not_music
    SEC ; Set Carry Flag
    SBC #$20
    BCC not_music ; If sound value is less than 20, branch to a duplicate of the original code.
    %CheckNoMSU(not_music) ; Same thing for if there is no MSU1 "chip".
    LDA #$00
    STA $2143 ; Otherwise...
    lda $0512,X
    SEC ; Set Carry Flag
    SBC #$1F
   Sta $2004 ;store incoming track to MSU1
    Stz $2005 ;zero to msu1 high byte. looks like 00XX for track number
    STZ $2006 ;zero to 2006.stops static/noise from msu during track loading on console.

loop:
    Bit $2000 ;checking MSU1 state
    BVS loop

    LDA $2000;
    AND #$08 ; is the track found?
    BEQ $02 ;if yes, don't play spc.
    bra not_music
    lda $0512,X
    SEC ; Set Carry Flag
    SBC #$1F
;noloop tracks here
    cmp #$02 ;noloop 1
    beq noloop
    cmp #$03 ;noloop2
    beq noloop
    cmp #$04 ;noloop2
    beq noloop
    cmp #$06 ;noloop2
    beq noloop
    LDA #$03 ;everything else loops
    bra $02
noloop:
    LDA #$01
    STA $2007 ; sets MSU play
    LDA #$FF ;\raises volume
    STA $2006;/
RTL

not_music:
    LDA $0512,X
    STA $2143
RTL

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Conn Sat 27 Aug 2022 - 21:17

Stack operations are crucial in any hackings... You are good adviced to learn about them as they are a very powerful tool.
Mostly they are used to restore values when you overwrite them
Like

Pha A:0094
LDA #32 A:0094
Sta $7fffff A:0032
Pla A:0032
RTL A:0094
(In this example the accumulator restores the previous value after you overwrote it

Every jsl puts the return address on the stack, so if you pull the stack into the accumulator without pushing it before, you pull the return address from your jsl into A, and the game returns through the RTL... Elsewhere Smile
There are pha, pla, PHX, plx, ...plp PHP, and so on. Never pull a value from stack before pushing it before, and never push a value without pulling it later Wink
Conn
Conn

 Puzzle Bobble / Bust-A-Move Image212

Since : 2013-06-30

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sat 27 Aug 2022 - 21:24

in this case, you'd PHA when you have your track number set on your accumulator.
so you could pha right around your sta $2004
then pla after the

     
    AND #$08 ; is the track found?
    BEQ $02 ;if yes, don't play spc.
    bra not_music2
    lda $0512,X
    SEC ; Set Carry Flag
    SBC #$1F

    PLA ;(gets you the same number as the code above)


in this case you will ALSO need a PLA before you enter your not_music, so what i usually do is have a not_music2: that leads into a PLA, then does not_music, like so:

not_music2:
pla
not_music:
    LDA $0512,X
    STA $2143
RTL


for more information on the stack, try reading this
https://ersanio.gitbook.io/assembly-for-the-snes/collection-of-values/stack
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sat 27 Aug 2022 - 21:52

Now I'm trying to get the MSU-1 music to pause, I found with Mesen-S's debugger that it seems like pausing the game calls music value #$94? Not sure what the unpause one is since I tired and it seems to only result in the value of the "coin" sound.

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by Cubear Sun 28 Aug 2022 - 0:35

pause status seems to be saved to memory value $0841 by instruction $80be04

Note: in this area of code the accumulator is in 16 bit mode, this changes how lots of things work, so you're best off saving your processor bits immediately.

$10 is pause, $00 is no pause

To pause and unpause the MSU1 you send commands to $2007
#$04 sets a resume point for the next time a track is played.

You may need to save your track number to some free ram somewhere to recall it for the unpause resume.  you can send your code back through the MSU play routine that you already have after loading this value and it should work fine.


an example would be 


org $80be01
jsl pause




pause:
eor $0840;native code
sta $0840;native code

PHP;saves the processor bits
SEP #$20 ;puts A into 8-bit mode
lda $0841
cmp #$10
beq dopause
cmp #$00
beq dounpause


more of your code here...

dounpause:
lda track number in ram
jsl playmsu ;just jump into it just before your sta $2004

then exiting you'll want to go



PLP
rtl
Cubear
Cubear

 Puzzle Bobble / Bust-A-Move Image211

Since : 2021-11-17

https://www.patreon.com/Cubear

Back to top Go down

 Puzzle Bobble / Bust-A-Move Empty Re: Puzzle Bobble / Bust-A-Move

Post by zdrmonstera Sun 28 Aug 2022 - 1:19

Code:

lorom

macro CheckNoMSU(labelToJump)
   LDA $2002  ; Stolen from the MSU-1 port of Super Mario World (Plus), sue me.
   CMP #$53
   BNE <labelToJump>
endmacro

org $05B938
autoclean JSL spc_mute
nop
nop

org $80be01
autoclean JSL pause
nop
nop

;org $108000 Might work, might not work.
freedata
spc_mute:
    LDA $0512,X
    CMP #$00
    BEQ stop_music
    cmp #$29
    bcs not_music
    SEC ; Set Carry Flag
    SBC #$20
    BCC not_music ; If sound value is less than 20, branch to a duplicate of the original code.
    %CheckNoMSU(not_music) ; Same thing for if there is no MSU1 "chip".
    LDA #$00
    STA $2143 ; Otherwise...
    lda $0512,X
    SEC ; Set Carry Flag
    SBC #$1F
msuunpause:
    PHA
   Sta $2004 ;store incoming track to MSU1
    STA $0430 ; Not sure if this is good, but should work.
    Stz $2005 ;zero to msu1 high byte. looks like 00XX for track number
    STZ $2006 ;zero to 2006.stops static/noise from msu during track loading on console.

loop:
    Bit $2000 ;checking MSU1 state
    BVS loop

    LDA $2000;
    AND #$08 ; is the track found?
    BEQ $02 ;if yes, don't play spc.
    bra not_music2
    PLA
;noloop tracks here
    cmp #$02 ;noloop 1
    beq noloop
    cmp #$03 ;noloop2
    beq noloop
    cmp #$04 ;noloop2
    beq noloop
    cmp #$06 ;noloop2
    beq noloop
    LDA #$03 ;everything else loops
    bra $02
noloop:
    LDA #$01
    STA $2007 ; sets MSU play
    LDA #$FF ;\raises volume
    STA $2006;/
RTL

not_music2:
    pla
not_music:
    LDA $0512,X
    STA $2143
RTL

stop_music:
    STZ $2143
    %CheckNoMSU(stop_music2)
    STZ $2007
stop_music2:
    nop
RTL

pause:
    eor $0840;native code
    sta $0840;native code

    PHP;saves the processor bits
    SEP #$20 ;puts A into 8-bit mode
    %CheckNoMSU(pauseB)
    lda $0841
    cmp #$10
    beq dopause
    cmp #$00
    beq dounpause
pauseB:
    PLP
RTL

dopause:
    LDA #$04
    STA $2007 ; sets MSU play
dopause2:
    nop
    nop
    nop
    PLP
RTL

dounpause:
    lda $0430
    jsl msuunpause
    PLP
RTL

Not sure if I'm following along with this properly.
Nevermind, I think I got it. This patch seems pretty complete now with the pausing in place.


Last edited by zdrmonstera on Sun 28 Aug 2022 - 10:20; edited 1 time in total

zdrmonstera

 Puzzle Bobble / Bust-A-Move Image111

Since : 2022-08-26

Back to top Go down

Page 1 of 2 1, 2  Next

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum