2014-05-12 01:03:44 +00:00
|
|
|
;
|
|
|
|
; Standard joystick driver for the Atari 5200.
|
|
|
|
;
|
2014-05-27 22:35:49 +00:00
|
|
|
; Christian Groessler, 2014-05-28
|
2014-05-12 01:03:44 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
.include "zeropage.inc"
|
|
|
|
|
|
|
|
.include "joy-kernel.inc"
|
|
|
|
.include "joy-error.inc"
|
|
|
|
.include "atari5200.inc"
|
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
.macpack module
|
|
|
|
|
2014-05-12 01:03:44 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Header. Includes jump table
|
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
module_header _atr5200std_joy
|
2014-05-12 01:03:44 +00:00
|
|
|
|
|
|
|
; Driver signature
|
|
|
|
|
|
|
|
.byte $6A, $6F, $79 ; "joy"
|
|
|
|
.byte JOY_API_VERSION ; Driver API version number
|
|
|
|
|
|
|
|
; Library reference
|
|
|
|
|
|
|
|
.addr $0000
|
|
|
|
|
|
|
|
; Jump table.
|
|
|
|
|
|
|
|
.addr INSTALL
|
|
|
|
.addr UNINSTALL
|
|
|
|
.addr COUNT
|
|
|
|
.addr READJOY
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; INSTALL routine. Is called after the driver is loaded into memory. If
|
|
|
|
; possible, check if the hardware is present and determine the amount of
|
|
|
|
; memory available.
|
|
|
|
; Must return an JOY_ERR_xx code in a/x.
|
|
|
|
;
|
|
|
|
|
|
|
|
INSTALL:
|
|
|
|
lda #JOY_ERR_OK
|
|
|
|
ldx #0
|
|
|
|
; rts ; Run into UNINSTALL instead
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; UNINSTALL routine. Is called before the driver is removed from memory.
|
|
|
|
; Can do cleanup or whatever. Must not return anything.
|
|
|
|
;
|
|
|
|
|
|
|
|
UNINSTALL:
|
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; COUNT: Return the total number of available joysticks in a/x.
|
|
|
|
;
|
|
|
|
|
|
|
|
COUNT:
|
2014-05-27 22:35:49 +00:00
|
|
|
lda $FD32 ; check ROM version
|
|
|
|
cmp #$E8
|
|
|
|
bne @2port
|
|
|
|
lda #4
|
|
|
|
.byte $2C ; bit opcode, eats the next 2 bytes
|
|
|
|
@2port: lda #2
|
2014-05-12 01:03:44 +00:00
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; READ: Read a particular joystick passed in A.
|
|
|
|
;
|
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
CENTER = 228 / 2
|
|
|
|
SENSIVITY = 16
|
2014-05-12 01:03:44 +00:00
|
|
|
|
|
|
|
READJOY:
|
2014-05-27 22:35:49 +00:00
|
|
|
and #3 ; put joystick number in range, just in case
|
|
|
|
tay
|
|
|
|
asl a
|
2014-05-12 01:03:44 +00:00
|
|
|
tax ; Joystick number * 2 (0-6) into X, index into ZP shadow registers
|
2014-05-27 22:35:49 +00:00
|
|
|
|
|
|
|
lda #0 ; Initialize return value
|
|
|
|
cmp TRIG0,y
|
|
|
|
bne @notrg
|
2017-08-19 17:11:28 +00:00
|
|
|
lda #$10 ; JOY_BTN
|
2014-05-12 01:03:44 +00:00
|
|
|
|
|
|
|
; Read joystick
|
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
@notrg: ldy PADDL0,x ; get horizontal position
|
|
|
|
cpy #CENTER-SENSIVITY
|
|
|
|
bcs @chkleft
|
2014-05-12 01:03:44 +00:00
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
ora #4 ; JOY_LEFT
|
|
|
|
bne @updown
|
2014-05-12 01:03:44 +00:00
|
|
|
|
|
|
|
@chkleft:
|
2014-05-27 22:35:49 +00:00
|
|
|
cpy #CENTER+SENSIVITY
|
|
|
|
bcc @updown
|
2014-05-12 01:03:44 +00:00
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
ora #8 ; JOY_RIGHT
|
2014-05-12 01:03:44 +00:00
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
@updown:ldy PADDL0+1,x ; get vertical position
|
|
|
|
cpy #CENTER-SENSIVITY
|
|
|
|
bcs @chkdown
|
2014-05-12 01:03:44 +00:00
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
ora #1 ; JOY_UP
|
|
|
|
bne @done
|
2014-05-12 01:03:44 +00:00
|
|
|
|
|
|
|
@chkdown:
|
2014-05-27 22:35:49 +00:00
|
|
|
cpy #CENTER+SENSIVITY
|
|
|
|
bcc @done
|
2014-05-12 01:03:44 +00:00
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
ora #2 ; JOY_DOWN
|
2014-05-12 01:03:44 +00:00
|
|
|
|
2014-05-27 22:35:49 +00:00
|
|
|
@done: rts
|