Results 1 to 14 of 14

Thread: Super Mario Bros. - 128 Lives Fix

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Cherry (Level 1)
    Join Date
    Oct 2010
    Location
    Milwaukie (Oak Grove), Oregon
    Posts
    352
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    1
    Thanked in
    1 Post

    Default Super Mario Bros. - 128 Lives Fix

    It is well known that there is a bug in Super Mario Bros. for the NES that, if you manage to score 128 or more lives, you will get Game Over the next time you die.

    My question is, which code would I modify to correct this data, so that obtaining 128 lives and beyond won't mean Game Over anymore, and would also cap 255 ($ff) as the maximum, without resetting to zero? Subsequent remakes such as Super Mario All-Stars (SNES) and Super Mario Bros. Deluxe (Game Boy Color) acknowledged the bug and the resulting side effect from the original NES port, and so have fixed this issue, thus capping the extra life amount to 127.

    Thank you,



    Ben

  2. #2
    Red (Level 21) Jorpho's Avatar
    Join Date
    Jul 2002
    Location
    We're all mad here
    Posts
    13,554
    Thanks Thanks Given 
    2
    Thanks Thanks Received 
    1
    Thanked in
    1 Post

    Default

    Are you sure about that? I thought the bug persisted in SMB in Super Mario All-Stars. (Of course, the number of lives will at least display correctly.)

    Anyway, you might want to take your question to a more specialized board. It's probably possible, given that there's a complete annotated disassembly of the SMB ROM out there, but I doubt it's straightforward – things probably have to be rearranged substantially.
    "There is much pleasure to be gained from useless knowledge." --Bertrand Russel (attributed)

  3. #3
    Cherry (Level 1)
    Join Date
    Oct 2010
    Location
    Milwaukie (Oak Grove), Oregon
    Posts
    352
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    1
    Thanked in
    1 Post

    Default

    Quote Originally Posted by Jorpho View Post
    Are you sure about that? I thought the bug persisted in SMB in Super Mario All-Stars. (Of course, the number of lives will at least display correctly.)

    Anyway, you might want to take your question to a more specialized board. It's probably possible, given that there's a complete annotated disassembly of the SMB ROM out there, but I doubt it's straightforward – things probably have to be rearranged substantially.
    It indeed stops at 127 lives in SMAS and SMBDX.

    What I did so far for the original SMB was to change the instruction at $91D9 in the PRG-ROM so that it branches on not equal (BNE) instead of equal (BEQ) (to get Game Over after losing your last life, not when it goes into negative territory at 128 and beyond). I must give due thanks to KingMike at Romhacking.net for that bit of help.

    ~Ben
    Last edited by ColecoFan1981; 09-27-2014 at 02:39 AM.

  4. #4
    Strawberry (Level 2) Custom rank graphic
    FoxNtd's Avatar
    Join Date
    Mar 2010
    Location
    USA/米国
    Posts
    570
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    4
    Thanked in
    4 Posts

    Default

    Is this basically a 6502 assembly question? Ok then...

    In general, architecture aside, there are a few things you could try. Change the variable to unsigned so that the limit effectively becomes 255. (No idea why the game uses a signed 8-bit integer, it's not like there is any meaningful use for negative lives. That's what causes your game over surely, because any negative is less than 0 and that represents game over.) You could modify the routine which is incrementing the lives counter and add a bounds check to insure it does not increment once the maximum is reached. Assuming that Famicom supports 16-bit variables (I really don't know lol) allocate more memory for the lives counter. An unsigned 16-bit int will get you a cap of 65,535. The game has trouble displaying numbers on the life total screen that are greater than 9 I think so I'm not sure what side-effects there may be by trying to make the variable 16-bit instead of 8-bit...

  5. #5
    Cherry (Level 1)
    Join Date
    Dec 2005
    Location
    Augusta, Georgia, USA
    Posts
    268
    Thanks Thanks Given 
    0
    Thanks Thanks Received 
    2
    Thanked in
    2 Posts

    Default

    The code must just simply be checking the 6502 N flag... In which case the fix you applied may be fine, assuming there aren't any other side effects based on the number of lives.

    I looked at the disassembly... here is the code.

    PlayerLoseLife:
    inc DisableScreenFlag ;disable screen and sprite 0 check
    lda #$00
    sta Sprite0HitDetectFlag
    lda #Silence ;silence music
    sta EventMusicQueue
    dec NumberofLives ;take one life from player
    bpl StillInGame ;if player still has lives, branch
    lda #$00
    sta OperMode_Task ;initialize mode task,
    lda #GameOverModeValue ;switch to game over mode
    sta OperMode ;and leave
    rts

    Changing "bpl StillInGame" to "bne StillInGame" should make it so the game only ends when the variable is 0, not 128-255. However, the check will be one less than normal, so test this and see if the game ends when you have one life left instead of 0.

    There may another side effect to this simple patch, though. At the end of each world, the game sets the lives to 255 when you press B. It may cause some issue. It looks like it may get set back to 3 when the game restarts anyway, so maybe not.
    Last edited by Pete Rittwage; 09-27-2014 at 11:38 AM.
    -
    Pete Rittwage
    C64 Preservation Project
    http://c64preservation.com

  6. #6
    Cherry (Level 1)
    Join Date
    Oct 2010
    Location
    Milwaukie (Oak Grove), Oregon
    Posts
    352
    Thanks Thanks Given 
    1
    Thanks Thanks Received 
    1
    Thanked in
    1 Post

    Default

    Quote Originally Posted by Pete Rittwage View Post
    The code must just simply be checking the 6502 N flag... In which case the fix you applied may be fine, assuming there aren't any other side effects based on the number of lives.

    I looked at the disassembly... here is the code.

    PlayerLoseLife:
    inc DisableScreenFlag ;disable screen and sprite 0 check
    lda #$00
    sta Sprite0HitDetectFlag
    lda #Silence ;silence music
    sta EventMusicQueue
    dec NumberofLives ;take one life from player
    bpl StillInGame ;if player still has lives, branch
    lda #$00
    sta OperMode_Task ;initialize mode task,
    lda #GameOverModeValue ;switch to game over mode
    sta OperMode ;and leave
    rts

    Changing "bpl StillInGame" to "bne StillInGame" should make it so the game only ends when the variable is 0, not 128-255. However, the check will be one less than normal, so test this and see if the game ends when you have one life left instead of 0.

    There may another side effect to this simple patch, though. At the end of each world, the game sets the lives to 255 when you press B. It may cause some issue. It looks like it may get set back to 3 when the game restarts anyway, so maybe not.
    Still no Game Over.

    Thus, I ask: I wonder how this logic works in both Super Mario All-Stars and Super Mario Bros. Deluxe? SMAS relies on the more advanced 65816 code, whereas SMBDX relies on Z80 code.

    ~Ben
    Last edited by ColecoFan1981; 09-27-2014 at 01:28 PM.

Similar Threads

  1. Super Mario Bros. Toy - Two Ladders & Mario Luigi Figures
    By ZackyH in forum Buying and Selling
    Replies: 5
    Last Post: 10-31-2007, 03:06 AM
  2. FS: N64 Mario Kart 64, Mario Golf, Super Smash Bros $35
    By Perkar in forum Buying and Selling
    Replies: 2
    Last Post: 08-25-2006, 12:31 AM
  3. NEW Super Mario Bros. an evolution of classic 2D Mario
    By Jasoco in forum Classic Gaming
    Replies: 28
    Last Post: 05-19-2005, 04:25 PM
  4. FA: Mario Bros / Zelda Toy Chest, Super Mario 2 Inside Out
    By TisLord in forum Buying and Selling
    Replies: 2
    Last Post: 10-21-2004, 10:25 AM
  5. Everybody Rejoice ---- Super Mario Bros. Super Show! - Vol 1
    By www.consolegames.org in forum Classic Gaming
    Replies: 11
    Last Post: 06-28-2004, 05:28 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •