From 795904266757a75e48474109e6b2109e44b1c79f Mon Sep 17 00:00:00 2001 From: Vince Weaver Date: Thu, 11 Nov 2021 21:41:43 -0500 Subject: [PATCH] d2_hgr: add code to quit when key pressed then optimized to find room for it --- demos/d2/d2.s | 33 ++++++++++++++++++++++++++++----- demos/d2/dsr_shape.s | 19 ------------------- demos/d2/fast_hclr.s | 18 ++++++++++++++++++ demos/d2/hello.bas | 6 +++++- demos/d2/interrupt_handler.s | 19 ++++++++++--------- demos/d2/moving.s | 14 -------------- 6 files changed, 61 insertions(+), 48 deletions(-) create mode 100644 demos/d2/fast_hclr.s diff --git a/demos/d2/d2.s b/demos/d2/d2.s index 837f09bb..30cfd3c7 100644 --- a/demos/d2/d2.s +++ b/demos/d2/d2.s @@ -1,8 +1,10 @@ ; HGR Demo2 -; by deater (Vince Weaver) +; Apple II graphics/music in 1k -; 1484 +; 1k demo for Demosplash 2021 + +; by deater (Vince Weaver) ; Zero Page .include "zp.inc" @@ -117,11 +119,15 @@ forever: .include "moving.s" - ;===================== - ; clear screen + ;========================= + ; clear screen first time + +skip_clear_smc: + lda #0 + bne skip_clear jsr fast_hclr - +skip_clear: jsr flip_page ;===================== @@ -145,6 +151,7 @@ forever: lda #$7f sta color_smc+1 + sta skip_clear_smc+1 lda #159 sta moving_size_smc+1 sta oval_size_smc+1 @@ -163,6 +170,9 @@ forever: ; common flip page routine flip_page: + lda KEYPRESS + bmi its_over + ldy #$0 lda HGR_PAGE ; will be $20/$40 cmp #$20 @@ -176,7 +186,18 @@ done_flip_page: rts + ;================ + ; halt music + ; stop playing + ; turn off sound +its_over: + sei + lda #$3f + ldx #7 + jsr ay3_write_reg +stuck_forever: + bne stuck_forever ; 01234567890123456789012345678901234567890" @@ -222,6 +243,8 @@ sinetable_base: sinetable=$8000 +.include "fast_hclr.s" + ; music .include "mA2E_2.s" .include "interrupt_handler.s" diff --git a/demos/d2/dsr_shape.s b/demos/d2/dsr_shape.s index ae620794..1f30dda2 100644 --- a/demos/d2/dsr_shape.s +++ b/demos/d2/dsr_shape.s @@ -58,25 +58,6 @@ long_wait: dex bne long_wait - rts - -fast_hclr: - lda HGR_PAGE - sta hclr_smc+2 - ldy #0 -hclr_outer: - tya -hclr_inner: -hclr_smc: - sta $2000,Y - iny - bne hclr_inner - - inc hclr_smc+2 - lda hclr_smc+2 - and #$1f - bne hclr_outer - ; rts ;shape_dsr: diff --git a/demos/d2/fast_hclr.s b/demos/d2/fast_hclr.s new file mode 100644 index 00000000..ef4c5f3c --- /dev/null +++ b/demos/d2/fast_hclr.s @@ -0,0 +1,18 @@ +fast_hclr: + lda HGR_PAGE + sta hclr_smc+2 + ldy #0 +hclr_outer: + tya +hclr_inner: +hclr_smc: + sta $2000,Y + iny + bne hclr_inner + + inc hclr_smc+2 + lda hclr_smc+2 + and #$1f + bne hclr_outer + + rts diff --git a/demos/d2/hello.bas b/demos/d2/hello.bas index 133a44bb..52c966ed 100644 --- a/demos/d2/hello.bas +++ b/demos/d2/hello.bas @@ -1,2 +1,6 @@ 5 HOME -10 PRINT CHR$(4);"CATALOG" +10 PRINT "HGR DEMO2 - 1K DEMO AT DEMOSPLASH 2021" +20 PRINT CHR$(4);"CATALOG" +25 PRINT:PRINT "AUTOMATICALLY STARTING" +30 PRINT "]BRUN D2" +40 PRINT CHR$(4);"BRUN D2" diff --git a/demos/d2/interrupt_handler.s b/demos/d2/interrupt_handler.s index c278471f..8158f9c5 100644 --- a/demos/d2/interrupt_handler.s +++ b/demos/d2/interrupt_handler.s @@ -54,13 +54,13 @@ loop_forever: lda #0 sta SONG_OFFSET - lda #peasant_song - sta SONG_H +; lda #peasant_song +; sta SONG_H - jmp try_again + beq try_again ; bra all_ok: ; see if note @@ -117,10 +117,11 @@ blah_blah: y_smc: ldy #0 iny - bne not_wrap2 - inc SONG_H -not_wrap2: - jmp set_notes_loop + +; bne not_wrap2 ; assume less than 256 bytes +; inc SONG_H +;not_wrap2: + bne set_notes_loop ; bra handle_timing: ; was timing diff --git a/demos/d2/moving.s b/demos/d2/moving.s index bf834c65..c673205c 100644 --- a/demos/d2/moving.s +++ b/demos/d2/moving.s @@ -86,20 +86,6 @@ ror_nop_smc: jsr flip_page -;flip_pages: - - ; Y should be $FF here - -; lda HGR_PAGE ; will be $20/$40 -; cmp #$20 -; bne done_page -; dey -;done_page: -; ldx PAGE1-$FE,Y ; set display page to PAGE1 or PAGE2 - -; eor #$60 ; flip draw page between $2000/$4000 -; sta HGR_PAGE - lda FRAME cmp #$1b ; NOTE: NEEDS TO BE ODD bne draw_moving ; bra