2003-09-27 20:14:31 +00:00
|
|
|
;
|
|
|
|
; PTV-4 Player joystick driver for the C64
|
|
|
|
;
|
|
|
|
; Groepaz/Hitmen, 2002-12-23
|
|
|
|
; obviously based on Ullrichs driver :)
|
|
|
|
;
|
|
|
|
|
|
|
|
.include "zeropage.inc"
|
|
|
|
|
|
|
|
.include "joy-kernel.inc"
|
|
|
|
.include "joy-error.inc"
|
|
|
|
.include "c64.inc"
|
|
|
|
|
|
|
|
.macpack generic
|
2014-06-04 21:50:18 +00:00
|
|
|
.macpack module
|
|
|
|
|
2003-09-27 20:14:31 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Header. Includes jump table
|
|
|
|
|
2014-06-04 21:50:18 +00:00
|
|
|
module_header _c64_ptvjoy_joy
|
2003-09-27 20:14:31 +00:00
|
|
|
|
|
|
|
; Driver signature
|
|
|
|
|
|
|
|
.byte $6A, $6F, $79 ; "joy"
|
2013-05-09 11:56:54 +00:00
|
|
|
.byte JOY_API_VERSION ; Driver API version number
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2013-05-31 22:36:08 +00:00
|
|
|
; Library reference
|
|
|
|
|
|
|
|
.addr $0000
|
|
|
|
|
2003-09-27 20:14:31 +00:00
|
|
|
; Jump table.
|
|
|
|
|
2004-11-06 13:27:38 +00:00
|
|
|
.addr INSTALL
|
|
|
|
.addr UNINSTALL
|
|
|
|
.addr COUNT
|
|
|
|
.addr READ
|
2003-09-27 20:14:31 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Constants
|
|
|
|
|
|
|
|
JOY_COUNT = 4 ; Number of joysticks we support
|
|
|
|
|
|
|
|
|
|
|
|
.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 #>JOY_ERR_OK
|
2013-05-09 11:56:54 +00:00
|
|
|
; rts ; Run into UNINSTALL instead
|
2003-09-27 20:14:31 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2003-12-16 22:38:12 +00:00
|
|
|
; UNINSTALL routine. Is called before the driver is removed from memory.
|
2003-09-27 20:14:31 +00:00
|
|
|
; Can do cleanup or whatever. Must not return anything.
|
|
|
|
;
|
|
|
|
|
2003-12-16 22:38:12 +00:00
|
|
|
UNINSTALL:
|
2003-09-27 20:14:31 +00:00
|
|
|
rts
|
|
|
|
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; COUNT: Return the total number of available joysticks in a/x.
|
|
|
|
;
|
|
|
|
|
|
|
|
COUNT:
|
|
|
|
lda #<JOY_COUNT
|
|
|
|
ldx #>JOY_COUNT
|
|
|
|
rts
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; READ: Read a particular joystick passed in A.
|
|
|
|
;
|
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
READ: tax ; Joystick number into X
|
2003-09-28 21:39:20 +00:00
|
|
|
bne joy2
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
; Read joystick 1
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
joy1: lda #$7F
|
2003-09-27 20:14:31 +00:00
|
|
|
sei
|
2013-05-09 11:56:54 +00:00
|
|
|
sta CIA1_PRA
|
|
|
|
lda CIA1_PRB
|
2003-09-27 20:14:31 +00:00
|
|
|
cli
|
2013-05-09 11:56:54 +00:00
|
|
|
and #$1F
|
|
|
|
eor #$1F
|
2003-09-27 20:14:31 +00:00
|
|
|
rts
|
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
; Read joystick 2
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
joy2: dex
|
|
|
|
bne joy3
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2013-05-09 11:56:54 +00:00
|
|
|
lda #$E0
|
|
|
|
ldy #$FF
|
2003-09-27 20:14:31 +00:00
|
|
|
sei
|
2013-05-09 11:56:54 +00:00
|
|
|
sta CIA1_DDRA
|
|
|
|
lda CIA1_PRA
|
|
|
|
sty CIA1_DDRA
|
2003-09-27 20:14:31 +00:00
|
|
|
cli
|
2013-05-09 11:56:54 +00:00
|
|
|
and #$1F
|
|
|
|
eor #$1F
|
2003-09-27 20:14:31 +00:00
|
|
|
rts
|
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
; Read joystick 3
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2010-02-02 17:05:18 +00:00
|
|
|
joy3:
|
2003-09-28 21:39:20 +00:00
|
|
|
lda #%10000000 ; cia 2 port B Data-Direction
|
|
|
|
sta CIA2_DDRB ; bit 7: out bit 6-0: in
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2010-02-02 17:05:18 +00:00
|
|
|
dex
|
2005-08-28 20:57:16 +00:00
|
|
|
bne joy4
|
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
lda #$80 ; cia 2 port B read/write
|
|
|
|
sta CIA2_PRB ; (output one at PB7)
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
lda CIA2_PRB ; cia 2 port B read/write
|
2017-08-20 12:53:40 +00:00
|
|
|
and #$1F ; get bit 4-0 (PB4-PB0)
|
|
|
|
eor #$1F
|
2003-09-27 20:14:31 +00:00
|
|
|
rts
|
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
; Read joystick 4
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2005-08-28 20:57:16 +00:00
|
|
|
joy4: lda #$00 ; cia 2 port B read/write
|
2003-09-28 21:39:20 +00:00
|
|
|
sta CIA2_PRB ; (output zero at PB7)
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
lda CIA2_PRB ; cia 2 port B read/write
|
2017-08-20 12:53:40 +00:00
|
|
|
and #$0F ; get bit 3-0 (PB3-PB0)
|
2003-09-28 21:39:20 +00:00
|
|
|
sta tmp1 ; joy 4 directions
|
2003-09-27 20:14:31 +00:00
|
|
|
|
2003-09-28 21:39:20 +00:00
|
|
|
lda CIA2_PRB ; cia 2 port B read/write
|
|
|
|
and #%00100000 ; get bit 5 (PB5)
|
2003-09-27 20:14:31 +00:00
|
|
|
lsr
|
2003-09-28 21:39:20 +00:00
|
|
|
ora tmp1
|
2017-08-20 12:53:40 +00:00
|
|
|
eor #$1F
|
2003-09-27 20:14:31 +00:00
|
|
|
|
|
|
|
ldx #0
|
|
|
|
rts
|
|
|
|
|