Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; address of mario's x position
- !x_pos = $86
- ; ones, tens, and hundreds of x position (replaces level timer)
- !ones = $07FA
- !tens = $07F9
- !hundreds = $07F8
- ; this routine gets the x position in hex and outputs it in decimal to specified registers
- ; registers destroyed: X,A
- get_x_pos_in_decimal:
- LDA !x_pos
- JSR hex_to_decimal
- STA !ones
- TXA
- JSR hex_to_decimal
- STA !tens
- STX !hundreds
- RTS
- ; input:
- ; A - value in hex to convert
- ; output:
- ; A - "ones" in decimal of input value
- ; X - "tens" in hex of input value
- ; registers destroyed: X,A
- hex_to_decimal:
- LDX #$00
- .loop:
- CMP #$0A
- BCC .done
- SBC #$0A
- INX
- SEC
- BCS .loop
- .done:
- RTS
Add Comment
Please, Sign In to add comment