Skip to content

Commit

Permalink
Isue #1111: Add joystick support
Browse files Browse the repository at this point in the history
  • Loading branch information
suborb committed Feb 25, 2019
1 parent 01dd143 commit 2143f91
Show file tree
Hide file tree
Showing 6 changed files with 85 additions and 1 deletion.
6 changes: 6 additions & 0 deletions include/games.h
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,12 @@ extern const unsigned char *joystick_type[];
#define GAME_DEVICES 4
#endif

#ifdef __SV8000_
#ifdef DEFINE_JOYSTICK_TYPE
const unsigned char *joystick_type[] = {"Joystick R", "Joystick L" };
#endif
#define GAME_DEVICES 2
#endif

#ifdef __ACE__
#ifdef DEFINE_JOYSTICK_TYPE
Expand Down
7 changes: 6 additions & 1 deletion lib/target/sv8000/classic/sv8000_crt0.asm
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,21 @@ program:
call crt0_init_bss
ld (exitsp),sp
ei
; Reset to text mode
; Enable AY ports
ld a,7
out ($c1),a
ld a,$7f
out ($c0),a
; Reset to text mode
ld a,14
out ($c1),a
ld a,0
out ($c0),a

; Enable keyboard scanning
ld a,$92
out ($83),a
; Optional definition for auto MALLOC init
; it assumes we have free space between the end of
Expand Down
1 change: 1 addition & 0 deletions libsrc/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,7 @@ sv8000_clib.lib:
@echo ''
$(MAKE) gfxdeps
$(call buildgeneric,sv8000)
$(MAKE) -C games TARGET=sv8000
TARGET=sv8000 TYPE=z80 $(LIBLINKER) -DSTANDARDESCAPECHARS -DFORsv8000 -x$(OUTPUT_DIRECTORY)/sv8000_clib @$(LISTFILE_DIRECTORY)/sv8000.lst

# Colecovision - dom/stefano
Expand Down
6 changes: 6 additions & 0 deletions libsrc/games/games.inc
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,12 @@ IF FORz80tvgame
ENDIF

; Compatibily ones only, the following ports don't have a beeper
IF FORsv8000
defc sndbit_port = 0
defc sndbit_bit = 0
defc sndbit_mask = 0
ENDIF

IF FOReinstein
defc sndbit_port = 0
defc sndbit_bit = 0
Expand Down
63 changes: 63 additions & 0 deletions libsrc/games/sv8000/joystick.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@

SECTION code_clib

PUBLIC joystick
PUBLIC _joystick


; Joystick directions are on 8255 port a (0x80)
;
; Fire buttons # on ROW2
; Fire button * on ROW0


joystick:
_joystick:
ld c,$01 ;Bit for fire
in a,($80)
dec l
jr z,read_it
; Joystick 2 here, rotatel
ld c,$10
rrca
rrca
rrca
rrca
read_it:
ld hl,0
; Port is: RLDU RLDU
; Games is: #define MOVE_RIGHT 1
; #define MOVE_LEFT 2
; #define MOVE_DOWN 4
; #define MOVE_UP 8
; #define MOVE_FIRE 16
rrca
jr c,not_up
set 3,l
not_up:
rrca
jr c,not_down
set 2,l
not_down:
rrca
jr c,not_left
set 1,l
not_left:
rrca
jr c,not_right
set 0,l

not_right:
;Now to read a fire button, we'll use # as the fire button
; Write to port C on the 8255
ld a,$bb
out ($82),a
in a,($81) ;Read from port B
cpl
and c
ret z
set 4,l ;And fire is pressed
ret



3 changes: 3 additions & 0 deletions libsrc/sv8000.lst
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,7 @@ psg/sv8000/set_psg_callee
psg/sv8000/get_psg
psg/sv8000/psg_init
@psg/psg.lst
games/sv8000/joystick
games/obj/sv8000/joystick_type
@games/games.lst
@z80.lst

0 comments on commit 2143f91

Please sign in to comment.