Fix joystick driver. Add interruptor support.
Note that the joystick driver doesn't support combined movements (like left/up or right/down). This should be fixed.
This commit is contained in:
@@ -36,3 +36,7 @@ ZP_JOY1_DIR = $13
|
|||||||
ZP_JOY0_BUTTONS = $16
|
ZP_JOY0_BUTTONS = $16
|
||||||
ZP_JOY1_BUTTONS = $17
|
ZP_JOY1_BUTTONS = $17
|
||||||
|
|
||||||
|
;** BIOS
|
||||||
|
BIOS_IRQ1_ADDR = $FF3F
|
||||||
|
BIOS_IRQ2_ADDR = $FF52
|
||||||
|
BIOS_NMI_RESET_ADDR = $F808
|
||||||
|
|||||||
@@ -1,9 +1,38 @@
|
|||||||
/* CreatiVision Header */
|
/*****************************************************************************/
|
||||||
|
/* */
|
||||||
|
/* creativision.h */
|
||||||
|
/* */
|
||||||
|
/* Creativision system specific definitions */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* (C) 2013 cvemu */
|
||||||
|
/* (C) 2017 Christian Groessler <chris@groessler.org> */
|
||||||
|
/* */
|
||||||
|
/* */
|
||||||
|
/* This software is provided 'as-is', without any expressed or implied */
|
||||||
|
/* warranty. In no event will the authors be held liable for any damages */
|
||||||
|
/* arising from the use of this software. */
|
||||||
|
/* */
|
||||||
|
/* Permission is granted to anyone to use this software for any purpose, */
|
||||||
|
/* including commercial applications, and to alter it and redistribute it */
|
||||||
|
/* freely, subject to the following restrictions: */
|
||||||
|
/* */
|
||||||
|
/* 1. The origin of this software must not be misrepresented; you must not */
|
||||||
|
/* claim that you wrote the original software. If you use this software */
|
||||||
|
/* in a product, an acknowledgment in the product documentation would be */
|
||||||
|
/* appreciated but is not required. */
|
||||||
|
/* 2. Altered source versions must be plainly marked as such, and must not */
|
||||||
|
/* be misrepresented as being the original software. */
|
||||||
|
/* 3. This notice may not be removed or altered from any source */
|
||||||
|
/* distribution. */
|
||||||
|
/* */
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
#ifndef _CVISION_H
|
#ifndef _CVISION_H
|
||||||
|
|
||||||
#define _CVISION_H
|
#define _CVISION_H
|
||||||
|
|
||||||
|
/* Character codes */
|
||||||
#define CH_VLINE 33
|
#define CH_VLINE 33
|
||||||
#define CH_HLINE 34
|
#define CH_HLINE 34
|
||||||
#define CH_ULCORNER 35
|
#define CH_ULCORNER 35
|
||||||
@@ -11,6 +40,7 @@
|
|||||||
#define CH_LLCORNER 37
|
#define CH_LLCORNER 37
|
||||||
#define CH_LRCORNER 38
|
#define CH_LRCORNER 38
|
||||||
|
|
||||||
|
/* no support for dynamically loadable drivers */
|
||||||
#define DYN_DRV 0
|
#define DYN_DRV 0
|
||||||
|
|
||||||
/* Colours - from TMS9918 */
|
/* Colours - from TMS9918 */
|
||||||
@@ -31,29 +61,10 @@
|
|||||||
#define C_GREY 14
|
#define C_GREY 14
|
||||||
#define C_WHITE 15
|
#define C_WHITE 15
|
||||||
|
|
||||||
/* Joystick states */
|
|
||||||
#define JOY_UP 5
|
|
||||||
#define JOY_DOWN 1
|
|
||||||
#define JOY_LEFT 7
|
|
||||||
#define JOY_RIGHT 3
|
|
||||||
#define JOY_LEFT_UP 6
|
|
||||||
#define JOY_LEFT_DOWN 8
|
|
||||||
#define JOY_RIGHT_UP 4
|
|
||||||
#define JOY_RIGHT_DOWN 2
|
|
||||||
#define JOY_LBUTTON 1
|
|
||||||
#define JOY_RBUTTON 2
|
|
||||||
|
|
||||||
/* Joystick values */
|
|
||||||
#define JOY_LEFT_DIR 1
|
|
||||||
#define JOY_RIGHT_DIR 2
|
|
||||||
#define JOY_LEFT_BUTTONS 3
|
|
||||||
#define JOY_RIGHT_BUTTONS 4
|
|
||||||
|
|
||||||
/* Protos */
|
/* Protos */
|
||||||
void __fastcall__ psg_outb(unsigned char b);
|
void __fastcall__ psg_outb(unsigned char b);
|
||||||
void __fastcall__ psg_delay(unsigned char b);
|
void __fastcall__ psg_delay(unsigned char b);
|
||||||
void psg_silence(void);
|
void psg_silence(void);
|
||||||
void __fastcall__ bios_playsound(void *a, unsigned char b);
|
void __fastcall__ bios_playsound(void *a, unsigned char b);
|
||||||
unsigned char __fastcall__ joystate( unsigned char which );
|
|
||||||
|
|
||||||
#endif
|
#endif /* #ifndef _CVISION_H */
|
||||||
|
|||||||
@@ -4,11 +4,13 @@
|
|||||||
|
|
||||||
.export _exit
|
.export _exit
|
||||||
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
.export __STARTUP__ : absolute = 1 ; Mark as startup
|
||||||
|
.export irq2
|
||||||
.import zerobss, copydata
|
.import zerobss, copydata
|
||||||
.import initlib, donelib, callmain
|
.import initlib, donelib, callmain
|
||||||
.import __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__
|
.import __VECTORS_LOAD__, __VECTORS_RUN__, __VECTORS_SIZE__
|
||||||
.import __ZP_LAST__, __STACKSIZE__, __RAM_START__
|
.import __ZP_LAST__, __STACKSIZE__, __RAM_START__
|
||||||
|
|
||||||
|
.include "creativision.inc"
|
||||||
.include "zeropage.inc"
|
.include "zeropage.inc"
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
@@ -61,8 +63,8 @@ loop: jmp loop
|
|||||||
|
|
||||||
.segment "VECTORS"
|
.segment "VECTORS"
|
||||||
|
|
||||||
irq1: jmp $FF3F
|
irq1: jmp BIOS_IRQ1_ADDR
|
||||||
irq2: jmp $FF52
|
irq2: jmp BIOS_IRQ2_ADDR
|
||||||
|
|
||||||
; ------------------------------------------------------------------------
|
; ------------------------------------------------------------------------
|
||||||
; Define CART setup values for BIOS.
|
; Define CART setup values for BIOS.
|
||||||
@@ -92,7 +94,7 @@ irq2: jmp $FF52
|
|||||||
; BIOS Vector after NMI or RESET
|
; BIOS Vector after NMI or RESET
|
||||||
; Keeping with retail cartridges, we jump back to BIOS ROM and have it
|
; Keeping with retail cartridges, we jump back to BIOS ROM and have it
|
||||||
; setup zeropage etc, and show the Creativision logo and copyright.
|
; setup zeropage etc, and show the Creativision logo and copyright.
|
||||||
.addr $F808
|
.addr BIOS_NMI_RESET_ADDR
|
||||||
|
|
||||||
; BIOS Short Interrupt Handler
|
; BIOS Short Interrupt Handler
|
||||||
; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's
|
; Vectored from BIOS ROM:FE2C. This should contain a pointer to the user's
|
||||||
|
|||||||
40
libsrc/creativision/irq.s
Normal file
40
libsrc/creativision/irq.s
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
;
|
||||||
|
; IRQ handling (CreatiVision version)
|
||||||
|
;
|
||||||
|
|
||||||
|
.export initirq, doneirq
|
||||||
|
.import callirq, irq2
|
||||||
|
|
||||||
|
.include "creativision.inc"
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.segment "ONCE"
|
||||||
|
|
||||||
|
initirq:
|
||||||
|
lda #<IRQStub
|
||||||
|
ldx #>IRQStub
|
||||||
|
jmp setvec
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.code
|
||||||
|
|
||||||
|
doneirq:
|
||||||
|
lda #<BIOS_IRQ2_ADDR
|
||||||
|
ldx #>BIOS_IRQ2_ADDR
|
||||||
|
setvec: sei
|
||||||
|
sta irq2+1
|
||||||
|
stx irq2+2
|
||||||
|
cli
|
||||||
|
rts
|
||||||
|
|
||||||
|
; ------------------------------------------------------------------------
|
||||||
|
|
||||||
|
.segment "CODE"
|
||||||
|
|
||||||
|
IRQStub:
|
||||||
|
cld ; Just to be sure
|
||||||
|
jsr callirq ; Call the functions
|
||||||
|
jmp BIOS_IRQ2_ADDR ; Jump to the BIOS IRQ vector
|
||||||
|
|
||||||
@@ -167,6 +167,8 @@ cnv_2: txa
|
|||||||
beq done ; no, no direction
|
beq done ; no, no direction
|
||||||
|
|
||||||
and #%00001100 ; mask out other bits
|
and #%00001100 ; mask out other bits
|
||||||
|
lsr a
|
||||||
|
lsr a
|
||||||
tax
|
tax
|
||||||
lda #%00000100 ; init bitmask
|
lda #%00000100 ; init bitmask
|
||||||
loop: dex
|
loop: dex
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ int main (void)
|
|||||||
|
|
||||||
clrscr ();
|
clrscr ();
|
||||||
count = joy_count ();
|
count = joy_count ();
|
||||||
#ifdef __ATARI5200__
|
#if defined(__ATARI5200__) || defined(__CREATIVISION__)
|
||||||
cprintf ("JOYSTICKS: %d", count);
|
cprintf ("JOYSTICKS: %d", count);
|
||||||
#else
|
#else
|
||||||
cprintf ("Driver supports %d joystick(s)", count);
|
cprintf ("Driver supports %d joystick(s)", count);
|
||||||
@@ -55,13 +55,13 @@ int main (void)
|
|||||||
for (i = 0; i < count; ++i) {
|
for (i = 0; i < count; ++i) {
|
||||||
gotoxy (0, i+1);
|
gotoxy (0, i+1);
|
||||||
j = joy_read (i);
|
j = joy_read (i);
|
||||||
#ifdef __ATARI5200__
|
#if defined(__ATARI5200__) || defined(__CREATIVISION__)
|
||||||
cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s",
|
cprintf ("%1d:%-3s%-3s%-3s%-3s%-3s%-3s",
|
||||||
i,
|
i,
|
||||||
(j & joy_masks[JOY_UP])? " U " : " u ",
|
(j & joy_masks[JOY_UP])? " U " : " ",
|
||||||
(j & joy_masks[JOY_DOWN])? " D " : " d ",
|
(j & joy_masks[JOY_DOWN])? " D " : " ",
|
||||||
(j & joy_masks[JOY_LEFT])? " L " : " l ",
|
(j & joy_masks[JOY_LEFT])? " L " : " ",
|
||||||
(j & joy_masks[JOY_RIGHT])? " R " : " r ",
|
(j & joy_masks[JOY_RIGHT])? " R " : " ",
|
||||||
(j & joy_masks[JOY_FIRE])? " 1 " : " ",
|
(j & joy_masks[JOY_FIRE])? " 1 " : " ",
|
||||||
(j & joy_masks[JOY_FIRE2])? " 2 " : " ");
|
(j & joy_masks[JOY_FIRE2])? " 2 " : " ");
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user