Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; defines from crt0.s
- CTRL_PORT1 =$4016
- PAD_STATE =$04 ;2 bytes, one per controller
- PAD_STATEP =$06 ;2 bytes (poll)
- PAD_STATET =$08 ;2 bytes (trigger)
- TEMP =$1c
- PAD_BUF =TEMP+1 ; $1d
- ; routines from neslib.s
- ;unsigned char __fastcall__ pad_poll(unsigned char pad);
- _pad_poll:
- tay
- ldx #0
- @padPollPort:
- lda #1
- sta CTRL_PORT1
- lda #0
- sta CTRL_PORT1
- lda #8
- sta <TEMP
- @padPollLoop:
- lda CTRL_PORT1,y
- lsr a
- ror <PAD_BUF,x
- dec <TEMP
- bne @padPollLoop
- inx
- cpx #3
- bne @padPollPort
- lda <PAD_BUF
- cmp <PAD_BUF+1
- beq @done
- cmp <PAD_BUF+2
- beq @done
- lda <PAD_BUF+1
- @done:
- sta <PAD_STATE,y
- tax
- eor <PAD_STATEP,y
- and <PAD_STATE ,y
- sta <PAD_STATET,y
- txa
- sta <PAD_STATEP,y
- rts
- ;unsigned char __fastcall__ pad_trigger(unsigned char pad);
- _pad_trigger:
- pha
- jsr _pad_poll
- pla
- tax
- lda <PAD_STATET,x
- rts
- ;unsigned char __fastcall__ pad_state(unsigned char pad);
- _pad_state:
- tax
- lda <PAD_STATE,x
- rts
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement