News
Welcome to NeoRHDN! This place is still a work-in-progress, so pardon the construction...
Views: 526,556
Sections: Documents | Utilities | ROM Hacks | Games | Translations | Homebrew | Fonts
Site: Main | Rules/FAQ | Discord | Memberlist | Latest posts | Stats | Ranks | Online users
10-08-24 11:53 AM
Guest: Register | Login

0 users currently in Hacking Discussion | 1 guest

Main - Hacking Discussion - Super Mario Bros. Fixes (3)

Pages: 1 2

ShaneM
Posted on 09-12-24 12:42 AM, in (rev. 10 of 09-12-24 03:34 PM by ShaneM) Link | ID: 790

Micro-Goomba

Level: 5

Posts: 7/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
I had you NOP the other stuff for neatness. The code is really only used in the conditional statement in ChkStart. It is only set/cleared in the other two routines. It did exactly what I thought it would. There are a few ways to do that. I’ve coded mine a different way.

Also, $0B7A is not a valid flag on SMB1 NES. I’d use a different one.

SMB2J-2Q
Posted on 09-12-24 03:39 PM, in (rev. 3 of 09-12-24 03:41 PM by SMB2J-2Q) Link | ID: 794

Goomba

Level: 7

Posts: 18/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Posted by ShaneM
I had you NOP the other stuff for neatness. The code is really only used in the conditional statement in ChkStart. It is only set/cleared in the other two routines. It did exactly what I thought it would. There are a few ways to do that. I’ve coded mine a different way.

Also, $0B7A is not a valid flag on SMB1 NES. I’d use a different one.

In my case, I did assign it to a different one: $06B7, formerly used by JumpCoinMiscOffset.

I will use your version of the code, though, but I was curious as to what it did.

~Ben

SMB2J-2Q
Posted on 09-15-24 01:52 AM, in (rev. 7 of 09-15-24 02:32 AM by SMB2J-2Q) Link | ID: 819

Goomba

Level: 7

Posts: 19/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Hi Shane,

I am curious as to the ChkGERtn routine:

ChkGERtn: lda GameEngineSubroutine ;get number of game engine routine running
cmp #$07
beq ExCSM ;if running player entrance routine or
cmp #$08 ;player control routine, go ahead and branch to leave
bne ExCSM
lda #$02
sta GameEngineSubroutine ;otherwise set sideways pipe entry routine to run
rts ;and leave

Specifically, this checks the GameEngineSubroutine variable for either routine $07 (for player entrance) or $08 (for player control) in action, and to branch to exit (ExCSM) if so. However, when checking for routine $08 it then says BNE (if not equal) and also leave the routine (to ExCSM), so unless they had intended to add additional code after this, then shouldn't that also be a BEQ or else if it is supposed to be a BNE branch, then shouldn't it be to StopPlayerMove? I am going to try that to see if any anomalies happen during the pipe intro scene.

UPDATE: I played the game with the change I applied and so far I have found no outstanding anomalies during Mario's automatic movement during the pipe intro scene.

~Ben

ShaneM
Posted on 09-15-24 04:45 PM, in (rev. 5 of 09-15-24 05:06 PM by ShaneM) Link | ID: 830

Micro-Goomba

Level: 5

Posts: 8/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
Posted by SMB2J-2Q
Hi Shane,

I am curious as to the ChkGERtn routine:

ChkGERtn: lda GameEngineSubroutine ;get number of game engine routine running
cmp #$07
beq ExCSM ;if running player entrance routine or
cmp #$08 ;player control routine, go ahead and branch to leave
bne ExCSM
lda #$02
sta GameEngineSubroutine ;otherwise set sideways pipe entry routine to run
rts ;and leave

Specifically, this checks the GameEngineSubroutine variable for either routine $07 (for player entrance) or $08 (for player control) in action, and to branch to exit (ExCSM) if so. However, when checking for routine $08 it then says BNE (if not equal) and also leave the routine (to ExCSM), so unless they had intended to add additional code after this, then shouldn't that also be a BEQ or else if it is supposed to be a BNE branch, then shouldn't it be to StopPlayerMove? I am going to try that to see if any anomalies happen during the pipe intro scene.

UPDATE: I played the game with the change I applied and so far I have found no outstanding anomalies during Mario's automatic movement during the pipe intro scene.

~Ben


