From 1fb453807bba7f32b04e312f0255b417d578829e Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 2 Nov 2023 21:41:51 -0400 Subject: [PATCH] second: more timing urgh it's a pain --- demos/second/irq_wait.s | 3 +- demos/second/part04_chess_shapes/chess.s | 4 +- demos/second/part12_plasma/plasma.s | 4 ++ demos/second/part15_transmission/spheres.s | 57 +++++++++++++++++++++- demos/second/zp.inc | 6 ++- 5 files changed, 68 insertions(+), 6 deletions(-) diff --git a/demos/second/irq_wait.s b/demos/second/irq_wait.s index 06da0b45..96264c9f 100644 --- a/demos/second/irq_wait.s +++ b/demos/second/irq_wait.s @@ -5,7 +5,8 @@ ; pattern # in A wait_for_pattern: cmp current_pattern_smc+1 - beq done_check_pattern_done + bcc done_check_pattern_done ; blt + beq done_check_pattern_done ; ble lda KEYPRESS bpl done_check_pattern_notdone diff --git a/demos/second/part04_chess_shapes/chess.s b/demos/second/part04_chess_shapes/chess.s index ae080215..8c0e2025 100644 --- a/demos/second/part04_chess_shapes/chess.s +++ b/demos/second/part04_chess_shapes/chess.s @@ -343,7 +343,7 @@ main_tunnel_done: lda #13 sta BAR_X1 - lda #27 + lda #26 sta BAR_X2 jsr falling_bars @@ -352,7 +352,7 @@ main_tunnel_done: ; right - lda #27 + lda #26 sta BAR_X1 lda #39 sta BAR_X2 diff --git a/demos/second/part12_plasma/plasma.s b/demos/second/part12_plasma/plasma.s index 5ce3cace..2fc86e5b 100644 --- a/demos/second/part12_plasma/plasma.s +++ b/demos/second/part12_plasma/plasma.s @@ -142,6 +142,10 @@ change_mono: jsr scroll_off + lda #0 + jsr hgr_page1_clearscreen + jsr hgr_page2_clearscreen + rts .include "init_plasma.s" diff --git a/demos/second/part15_transmission/spheres.s b/demos/second/part15_transmission/spheres.s index 3da18aa1..84b2dda4 100644 --- a/demos/second/part15_transmission/spheres.s +++ b/demos/second/part15_transmission/spheres.s @@ -91,7 +91,7 @@ spheres_start: ; "10 seconds to transmission" ; do we wait 10s? - lda #4 + lda #2 jsr wait_seconds @@ -114,7 +114,7 @@ move_sword_loop: jsr page_flip - lda #25 + lda #16 jsr wait_ticks lda KEYPRESS @@ -152,6 +152,7 @@ draw_sword: sta CURRENT_SPRITEH ; copy start for sprite ldx #0 + stx REFCOUNT lda #3 sta COUNT @@ -173,9 +174,44 @@ sword_inner_loop: beq skip_pixel sta (GBASL),Y skip_pixel: + ;==================================== + dey bpl sword_inner_loop + ; handle reflections + + lda REFCOUNT + lsr + bcs pixel_odd + + tay + lda reflect1_h,Y + clc + adc DRAW_PAGE + sta REF1H + lda reflect1_l,Y + sta REF1L + + lda reflect2_h,Y + clc + adc DRAW_PAGE + sta REF2H + lda reflect2_l,Y + sta REF2L + + ldy #3 + lda (CURRENT_SPRITEL),Y + beq pixel_odd ; skip if black + + ldy #0 + sta (REF1L),Y + sta (REF2L),Y + +pixel_odd: + ;============================ + + inc REFCOUNT inc COUNT clc @@ -225,6 +261,23 @@ page_flip_show_1: sta DRAW_PAGE rts +reflect1_h: + ; 46,44,42,40,38,36,34 + .byte >$7d0,>$750,>$6d0,>$650,>$5d0,>$550,>$4d0 + ; 39, 38, 37, 36, 36, 34, 33 +reflect1_l: + .byte <$7d0+39,<$750+38,<$6d0+37,<$650+36,<$5d0+35,<$550+34,<$4d0+33 + + +reflect2_h: + ; 4,6,8,10,12,14,16 + .byte >$500,>$580,>$600,>$680,>$700,>$780,>$428 +reflect2_l: + .byte <$500+32,<$580+31,<$600+30,<$680+29,<$700+28,<$780+27,<$428+26 + + + + .include "../wait_keypress.s" diff --git a/demos/second/zp.inc b/demos/second/zp.inc index a0ee0b2d..9fe04108 100644 --- a/demos/second/zp.inc +++ b/demos/second/zp.inc @@ -220,7 +220,11 @@ BASE_SPRITEH = $F1 CURRENT_SPRITEL = $F2 CURRENT_SPRITEH = $F3 XMISSION_COUNT = $F4 - +REF1L = $F5 +REF1H = $F6 +REF2L = $F7 +REF2H = $F8 +REFCOUNT = $F9 ;============================================== ; $FC-$FF we use for in/out pointers