Telestrat joystick management

This commit is contained in:
jede
2020-05-24 22:47:20 +02:00
committed by greg-king5
parent f8be35b41e
commit 532240a2db
6 changed files with 155 additions and 5 deletions

View File

@@ -0,0 +1,109 @@
;
; Telestrat joystick driver
;
; 2002-12-20, Based on Ullrich von Bassewitz's code.
; 2017-11-01, Stefan Haubenthal
; 2020-05-20n, Jede
;
.include "joy-kernel.inc"
.include "joy-error.inc"
.include "telestrat.inc"
.macpack module
; ------------------------------------------------------------------------
; Header. Includes jump table
module_header _telestrat_joy
; Driver signature
.byte $6A, $6F, $79 ; "joy"
.byte JOY_API_VERSION ; Driver API version number
; Library reference
.addr $0000
; Jump table.
.addr INSTALL
.addr UNINSTALL
.addr COUNT
.addr READ
; ------------------------------------------------------------------------
; Constants
JOY_COUNT = 2 ; Number of joysticks we support
.code
; ------------------------------------------------------------------------
; INSTALL routine. Is called after the driver is loaded into memory. If
; possible, check if the hardware is present and determine the amount of
; memory available.
; Must return an JOY_ERR_xx code in a/x.
;
INSTALL:
lda #%11000000
sta VIA2::DDRB
sta VIA2::PRB
; We could detect joysticks because with previous command bit0,1,2,3,4 should be set to 1 after
; But if some one press fire or press direction, we could reach others values which could break Joystick détection.
lda #<JOY_ERR_OK
ldx #>JOY_ERR_OK
; rts ; Run into UNINSTALL instead
; ------------------------------------------------------------------------
; UNINSTALL routine. Is called before the driver is removed from memory.
; Can do cleanup or whatever. Must not return anything.
;
UNINSTALL:
rts
; ------------------------------------------------------------------------
; COUNT: Return the total number of available joysticks in a/x.
;
COUNT:
lda #<JOY_COUNT
ldx #>JOY_COUNT
rts
; ------------------------------------------------------------------------
; READ: Read a particular joystick passed in A.
;
; How telestrat joysticks works
; PB7 and PB6 select right or left port
; When PB7 and PB6 are high, it controls two CA3083 (2 NPN transistors array) bases.
; In that case, PB0 to PB4 are set to high (it means no action are pressed)
; When the user press something then bit will be set to 0.
; bit 0 is right
; bit 1 is left
; bit 2 is fire
; ...
READ:
beq right
lda #%10000000
ora VIA2::PRB
sta VIA2::PRB
; then read
lda VIA2::PRB
eor #%10011111
rts
right:
lda #%01000000
ora VIA2::PRB
sta VIA2::PRB
; then read
lda VIA2::PRB
eor #%01011111
rts

View File

@@ -0,0 +1,14 @@
;
; Address of the static standard joystick driver
;
; Oliver Schmidt, 2012-11-01
;
; const void joy_static_stddrv[];
;
.export _joy_static_stddrv
.import _telestrat_joy
.rodata
_joy_static_stddrv := _telestrat_joy

View File

@@ -0,0 +1,13 @@
;
; Name of the standard joystick driver
;
; Oliver Schmidt, 2012-11-01
;
; const char joy_stddrv[];
;
.export _joy_stddrv
.rodata
_joy_stddrv: .asciiz "telestrat_joy"

View File

@@ -2,7 +2,8 @@
; Jede (jede@oric.org), 2017-10-16
;
.export tgi_libref
.export joy_libref, tgi_libref
.import _exit
joy_libref := _exit
tgi_libref := _exit