I optimized it and commented it anew. Use this one and credit me if borrowed.


ChkGERtn: lda GameEngineSubroutine ;load number of game engine routine running
cmp #$08 ;compare against the player control routine
bne ExChkGERtn ;if any other routine, branch to leave
lda #$02 ;otherwise load value to
sta GameEngineSubroutine ;set sideways pipe entry routine to run
ExChkGERtn:rts ;leave


Also, in the future could you please ask in a more generalized way instead of specifically calling me in every post for an answer? This is a community thread for everyone to participate in not just me. Thanks. LOL



SMB2J-2Q
Posted on 09-15-24 05:43 PM, in (rev. 2 of 09-15-24 05:47 PM by SMB2J-2Q) Link | ID: 831

Goomba

Level: 7

Posts: 20/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Posted by ShaneM
Posted by SMB2J-2Q
Hi Shane,

I am curious as to the ChkGERtn routine:

ChkGERtn: lda GameEngineSubroutine ;get number of game engine routine running
cmp #$07
beq ExCSM ;if running player entrance routine or
cmp #$08 ;player control routine, go ahead and branch to leave
bne ExCSM
lda #$02
sta GameEngineSubroutine ;otherwise set sideways pipe entry routine to run
rts ;and leave

Specifically, this checks the GameEngineSubroutine variable for either routine $07 (for player entrance) or $08 (for player control) in action, and to branch to exit (ExCSM) if so. However, when checking for routine $08 it then says BNE (if not equal) and also leave the routine (to ExCSM), so unless they had intended to add additional code after this, then shouldn't that also be a BEQ or else if it is supposed to be a BNE branch, then shouldn't it be to StopPlayerMove? I am going to try that to see if any anomalies happen during the pipe intro scene.

UPDATE: I played the game with the change I applied and so far I have found no outstanding anomalies during Mario's automatic movement during the pipe intro scene.

~Ben


I optimized it and commented it anew. Use this one and credit me if borrowed.


ChkGERtn: lda GameEngineSubroutine ;load number of game engine routine running
cmp #$08 ;compare against the player control routine
bne ExChkGERtn ;if any other routine, branch to leave
lda #$02 ;otherwise load value to
sta GameEngineSubroutine ;set sideways pipe entry routine to run
ExChkGERtn:rts ;leave


Also, in the future could you please ask in a more generalized way instead of specifically calling me in every post for an answer? This is a community thread for everyone to participate in not just me. Thanks. LOL




Sorry about that.

I will try your optimized fix.

~Ben

SMB2J-2Q
Posted on 09-18-24 12:04 AM, in (rev. 2 of 09-18-24 12:06 AM by SMB2J-2Q) Link | ID: 862

Goomba

Level: 7

Posts: 21/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
I was just told by the person who compiled the SMAS-style level breakdown for SMB that the new $BA RAM flag was a flag created specifically for the underwater scene in world 8-4 in both SMB and SMBLL, which although it has the map type of underwater it keeps the palette and music attributes related to the castle level, hence why we're hearing the castle level music here.

~Ben (SMB2J-2Q)

SMB2J-2Q
Posted on 09-20-24 01:53 AM, in (rev. 4 of 09-20-24 04:21 AM by SMB2J-2Q) Link | ID: 890

Goomba

Level: 7

Posts: 22/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Could anyone please let me know what you think of my new fix for HandlePowerUpCollision?


HandlePowerUpCollision:
jsr EraseEnemyObject ;erase the power-up object
lda #$06
jsr SetupFloateyNumber ;award 1000 points to player by default
lda PowerUpType ;check power-up type
cmp #$02
beq SetForStar ;if star, branch
cmp #$03
beq SetFor1Up ;if 1-up mushroom, branch
lda #Sfx_PowerUpGrab
sta Square2SoundQueue ;otherwise super mushroom or fire flower, so play the power-up sound
bne Shroom_Flower_PUp ;then do unconditional branch ahead to corresponding routine
SetForStar:
lda #$23 ;set star mario invincibility timer,
sta StarInvincibleTimer ;and load the star mario music
lda #StarPowerMusic ;into the area music queue, then leave
sta AreaMusicQueue
rts

