For example, this code in Super Mario All-Stars that checks the number of lives for both Super Mario Bros. and Super Mario Bros.: The Lost Levels:
Code: Select all
CODE_048596:
LDA $075A ;check current player's lives
INC $075A ;increase by one if player collected: a) 1-UP Mushroom; b) 100 coins; c) destroyed eight or more enemies with a Koopa shell or Buzzy Beetle; or d) repeatedly stomped on a Koopa shell or Buzzy Beetle at least eight times
CMP #$80 ;see if we have more than 127 lives
BCC CODE_0485A5 ;if not, skip the rest of this routine
LDA #$7F ;otherwise set A to 127
STA $075A ;store in A and leave
CODE_0485A5:
RTL
Code: Select all
CODE_048596:
LDA $075A ;check current player's lives
INC A ;increase A by one if player collected: a) 1-UP Mushroom; b) 100 coins; c) destroyed eight or more enemies with a Koopa shell or Buzzy Beetle; or d) repeatedly stomped on a Koopa shell or Buzzy Beetle at least eight times
CMP #$80 ;see if we have more than 127 lives
BCC CODE_0485A1 ;if not, skip the rest of this routine
DEC A ;otherwise subtract A to cap it at 127
STA $075A ;store in A and leave
CODE_0485A1:
RTL