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 ; JOY_FIRE2 unavailable
34 .byte $00 ; Future expansion
35 .byte $00 ; Future expansion
45 ; ------------------------------------------------------------------------
48 JOY_COUNT = 4 ; Number of joysticks we support
50 ; ------------------------------------------------------------------------
51 ; Data. Written in the IRQ, read by the READ routine
60 ; ------------------------------------------------------------------------
61 ; INSTALL routine. Is called after the driver is loaded into memory. If
62 ; possible, check if the hardware is present and determine the amount of
64 ; Must return an JOY_ERR_xx code in a/x.
71 ; rts ; Run into UNINSTALL instead
73 ; ------------------------------------------------------------------------
74 ; UNINSTALL routine. Is called before the driver is removed from memory.
75 ; Can do cleanup or whatever. Must not return anything.
81 ; ------------------------------------------------------------------------
82 ; IRQ entry point. Is called from the C layer as a subroutine in the
83 ; interrupt. The routine MUST return carry set if the interrupt has been
84 ; 'handled' - which means that the interrupt source is gone. Otherwise it
85 ; MUST return carry clear.
89 ldy #$00 ; port b direction
92 sty $dd05 ; cia2 timer a highbyte
93 sty $dc05 ; cia1 timer a highbyte
95 sty $dd04 ; cia2 timer a lowbyte
96 sty $dc04 ; cia1 timer a lowbyte
99 sta $dd0e ; control register a
107 sta $dc0e ; control register a
111 ; serial port: output
114 lda $dd01 ;read cia 2 port b
119 lda $dd02 ;cia 2 port a
120 and #%11111011 ;data direction
121 sta $dd02 ;=> bit 2 input
123 lda $dd00 ;read cia 2 p.A
124 and #%00000100 ;check bit 2
131 lda $dd01 ;read cia 2 port b
139 ldx #$ff ;serial data register
140 stx $dc0c ;=> writing $ff causes
142 ;count signals at cnt1
144 ldx $dd0c ;read cia 2 serial in
145 beq fire ;button press if zero
152 ; Default Value: $40/64 on PAL
156 ; Default Value: $25/37 on PAL
161 ; We do never "handle" the interrupt, we use it just as a timer.
165 ; ------------------------------------------------------------------------
166 ; COUNT: Return the total number of available joysticks in a/x.
169 COUNT: lda #<JOY_COUNT
173 ; ------------------------------------------------------------------------
174 ; READ: Read a particular joystick passed in A.
177 READ: tax ; Joystick number into X