mist: add joystick support

made room by removing flipped-sprite support which we weren't using
This commit is contained in:
Vince Weaver 2020-09-06 00:28:26 -04:00
parent 8b73c22efc
commit 543aa7d555
7 changed files with 124 additions and 17 deletions

View File

@ -31,21 +31,21 @@ page_flip =$1a11
; gr_putsprite_crop.s
put_sprite_crop =$1a2b
psc_smc1 =$1a4e
psc_smc2 =$1ae6
psc_smc2 =$1ac0
; keyboard.s
handle_keypress =$1b67
change_direction =$1c2f
change_location =$1c68
handle_keypress =$1ac0
change_direction =$1bcb
change_location =$1bfe
; text_print.s
move_and_print =$1d00
ps_smc1 =$1d2d
move_and_print =$1c96
ps_smc1 =$1cc3
; page_sprites.inc
blue_page_sprite =$1e4f
red_page_sprite =$1e65
white_page_sprite =$1e7b
blue_page_small_sprite =$1e91
red_page_small_sprite =$1e99
blue_page_sprite =$1e12
red_page_sprite =$1e28
white_page_sprite =$1e3e
blue_page_small_sprite =$1e54
red_page_small_sprite =$1e5c

View File

@ -176,6 +176,8 @@ crop_sprite_done:
;
;
.if 0
;=============================================
; put_sprite_flipped_crop
;=============================================
@ -354,3 +356,4 @@ fcrop_sprite_done:
rts ; return ; 6
.endif

46
mist/joystick.s Normal file
View File

@ -0,0 +1,46 @@
; Oliver Schmidt
; comp.sys.apple2.programmer
; Call with joystick number (0 or 1) in A.
; Results are stored in value0 and value1.
; UPPER_THRESHOLD is the paddle value you want to consider as "right enough" /
; "down enough".
UPPER_THRESHOLD = 128
;PTRIG = $c070
PADDL1 = $C065
handle_joystick:
lda #0
; Read both paddles simultaneously
asl ; Joystick number -> paddle number
tax
ldy #$00
sty value0
sty value1
lda PTRIG ; Trigger paddles
loop: lda PADDL0,x ; Read paddle (0 or 2)
bmi set0 ; Cycles: 2 3
nop ; Cycles: 2
bpl nop0 ; Cycles: 3
set0: sty value0 ; Cycles: 4
nop0: ; - -
; Cycles: 7 7
lda PADDL1,x ; Read paddle (1 or 3)
bmi set1 ; Cycles: 2 3
nop ; Cycles: 2
bpl nop1 ; Cycles: 3
set1: sty value1 ; Cycles: 4
nop1: ; - -
; Cycles: 7 7
iny
cpy #UPPER_THRESHOLD+1
bne loop
rts
value0: .byte $00
value1: .byte $00

View File

@ -4,6 +4,62 @@
;==============================
handle_keypress:
; first handle joystick
lda JOYSTICK_ENABLED
beq actually_handle_keypress
check_button:
lda PADDLE_BUTTON0
bpl button_clear
lda JS_BUTTON_STATE
bne js_check
lda #1
sta JS_BUTTON_STATE
lda #' '
jmp check_sound
button_clear:
lda #0
sta JS_BUTTON_STATE
js_check:
jsr handle_joystick
js_check_left:
lda value0
cmp #$20
bcs js_check_right ; if less than 32, left
lda #'A'
bne check_sound
js_check_right:
cmp #$40
bcc js_check_up
lda #'D'
bne check_sound
js_check_up:
lda value1
cmp #$20
bcs js_check_down
lda #'W'
bne check_sound
js_check_down:
cmp #$40
bcc done_joystick
lda #'S'
bne check_sound
done_joystick:
actually_handle_keypress:
lda KEYPRESS
bmi keypress
@ -26,7 +82,8 @@ check_sound:
; can't be ^J as that's the same as down
check_joystick:
cmp #$10 ; control-P
; cmp #$10 ; control-P
cmp #'J'
bne check_load
lda JOYSTICK_ENABLED
@ -177,7 +234,7 @@ change_direction:
; also change sprite cutoff
ldx #40
stx psc_smc1+1
stx psc_smc2+1
; stx psc_smc2+1
jmp done_split
no_split:
@ -186,7 +243,7 @@ no_split:
; also change sprite cutoff
ldx #48
stx psc_smc1+1
stx psc_smc2+1
; stx psc_smc2+1
done_split:
and #$f ; mask off special flags

View File

@ -236,6 +236,7 @@ length_array:
.include "keyboard.s"
.include "text_print.s"
.include "loadstore.s"
.include "joystick.s"
.include "page_sprites.inc"
.include "common_sprites.inc"

View File

@ -37,11 +37,11 @@ text_loop:
boot_message:
.byte 0,0, "LOADING MIST V0.99.6",0
.byte 0,0, "LOADING MIST V0.99.7",0
.byte 0,3, "CONTROLS:",0
.byte 5,4, "MOVE CURSOR : ARROWS OR WASD",0
.byte 5,5, "FORWARD/ACTION : ENTER",0
.byte 5,7, "JOYSTICK (TODO): J",0
.byte 5,7, "ENABLE JOYSTICK: J",0
.byte 5,8, "LOAD GAME : CONTROL-L",0
.byte 5,9, "SAVE : CONTROL-S",0
.byte 5,10,"TOGGLE SOUND : CONTROL-T",0

View File

@ -285,7 +285,7 @@ END_OF_SAVE = $D9
; done game puzzle state
JS_BUTTON_STATE = $DB
CURRENT_DISK = $DC
JOYSTICK_ENABLED= $DD
SOUND_STATUS = $DE