1; 2; Standard joystick driver for the C64. May be used multiple times when linked 3; to the statically application. 4; 5; Ullrich von Bassewitz, 2002-12-20 6; 7 8 .include "zeropage.inc" 9 10 .include "joy-kernel.inc" 11 .include "joy-error.inc" 12 .include "c64.inc" 13 14 .macpack generic 15 .macpack module 16 17 18; ------------------------------------------------------------------------ 19; Header. Includes jump table 20 21 module_header _c64_stdjoy_joy 22 23; Driver signature 24 25 .byte $6A, $6F, $79 ; "joy" 26 .byte JOY_API_VERSION ; Driver API version number 27 28; Library reference 29 30 .addr $0000 31 32; Jump table. 33 34 .addr INSTALL 35 .addr UNINSTALL 36 .addr COUNT 37 .addr READ 38 39; ------------------------------------------------------------------------ 40; Constants 41 42JOY_COUNT = 2 ; Number of joysticks we support 43 44 45; ------------------------------------------------------------------------ 46; Data. 47 48 49.code 50 51; ------------------------------------------------------------------------ 52; INSTALL routine. Is called after the driver is loaded into memory. If 53; possible, check if the hardware is present and determine the amount of 54; memory available. 55; Must return an JOY_ERR_xx code in a/x. 56; 57 58INSTALL: 59 lda #<JOY_ERR_OK 60 ldx #>JOY_ERR_OK 61 62; rts ; Run into UNINSTALL instead 63 64; ------------------------------------------------------------------------ 65; UNINSTALL routine. Is called before the driver is removed from memory. 66; Can do cleanup or whatever. Must not return anything. 67; 68 69UNINSTALL: 70 rts 71 72 73; ------------------------------------------------------------------------ 74; COUNT: Return the total number of available joysticks in a/x. 75; 76 77COUNT: 78 lda #<JOY_COUNT 79 ldx #>JOY_COUNT 80 rts 81 82; ------------------------------------------------------------------------ 83; READ: Read a particular joystick passed in A. 84; 85 86READ: tax ; Joystick number into X 87 bne joy2 88 89; Read joystick 1 90 91joy1: lda #$7F 92 sei 93 sta CIA1_PRA 94 lda CIA1_PRB 95 cli 96 and #$1F 97 eor #$1F 98 rts 99 100; Read joystick 2 101 102joy2: ldx #0 103 lda #$E0 104 ldy #$FF 105 sei 106 sta CIA1_DDRA 107 lda CIA1_PRA 108 sty CIA1_DDRA 109 cli 110 and #$1F 111 eor #$1F 112 rts 113 114 115