1
0
mirror of https://github.com/RevCurtisP/C02.git synced 2024-11-24 15:31:17 +00:00
C02/include/x16/joystk.a02

34 lines
1.0 KiB
Plaintext
Raw Normal View History

;Joystick Constants and Functions
2019-11-20 15:52:41 +00:00
;for Commander X16 Computer
JYSTKS EQU 2 ;Number of Joysticks
2019-11-20 15:52:41 +00:00
.JYDATA EQU $02BC ;Joystick 0 Data
2019-11-20 15:52:41 +00:00
.GETJOY EQU $FF06 ;Kernal GETJOY Routine
;Joystick Bit Masks
JOYUP EQU $08 ;Up
JOYDN EQU $04 ;Down
JOYLF EQU $02 ;Left
JOYRT EQU $01 ;Right
JOYB0 EQU $80 ;Button
;Read Joystick
JOYSTK: CMP #JYSTKS ;If Invalid Joystick Number
BCS JOYSTE ; Return ERROR
STA TEMP0 ;Save Joystick Number
JSR $FF06 ;Call Kernal GETJOY Routine
LDA TEMP0 ;Retrieve Joystick Number
ASL ;Multiply it by 3
ADC TEMP0 ;(Assumes Number<128)
TAX ;and Copy to X-Register
LDA $02BE,X ;If Controller Not Present
BNE JOYSTE ; Return ERROR
LDA $02BC,X ;Read Controller Status
;EOR #$FF ;Invert Bits
AND #$CF ;and Mask off Select/Start
RTS
2019-11-20 15:52:41 +00:00
JOYSTE: LDA #255 ;Return Error Code
RTS