2019-09-27 07:38:51 +00:00
|
|
|
;
|
|
|
|
; Standard joystick driver for the CX16.
|
2019-12-25 15:56:32 +00:00
|
|
|
; May be installed multiple times when statically linked to an application.
|
2019-09-27 07:38:51 +00:00
|
|
|
;
|
2019-12-25 15:56:32 +00:00
|
|
|
; 2019-12-24, Greg King
|
2019-09-27 07:38:51 +00:00
|
|
|
;
|
|
|
|
|
|
|
|
.include "joy-kernel.inc"
|
|
|
|
.include "joy-error.inc"
|
|
|
|
|
|
|
|
.include "cbm_kernal.inc"
|
|
|
|
.include "cx16.inc"
|
|
|
|
|
|
|
|
.macpack generic
|
|
|
|
.macpack module
|
|
|
|
|
2019-12-25 15:56:32 +00:00
|
|
|
.importzp tmp1
|
|
|
|
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Header. Includes jump table
|
|
|
|
|
2019-11-16 18:11:40 +00:00
|
|
|
module_header _cx16_std_joy
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
; Driver signature
|
|
|
|
|
|
|
|
.byte $6A, $6F, $79 ; ASCII "joy"
|
|
|
|
.byte JOY_API_VERSION ; Driver API version number
|
|
|
|
|
|
|
|
; Library reference
|
|
|
|
|
|
|
|
.addr $0000
|
|
|
|
|
|
|
|
; Jump table.
|
|
|
|
|
|
|
|
.addr INSTALL
|
|
|
|
.addr UNINSTALL
|
|
|
|
.addr COUNT
|
|
|
|
.addr READ
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Constant
|
|
|
|
|
|
|
|
JOY_COUNT = 2 ; Number of joysticks we support
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
|
|
|
; Data.
|
|
|
|
|
|
|
|
|
|
|
|
.code
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2019-11-16 18:11:40 +00:00
|
|
|
; INSTALL routine -- is called after the driver is loaded into memory.
|
2019-09-27 07:38:51 +00:00
|
|
|
; If possible, check if the hardware is present, and determine the amount
|
|
|
|
; of memory available.
|
2019-11-16 18:11:40 +00:00
|
|
|
; Must return a JOY_ERR_xx code in .XA .
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
INSTALL:
|
|
|
|
lda #<JOY_ERR_OK
|
|
|
|
ldx #>JOY_ERR_OK
|
|
|
|
; rts ; Run into UNINSTALL instead
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2019-11-16 18:11:40 +00:00
|
|
|
; UNINSTALL routine -- is called before the driver is removed from memory.
|
|
|
|
; Can do clean-up or whatever. Shouldn't return anything.
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
UNINSTALL:
|
|
|
|
rts
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2019-11-16 18:11:40 +00:00
|
|
|
; COUNT: Return the total number of possible joysticks, in .XA .
|
2019-09-27 07:38:51 +00:00
|
|
|
|
|
|
|
COUNT: lda #<JOY_COUNT
|
|
|
|
ldx #>JOY_COUNT
|
|
|
|
rts
|
|
|
|
|
|
|
|
; ------------------------------------------------------------------------
|
2019-11-16 18:11:40 +00:00
|
|
|
; READ: Read a particular joystick passed in .A .
|
2019-09-27 07:38:51 +00:00
|
|
|
|
2019-12-25 15:56:32 +00:00
|
|
|
READ: and #%00000001
|
|
|
|
jsr JOYSTICK_GET
|
|
|
|
sta tmp1
|
|
|
|
txa
|
|
|
|
bit #%00001110 ; Is it NES or SNES controller?
|
|
|
|
bze nes
|
2019-11-16 18:11:40 +00:00
|
|
|
|
2019-12-25 15:56:32 +00:00
|
|
|
asl tmp1 ; Get SNES's B button
|
2019-09-27 07:38:51 +00:00
|
|
|
ror a ; Put it next to the A button
|
2019-12-25 15:56:32 +00:00
|
|
|
asl tmp1 ; Drop SNES's Y button
|
2019-11-16 18:11:40 +00:00
|
|
|
asl a ; Get back the B button
|
2019-12-25 15:56:32 +00:00
|
|
|
ror tmp1
|
2019-09-27 07:38:51 +00:00
|
|
|
asl a ; Get SNES's A button
|
2019-12-25 15:56:32 +00:00
|
|
|
ror tmp1 ; Make byte look like NES pad
|
2019-11-16 18:11:40 +00:00
|
|
|
|
2019-12-25 15:56:32 +00:00
|
|
|
nes: lda tmp1 ; The controllers give zeroes for "pressed"
|
|
|
|
eor #%11111111 ; We want ones for "pressed"
|
2019-09-27 07:38:51 +00:00
|
|
|
rts
|