fireworks: add sound

This commit is contained in:
Vince Weaver 2018-09-12 11:46:08 -04:00
parent af55118c65
commit d55c2b94c3
5 changed files with 39 additions and 11 deletions

18
fireworks/README Normal file
View File

@ -0,0 +1,18 @@
Apple II Cycle-Counting Fireworks demo
by Vince "Deater" Weaver
vince@deater.net
http://www.deater.net/weave/vmwprod/
Loosely based on a BASIC program by FozzTexx
Usage:
BRUN FIREWORKS
press any key to toggle sound and restart
This code uses cycle counting extensively.
This is how HGR and 40x96 LORES are mixed.
HPLOT0 was made cycle-invariant, which was a pain.
HGLIN (allowing HPLOT TO) was intended to be too, but I ran out of interest.

View File

@ -12,4 +12,6 @@ remove dead code
adjust speed adjust speed
adjust colors of gradient

View File

@ -27,6 +27,7 @@ WHICH = $FB
; Soft Switches ; Soft Switches
KEYPRESS= $C000 KEYPRESS= $C000
KEYRESET= $C010 KEYRESET= $C010
SPEAKER = $C030
SET_GR = $C050 ; Enable graphics SET_GR = $C050 ; Enable graphics
FULLGR = $C052 ; Full screen, no text FULLGR = $C052 ; Full screen, no text
PAGE0 = $C054 ; Page0 PAGE0 = $C054 ; Page0

View File

@ -89,16 +89,19 @@ done_fireworks:
;=========================== ;===========================
; LAUNCH_FIREWORK ; LAUNCH_FIREWORK
;=========================== ;===========================
; cycles= 56+60+67+60+56+56+15+8+21+11 = 410 ; cycles= 60+60+67+60+56+56+15+8+21+11 = 414
launch_firework: launch_firework:
sound1:
bit SPEAKER ; 4
jsr random16 ; 6+42 jsr random16 ; 6+42
lda SEEDL ; 3 lda SEEDL ; 3
and #$4 ; 2 and #$4 ; 2
sta COLOR_GROUP ; HGR color group (0 PG or 4 BO) ; 3 sta COLOR_GROUP ; HGR color group (0 PG or 4 BO) ; 3
;============ ;============
; 56 ; 60
jsr random16 ; 6+42 jsr random16 ; 6+42
lda SEEDL ; 3 lda SEEDL ; 3
@ -620,13 +623,17 @@ continue_explosion:
;============ ;============
; 2233 ; 2233
explosion_erase_waste: explosion_erase_waste:
; waste 2176-4 = 2172
; Try X=7 Y=53 cycles=2174 R2 sound2:
bit SPEAKER ; 4
nop ; Try X=47 Y=9 cycles=2170 R2
ldy #53 ; 2 nop ; 2
eeloop1:ldx #7 ; 2
ldy #9 ; 2
eeloop1:ldx #47 ; 2
eeloop2:dex ; 2 eeloop2:dex ; 2
bne eeloop2 ; 2nt/3 bne eeloop2 ; 2nt/3
dey ; 2 dey ; 2

View File

@ -18,19 +18,19 @@ action_stars:
;================================= ;=================================
; and take 4504 cycles to do it ; and take 4504 cycles to do it
; we take 419 so waste 4085 ; we take 423 so waste 4081
action_launch_firework: action_launch_firework:
; Try X=203 Y=4 cycles=405 ; Try X=26 Y=30 cycles=4081
ldy #4 ; 2 ldy #30 ; 2
Xloop1: ldx #203 ; 2 Xloop1: ldx #26 ; 2
Xloop2: dex ; 2 Xloop2: dex ; 2
bne Xloop2 ; 2nt/3 bne Xloop2 ; 2nt/3
dey ; 2 dey ; 2
bne Xloop1 ; 2nt/3 bne Xloop1 ; 2nt/3
jsr launch_firework ; 6+410 = 416 jsr launch_firework ; 6+414 = 420
jmp check_keyboard ; 3 jmp check_keyboard ; 3