Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- init:
- STZ $1411
- RTL
- main:
- STZ $04 : STZ $05 : STZ $06 ; Clear some scratch RAM
- LDX #$0C ; > Set-up for a loop through the sprites
- -
- DEX ; \ Leave the loop if we ran out of sprites
- BMI + ; /
- LDA $9E,X ; \ Keep looping if the sprite isn't a
- CMP #$63 ; | checkerboarded/brown line-guided platform
- BNE - ; /
- LDA $14C8,X ; \ O and it has to be alive
- CMP #$08 ; |
- BMI - ; /
- LDA $04 ; \
- CLC : ADC $E4,X ; | Add the position of the sprite to $04
- STA $04 ; |
- LDA $05 ; |
- ADC $14E0,X ; |
- STA $05 ; /
- INC $06 ; > Hey, we found one!
- LDA $06 : CMP #$02 ; \ Stop looking after we found 2
- BNE - ; /
- LSR $05 ; \ Divide $04 by 2
- ROR $04 ; /
- -
- LDA $04 ; \
- SEC : SBC #$80 ; | Subtract 0x80 from the average to find the camera
- STA $04 ; | position
- LDA $05 ; |
- SBC #$00 ; /
- BMI ++ ; \ Set $04 if its value is position
- STA $05 ; /
- REP #$30 ; \ And update all the relevant RAM addresses
- BRA .moveFix ; /
- ++ ; \ Otherwise, set the camera position to 0
- REP #$30 ; |
- STZ $04 ; /
- BRA .moveFix ; > Update all the relevant RAM addresses
- + ; > If we ran out of sprites to search
- LDA $06 ; > And we found a sprite
- BNE - ; > Don't divide $04 by 2
- LDA #$01 ; \ If we found no sprites, then center the camera around mario
- STA $1411 ; /
- RTL
- .moveFix ; > This sets all the relevant RAM addresses
- LDA $04
- STA $1462
- LDA $1A
- SEC : SBC $04
- SEP #$30
- LDA $17BD
- LDA $04 : STA $1A
- LDA $05 : STA $1B
- RTL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement