Puzzle Bobble / Bust-A-Move
Zeldix :: MSU-1 Hacking :: MSU-1 Development :: Finished
Page 2 of 2
Page 2 of 2 • 1, 2
Re: Puzzle Bobble / Bust-A-Move
zdrmonstera
well, the code we are replacing to hook at pause is once again 6 bytes in length. so you need two more NOP commands at the hook to avoid wrong execution of code
you don't need the macro msu detection at all for dopause, since to get to dopause you have already passed the check.
other than those issues this looks good.
- 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
;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:
%CheckNoMSU(dopause2)
LDA #$04
STA $2007 ; sets MSU play
nop
STZ $2007 ; sets MSU play
dopause2:
nop
nop
nop
PLP
RTL
dounpause:
lda $0430
jsl msuunpause
PLP
RTL
well, the code we are replacing to hook at pause is once again 6 bytes in length. so you need two more NOP commands at the hook to avoid wrong execution of code
you don't need the macro msu detection at all for dopause, since to get to dopause you have already passed the check.
other than those issues this looks good.
Re: Puzzle Bobble / Bust-A-Move
Just a few common notes to avoid troubles when hijacking code:
1. always nop out the correct number of bytes where you hijack, you need to count, for example
Stz $0101
Stz $02
Are 5 bytes, a jsl takes 4 bytes, so 1 nop
Stz $0101
Stz $0202
Are 6 bytes so 2 nops after your jsl
2.
Execute the code you overwrote for hijacking in the new code area. This is almost always necessary, for example:
.Freespace:
Stz $0101
Stz $02
...then write your new code
3. Whenever you change something in a, x, y, or processor status, push the values on stack first to restore them later, e.g.
.freespace:
Pha
PHX
Phy
PHP
Sep #$20
....your code
Plp
Ply
Plx
Pla
RTL
(Pull stack in reversed order)
With these Tipps you may avoid some frustrations
1. always nop out the correct number of bytes where you hijack, you need to count, for example
Stz $0101
Stz $02
Are 5 bytes, a jsl takes 4 bytes, so 1 nop
Stz $0101
Stz $0202
Are 6 bytes so 2 nops after your jsl
2.
Execute the code you overwrote for hijacking in the new code area. This is almost always necessary, for example:
.Freespace:
Stz $0101
Stz $02
...then write your new code
3. Whenever you change something in a, x, y, or processor status, push the values on stack first to restore them later, e.g.
.freespace:
Pha
PHX
Phy
PHP
Sep #$20
....your code
Plp
Ply
Plx
Pla
RTL
(Pull stack in reversed order)
With these Tipps you may avoid some frustrations
Conn- Since : 2013-06-30
Re: Puzzle Bobble / Bust-A-Move
I didn't see this before I realized there was a number 2 at the bottom of the page (haha), so I brought out Mesen-S's debugger and figured out to put in the two nops myself. Now that the patch is complete for the PAL version, how would I go about porting it to Bust-A-Move (US version)?Cubear wrote:zdrmonstera
- 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
;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:
%CheckNoMSU(dopause2)
LDA #$04
STA $2007 ; sets MSU play
nop
STZ $2007 ; sets MSU play
dopause2:
nop
nop
nop
PLP
RTL
dounpause:
lda $0430
jsl msuunpause
PLP
RTL
well, the code we are replacing to hook at pause is once again 6 bytes in length. so you need two more NOP commands at the hook to avoid wrong execution of code
you don't need the macro msu detection at all for dopause, since to get to dopause you have already passed the check.
other than those issues this looks good.
9:XX AM code (In case you didn't see it in the edit):
- 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
zdrmonstera- Since : 2022-08-26
Re: Puzzle Bobble / Bust-A-Move
most of the time, a different version of the game will have very similar code, maybe with a few things moved at the time the rom was assembled/compiled
porting your code to a different version means finding where in that new rom all your hooks are supposed to be.
there's a few ways to do this, you can breakpoint the same ways and find the same things, or you can search the rom with a hex editor (using the hex for the original code) to find the new addresses.
porting your code to a different version means finding where in that new rom all your hooks are supposed to be.
there's a few ways to do this, you can breakpoint the same ways and find the same things, or you can search the rom with a hex editor (using the hex for the original code) to find the new addresses.
Re: Puzzle Bobble / Bust-A-Move
i use bsnes plus for its debugger, so you may have a different experience through this, but i open up the "memory manager" and go to the address of my hook.
.
that's your "pause" hook in the PAL rom (unmodified)
i copy it out and put it into the "search hex" function in a hex editor
i usually try two or three searches just to make sure i didn't make a mistake. you can tell if you get the right one because the hex code before your instructions is the same ($3D)
here's the file in HxD, a free hex editor. you can see it found the hook's native code, and the preceding value is also $3D so this is likely the spot.
then you need to convert the PC address back to a SNES address
so $00be01 should be where you can hook in the USA rom for pausing.
.
that's your "pause" hook in the PAL rom (unmodified)
i copy it out and put it into the "search hex" function in a hex editor
i usually try two or three searches just to make sure i didn't make a mistake. you can tell if you get the right one because the hex code before your instructions is the same ($3D)
here's the file in HxD, a free hex editor. you can see it found the hook's native code, and the preceding value is also $3D so this is likely the spot.
then you need to convert the PC address back to a SNES address
so $00be01 should be where you can hook in the USA rom for pausing.
Re: Puzzle Bobble / Bust-A-Move
looking at this from here though, this is a lot of work to show you that your hooks are probably fine and don't need to be changed, but it is good for you to learn to do this >:)
Re: Puzzle Bobble / Bust-A-Move
I think my patch is pretty much now complete, where can I submit it and what are the requirements for a MSU-1 hack to get onto the database?
zdrmonstera- Since : 2022-08-26
Re: Puzzle Bobble / Bust-A-Move
well, it's not "complete" until you have a PCM pack to go with it, once that is done you can post it yourself in the database section
Page 2 of 2 • 1, 2
Similar topics
» Puzzle Bobble: Bust-A-Move
» Can not move when holding sword
» How to move fog overlay in lost woods
» How to move doors in dungeon rooms
» Zelda3 Puzzle of Life
» Can not move when holding sword
» How to move fog overlay in lost woods
» How to move doors in dungeon rooms
» Zelda3 Puzzle of Life
Zeldix :: MSU-1 Hacking :: MSU-1 Development :: Finished
Page 2 of 2
Permissions in this forum:
You cannot reply to topics in this forum