2018-08-27 19:39:08 +00:00
|
|
|
;------------------------------------------------------------------------------
|
|
|
|
; HasJoystick
|
|
|
|
; Checks whether computer has joystick connected
|
|
|
|
;
|
|
|
|
; in: none
|
2018-08-29 19:27:30 +00:00
|
|
|
; out: C set if joystick found
|
|
|
|
; C clear if no joystick found
|
2018-08-27 19:39:08 +00:00
|
|
|
; 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
|
|
|
|
;------------------------------------------------------------------------------
|
2020-09-04 15:20:37 +00:00
|
|
|
; Fastchip firmware 0.4b-compatibility fix by Frank M. (0.5b seems unaffected)
|
|
|
|
;------------------------------------------------------------------------------
|
2018-08-27 19:39:08 +00:00
|
|
|
HasJoystick
|
2020-09-04 15:20:37 +00:00
|
|
|
lda $FBB3
|
|
|
|
cmp #$06
|
|
|
|
bne ++
|
|
|
|
lda $FBC0
|
|
|
|
cmp #$E0
|
|
|
|
beq + ; test for Fastchip on enhanced //e
|
|
|
|
cmp #$EA
|
|
|
|
beq + ; test for Fastchip on non-enhanced //e
|
|
|
|
jmp ++
|
|
|
|
|
|
|
|
+ ; FASTChip
|
|
|
|
fc_lock = $C06A
|
|
|
|
fc_enable = $C06B
|
|
|
|
fc_config = $C06E
|
|
|
|
fc_data = $C06F
|
|
|
|
FC_UNLOCK = $6A ; write 4 times
|
|
|
|
FC_LOCK = $A6
|
|
|
|
FC_SPKR = 2 ; speaker delay register
|
|
|
|
FC_HIFI = 4 ; set to 'HIFI'
|
|
|
|
FC_JOY = 3 ; joystick delay register
|
|
|
|
FC_LONG = 2 ; set to 'LONG'
|
|
|
|
|
|
|
|
lda #FC_UNLOCK
|
|
|
|
sta fc_lock
|
|
|
|
sta fc_lock
|
|
|
|
sta fc_lock
|
|
|
|
sta fc_lock
|
|
|
|
sta fc_enable
|
|
|
|
lda fc_enable ; 00 if no fastchip
|
|
|
|
cmp #$80 ; 80 if Fastchip normal
|
|
|
|
bne ++ ; A0 if Fastchip disabled
|
|
|
|
|
|
|
|
lda #FC_JOY ; change Fastchip joystick delay setting to 'LONG'
|
|
|
|
sta fc_config ; (improves joystick detection)
|
|
|
|
lda #FC_LONG
|
|
|
|
sta fc_data
|
|
|
|
|
|
|
|
lda #FC_SPKR ; change Fastchip speaker delay setting to 'HIFI'
|
|
|
|
sta fc_config ; (improves sound on most games)
|
|
|
|
lda #FC_HIFI
|
|
|
|
sta fc_data
|
|
|
|
|
|
|
|
lda #FC_LOCK ; (settings revert on power cycle)
|
|
|
|
sta fc_lock
|
|
|
|
++
|
2018-08-27 19:39:08 +00:00
|
|
|
lda #0
|
2018-08-29 19:27:30 +00:00
|
|
|
sta @joyX
|
|
|
|
sta @joyY
|
2018-08-27 19:39:08 +00:00
|
|
|
lda $C070 ; reset analog input timers
|
|
|
|
@loop ldx #1
|
|
|
|
@1 lda $C064,x ; check timer input
|
|
|
|
bpl @beat
|
2018-08-29 19:27:30 +00:00
|
|
|
inc @joyX,x ; still high, increment counter
|
2018-08-27 19:39:08 +00:00
|
|
|
@nextpdl dex
|
|
|
|
bpl @1
|
|
|
|
lda $C064
|
|
|
|
ora $C065
|
2018-08-29 19:27:30 +00:00
|
|
|
bpl @yes ; both inputs low, we're done
|
|
|
|
lda @joyX
|
|
|
|
ora @joyY
|
2018-08-27 19:39:08 +00:00
|
|
|
bpl @loop ; do it again
|
2018-08-29 19:27:30 +00:00
|
|
|
@no clc
|
2018-08-27 19:39:08 +00:00
|
|
|
+HIDE_NEXT_BYTE
|
2018-08-29 19:27:30 +00:00
|
|
|
@yes sec
|
2018-08-27 19:39:08 +00:00
|
|
|
rts
|
|
|
|
@beat nop
|
|
|
|
bpl @nextpdl ; kill time
|
2018-08-29 19:27:30 +00:00
|
|
|
@joyX !byte 0
|
|
|
|
@joyY !byte 0
|