News:

11 March 2016 - Forum Rules

Main Menu

SMB1 hud changes

Started by capnkatie, April 13, 2022, 06:15:42 PM

Previous topic - Next topic

capnkatie

here's a fun question- is it possible to swap out the score counter in the top left of the smb1 screen with say, the lives counter for example? i feel like it would be a relatively simple change but i genuinely cant find any documentation on this without having to deal with the disassembled code

what do you think?

Cyneprepou4uk

Yeah, it's possible and isn't too hard.

I think that most game specific docs don't tell you how make random hacks like this. Instead they might tell you where score values and lives counter are located in RAM, so you can use this info to find the code and change it to whatever you want, all by yourself.

capnkatie

you know after seeing this i went "alright then, i'll do it myself" and sat down, got a map of the memory and apart from the score being stored in a weird decimal format it was actually really easy to replace some of the code without even using a disassembly

i mean i doubt i am going to use this for anything but it was a fun exercise and its kinda cool to see i can do something like that, so hey thanks lmao

Cyneprepou4uk

Didn't expect that. Welldone dude  :thumbsup:

NesDraug

Quote from: capnkatie on April 14, 2022, 05:56:23 PM
you know after seeing this i went "alright then, i'll do it myself" and sat down, got a map of the memory and apart from the score being stored in a weird decimal format it was actually really easy to replace some of the code without even using a disassembly

i mean i doubt i am going to use this for anything but it was a fun exercise and its kinda cool to see i can do something like that, so hey thanks lmao

You managed to make a life counter in HUD? I've tried to do that myself but couldnt figure it out. Care to explain or share a patch?

April 15, 2022, 05:17:40 AM - (Auto Merged - Double Posts are not allowed before 7 days.)

Quote from: capnkatie on April 14, 2022, 05:56:23 PM
you know after seeing this i went "alright then, i'll do it myself" and sat down, got a map of the memory and apart from the score being stored in a weird decimal format it was actually really easy to replace some of the code without even using a disassembly

i mean i doubt i am going to use this for anything but it was a fun exercise and its kinda cool to see i can do something like that, so hey thanks lmao

You managed to make a life counter in HUD? I've tried to do that myself but couldnt figure it out. Care to explain or share a patch? :D
✍️ Blog: https://www.tumblr.com/blog/nesdraug

💀 Join my crypt on discord:
https://discord.gg/Eb4HTSNzeg

capnkatie

oh no im so sorry i didnt save the rom!

if you want to know what i did though i essentially ctrl+Fed the rom in a hex editor to find each instance that it read/wrote the score, fiddled with each subroutine to find out what they did and after like half a day of on and off tweaking i got it so that a) what you press start the (second) last digit of the score gets changed to the lives instead of the player 2 lives byte and b) every time the game goes to add to the score it instead jumps back for a second and just writes the lives again. i then got lazy and used a standard tool thing you can download here to just remove the last 0 from the score counter

it took absolutely ages and i had to keep referencing what each byte represented in terms of an assembly command but by the end it sort of worked? now i know what im doing i can probably recreate it if i have time later

honestly the part i was most proud of is when i was going through checking what kind of stuff referenced the lives counter i came across a section that checked if the value was greater than $A0 then subtracted that value and wrote something to some graphics buffer area in the ram- and i immediately clocked that it was adding the crown graphic to the black intermediate screen. basically for a second i felt a weird connection to the programmer adding that tiny reward and it was a really nice moment ahahaha

Ooxie

Hi, thought I would chime in (first post on RHDN by the way).

I happen to have worked on a solution for displaying the lives counter in place of the score counter in the HUD for my own ongoing hack. Here is the pseudo-patch, that I thought I would share:

aaaa LDX NumberofLives           ; Subroutine a: Increment the number of lives; limit it to 99
     CPX #$63                    ;
     BPL #$08                    ;
     INC NumberofLives           ;
     LDA #$01                    ;
     JSR dddd                    ; When getting an extra life, jump to previous subroutine d
     RTS                         ;

bbbb LDA #$03                    ; Subroutine b: Display the number of lives on the bottom status line
     JSR $8f21                   ;
     JSR $bc40                   ;
     RTS                         ;

cccc STA ScoreAndCoinDisplay,x   ; Subroutine c: Display the initial number of lives after selecting Start
     DEX                         ;
     BPL #$fa                    ;
     LDA NumberofLives           ;
     LDY #$00                    ;
     CMP #$0a                    ;
     BMI #$05                    ;
     SBC #$0a                    ;
     INY                         ;
     BPL #$f7                    ;
     STY $07f3                   ;
     STA $07f4                   ;
     RTS                         ;

dddd STA DigitModifier+5         ; Subroutine d: Reflect change on the bottom status line
     LDY #$1d                    ;
     JSR $f6f                    ;
     LDA #03                     ;
     JSR $f01                    ;
     RTS                         ;

eeee DEC NumberofLives           ; Subroutine e: Decrement the number of lives; do not process digits and printing if already at 0
     LDA $07f3                   ;
     ORA $07f4                   ;
     BEQ #$05                    ;
     LDA #$ff                    ;
     JSR dddd                    ;
     LDA NumberofLives           ;
     RTS                         ;

4f6 JSR aaaa                    ; When we pick up a 1-up mushroom or when we chain enough enemy-defeating actions, jump to subroutine a

3c2b JSR aaaa                    ; When we have collected 100 coins, jump to subroutine a

f1b RTS                         ; Do not display the first 5 digits of the score
     NOP                         ;
     NOP                         ;
     NOP                         ;
     NOP                         ;
     NOP                         ;

77b .DB $24                     ; Do not display the trailing digit

765 .DB $15, $12, $1f, $0e, $1c ; Display "LIVES" instead of "MARIO"

66a JSR bbbb                    ; When writing the bottom status line, jump to subroutine b

3c51 NOP                         ; Do not overwrite the highest digit with a space tile for zero suppression
     NOP                         ;
     NOP                         ;
     NOP                         ;
     NOP                         ;

f0c .DB $66                     ; Move the number of lives underneath "LIVES"

317 NOP                         ; When clearing player scores and coin displays, jump to subroutine c
     NOP                         ;
     NOP                         ;
     JSR cccc                    ;

11e9 JSR eeee                    ; When losing a life, jump to subroutine e


A few comments:
- The labels are taken from the SMB1 disassembly, found at https://gist.github.com/1wErt3r/4048722.
- There are 5 subroutines, named "a" to "e", to add wherever you can find free space in the ROM. I am working on a MMC1-converted ROM to begin with. The pseudo-addresses ("aaaa" to "eeee") need to be replaced by your own addresses with the usual caveats applying to pointers.
- As this is almost directly taken from my hack, you will also find a subroutine to limit the number of lives to 99 (as a gift), because the patch is dependent on this subroutine.
- Also because of that, the top score on the menu screen is messed up.
- Still because of that, Luigi is not impacted, so this only applies to Mario.
- And finally, I chose to display the number of lives that are left beyond the current one, like is done in SMB3, so it does not match the number of lives you can see on the level init screen (it is 1 down).

Any question and comment welcome!