d2_hgr: add code to quit when key pressed

then optimized to find room for it
This commit is contained in:
Vince Weaver 2021-11-11 21:41:43 -05:00
parent 0169619c28
commit 7959042667
6 changed files with 61 additions and 48 deletions

View File

@ -1,8 +1,10 @@
; HGR Demo2 ; HGR Demo2
; by deater (Vince Weaver) <vince@deater.net> ; Apple II graphics/music in 1k
; 1484 ; 1k demo for Demosplash 2021
; by deater (Vince Weaver) <vince@deater.net>
; Zero Page ; Zero Page
.include "zp.inc" .include "zp.inc"
@ -117,11 +119,15 @@ forever:
.include "moving.s" .include "moving.s"
;===================== ;=========================
; clear screen ; clear screen first time
skip_clear_smc:
lda #0
bne skip_clear
jsr fast_hclr jsr fast_hclr
skip_clear:
jsr flip_page jsr flip_page
;===================== ;=====================
@ -145,6 +151,7 @@ forever:
lda #$7f lda #$7f
sta color_smc+1 sta color_smc+1
sta skip_clear_smc+1
lda #159 lda #159
sta moving_size_smc+1 sta moving_size_smc+1
sta oval_size_smc+1 sta oval_size_smc+1
@ -163,6 +170,9 @@ forever:
; common flip page routine ; common flip page routine
flip_page: flip_page:
lda KEYPRESS
bmi its_over
ldy #$0 ldy #$0
lda HGR_PAGE ; will be $20/$40 lda HGR_PAGE ; will be $20/$40
cmp #$20 cmp #$20
@ -176,7 +186,18 @@ done_flip_page:
rts 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" ; 01234567890123456789012345678901234567890"
@ -222,6 +243,8 @@ sinetable_base:
sinetable=$8000 sinetable=$8000
.include "fast_hclr.s"
; music ; music
.include "mA2E_2.s" .include "mA2E_2.s"
.include "interrupt_handler.s" .include "interrupt_handler.s"

View File

@ -58,25 +58,6 @@ long_wait:
dex dex
bne long_wait 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 ; rts
;shape_dsr: ;shape_dsr:

18
demos/d2/fast_hclr.s Normal file
View File

@ -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

View File

@ -1,2 +1,6 @@
5 HOME 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"

View File

@ -54,13 +54,13 @@ loop_forever:
lda #0 lda #0
sta SONG_OFFSET sta SONG_OFFSET
lda #<peasant_song ; lda #<peasant_song
sta SONG_L ; sta SONG_L
lda #>peasant_song ; lda #>peasant_song
sta SONG_H ; sta SONG_H
jmp try_again beq try_again ; bra
all_ok: all_ok:
; see if note ; see if note
@ -117,10 +117,11 @@ blah_blah:
y_smc: y_smc:
ldy #0 ldy #0
iny iny
bne not_wrap2
inc SONG_H ; bne not_wrap2 ; assume less than 256 bytes
not_wrap2: ; inc SONG_H
jmp set_notes_loop ;not_wrap2:
bne set_notes_loop ; bra
handle_timing: handle_timing:
; was timing ; was timing

View File

@ -86,20 +86,6 @@ ror_nop_smc:
jsr flip_page 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 lda FRAME
cmp #$1b ; NOTE: NEEDS TO BE ODD cmp #$1b ; NOTE: NEEDS TO BE ODD
bne draw_moving ; bra bne draw_moving ; bra