mirror of
https://github.com/a2-4am/4cade.git
synced 2024-11-30 13:50:45 +00:00
41 lines
1.2 KiB
Plaintext
41 lines
1.2 KiB
Plaintext
;------------------------------------------------------------------------------
|
|
; HasJoystick
|
|
; Checks whether computer has joystick connected
|
|
;
|
|
; in: none
|
|
; out: C set if joystick found
|
|
; C clear if no joystick found
|
|
; other flags clobbered
|
|
; A,X clobbered
|
|
; Y preserved
|
|
;
|
|
; adapted from "Prince of Persia" by Jordan Mechner
|
|
; (c) 1989 Broderbund Software
|
|
; https://github.com/jmechner/Prince-of-Persia-Apple-II/blob/master/01%20POP%20Source/Source/GRAFIX.S#L1225
|
|
;------------------------------------------------------------------------------
|
|
HasJoystick
|
|
lda #0
|
|
sta @joyX
|
|
sta @joyY
|
|
lda $C070 ; reset analog input timers
|
|
@loop ldx #1
|
|
@1 lda $C064,x ; check timer input
|
|
bpl @beat
|
|
inc @joyX,x ; still high, increment counter
|
|
@nextpdl dex
|
|
bpl @1
|
|
lda $C064
|
|
ora $C065
|
|
bpl @yes ; both inputs low, we're done
|
|
lda @joyX
|
|
ora @joyY
|
|
bpl @loop ; do it again
|
|
@no clc
|
|
+HIDE_NEXT_BYTE
|
|
@yes sec
|
|
rts
|
|
@beat nop
|
|
bpl @nextpdl ; kill time
|
|
@joyX !byte 0
|
|
@joyY !byte 0
|