Here, both the invincibility star and 1-UP are checked first, and if either are found, to bypass playing the power-up grab sound (SMB2USA, SMB3 and SMBDX all have it not play the power-up sound when a Star is collected), otherwise if it's the Super Mushroom or Fire Flower, the power-up sound is played and we then do an unconditional branch (BNE) to the Shroom_Flower_PUp routine.

~Ben

ShaneM
Posted on 09-20-24 11:05 PM, in (rev. 16 of 09-21-24 02:00 PM by ShaneM) Link | ID: 898

Micro-Goomba

Level: 5

Posts: 9/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
@SMB2J-2Q great find! I didn't realize SMB Deluxe GBC did that. I optimized it for you. My whole routine is different in SMB2J where it does the modern powerdown so if you're fiery you become super and having multiple powerups on screen at once so I did it from scratch from Doppleganger's SMB1 disassembly. Test it and let me know. It doesn't require new space, actually saves 6 bytes and fixes:

*powerup sound playing with 1-UP mushroom
*powerup sound playing with Starman
*double jump glitch when grabbing a powerup


HandlePowerUpCollision:
jsr EraseEnemyObject ;erase the power-up object
lda #$06
jsr SetupFloateyNumber ;award 1000 points to player by default
lda PowerUpType ;check power-up type
cmp #$02
bcc Shroom_Flower_PUp ;if mushroom or fire flower, branch
cmp #$03
beq SetFor1Up ;if 1-up mushroom, branch
lda #$23 ;otherwise set star mario invincibility
sta StarInvincibleTimer ;timer, and load the star mario music
lda #StarPowerMusic ;into the area music queue, then leave
sta AreaMusicQueue
NoPUp:rts ;(SM label moved here, slightly saves on cycling)

Shroom_Flower_PUp: ;SM let's use Y register
ldy #Sfx_PowerUpGrab ;SM load the power-up sound
sty Square2SoundQueue ;SM and store it to play
ldy PlayerStatus ;if player status = small, branch
beq UpToSuper
cpy #$01 ;if player status not super, leave
bne NoPUp
iny ;set player status to fiery (SM saves 1 byte)
sty PlayerStatus
jsr GetPlayerColors ;run sub to change colors of player
lda #$0c ;set value to be used by subroutine tree (fiery)
bne UpToFiery ;branch to set values accordingly (SM originally was a jmp)

SetFor1Up:
lda #$0b ;change 1000 points into 1-up instead
sta FloateyNum_Control,x ;and then leave
rts

UpToSuper:
lda #$01 ;set player status to super
sta PlayerStatus
lda #$09 ;set value to be used by subroutine tree (super)

UpToFiery:
ldy PlayerStatus ;SM set value to be used as new player state
jmp SetPRout ;set values to stop certain things in motion (SM originally was a JSR RTS. Saves on cycling)


Credit me if borrowed. -ShaneM

EDIT: I was able to save another byte by using Y register in "Shroom_Flower_PUp:".




SMB2J-2Q
Posted on 09-21-24 12:33 PM, in (rev. 2 of 09-21-24 12:33 PM by SMB2J-2Q) Link | ID: 901

Goomba

Level: 7

Posts: 23/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Posted by ShaneM
@SMB2J-2Q great find! I didn't realize SMB Deluxe GBC did that. I optimized it for you. My whole routine is different in SMB2J where it does the modern powerdown so if you're fiery you become super and having multiple powerups on screen at once so I did it from scratch from Doppleganger's SMB1 disassembly. Test it and let me know. It doesn't require new space, actually saves 6 bytes and fixes:

*powerup sound playing with 1-UP mushroom
*powerup sound playing with Starman
*double jump glitch when grabbing a powerup


HandlePowerUpCollision:
jsr EraseEnemyObject ;erase the power-up object
lda #$06
jsr SetupFloateyNumber ;award 1000 points to player by default
lda PowerUpType ;check power-up type
cmp #$02
bcc Shroom_Flower_PUp ;if mushroom or fire flower, branch
cmp #$03
beq SetFor1Up ;if 1-up mushroom, branch
lda #$23 ;otherwise set star mario invincibility
sta StarInvincibleTimer ;timer, and load the star mario music
lda #StarPowerMusic ;into the area music queue, then leave
sta AreaMusicQueue
NoPUp:rts ;(SM label moved here, slightly saves on cycling)

