Dotsarecool

SMB X-pos Display

Jan 9th, 2016
331
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. ; address of mario's x position
  2. !x_pos = $86
  3. ; ones, tens, and hundreds of x position (replaces level timer)
  4. !ones = $07FA
  5. !tens = $07F9
  6. !hundreds = $07F8
  7.  
  8. ; this routine gets the x position in hex and outputs it in decimal to specified registers
  9. ; registers destroyed: X,A
  10.  
  11. get_x_pos_in_decimal:
  12. LDA !x_pos
  13. JSR hex_to_decimal
  14. STA !ones
  15. TXA
  16. JSR hex_to_decimal
  17. STA !tens
  18. STX !hundreds
  19. RTS
  20.  
  21. ; input:
  22. ; A - value in hex to convert
  23. ; output:
  24. ; A - "ones" in decimal of input value
  25. ; X - "tens" in hex of input value
  26. ; registers destroyed: X,A
  27.  
  28. hex_to_decimal:
  29. LDX #$00
  30. .loop:
  31. CMP #$0A
  32. BCC .done
  33. SBC #$0A
  34. INX
  35. SEC
  36. BCS .loop
  37. .done:
  38. RTS
Add Comment
Please, Sign In to add comment