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 $00 ; 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
107 sty $dd05 ; cia2 timer a highbyte
108 sty $dc05 ; cia1 timer a highbyte
111 sty $dd04 ; cia2 timer a lowbyte
112 sty $dc04 ; cia1 timer a lowbyte
115 sta $dd0e ; control register a
124 ; sty $dc0d ; irq ctrl reg
127 sta $dc0e ; control register a
131 ; serial port: output
136 lda $dd01 ;read cia 2 port b
142 lda $dd02 ;cia 2 port a
143 and #%11111011 ;data direction
144 sta $dd02 ;=> bit 2 input
146 lda $dd00 ;read cia 2 p.A
147 and #%00000100 ;check bit 2
155 lda $dd01 ;read cia 2 port b
164 ldx #$ff ;serial data register
165 stx $dc0c;=> writing $ff causes
167 ;count signals at cnt1
169 ldx $dd0c ;read cia 2 serial in
170 beq fire ;button press if zero
178 ; Default Value: $40/64 on PAL
182 ; Default Value: $25/37 on PAL
189 ; ------------------------------------------------------------------------
190 ; COUNT: Return the total number of available joysticks in a/x.
198 ; ------------------------------------------------------------------------
199 ; READ: Read a particular joystick passed in A.
203 tax ; Joystick number into X