Advertisement
Guest User

Untitled

a guest
Nov 21st, 2012
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. ; defines from crt0.s
  2. CTRL_PORT1 =$4016
  3.  
  4. PAD_STATE =$04 ;2 bytes, one per controller
  5. PAD_STATEP =$06 ;2 bytes (poll)
  6. PAD_STATET =$08 ;2 bytes (trigger)
  7. TEMP =$1c
  8. PAD_BUF =TEMP+1 ; $1d
  9.  
  10. ; routines from neslib.s
  11. ;unsigned char __fastcall__ pad_poll(unsigned char pad);
  12.  
  13. _pad_poll:
  14. tay
  15. ldx #0
  16.  
  17. @padPollPort:
  18. lda #1
  19. sta CTRL_PORT1
  20. lda #0
  21. sta CTRL_PORT1
  22. lda #8
  23. sta <TEMP
  24.  
  25. @padPollLoop:
  26. lda CTRL_PORT1,y
  27. lsr a
  28. ror <PAD_BUF,x
  29. dec <TEMP
  30. bne @padPollLoop
  31.  
  32. inx
  33. cpx #3
  34. bne @padPollPort
  35.  
  36. lda <PAD_BUF
  37. cmp <PAD_BUF+1
  38. beq @done
  39. cmp <PAD_BUF+2
  40. beq @done
  41. lda <PAD_BUF+1
  42. @done:
  43. sta <PAD_STATE,y
  44. tax
  45. eor <PAD_STATEP,y
  46. and <PAD_STATE ,y
  47. sta <PAD_STATET,y
  48. txa
  49. sta <PAD_STATEP,y
  50.  
  51. rts
  52.  
  53.  
  54. ;unsigned char __fastcall__ pad_trigger(unsigned char pad);
  55.  
  56. _pad_trigger:
  57. pha
  58. jsr _pad_poll
  59. pla
  60. tax
  61. lda <PAD_STATET,x
  62. rts
  63.  
  64.  
  65. ;unsigned char __fastcall__ pad_state(unsigned char pad);
  66.  
  67. _pad_state:
  68. tax
  69. lda <PAD_STATE,x
  70. rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement