Merge branch 'master' into master
This commit is contained in:
@@ -44,4 +44,4 @@ _exit: jsr donelib ; Run module destructors
|
||||
|
||||
; A 5200 program isn't supposed to exit.
|
||||
|
||||
halt: jmp halt
|
||||
halt: jmp halt
|
||||
|
||||
@@ -93,9 +93,7 @@ joy1: lda #$7F
|
||||
sta CIA1_PRA
|
||||
lda CIA1_PRB
|
||||
cli
|
||||
and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
jmp end
|
||||
|
||||
; Read joystick 2
|
||||
|
||||
@@ -107,8 +105,6 @@ joy2: ldx #0
|
||||
lda CIA1_PRA
|
||||
sty CIA1_DDRA
|
||||
cli
|
||||
and #$1F
|
||||
end: and #$1F
|
||||
eor #$1F
|
||||
rts
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
;
|
||||
; Standard joystick driver for the Creativision.
|
||||
;
|
||||
; Christian Groessler, 2017-03-08
|
||||
; 2017-03-08, Christian Groessler
|
||||
; 2021-06-01, Greg King
|
||||
;
|
||||
|
||||
.include "zeropage.inc"
|
||||
|
||||
.include "joy-kernel.inc"
|
||||
.include "joy-error.inc"
|
||||
.include "creativision.inc"
|
||||
@@ -13,10 +13,12 @@
|
||||
.macpack module
|
||||
|
||||
|
||||
buttons := tmp2
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Header. Includes jump table
|
||||
|
||||
module_header _creativisionstd_joy
|
||||
module_header _creativisionstd_joy
|
||||
|
||||
; Driver signature
|
||||
|
||||
@@ -39,16 +41,14 @@
|
||||
|
||||
JOY_COUNT = 2 ; Number of joysticks we support
|
||||
|
||||
; Symbolic names for joystick masks (similar names like the defines in joystick.h, but not related to them)
|
||||
; Symbolic names for joystick masks (similar names to the macros in joystick.h,
|
||||
; with the same values as the masks in creativision.h)
|
||||
|
||||
JOY_UP = $10
|
||||
JOY_DOWN = $04
|
||||
JOY_LEFT = $20
|
||||
JOY_RIGHT = $08
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; Code
|
||||
|
||||
.code
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -59,7 +59,7 @@ JOY_RIGHT = $08
|
||||
;
|
||||
|
||||
INSTALL: lda #JOY_ERR_OK
|
||||
ldx #0
|
||||
ldx #>$0000
|
||||
; rts ; Fall through
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
@@ -82,14 +82,14 @@ COUNT: lda #<JOY_COUNT
|
||||
; READ: Read a particular joystick passed in A.
|
||||
;
|
||||
|
||||
READJOY: and #1 ; fix joystick number
|
||||
bne READJOY_1 ; read right joystick
|
||||
READJOY: lsr a ; Get joystick number
|
||||
bcs READJOY_1 ; Read right joystick
|
||||
|
||||
; Read left joystick
|
||||
|
||||
ldx ZP_JOY0_DIR
|
||||
lda ZP_JOY0_BUTTONS
|
||||
jmp convert ; convert joystick state to cc65 values
|
||||
bcc convert ; Convert joystick state to cc65 values
|
||||
|
||||
; Read right joystick
|
||||
|
||||
@@ -97,11 +97,11 @@ READJOY_1: ldx ZP_JOY1_DIR
|
||||
lda ZP_JOY1_BUTTONS
|
||||
lsr a
|
||||
lsr a
|
||||
;jmp convert ; convert joystick state to cc65 values
|
||||
; fall thru...
|
||||
;jmp convert ; Convert joystick state to cc65 values
|
||||
; Fall thru...
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
; convert: make runtime lib compatible values
|
||||
; convert: make runtime lib-compatible values
|
||||
; inputs:
|
||||
; A - buttons
|
||||
; X - direction
|
||||
@@ -111,24 +111,24 @@ convert:
|
||||
|
||||
; ------
|
||||
; buttons:
|
||||
; Port values are for the left hand joystick (right hand joystick
|
||||
; Port values are for the left-hand joystick (right-hand joystick
|
||||
; values were shifted to the right to be identical).
|
||||
; Why are there two bits indicating a pressed trigger?
|
||||
; According to the "Second book of programs for the Dick Smith Wizard"
|
||||
; (pg. 88ff), the left hand button gives the value of
|
||||
; %00010001 and the right hand button gives %00100010
|
||||
; (pg. 88ff), the left-hand button gives the value of
|
||||
; %00010001 and the right-hand button gives %00100010
|
||||
; Why two bits? Can there be cases that just one of those bits is set?
|
||||
; Until these questions have been answered, we only use the lower two
|
||||
; bits and ignore the upper ones...
|
||||
; Until those questions have been answered, we only use the lower two
|
||||
; bits, and ignore the upper ones.
|
||||
|
||||
and #%00000011 ; button status came in in A, strip high bits
|
||||
sta retval ; initialize 'retval' with button status
|
||||
and #%00000011 ; Button status came in A, strip high bits
|
||||
sta buttons
|
||||
|
||||
; ------
|
||||
; direction:
|
||||
; CV has a 16-direction joystick
|
||||
; CV has a 16-direction joystick.
|
||||
;
|
||||
; port values: (compass points)
|
||||
; Port values: (compass points)
|
||||
; N - $49 - %01001001
|
||||
; NNE - $48 - %01001000
|
||||
; NE - $47 - %01000111
|
||||
@@ -147,55 +147,51 @@ convert:
|
||||
; NNW - $4A - %01001010
|
||||
; center - $00 - %00000000
|
||||
;
|
||||
; mapping to cc65 definitions (4-direction joystick with 8 possible directions thru combinations)
|
||||
; Mapping to cc65 definitions (4-direction joystick with 8 possible directions thru combinations):
|
||||
; N, E, S, W -> JOY_UP, JOY_RIGHT, JOY_DOWN, JOY_LEFT
|
||||
; NE, SE, SW, NW -> (JOY_UP | JOY_RIGHT), (JOY_DOWN | JOY_RIGHT), (JOY_DOWN | JOY_LEFT), (JOY_UP | JOY_LEFT)
|
||||
; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW:
|
||||
; toggle between straight and diagonal direction for every call, e.g.
|
||||
; toggle between the straight and diagonal directions for each call, e.g.,
|
||||
; NNE:
|
||||
; call to READJOY: return JOY_UP | JOY_RIGHT
|
||||
; call to READJOY: return JOY_UP
|
||||
; call to READJOY: return JOY_UP | JOY_RIGHT
|
||||
; call to READJOY: return JOY_UP
|
||||
; call to READJOY: return JOY_UP | JOY_RIGHT
|
||||
; etc...
|
||||
; etc.
|
||||
|
||||
txa ; move direction status into A
|
||||
beq done ; center position (no bits are set), nothing to do
|
||||
txa ; Move direction status into A
|
||||
beq done ; Center position (no bits are set), nothing to do
|
||||
|
||||
and #$0F ; get rid of the "$40" bit
|
||||
bit bit0 ; is it a "three letter" direction (NNE, ENE, etc.)?
|
||||
beq special ; yes (bit #0 is zero)
|
||||
and #$0F ; Get rid of the "$40" bit
|
||||
lsr a ; Is it "three-letter" direction (NNE, ENE, etc.)?
|
||||
tax ; Create index into table
|
||||
bcc special ; Yes (bit #0 was zero)
|
||||
|
||||
lsr a ; create index into table
|
||||
tax
|
||||
lda dirtable,x
|
||||
done: ora retval ; include "button" bits
|
||||
ldx #0
|
||||
done: ora buttons ; Include button bits
|
||||
ldx #>$0000
|
||||
rts
|
||||
|
||||
; NNE, ENE, ESE, SSE, SSW, WSW, WNW, NNW
|
||||
|
||||
special: lsr a
|
||||
tax
|
||||
|
||||
lda toggler ; toggle the toggler
|
||||
special: lda toggle ; Toggle the flag
|
||||
eor #$01
|
||||
sta toggler
|
||||
bne spec_1 ; toggler is 1, use spectable_1 entry
|
||||
sta toggle
|
||||
bne spec_1 ; Flag is 1, use spectable_1 entry
|
||||
|
||||
lda spectable_0,x ; toggler is 0, use spectable_0 entry
|
||||
bne done ; jump always
|
||||
lda spectable_0,x
|
||||
bne done ; Jump always
|
||||
|
||||
spec_1: lda spectable_1,x
|
||||
bne done ; jump always
|
||||
bne done ; Jump always
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
.rodata
|
||||
|
||||
; a mapping table of "port values" to "cc65 values"
|
||||
; port value had been shifted one bit to the right (range 0..7)
|
||||
; A mapping table of "port values" to "cc65 values"
|
||||
; Port value had been shifted one bit to the right (range 0..7)
|
||||
dirtable: .byte JOY_DOWN ; S
|
||||
.byte JOY_DOWN | JOY_RIGHT ; SE
|
||||
.byte JOY_RIGHT ; E
|
||||
@@ -205,12 +201,12 @@ dirtable: .byte JOY_DOWN ; S
|
||||
.byte JOY_LEFT ; W
|
||||
.byte JOY_DOWN | JOY_LEFT ; SW
|
||||
|
||||
; two "special" mapping tables for three-letter directions (NNE, etc.)
|
||||
; Two "special" mapping tables for three-letter directions (NNE, etc.)
|
||||
spectable_0: .byte JOY_DOWN ; SSW
|
||||
.byte JOY_DOWN ; SSE
|
||||
.byte JOY_RIGHT ; ESE
|
||||
.byte JOY_RIGHT ; ENE
|
||||
.byte JOY_RIGHT ; NNE
|
||||
.byte JOY_UP ; NNE
|
||||
.byte JOY_UP ; NNW
|
||||
.byte JOY_LEFT ; WNW
|
||||
.byte JOY_LEFT ; WSW
|
||||
@@ -224,14 +220,10 @@ spectable_1: .byte JOY_DOWN | JOY_LEFT ; SSW
|
||||
.byte JOY_UP | JOY_LEFT ; WNW
|
||||
.byte JOY_DOWN | JOY_LEFT ; WSW
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
bit0: .byte $01
|
||||
|
||||
; ------------------------------------------------------------------------
|
||||
;
|
||||
.bss
|
||||
toggler: .res 1
|
||||
retval: .res 1
|
||||
|
||||
toggle: .res 1
|
||||
|
||||
.end
|
||||
|
||||
40
libsrc/creativision/playsound.s
Normal file
40
libsrc/creativision/playsound.s
Normal file
@@ -0,0 +1,40 @@
|
||||
; void __fastcall__ bios_playsound (void *a, unsigned char b);
|
||||
|
||||
|
||||
.export _bios_playsound
|
||||
|
||||
.import popax
|
||||
|
||||
.include "creativision.inc"
|
||||
|
||||
|
||||
songptr := $00 ; Points to current tune data
|
||||
volptr := $04 ; Points to current volume table
|
||||
|
||||
|
||||
;* Creativision Sound Player
|
||||
;* Based on BIOS song player.
|
||||
;*
|
||||
;* Pass a pointer to a set of note triples, terminated with a tempo byte;
|
||||
;* and pass the length of the triples and tempo (max 255).
|
||||
;*
|
||||
;* Note: tune data must be stored backwards.
|
||||
|
||||
_bios_playsound:
|
||||
php
|
||||
pha ; Save tune length
|
||||
sei
|
||||
|
||||
lda #<$FCD5 ; BIOS decreasing-volume table
|
||||
ldx #>$FCD5
|
||||
sta volptr
|
||||
stx volptr+1
|
||||
|
||||
jsr popax ; Get tune array pointer
|
||||
sta songptr
|
||||
stx songptr+1
|
||||
|
||||
pla
|
||||
tay
|
||||
dey ; Point to tempo byte
|
||||
jmp BIOS_PLAY_SONG ; Let BIOS do its thing
|
||||
@@ -1,63 +1,30 @@
|
||||
; void __fastcall__ psg_outb( unsigned char b );
|
||||
; void __fastcall__ psg_delayms( unsigned char c);
|
||||
; void __fastcall__ bios_playsound( void *b, unsigned char c);
|
||||
; void psg_silence( void );
|
||||
; void __fastcall__ psg_outb (unsigned char b);
|
||||
; void __fastcall__ psg_delay (unsigned char b);
|
||||
; void psg_silence (void);
|
||||
|
||||
|
||||
.export _psg_outb, _psg_silence, _psg_delay
|
||||
|
||||
.export _psg_outb, _psg_silence, _psg_delay
|
||||
.export _bios_playsound
|
||||
.import popa
|
||||
.include "creativision.inc"
|
||||
|
||||
_psg_outb:
|
||||
|
||||
;* Let BIOS output the value
|
||||
jmp $FE77
|
||||
;* Let BIOS output the value.
|
||||
_psg_outb := BIOS_POKE_PSG
|
||||
|
||||
_psg_silence:
|
||||
|
||||
jmp $FE54
|
||||
_psg_silence := BIOS_QUIET_PSG
|
||||
|
||||
|
||||
_psg_delay:
|
||||
|
||||
tay
|
||||
l1: lda #200
|
||||
l2: sbc #1
|
||||
bne l2
|
||||
l1: lda #200
|
||||
l2: sbc #1
|
||||
bne l2
|
||||
|
||||
lda #200
|
||||
l3: sbc #1
|
||||
bne l3
|
||||
lda #200
|
||||
l3: sbc #1
|
||||
bne l3
|
||||
|
||||
dey
|
||||
bne l1
|
||||
|
||||
bne l1
|
||||
rts
|
||||
|
||||
|
||||
;* Creativision Sound Player
|
||||
;*
|
||||
;* Based on BIOS sound player.
|
||||
;* Pass a pointer to a set of note triples, terminated with a tempo byte
|
||||
;* and the len (max 255)
|
||||
|
||||
_bios_playsound:
|
||||
|
||||
pha ; Save Length Byte
|
||||
sei
|
||||
|
||||
lda #$D5 ; BIOS volume table low
|
||||
sta $4
|
||||
lda #$FC ; BIOS volume table high
|
||||
sta $5
|
||||
|
||||
jsr popa ; Get Sound table pointer low
|
||||
sta $0
|
||||
jsr popa ; Get Sound table pointer high
|
||||
sta $1
|
||||
|
||||
pla
|
||||
tay ; Put length in Y
|
||||
dey
|
||||
php
|
||||
jmp $FBED ; Let BIOS do it's thing
|
||||
|
||||
@@ -36,7 +36,7 @@ emd_sig: .byte $65, $6d, $64, EMD_API_VERSION ; "emd", version
|
||||
|
||||
|
||||
;----------------------------------------------------------------------------
|
||||
; unsigned char __fastcall__ em_install (void* driver);
|
||||
; unsigned char __fastcall__ em_install (const void* driver);
|
||||
; /* Install the driver once it is loaded */
|
||||
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
;
|
||||
; 25.12.99
|
||||
|
||||
; void GraphicsString (char *myString);
|
||||
; void GraphicsString (const void *myString);
|
||||
|
||||
.export _GraphicsString
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@ joy_sig: .byte $6A, $6F, $79, JOY_API_VERSION ; "joy", version
|
||||
|
||||
.code
|
||||
;----------------------------------------------------------------------------
|
||||
; unsigned char __fastcall__ joy_install (void* driver);
|
||||
; unsigned char __fastcall__ joy_install (const void* driver);
|
||||
; /* Install the driver once it is loaded */
|
||||
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ ser_sig: .byte $73, $65, $72, SER_API_VERSION ; "ser", version
|
||||
|
||||
.code
|
||||
;----------------------------------------------------------------------------
|
||||
; unsigned char __fastcall__ ser_install (void* driver);
|
||||
; unsigned char __fastcall__ ser_install (const void* driver);
|
||||
; /* Install the driver once it is loaded */
|
||||
|
||||
|
||||
|
||||
@@ -67,13 +67,13 @@ not_dma:
|
||||
; Removing this segment gives only a warning.
|
||||
.segment "FFF0"
|
||||
.proc reset32kcode
|
||||
lda #(6<<5) | SV_LCD_ON | SV_NMI_ENABLE_ON
|
||||
lda #(6<<5) | SV_LCD_ON | SV_NMI_ENABLE_ON
|
||||
sta sv_bank
|
||||
; Now, the 32Kbyte image can reside in the top of 64Kbyte and 128Kbyte ROMs.
|
||||
jmp reset
|
||||
.endproc
|
||||
|
||||
.segment "VECTOR"
|
||||
.segment "VECTORS"
|
||||
|
||||
.word nmi
|
||||
.word reset32kcode
|
||||
|
||||
@@ -88,7 +88,7 @@ tgi_sig: .byte $74, $67, $69, TGI_API_VERSION ; "tgi", version
|
||||
|
||||
.code
|
||||
;----------------------------------------------------------------------------
|
||||
; void __fastcall__ tgi_install (void* driver);
|
||||
; void __fastcall__ tgi_install (const void* driver);
|
||||
; /* Install an already loaded driver. */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user