News: 11 March 2016 - Forum Rules
Current Moderators - DarkSol, KingMike, MathOnNapkins, Azkadellia, Danke

Author Topic: Super Mario Bros. (NES) - Lives Screen Display Fix  (Read 2151 times)

SMB2J-2Q

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Super Mario Bros. (NES) - Lives Screen Display Fix
« on: July 27, 2017, 08:00:46 pm »
Hi,

I am wondering if there might be a way to hack the NES version of Super Mario Bros. so that I can do the following two fixes?

My intended fixes are:
1. Fixing the number of lives so they are read as proper numbers after both 10 lives and 19 lives instead of showing all these random symbols pulled from the game's character map.

2. Setting the maximum number of lives to 128 ($7f hex) so that (a) you never go beyond this limit, as is the case with the Game Boy Color port Super Mario Bros. Deluxe, though the maximum number of lives in the SNES Super Mario All-Stars version of SMB (and SMB2-J, here called SMB: The Lost Levels) for the NES is 99; and thus (b) no Game Over for losing your next life after racking up 129 or more lives.

Thank you,



Ben
« Last Edit: July 27, 2017, 08:06:37 pm by SMB2J-2Q »

Disch

  • Hero Member
  • *****
  • Posts: 2699
  • NES Junkie
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #1 on: July 27, 2017, 08:36:11 pm »
Yes.  Both of those fixes are possible.   :P

SMB2J-2Q

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #2 on: July 27, 2017, 09:22:34 pm »
Yes.  Both of those fixes are possible.   :P
https://gist.github.com/1wErt3r/4048722

What would I change here?

Code: [Select]
EndGameText:
    ...
    lda NumberOfLives    ;otherwise, check for number of lives
    clc                  ;and increment by one for display
    adc #$01
    cmp #10              ;more than 9 lives?
    bcc PutLives         
    sbc #10              ;if so, subtract 10 and put a crown tile
    ldy #$9f             ;next to the difference... strange things happen if
    sty VRAM_Buffer1+7   ;the number of lives exceeds 19

And where in the code does it prompt a Game Over for racking 129 lives or more, which occurs when losing a life from that point? I want to fix that, too.

~Ben
« Last Edit: July 27, 2017, 09:31:35 pm by SMB2J-2Q »

Jorpho

  • Hero Member
  • *****
  • Posts: 4087
  • The cat screams with the voice of a man.
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #3 on: July 28, 2017, 12:16:13 am »
And where in the code does it prompt a Game Over for racking 129 lives or more, which occurs when losing a life from that point? I want to fix that, too.
If I'm not mistaken, that happens because the number of lives is stored as a signed 8-bit integer – when you add 1 to 127, the game decides that you have negative 128 lives.  The game checks if your number of lives is positive when you die (dec NumberofLives, bpl StillInGame) to decide if you have a Game Over.

So, I guess you would need to add extra code somewhere – probably a check to see if the number of lives is negative after you gain an extra life, which then sets the number of lives back to 128.  Makes sense?
This signature is an illusion and is a trap devised by Satan. Go ahead dauntlessly! Make rapid progres!

SMB2J-2Q

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #4 on: July 28, 2017, 02:48:50 am »
If I'm not mistaken, that happens because the number of lives is stored as a signed 8-bit integer – when you add 1 to 127, the game decides that you have negative 128 lives.  The game checks if your number of lives is positive when you die (dec NumberofLives, bpl StillInGame) to decide if you have a Game Over.

So, I guess you would need to add extra code somewhere – probably a check to see if the number of lives is negative after you gain an extra life, which then sets the number of lives back to 128.  Makes sense?
Yes, indeed... I'd probably have to create a clean-slate ROM and copy the contents of the SMB ROM to that.

~Ben

July 29, 2017, 10:32:53 pm - (Auto Merged - Double Posts are not allowed before 7 days.)
The code in the SNES version (as part of SMAS) which counts how many lives are earned:
Code: [Select]
CODE_048596: EE 5A 07 INC $075A       ;increase lives by 1 & make sure
CODE_048599: AD 5A 07 LDA $075A       ;it doesn't get past 128
CODE_04859C: C9 80    CMP #$80
CODE_04859E: 90 05    BCC CODE_0485A5
CODE_0485A0: A9 7F    LDA #$7F
CODE_0485A2: 8D 5A 07 STA $075A
CODE_0485A5: 6B       RTL

I wonder where I would be able to put this particular code within the NES version's ROM?

~Ben
« Last Edit: July 29, 2017, 10:32:53 pm by SMB2J-2Q »

Teeporage777

  • Jr. Member
  • **
  • Posts: 77
  • rom hacker of mario games
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #5 on: August 01, 2017, 06:48:48 am »
I have a patch that can fix the number lives glitch if you think it could be helpful.
"..But it doesn't matter. Nothing matters anymore.."

SMB2J-2Q

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #6 on: August 02, 2017, 12:59:56 am »
I have a patch that can fix the number lives glitch if you think it could be helpful.
May I see the code for your fix, please?

If your fix works 100 percent correctly, then we should include that on The Cutting Room Floor's Super Mario Bros. page here:
https://tcrf.net/Super_Mario_Bros.

Thank you,



Ben

Teeporage777

  • Jr. Member
  • **
  • Posts: 77
  • rom hacker of mario games
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #7 on: August 06, 2017, 02:49:52 am »
it is actually just an old patch i had for a while now. It work just fine. I am not the author so i am not sure of the coding. But i would be more then happy to send it to you if you want to check it out.
"..But it doesn't matter. Nothing matters anymore.."

Eden.GT

  • Full Member
  • ***
  • Posts: 103
  • Hardcore SMB1 Player and Hacker
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #8 on: August 06, 2017, 06:35:29 am »
I have a patch that can fix the number lives glitch if you think it could be helpful.

To put down additional information, the author of this patch is sjk-e351. Known as adjust_remain.ips .

2. Setting the maximum number of lives to 128 ($7f hex) so that (a) you never go beyond this limit, as is the case with the Game Boy Color port Super Mario Bros. Deluxe, though the maximum number of lives in the SNES Super Mario All-Stars version of SMB (and SMB2-J, here called SMB: The Lost Levels) for the NES is 99; and thus (b) no Game Over for losing your next life after racking up 129 or more lives.

That patch also exists. I think it was ShaneM who did the patch.
https://www.dropbox.com/s/ucwcuf23laskqfd/127.ips?dl=0

However, patching the two together would not get the overall desired result you wanted.
« Last Edit: August 06, 2017, 06:47:29 am by Eden.GT »
Is the pool clean?

SMB2J-2Q

  • Full Member
  • ***
  • Posts: 125
    • View Profile
Re: Super Mario Bros. (NES) - Lives Screen Display Fix
« Reply #9 on: August 15, 2017, 05:43:46 pm »
https://www.youtube.com/watch?v=fZOUezXZS4U

This video seems to involve hacking the lives instructions.

Again, I want to try to rework the machinations of the lives instructions to match with that of the SNES Super Mario All-Stars version.

~Ben