Shroom_Flower_PUp: :SM let's use Y register
ldy #Sfx_PowerUpGrab ;SM load the power-up sound
sty Square2SoundQueue ;SM and store it to play
ldy PlayerStatus ;if player status = small, branch
beq UpToSuper
cpy #$01 ;if player status not super, leave
bne NoPUp
iny ;set player status to fiery (SM saves 1 byte)
sty PlayerStatus
jsr GetPlayerColors ;run sub to change colors of player
lda #$0c ;set value to be used by subroutine tree (fiery)
bne UpToFiery ;branch to set values accordingly (SM originally was a jmp)

SetFor1Up:
lda #$0b ;change 1000 points into 1-up instead
sta FloateyNum_Control,x ;and then leave
rts

UpToSuper:
lda #$01 ;set player status to super
sta PlayerStatus
lda #$09 ;set value to be used by subroutine tree (super)

UpToFiery:
ldy PlayerStatus ;SM set value to be used as new player state
jmp SetPRout ;set values to stop certain things in motion (SM originally was a JSR RTS. Saves on cycling)


Credit me if borrowed. -ShaneM

EDIT: I was able to save another byte by using Y register in "Shroom_Flower_PUp:".





Hi Shane,

That is a pretty awesome code fix there! I do think the power-up grab sound should have been part of the Shroom_Flower_PUp routine in the first place.

~Ben (SMB2J-2Q)

ShaneM
Posted on 09-21-24 01:58 PM, in (rev. 4 of 09-21-24 02:02 PM by ShaneM) Link | ID: 903

Micro-Goomba

Level: 5

Posts: 10/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
@SMB2J-2Q

Replace with “;SM let's use Y register” to get it to assemble. I added that comment last minute.

Did you find any more changes from SMB Deluxe or SMAS?

SMB2J-2Q
Posted on 09-21-24 09:14 PM, in Link | ID: 913

Goomba

Level: 7

Posts: 24/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Posted by ShaneM
@SMB2J-2Q

Replace with “;SM let's use Y register” to get it to assemble. I added that comment last minute.

Did you find any more changes from SMB Deluxe or SMAS?

Shane,

I relocated the power-up grab sound to Shroom_Flower_PUp and the fix worked flawlessly.

If I do find anymore changes related to either one of these, as always, I will let you know any time.

~Ben

ShaneM
Posted on 09-22-24 12:22 AM, in (rev. 4 of 09-22-24 12:25 AM by ShaneM) Link | ID: 915

Micro-Goomba

Level: 5

Posts: 11/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
I was able to optimize the routine even further. Saving yet another byte:


HandlePowerUpCollision:
jsr EraseEnemyObject ;erase the power-up object
lda #$06
jsr SetupFloateyNumber ;award 1000 points to player by default
lda PowerUpType ;check power-up type
cmp #$02
bcc Shroom_Flower_PUp ;if mushroom or fire flower, branch
cmp #$03
beq SetFor1Up ;if 1-up mushroom, branch
lda #$23 ;otherwise set star mario invincibility
sta StarInvincibleTimer ;timer, and load the star mario music
lda #StarPowerMusic ;into the area music queue, then leave
sta AreaMusicQueue
NoPUp:rts ;(SM label moved here, slightly saves on cycling)

Shroom_Flower_PUp: ;SM let's use Y register
ldy #Sfx_PowerUpGrab ;SM load the power-up sound
sty Square2SoundQueue ;SM and store it to play
ldy PlayerStatus ;if player status = small, branch
beq UpToSuper
cpy #$01 ;if player status not super, leave
bne NoPUp
iny ;set player status to fiery (SM saves 1 byte)
sty PlayerStatus
jsr GetPlayerColors ;run sub to change colors of player
lda #$0c ;set value to be used by subroutine tree (fiery)
bne UpToFiery ;branch to set values accordingly (SM originally was a jmp)

SetFor1Up:
lda #$0b ;change 1000 points into 1-up instead
sta FloateyNum_Control,x ;and then leave
rts

UpToSuper:
iny ;set player status to super
sty PlayerStatus
lda #$09 ;set value to be used by subroutine tree (super)

UpToFiery:
ldy Player_State ;SM set value to be used as new player state
jmp SetPRout ;set values to stop certain things in motion (SM originally was a JSR RTS. Saves on cycling)


