chiptune: pause now works

This commit is contained in:
Vince Weaver 2018-02-26 10:02:32 -05:00
parent a0e9a4f428
commit 122b8b9f40
5 changed files with 85 additions and 5 deletions

View File

@ -0,0 +1,48 @@
;==========================================================
; Get Key
;==========================================================
;
get_key:
lda KEYPRESS ; 3
bpl no_key ; 2nt/3
figure_out_key:
cmp #' '+128 ; the mask destroys space ; 2
beq save_key ; so handle it specially ; 2nt/3
and #$5f ; mask, to make upper-case ; 2
check_right_arrow:
cmp #$15 ; 2
bne check_left_arrow ; 2nt/3
lda #'D' ; 2
check_left_arrow:
cmp #$08 ; 2
bne check_up_arrow ; 2nt/3
lda #'A' ; 2
check_up_arrow:
cmp #$0B ; 2
bne check_down_arrow ; 2nt/3
lda #'W' ; 2
check_down_arrow:
cmp #$0A ; 2
bne check_escape ; 2nt/3
lda #'S' ; 2
check_escape:
cmp #$1B ; 2
bne save_key ; 2nt/3
lda #'Q' ; 2
jmp save_key ; 3
no_key:
lda #0 ; no key, so save a zero ; 2
save_key:
sta LASTKEY ; save the key to our buffer ; 2
bit KEYRESET ; clear the keyboard buffer ; 4
rts ; 6
;============

View File

@ -33,6 +33,7 @@ chiptune_player.o: chiptune_player.s \
../asm_routines/mockingboard.s \
../asm_routines/dos33_routines.s \
../asm_routines/lz4_decode.s \
../asm_routines/keypress_minimal.s \
rasterbars.s volume_bars.s interrupt_handler.s \
chip_title.inc zp.inc
ca65 -o chiptune_player.o chiptune_player.s -l chiptune_player.lst

View File

@ -196,8 +196,11 @@ check_decompress:
; jsr page_flip
check_done:
lda DONE_PLAYING
beq main_loop
lda #$ff
bit DONE_PLAYING
beq main_loop ; if was all zeros, loop
bmi main_loop ; if high bit set, paused
done_play:
@ -552,6 +555,7 @@ krw_file:
.include "../asm_routines/dos33_routines.s"
.include "../asm_routines/gr_hlin.s"
.include "../asm_routines/lz4_decode.s"
.include "../asm_routines/keypress_minimal.s"
.include "rasterbars.s"
.include "volume_bars.s"
.include "interrupt_handler.s"

View File

@ -21,9 +21,8 @@ interrupt_handler:
lda DONE_PLAYING ; 3
beq update_time
jmp exit_interrupt ;============
jmp check_keyboard ;============
; 7
;=====================
; Update time counter
;=====================
@ -272,6 +271,34 @@ done_interrupt:
jsr volume_bars
jsr page_flip
check_keyboard:
jsr get_key
lda LASTKEY
beq exit_interrupt
cmp #(' '+$80)
bne key_left
key_space:
lda #$80
eor DONE_PLAYING
sta DONE_PLAYING
jsr clear_ay_both
bne done_key
key_left:
cmp #'D'
bne key_right
key_right:
cmp #'A'
bne done_key
done_key:
exit_interrupt:

View File

@ -150,7 +150,7 @@ DISP_PAGE EQU $ED
DRAW_PAGE EQU $EE
;FIRST EQU $F0
;LASTKEY EQU $F1
LASTKEY EQU $F1
;PADDLE_STATUS EQU $F2
XPOS EQU $F3
YPOS EQU $F4