I just found out that the max lives code located at 0x48596 in the ROM bank (with header) can also be written conservatively to save space.
As written in the ROM bank:
Code: Select all
CODE_048596:
LDA $075A ; check player's lives
INC $075A ; increment A by one
CMP #$80 ; are we at 128 lives yet?
BCC CODE_0485A5 ; no, skip rest of routine
LDA #$7F ; otherwise, stop at 127 lives
STA $075A ; store in A and leave
CODE_0485A5:
RTL
65816 also has the single-byte INC A and DEC A opcodes, which can be used to re-write the code:
Code: Select all
CODE_048596:
LDA $075A ; check player's lives
INC A ; increment A by one
CMP #$80 ; are we at 128 lives yet?
BCC CODE_0485A2 ; no, skip rest of routine
DEC A ; otherwise, decrement A by one to stop at 127 lives
STA $075A ; store in A and leave
CODE_0485A2:
RTL
However, it can also be re-written in the same way Shane M. did for the max lives for his NES/FDS SMB1 and SMB2J hacks:
Code: Select all
CODE_048596:
LDA $075A ; check player's lives
CMP #$7E ; are we at 127 lives? (since we wrote down the compare check before we did the incrementing, the hex value is written as one less than what is onscreen)
BCS CODE_04859E ; if yes, we're done
INC A ; otherwise increment A by one (only up to 127 lives)
CODE_04859E:
RTL
~Ben