What I did was use the Y register in "UpToSuper" instead. That subroutine is only taken if Y=#0. So I just made it INY STY instead of LDA #$01 STA. Also in "UpToFiery" changed it to "ldy Player_State". I meant to do that but it was a typo. -ShaneM


SMB2J-2Q
Posted on 09-22-24 09:19 AM, in (rev. 2 of 09-22-24 09:29 AM by SMB2J-2Q) Link | ID: 918

Goomba

Level: 7

Posts: 25/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
There is something new I found in SMAS, also: the end-of-level music has been moved out of "PlayerEndLevel" and relocated to "FlagpoleRoutine." SMAS also does away with the initial scroll lock check, just as in the original FDS SMB2J (SMBLL) and ANNSMB, and SMAS also does away with the FlagpoleMusicFlag variable present in both SMB2J and ANNSMB because I looked at the SMAS version of the SMB2J code and it does not have that specific flag (was RAM $07F6) anymore.

For SMB, this change alone saves 5 bytes.

Old way (NES):

PlayerEndLevel:
lda #$01 ;force player to walk to the right
jsr AutoControlPlayer
lda Player_Y_Position ;check player's vertical position
cmp #$ae
bcc ChkStop ;if player is not yet off the flagpole, skip this part
lda ScrollLock ;if scroll lock not set, branch ahead to next part (removed in SMB2J, ANNSMB and SMAS)
beq ChkStop ;because we only need to do this part once (removed in SMB2J, ANNSMB and SMAS)
lda #EndOfLevelMusic ;(relocated to FlagpoleRoutine in SMAS)
sta EventMusicQueue ;load win level music in event music queue (relocated to FlagpoleRoutine in SMAS)
lda #$00
sta ScrollLock ;turn off scroll lock to skip this part later
ChkStop: lda Player_CollisionBits ;get player collision bits


New way (SMAS):

FlagpoleRoutine:
...
GiveFPScr: ldy FlagpoleScore ;get score offset from earlier (when player touched flagpole)
lda FlagpoleScoreMods,y ;get amount to award player points
ldx FlagpoleScoreDigits,y ;get digit with which to award points
sta DigitModifier,x ;store in digit modifier
jsr AddToScore ;do sub to award player points depending on height of collision
lda #$05
sta GameEngineSubroutine ;set to run end-of-level subroutine on next frame
lda #EndofLevelMusic
sta EventMusicQueue ;SMAS diff: load win level music in event music queue
FPGfx: jsr GetEnemyOffscreenBits ;get offscreen information

I wonder why they relocated the end of level music load to after the end of level game routine here?

~Ben

ShaneM
Posted on 09-23-24 05:17 AM, in (rev. 4 of 09-23-24 03:33 PM by ShaneM) Link | ID: 926

Micro-Goomba

Level: 5

Posts: 12/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
@SMB2J-2Q

I haven’t had time to look into it yet. It doesn’t fix any glitch I’m aware of. I know the music engine is set up differently on SNES. I looked up a Youtube video of the NES version and SNES. I notice that on NES the end of level music doesn’t play until after Mario gets off the flag and there’s a brief sound pause. But on SNES it plays while still on the flag. That lines up with the code’s order. My guess is that is what it does - changes a moment of silence from the NES version to make the transition more fluid. I’ll know more when I test it.

Edit: Yeah; that’s exactly what it does.



SMB2J-2Q
Posted on 09-24-24 02:54 AM, in Link | ID: 938

Goomba

Level: 7

Posts: 26/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Posted by ShaneM
@SMB2J-2Q

I haven’t had time to look into it yet. It doesn’t fix any glitch I’m aware of. I know the music engine is set up differently on SNES. I looked up a Youtube video of the NES version and SNES. I notice that on NES the end of level music doesn’t play until after Mario gets off the flag and there’s a brief sound pause. But on SNES it plays while still on the flag. That lines up with the code’s order. My guess is that is what it does - changes a moment of silence from the NES version to make the transition more fluid. I’ll know more when I test it.

Edit: Yeah; that’s exactly what it does.




Shane,

Yep, I knew that too when I tried it... a reduced delay between the end of the flagpole sound and the beginning of the end-of-level music.

~Ben

ShaneM
Posted on 09-24-24 03:18 AM, in (rev. 9 of 09-24-24 05:16 AM by ShaneM) Link | ID: 939

Micro-Goomba

Level: 5

Posts: 13/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
SMB2J-2Q,

If you already knew the answer then why did you ask the question? Lol

You could have just shared what it did.

What the SNES does is run the end level music one frame sooner than the NES version does. I do like that change.

Here’s one I noticed: On SNES it just uses big Mario’s jump sound for both size players when jumping.



SMB2J-2Q
Posted on 09-24-24 07:03 AM, in (rev. 2 of 09-24-24 07:14 AM by SMB2J-2Q) Link | ID: 943

Goomba

Level: 7

Posts: 27/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
Posted by ShaneM
SMB2J-2Q,

If you already knew the answer then why did you ask the question? Lol

You could have just shared what it did.

What the SNES does is run the end level music one frame sooner than the NES version does. I do like that change.

Here’s one I noticed: On SNES it just uses big Mario’s jump sound for both size players when jumping.




Hi Shane,

They first did that in Super Mario Bros. 3, but they did use the small jump sound for Frog Mario when he hops on dry land.

~Ben (SMB2J-2Q)

SMB2J-2Q
Posted on 10-01-24 02:30 AM, in (rev. 3 of 10-01-24 07:39 AM by SMB2J-2Q) Link | ID: 974

Goomba

Level: 7

Posts: 28/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
In SMAS, the "ContinueGame" routine has been slightly changed to this:

ContinueGame:
jsr LoadAreaPointer ;update level pointer with
lda #$01 ;actual world and area numbers, then
sta PlayerSize ;reset player's size, status, and
lsr ;SMAS diff: shift bit right to initialize player status
sta PlayerStatus ;SMAS diff
inc FetchNewGameTimerFlag ;set game timer flag to reload
lda #$00 ;game timer from header
sta TimerControl ;also set flag for timers to count again
sta GameEngineSubroutine ;reset task for game core
sta OperMode_Task ;set modes and leave
lda #$01 ;if in game over mode, switch back to
sta OperMode ;game mode, because game is still on
GameIsOn: rts

I would like to know if it is safe (because of the INC statement) to remove the LDA #$00 before the TimerControl flag because I placed an LSR before the PlayerStatus flag to change 1 to 0?

~Ben

SMB2J-2Q
Posted on 10-02-24 08:13 AM, in (rev. 10 of 10-06-24 08:12 PM by SMB2J-2Q) Link | ID: 988

Goomba

Level: 7

Posts: 29/29
EXP: 1086
Next: 362

Since: 08-21-24
From: Oak Grove, OR

Last post: 6 days
Last view: 20 hours
I found SMAS has a new separate enemy slot check just for Piranha Plants, which is a reversed version of the existing FindEmptyEnemySlot routine in that X is loaded with the value pointing to the last enemy slot and is decremented with each loop until it goes to $FF, and also replaces the existing JSR to the FindEmptyEnemySlot routine within the WarpPipe routine.
https://github.com/Maseya/SMAS-Disassembly/blob/master/Assembly/SMB1/code/b03/ParseAreaData.asm

Here is that code:

FindPiranhaPlantSlot:
ldx #$05 ;start at last enemy slot
PPChkLp: clc ;clear carry flag by default
lda Enemy_Flag,x ;check enemy buffer for nonzero
beq ExitPPChk ;if zero, leave
dex
cpx #$ff ;if nonzero, check next value
bne PPChkLp
ExitPPChk: rts ;if all values nonzero, carry is set

For some reason, it disallows Mario from destroying it with fireballs, so what else should I do to make it work with fireballs again (other than removing this new code)?

UPDATE: According to TakuikaNinja at the old RHDN, in the old SMB fixes thread he replied to, he suggested that this new code doesn't have to be used. Instead, under the WarpPipe routine, under the JSR to FindEmptyEnemySlot, let's do this...

WarpPipe:
... jsr FindEmptyEnemySlot ;check for an empty moving buffer space
bcc DrawPPlant ;if found, draw the piranha plant
lda Enemy_Flag,x ;check if the enemy buffer is full
bne DrawPipe ;if so, skip to draw pipe
DrawPPlant:
jsr GetAreaObjXPosition ;get horizontal pixel coordinate


~Ben (SMB2J-2Q)

ShaneM
Posted on 10-08-24 04:27 AM, in Link | ID: 1051

Micro-Goomba

Level: 5

Posts: 14/14
EXP: 364
Next: 165

Since: 08-21-24

Last post: 7 hours
Last view: 7 hours
On the original, when Bowser turns to face the player he flips but in an odd way. It makes him go into the ax at times. SMAS fixes this and SMB Deluxe GBC partially fixes this by making him properly turn. I wrote this code from scratch to fix it, it was made with SMB2J in mind but should work on SMB1; credit me if borrowed:


;new RAM addresses
StarMusBWSRFlag = $4c
BowserHTimer = $0788



ResetMDr: lda EnemyFrameTimer,x ;if timer set here expired,
beq GetPRCmp ;branch to next section
jsr PlayerEnemyDiff ;get horizontal difference between player and bowser,
bmi MoveBRght ;and branch if bowser to the right of the player
MoveBLft: lda BowserHTimer ;SM load Bowser's horizontal flip timer
bne DNMB+5 ;SM if Bowser just turned rightward, branch
lda #$02 ;otherwise load value to
sta Enemy_MovingDir,x ;set Bowser to move and face to the left
lda StarMusBWSRFlag ;SM load Bowser's flip flag (note this is only set if Bowser has flipped from left to right)
beq BBoundChk ;SM if not set, branch to continue with Bowser's boundary check
lda Enemy_X_Position,x ;SM get Bowser's front horizontal coordinate
sec ;SM
sbc #$10 ;SM take away ten from it thus giving the illusion of his front and rear flipping
sta Enemy_X_Position,x ;SM then store as Bowser's new front horizontal coordinate
dec StarMusBWSRFlag ;SM clear Bowser's flip flag
lda #$10 ;SM load value to
sta BowserHTimer ;SM set Bowser's horizontal flip timer
bne GetPRCmp ;SM then branch unconditionally
MoveBRght: lda BowserHTimer ;SM load Bowser's horizontal flip timer
bne BBoundChk ;SM if Bowser's horizontal flip timer is still going, branch
lda #$01 ;load value to
sta Enemy_MovingDir,x ;set Bowser to move and face to the right
lda StarMusBWSRFlag ;SM load Bowser's flip flag
bne DNMB ;SM branch if flag already set to avoid wrong enemy placement
lda Enemy_X_Position,x ;SM get Bowser's front horizontal coordinate
clc ;SM
adc #$10 ;SM add ten to horizontal coordinate
sta Enemy_X_Position,x ;SM then store as Bowser's new front horizontal coordinate
inc StarMusBWSRFlag ;SM set Bowser's flip flag (this gets the ball rolling)
lda #$10 ;SM load value to
sta BowserHTimer ;SM set Bowser's horizontal flip timer
DNMB: lda #$02
sta BowserMovementSpeed ;set movement speed
lda #$20
sta EnemyFrameTimer,x ;set timer here
sta BowserFireBreathTimer ;set timer used for bowser's flame
BBoundChk: lda Enemy_X_Position,x
cmp #$bf ;(SM original value #$c8) if bowser to the right past a certain point,
bcs HammerChk ;skip ahead to some other section


I also discovered that on 1-2 of SMB2J if you collect the Starman and run to the sideways warp pipe the SFX will not play most of the time if still invincible. SMB Deluxe and SMAS fixes this. I don't know offhand if Starman + sideways pipe ever occurs in the same room on SMB1. I don't think so hence this oversight. My code is from scratch, credit me if borrowed:


PipeDwnS: ldy StarInvincibleTimer ;SM load invincibility timer
bne PlayPipeDwnS ;SM branch if set to play SFX (fixes SFX not playing on 1-2)
lda Player_SprAttrib ;check player's attributes
bne PlyrPipe ;if already set, branch, do not play sound again
PlayPipeDwnS:
ldy #Sfx_PipeDown_Injury
sty Square1SoundQueue ;otherwise load pipedown/injury sound
PlyrPipe: ora #%00100000


Yes, the Bowser fix does take up a lot of space, but it's worth it IMO. -ShaneM
Pages: 1 2


Main - Hacking Discussion - Super Mario Bros. Fixes (3)


Acmlmboard v2.5.6+neo (2024-08-13)
© 2005-2024 Acmlm, Emuz, NinCollin, et al.

Page rendered in 0.136 seconds. (997KB of memory used)
MySQL - queries: 119, rows: 481/490, time: 0.111 seconds.