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

@ -189,15 +189,20 @@ port cardridge.
<sect1>Joystick drivers<p>
Telemon 2.4 & 3.0 manages joysticks but it had been handled yet. This means that
joysticks driver could be written easily.
Telemon 2.4 returns in keyboard buffer the direction of the joysticks. This means that
if you get input from keyboard by conio cgetc function, you will get direction from joysticks.
Anyway, if you don't want to use ROM, you can use joysticks standard drivers in your code.
The standard driver manages two joysticks. Only one button is managed for theses joysticks.
Telestrat can handle one button for the left port, and three buttons for the right port (but this port was designed for a mouse).
If you find a Telestrat mouse (which almost impossible :), these driver will work too because there is some extra hardware in the mouse to send direction.
<sect1>Mouse drivers<p>
Telestrat manages also mouse, but it had been no handled yet in this version.
Telestrat manages also mouse (Joystick port)
Telestrat mouse is really difficult to find.
<sect1>RS232 device drivers<p>

View File

@ -98,7 +98,15 @@ extern void telestrat_240_200_2_tgi[]; /* Referred to by tgi_static_stddrv[
#define CH_LIRA 95
#define CH_ESC 27
/* Masks for joy_read */
#define JOY_UP_MASK 0x10
#define JOY_DOWN_MASK 0x08
#define JOY_LEFT_MASK 0x01
#define JOY_RIGHT_MASK 0x02
#define JOY_BTN_1_MASK 0x04
/* The addresses of the static drivers */
extern void telestrat_joy[]; /* Referred to by joy_static_stddrv[] */
void oups();
void ping();

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