1
0
mirror of https://github.com/cc65/cc65.git synced 2024-09-08 01:54:33 +00:00
cc65/libsrc/creativision/joy.s

59 lines
1.2 KiB
ArmAsm
Raw Normal View History

2013-12-05 11:40:44 +00:00
;*
;* Creativision Joystick Function
2017-02-01 18:46:04 +00:00
;*
2013-12-05 11:40:44 +00:00
;* unsigned char __fastcall__ joystate(unsigned char joy);
;*
;* JOY_1 -> Return Left Joystick direction
;* JOY_2 -> Return Right Joystick direction
;* JOY_3 -> Return Left Joystick buttons
;* JOY_4 -> Return Right Joystick buttons
;*
;* Will only work if interrupts are enabled.
.export _joystate
.include "creativision.inc"
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
_joystate:
cmp #1 ; Left Direction
bne l1
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
lda $11
beq l5
2017-02-01 18:46:04 +00:00
and #$0F
2013-12-05 11:40:44 +00:00
lsr a
tax
inx
txa
rts
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
l1: cmp #2 ; Right Direction
bne l2
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
lda $13
beq l5
2017-02-01 18:46:04 +00:00
and #$0F
2013-12-05 11:40:44 +00:00
lsr a
tax
inx
txa
rts
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
l2: cmp #3 ; Left Buttons
bne l3
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
lda $16
beq l5
2017-02-01 18:46:04 +00:00
and #$0F
2013-12-05 11:40:44 +00:00
rts
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
l3: cmp #4
bne l4
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
lda $17
beq l5
2017-02-01 18:46:04 +00:00
and #$0F
2013-12-05 11:40:44 +00:00
rts
2017-02-01 18:46:04 +00:00
2013-12-05 11:40:44 +00:00
l4: lda #0
l5: rts