Streamlined machine detection.

This commit is contained in:
Oliver Schmidt 2020-06-15 19:07:59 +02:00
parent 6adf175691
commit e0a0b2dc25

View file

@ -52,8 +52,7 @@ libref: .addr $0000
.bss .bss
maxnum: .res 1 ; Maximum joystick number (0 or 1) ostype: .res 1
iigs: .res 1
value0: .res 1 value0: .res 1
value1: .res 1 value1: .res 1
@ -68,20 +67,10 @@ value1: .res 1
INSTALL: INSTALL:
lda libref lda libref
ldx libref+1 ldx libref+1
sta ostype+1 sta gettype+1
stx ostype+2 stx gettype+2
ostype: jsr $0000 ; X = 0 gettype:jsr $0000
and #$F0 ; Mask variants sta ostype
cmp #$50 ; Any Apple //c
beq :+ ; Only one joystick
inx
: stx maxnum
ldx #$00
cmp #$80 ; Any Apple IIgs
bne :+
inx
: stx iigs
lda #<JOY_ERR_OK lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK ldx #>JOY_ERR_OK
; Fall through ; Fall through
@ -97,9 +86,11 @@ UNINSTALL:
; COUNT routine. Return the total number of available joysticks in a/x. ; COUNT routine. Return the total number of available joysticks in a/x.
COUNT: COUNT:
ldx maxnum ldx #$02
inx bit ostype
txa ; Number of joysticks we support bvc noiic ; Not $4x
dex ; Only one joystick for the //c
noiic: txa ; Number of joysticks we support
ldx #$00 ldx #$00
rts rts
@ -112,14 +103,15 @@ READ:
sty value1 sty value1
; If IIgs -> set speed to normal ; If IIgs -> set speed to normal
lda iigs bit ostype
beq nogs1 bpl nogs1 ; Not $8x
lda CYAREG lda CYAREG
pha pha
and #%01111111 and #%01111111
sta CYAREG sta CYAREG
; Read both paddles simultaneously ; Read both paddles simultaneously according to:
; Apple IIe Technote #6, The Apple II Paddle Circuits
nogs1: lda PTRIG ; Trigger paddles nogs1: lda PTRIG ; Trigger paddles
loop: lda PADDL0,x ; Read paddle (0 or 2) loop: lda PADDL0,x ; Read paddle (0 or 2)
bmi set0 ; Cycles: 2 3 bmi set0 ; Cycles: 2 3
@ -140,8 +132,8 @@ nop1: ; - -
bne loop bne loop
; If IIgs -> restore speed ; If IIgs -> restore speed
lda iigs bit ostype
beq nogs2 bpl nogs2 ; Not $8x
pla pla
sta CYAREG sta CYAREG