2 ; DXS/HIT-4 Player joystick driver for the C64
4 ; Groepaz/Hitmen, 2002-12-23
5 ; obviously based on Ullrichs driver :)
8 .include "zeropage.inc"
10 .include "joy-kernel.inc"
11 .include "joy-error.inc"
16 ; ------------------------------------------------------------------------
17 ; Header. Includes jump table
23 .byte $6A, $6F, $79 ; "joy"
24 .byte JOY_API_VERSION ; Driver API version number
26 ; Button state masks (8 values)
33 .byte $00 ; Future expansion
34 .byte $00 ; Future expansion
35 .byte $00 ; Future expansion
44 ; ------------------------------------------------------------------------
47 JOY_COUNT = 4 ; Number of joysticks we support
49 ; ------------------------------------------------------------------------
50 ; Data. Written in the IRQ, read by the READ routine
59 ; ------------------------------------------------------------------------
60 ; INSTALL routine. Is called after the driver is loaded into memory. If
61 ; possible, check if the hardware is present and determine the amount of
63 ; Must return an JOY_ERR_xx code in a/x.
83 ; ------------------------------------------------------------------------
84 ; DEINSTALL routine. Is called before the driver is removed from memory.
85 ; Can do cleanup or whatever. Must not return anything.
97 ; ------------------------------------------------------------------------
98 ; we must use an irq here since we need timers
99 ; which otherwhise would conflict with system-irq
103 ldy #$00 ; port b direction
106 sty $dd05 ; cia2 timer a highbyte
107 sty $dc05 ; cia1 timer a highbyte
109 sty $dd04 ; cia2 timer a lowbyte
110 sty $dc04 ; cia1 timer a lowbyte
113 sta $dd0e ; control register a
121 sta $dc0e ; control register a
125 ; serial port: output
129 lda $dd01 ;read cia 2 port b
134 lda $dd02 ;cia 2 port a
135 and #%11111011 ;data direction
136 sta $dd02 ;=> bit 2 input
138 lda $dd00 ;read cia 2 p.A
139 and #%00000100 ;check bit 2
146 lda $dd01 ;read cia 2 port b
154 ldx #$ff ;serial data register
155 stx $dc0c;=> writing $ff causes
157 ;count signals at cnt1
159 ldx $dd0c ;read cia 2 serial in
160 beq fire ;button press if zero
168 ; Default Value: $40/64 on PAL
172 ; Default Value: $25/37 on PAL
179 ; ------------------------------------------------------------------------
180 ; COUNT: Return the total number of available joysticks in a/x.
188 ; ------------------------------------------------------------------------
189 ; READ: Read a particular joystick passed in A.
193 tax ; Joystick number into X