2018-09-17 15:34:26 +00:00
|
|
|
;Joystick Assembly Language Module for C64
|
|
|
|
|
2018-11-07 05:11:09 +00:00
|
|
|
JYSTKS EQU $04 ;Number of Joysticks
|
2018-09-17 15:34:26 +00:00
|
|
|
|
|
|
|
;Joystick Bit Masks
|
|
|
|
JOYUP EQU $01 ;Bit 0 - Up
|
|
|
|
JOYDN EQU $02 ;Bit 1 - Down
|
|
|
|
JOYLF EQU $04 ;Bit 2 - Left
|
|
|
|
JOYRT EQU $08 ;Bit 3 - Right
|
|
|
|
JOYB0 EQU $10 ;Bit 4 - Button
|
|
|
|
|
|
|
|
;Read Joystick
|
|
|
|
JOYSTK: CMP #JYSTKS ;If Invalid Joystick#
|
|
|
|
BCS JOYSTZ ; Return Error
|
2018-11-07 05:11:09 +00:00
|
|
|
TAX ;Copy Joystick # to X
|
|
|
|
LDA $0284,X ;Read Trigger Control Register
|
|
|
|
ROR ;Move Bit 0 into Carry
|
|
|
|
LDA $DC00,X ;Read Joystick Shadow Register
|
2018-09-17 15:34:26 +00:00
|
|
|
EOR #$FF ;Invert and
|
2018-11-07 05:11:09 +00:00
|
|
|
AND #$0F ;Mask Bits
|
|
|
|
BCS JOYSTX ;If Trigger Pressed
|
|
|
|
ORA #$10 ; Set Bit 4
|
|
|
|
HOYSTX: RTS
|
2018-09-17 15:34:26 +00:00
|
|
|
JOYSTZ: LDA #$FF ;Return Error
|
|
|
|
RTS
|