ds: vapor lock again with keyboard emulated on escape

This commit is contained in:
Vince Weaver 2019-11-06 22:25:11 -05:00
parent e5aad30da9
commit 58e8791fe3
6 changed files with 80 additions and 11 deletions

View File

@ -55,7 +55,7 @@ demosplash.o: demosplash.s \
interrupt_handler.s \ interrupt_handler.s \
missing.s k_40_48d.inc create_update_type1.s \ missing.s k_40_48d.inc create_update_type1.s \
open_book.s graphics/book_open/book_open.inc \ open_book.s graphics/book_open/book_open.inc \
starbase.s keyboard.s \ starbase.s starbase_keyboard.s \
starbase_action.s starbase_laser.s starbase_blast.s \ starbase_action.s starbase_laser.s starbase_blast.s \
gr_run_sequence.s \ gr_run_sequence.s \
graphics/starbase/starbase.inc \ graphics/starbase/starbase.inc \

View File

@ -251,3 +251,5 @@ PT3_LOC = song
.align 256 .align 256
song: song:
.incbin "dya_space_demo2.pt3" .incbin "dya_space_demo2.pt3"
end_of_line:

View File

@ -31,6 +31,7 @@ escape:
sta SPRITE_XPOS sta SPRITE_XPOS
sta SPRITE_YPOS sta SPRITE_YPOS
sta FIRE_Y sta FIRE_Y
sta KEYPTR
lda #$44 lda #$44
sta GREEN0 sta GREEN0
@ -53,6 +54,7 @@ escape:
lda #1 lda #1
sta ASTEROID_SPEED sta ASTEROID_SPEED
sta XPOS sta XPOS
sta KEY_COUNTDOWN
;================== ;==================
; setup graphics ; setup graphics
@ -191,7 +193,7 @@ sprites_display_loop:
; -35 -- move asteroid ; -35 -- move asteroid
; -436 -- draw fire ; -436 -- draw fire
; -337 -- draw asteroid ; -337 -- draw asteroid
; -61 -- keypress ; -82 -- -61 -- keypress
; -33 -- handle fire press ; -33 -- handle fire press
; -51 -- exploding asteroid ; -51 -- exploding asteroid
; -47 -- sparkle ; -47 -- sparkle
@ -199,10 +201,10 @@ sprites_display_loop:
; -25 -- loop ; -25 -- loop
; -3 -- alignment ; -3 -- alignment
;======= ;=======
; 151 ; 130 151
; -46 nop sled ; -46 nop sled
;=========== ;===========
; 105 ; 84 105
;================ ;================
; erase old ship ; erase old ship
@ -904,10 +906,13 @@ pad_time2:
escape_wait_loop: escape_wait_loop:
; Try X=15 Y=1 cycles=82R2
; Try X=4 Y=4 cycles=105 ; Try X=4 Y=4 cycles=105
ldy #4 ; 2 nop
loopY: ldx #4 ; 2
ldy #1 ; 2
loopY: ldx #15 ; 2
loopZ: dex ; 2 loopZ: dex ; 2
bne loopZ ; 2nt/3 bne loopZ ; 2nt/3
dey ; 2 dey ; 2
@ -1058,6 +1063,8 @@ done_level:
; separate function so we an align to avoid branches ; separate function so we an align to avoid branches
; crossing page boundaries ; crossing page boundaries
; ;
.if 0
; OLD
; NONE = 6+7 = 13 [42] ; NONE = 6+7 = 13 [42]
; ESC = doesn't matter ; ESC = doesn't matter
; ' ' = 6+6+9+5+7 = 33 [22] [[20]] ; ' ' = 6+6+9+5+7 = 33 [22] [[20]]
@ -1066,12 +1073,50 @@ done_level:
; 'A' = 6+6+9+5+5+5+7+7 = 50 [5] [[7]] ; 'A' = 6+6+9+5+5+5+7+7 = 50 [5] [[7]]
; 'Z' = 6+6+9+5+5+5+7+5+7 = 55 [0] [[5]] ; 'Z' = 6+6+9+5+5+5+7+5+7 = 55 [0] [[5]]
; unkno= 6+6+9+5+5+5+7+5+3+[4] = 55 [0] ; unkno= 6+6+9+5+5+5+7+5+3+[4] = 55 [0]
.endif
; NEW
; NONE = 6+11 = 17 [59]
; ESC = doesn't matter
; ' ' = 6+11+25+5+7 = 54 [22] [[20]]
; '.' = 6+11+25+5+5+7 = 69 [17] [[5]]
; ',' = 6+11+25+5+5+5+7 = 64 [12] [[5]]
; 'A' = 6+11+25+5+5+5+7+7 = 71 [5] [[7]]
; 'Z' = 6+11+25+5+5+5+7+5+7 = 76 [0] [[5]]
; unkno= 6+11+25+5+5+5+7+5+3+[4]= 76 [0]
escape_handle_keypress: escape_handle_keypress:
; read from mem instead of keyboard
; none 11+
; yes: 11+20 = 31
dec KEY_COUNTDOWN ; 5
lda KEY_COUNTDOWN ; 3
bne key_delay_59 ; 3
;====
; 11
; -1
ldy KEYPTR ; 3
lda escape_keys+1,Y ; 4+
sta KEY_COUNTDOWN ; 3
lda escape_keys,Y ; 4+
iny ; 2
iny ; 2
sty KEYPTR ; 3
;====
; 20
; 5 (from below) instead of 9
.if 0
lda KEYPRESS ; 4 lda KEYPRESS ; 4
bpl key_delay_42 ; 3 bpl key_delay_42 ; 3
; -1 ; -1
bit KEYRESET ; clear strobe ; 4 bit KEYRESET ; clear strobe ; 4
.endif
cmp #27+$80 ; 2 cmp #27+$80 ; 2
bne key_not_escape ; 3 bne key_not_escape ; 3
@ -1127,11 +1172,15 @@ key_not_z:
nop ; 2 nop ; 2
jmp keypress_done ; 3 jmp keypress_done ; 3
key_delay_42: key_delay_59:
inc TEMP ; 5 inc TEMP ; 5
dec TEMP ; 5 dec TEMP ; 5
inc TEMP ; 5 inc TEMP ; 5
dec TEMP ; 5 dec TEMP ; 5
inc TEMP ; 5
dec TEMP ; 5
inc TEMP ; 5
nop ; 2
key_delay_22: key_delay_22:
nop ; 2 nop ; 2
@ -1427,10 +1476,26 @@ asteroid_inc_after:
.assert >asteroid_inc_before = >asteroid_inc_after, error, "asteroid_inc crosses page" .assert >asteroid_inc_before = >asteroid_inc_after, error, "asteroid_inc crosses page"
score_before:
score_text2: score_text2:
.byte 0,0 .byte 0,0
.asciiz "LEVEL:3 LIVES:1 SCORE:000000 HI:001978" .asciiz "LEVEL:3 LIVES:1 SCORE:000000 HI:001978"
score_before:
.assert >score_before = >score_after, error, "score crosses page"
score_after: score_after:
.assert >score_before = >score_after, error, "score crosses page"
escape_keys_before:
escape_keys:
.byte 'A',20
.byte 'A',20
.byte 'Z',2
.byte 'Z',2
.byte ' ',5
.byte '.',200
.byte '.',200
.byte 27,2
escape_keys_after:
.assert >escape_keys_before = >escape_keys_after, error, "keys crosses page"

View File

@ -59,7 +59,8 @@ wait_loop:
.include "gr_hlin.s" .include "gr_hlin.s"
.include "gr_putsprite.s" .include "gr_putsprite.s"
.include "gr_putsprite_crop.s" .include "gr_putsprite_crop.s"
.include "keyboard.s"
.include "starbase_keyboard.s"
.include "starbase_astronaut.s" .include "starbase_astronaut.s"
.include "starbase_alien.s" .include "starbase_alien.s"

View File

@ -107,6 +107,7 @@ PT3_TEMP = $8A
KEYPTRL = $90 KEYPTRL = $90
KEYPTRH = $91 KEYPTRH = $91
KEY_COUNTDOWN = $92 KEY_COUNTDOWN = $92
KEYPTR = $93
; More zero-page addresses ; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related ; we try not to conflict with anything DOS, MONITOR or BASIC related