2 ; PTV-2 Player joystick driver for the PET
4 ; Stefan Haubenthal, 2005-05-25
5 ; Groepaz/Hitmen, 2002-12-23
6 ; obviously based on Ullrichs driver :)
9 .include "zeropage.inc"
11 .include "joy-kernel.inc"
12 .include "joy-error.inc"
17 ; ------------------------------------------------------------------------
18 ; Header. Includes jump table
20 module_header _pet_ptvjoy_joy
24 .byte $6A, $6F, $79 ; "joy"
25 .byte JOY_API_VERSION ; Driver API version number
37 .addr 0 ; IRQ entry unused
39 ; ------------------------------------------------------------------------
42 JOY_COUNT = 2 ; Number of joysticks we support
44 VIA_PRA := $E841 ; Port register A
45 VIA_DDRA := $E843 ; Data direction register A
50 ; ------------------------------------------------------------------------
51 ; INSTALL routine. Is called after the driver is loaded into memory. If
52 ; possible, check if the hardware is present and determine the amount of
54 ; Must return an JOY_ERR_xx code in a/x.
60 ; rts ; Run into UNINSTALL instead
62 ; ------------------------------------------------------------------------
63 ; UNINSTALL routine. Is called before the driver is removed from memory.
64 ; Can do cleanup or whatever. Must not return anything.
71 ; ------------------------------------------------------------------------
72 ; COUNT: Return the total number of available joysticks in a/x.
80 ; ------------------------------------------------------------------------
81 ; READ: Read a particular joystick passed in A.
84 READ: lda #%10000000 ; via port A Data-Direction
85 sta VIA_DDRA ; bit 7: out bit 6-0: in
87 tax ; Joystick number into X
92 joy1: lda #$80 ; via port A read/write
93 sta VIA_PRA ; (output one at PA7)
95 lda VIA_PRA ; via port A read/write
96 and #$1f ; get bit 4-0 (PA4-PA0)
102 joy2: lda #$00 ; via port A read/write
103 sta VIA_PRA ; (output zero at PA7)
105 lda VIA_PRA ; via port A read/write
106 and #$0f ; get bit 3-0 (PA3-PA0)
107 sta tmp1 ; joy 4 directions
109 lda VIA_PRA ; via port A read/write
110 and #%00100000 ; get bit 5 (PA5)