diff --git a/fireworks/README b/fireworks/README new file mode 100644 index 00000000..533a60db --- /dev/null +++ b/fireworks/README @@ -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. + diff --git a/fireworks/TODO b/fireworks/TODO index 66f233c3..ecf35292 100644 --- a/fireworks/TODO +++ b/fireworks/TODO @@ -12,4 +12,6 @@ remove dead code adjust speed +adjust colors of gradient + diff --git a/fireworks/fireworks.s b/fireworks/fireworks.s index d5da9c4f..54623bb6 100644 --- a/fireworks/fireworks.s +++ b/fireworks/fireworks.s @@ -27,6 +27,7 @@ WHICH = $FB ; Soft Switches KEYPRESS= $C000 KEYRESET= $C010 +SPEAKER = $C030 SET_GR = $C050 ; Enable graphics FULLGR = $C052 ; Full screen, no text PAGE0 = $C054 ; Page0 diff --git a/fireworks/fw.s b/fireworks/fw.s index fedc4690..97b5cb18 100644 --- a/fireworks/fw.s +++ b/fireworks/fw.s @@ -89,16 +89,19 @@ done_fireworks: ;=========================== ; 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: +sound1: + bit SPEAKER ; 4 + jsr random16 ; 6+42 lda SEEDL ; 3 and #$4 ; 2 sta COLOR_GROUP ; HGR color group (0 PG or 4 BO) ; 3 ;============ - ; 56 + ; 60 jsr random16 ; 6+42 lda SEEDL ; 3 @@ -620,13 +623,17 @@ continue_explosion: ;============ ; 2233 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 -eeloop1:ldx #7 ; 2 + nop ; 2 + + ldy #9 ; 2 +eeloop1:ldx #47 ; 2 eeloop2:dex ; 2 bne eeloop2 ; 2nt/3 dey ; 2 diff --git a/fireworks/state_machine.s b/fireworks/state_machine.s index 57f9eb2f..8a01362f 100644 --- a/fireworks/state_machine.s +++ b/fireworks/state_machine.s @@ -18,19 +18,19 @@ action_stars: ;================================= ; and take 4504 cycles to do it - ; we take 419 so waste 4085 + ; we take 423 so waste 4081 action_launch_firework: - ; Try X=203 Y=4 cycles=405 + ; Try X=26 Y=30 cycles=4081 - ldy #4 ; 2 -Xloop1: ldx #203 ; 2 + ldy #30 ; 2 +Xloop1: ldx #26 ; 2 Xloop2: dex ; 2 bne Xloop2 ; 2nt/3 dey ; 2 bne Xloop1 ; 2nt/3 - jsr launch_firework ; 6+410 = 416 + jsr launch_firework ; 6+414 = 420 jmp check_keyboard ; 3