second: more work on timing

This commit is contained in:
Vince Weaver
2023-11-01 00:36:34 -04:00
parent 5ba0e97c13
commit 162d2b07f5
3 changed files with 114 additions and 19 deletions

View File

@@ -1,4 +1,67 @@
; wait A * 1 50Hz tick ;============================
; wait for music pattern
; also check for keypress
;============================
; pattern # in A
wait_for_pattern:
cmp current_pattern_smc+1
beq done_check_pattern_done
lda KEYPRESS
bpl done_check_pattern_notdone
bit KEYRESET
jmp done_check_pattern_done
;============================
; setup timeout of A seconds
;============================
setup_timeout:
sta SECOND_COUNTDOWN
lda #0
sta IRQ_COUNTDOWN
rts
;===========================
; countodown second timeout
; also check for keypress
;===========================
; carry set = done
check_timeout:
; check keyboard first
lda KEYPRESS
bpl timeout_not_keypress
bit KEYRESET
; lda #0 ; reset, is this necessary?
; sta IRQ_COUNTDOWN
; sta SECOND_COUNTDOWN
jmp done_check_timeout_done
timeout_not_keypress:
lda IRQ_COUNTDOWN
bne done_check_timeout_notdone
irq_countdown_zero:
lda SECOND_COUNTDOWN
beq done_check_timeout_done
; otherwise we need to decrement and update
dec SECOND_COUNTDOWN
lda #50
sta IRQ_COUNTDOWN
done_check_pattern_notdone:
done_check_timeout_notdone:
clc
rts
done_check_pattern_done:
done_check_timeout_done:
sec
rts
;==========================
; busy wait A * 1 50Hz tick
;==========================
wait_ticks: wait_ticks:
sta IRQ_COUNTDOWN sta IRQ_COUNTDOWN
wait_tick_loop: wait_tick_loop:
@@ -8,6 +71,11 @@ wait_tick_done:
rts rts
;====================
; busy wait A seconds
;====================
; exit early if key pressed
wait_seconds: wait_seconds:
tax tax

View File

@@ -6,6 +6,7 @@
.include "../zp.inc" .include "../zp.inc"
.include "../hardware.inc" .include "../hardware.inc"
.include "../qload.inc" .include "../qload.inc"
.include "../music.inc"
mod7_table = $1c00 mod7_table = $1c00
div7_table = $1d00 div7_table = $1d00

View File

@@ -8,6 +8,7 @@
.include "../zp.inc" .include "../zp.inc"
.include "../hardware.inc" .include "../hardware.inc"
.include "../qload.inc" .include "../qload.inc"
.include "../music.inc"
mod7_table = $1c00 mod7_table = $1c00
div7_table = $1d00 div7_table = $1d00
@@ -19,20 +20,36 @@ chess_start:
; initializations ; initializations
;===================== ;=====================
;=================== ; some of this not necessary as we come in in HGR
; Load graphics
;===================
bit SET_GR bit SET_GR
bit HIRES bit HIRES
bit FULLGR bit FULLGR
bit PAGE1 bit PAGE1
bit KEYRESET
lda #$FF
jsr hgr_page1_clearscreen
lda #$00 lda #$00
jsr hgr_page2_clearscreen jsr hgr_page2_clearscreen
;===================
; Load graphics
;===================
; wait until pattern1
;pattern1_loop:
; lda #1
; jsr wait_for_pattern
; bcc pattern2_loop
; technically the above, but we're not fast enough
lda #175
jsr wait_ticks
; lda #$FF
; jsr hgr_page1_clearscreen
;========================== ;==========================
; Falling board animation ; Falling board animation
;========================== ;==========================
@@ -93,7 +110,7 @@ compact_inner_loop:
dey dey
bpl compact_inner_loop bpl compact_inner_loop
lda #50 lda #30
jsr wait jsr wait
inx inx
@@ -108,6 +125,9 @@ compact_inner_loop:
; Bouncing on board animation ; Bouncing on board animation
;============================= ;=============================
lda #10
jsr setup_timeout
bit PAGE2 bit PAGE2
; load image offscreen $6000 ; load image offscreen $6000
@@ -131,8 +151,8 @@ chess_bounce_loop:
ldx COUNT ldx COUNT
lda object_coords_x,X lda object_coords_x,X
cmp #$FF ; cmp #$FF
beq done_orange_loop ; beq done_orange_loop
sta SPRITE_X sta SPRITE_X
lda object_coords_y,X lda object_coords_y,X
@@ -156,11 +176,11 @@ chess_bounce_loop:
no_chess_bounce_oflo: no_chess_bounce_oflo:
lda KEYPRESS jsr check_timeout
bpl chess_bounce_loop bcc chess_bounce_loop ; clear if not timed out
done_chess_bounce_loop:
done_chess_bount_loop:
bit KEYRESET
;============================= ;=============================
; Orange Blob Animation ; Orange Blob Animation
@@ -187,8 +207,8 @@ orange_loop:
ldx COUNT ldx COUNT
lda object_coords_x,X lda object_coords_x,X
cmp #$FF ; cmp #$FF ; needed?
beq done_orange_loop ; beq done_orange_loop
sta SPRITE_X sta SPRITE_X
lda object_coords_y,X lda object_coords_y,X
@@ -212,11 +232,16 @@ orange_loop:
no_orange_oflo: no_orange_oflo:
lda KEYPRESS ; finish at music pattern #10 or keypress
bpl orange_loop lda #10
jsr wait_for_pattern
bcc orange_loop
done_orange_loop: ; lda KEYPRESS
bit KEYRESET ; bpl orange_loop
;done_orange_loop:
; bit KEYRESET
chess_done: chess_done:
@@ -300,6 +325,7 @@ main_interference_done:
.include "../hgr_clear_screen.s" .include "../hgr_clear_screen.s"
.include "../hgr_copy_fast.s" .include "../hgr_copy_fast.s"
.include "../hgr_sprite_big.s" .include "../hgr_sprite_big.s"
.include "../irq_wait.s"
.include "interference.s" .include "interference.s"
.include "circles.s" .include "circles.s"