check trigger button (TRIGx); correctly report joystick count depending

on 5200 console version
This commit is contained in:
Christian Groessler
2014-05-28 00:35:49 +02:00
parent 803e9904db
commit 98195a516e

View File

@@ -1,7 +1,7 @@
; ;
; Standard joystick driver for the Atari 5200. ; Standard joystick driver for the Atari 5200.
; ;
; Christian Groessler, 2014-05-12 ; Christian Groessler, 2014-05-28
; ;
.include "zeropage.inc" .include "zeropage.inc"
@@ -44,12 +44,6 @@
.addr READJOY .addr READJOY
.addr 0 ; IRQ entry not used .addr 0 ; IRQ entry not used
; ------------------------------------------------------------------------
; Constants
JOY_COUNT = 4 ; Number of joysticks we support
.code .code
; ------------------------------------------------------------------------ ; ------------------------------------------------------------------------
@@ -78,7 +72,12 @@ UNINSTALL:
; ;
COUNT: COUNT:
lda #JOY_COUNT lda $FD32 ; check ROM version
cmp #$E8
bne @2port
lda #4
.byte $2C ; bit opcode, eats the next 2 bytes
@2port: lda #2
ldx #0 ldx #0
rts rts
@@ -90,14 +89,19 @@ CENTER = 228 / 2
SENSIVITY = 16 SENSIVITY = 16
READJOY: READJOY:
and #3 ; fix joystick number and #3 ; put joystick number in range, just in case
tay
asl a asl a
tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers
lda #0 ; Initialize return value lda #0 ; Initialize return value
cmp TRIG0,y
bne @notrg
lda #$10 ; JOY_FIRE
; Read joystick ; Read joystick
ldy PADDL0,x ; get horizontal position @notrg: ldy PADDL0,x ; get horizontal position
cpy #CENTER-SENSIVITY cpy #CENTER-SENSIVITY
bcs @chkleft bcs @chkleft
@@ -115,16 +119,12 @@ READJOY:
bcs @chkdown bcs @chkdown
ora #1 ; JOY_UP ora #1 ; JOY_UP
bne @buttons bne @done
@chkdown: @chkdown:
cpy #CENTER+SENSIVITY cpy #CENTER+SENSIVITY
bcc @buttons bcc @done
ora #2 ; JOY_DOWN ora #2 ; JOY_DOWN
@buttons: @done: rts
; @@@ TODO: BOTTON STATE
rts