fireworks: split off state machine

This commit is contained in:
Vince Weaver 2018-09-11 14:07:16 -04:00
parent 3fbd3675a9
commit 73fe06387f
3 changed files with 51 additions and 54 deletions

View File

@ -17,7 +17,7 @@ FIREWORKS: fireworks.o
ld65 -o FIREWORKS fireworks.o -C ../linker_scripts/apple2_1000.inc
fireworks.o: fireworks.s gr_copy.s random16.s fw.s hgr.s \
vapor_lock.s gr_hline.s \
vapor_lock.s gr_hline.s state_machine.s \
background_final.inc
ca65 -o fireworks.o fireworks.s -l fireworks.lst

View File

@ -253,57 +253,7 @@ loop_forever:
jmp loop_forever
;=================================
; do nothing
;=================================
; and take 4533-6 = 4527 cycles to do it
do_nothing:
; Try X=4 Y=174 cycles=4525 R2
nop ; 2
ldy #174 ; 2
loop1:
ldx #4 ; 2
loop2:
dex ; 2
bne loop2 ; 2nt/3
dey ; 2
bne loop1 ; 2nt/3
rts ; 6
;=================================
; action_stars
;=================================
; and take 4533-6 = 4527 cycles to do it
action_stars:
jsr draw_stars ; 6+4492 = 4498
; 4527 - 4498 = 29
; Try X=4 Y=1 cycles=27 R2
nop
ldy #1 ; 2
bloop1:
ldx #4 ; 2
bloop2:
dex ; 2
bne bloop2 ; 2nt/3
dey ; 2
bne bloop1 ; 2nt/3
rts ; 6
.include "state_machine.s"
.include "gr_hline.s"
.include "../asm_routines/gr_unrle.s"
.include "../asm_routines/keypress.s"
@ -316,5 +266,3 @@ bloop2:
background:
.include "background_final.inc"

49
fireworks/state_machine.s Normal file
View File

@ -0,0 +1,49 @@
;=================================
; do nothing
;=================================
; and take 4533-6 = 4527 cycles to do it
do_nothing:
; Try X=4 Y=174 cycles=4525 R2
nop ; 2
ldy #174 ; 2
loop1:
ldx #4 ; 2
loop2:
dex ; 2
bne loop2 ; 2nt/3
dey ; 2
bne loop1 ; 2nt/3
rts ; 6
;=================================
; action_stars
;=================================
; and take 4533-6 = 4527 cycles to do it
action_stars:
jsr draw_stars ; 6+4492 = 4498
; 4527 - 4498 = 29
; Try X=4 Y=1 cycles=27 R2
nop
ldy #1 ; 2
bloop1:
ldx #4 ; 2
bloop2:
dex ; 2
bne bloop2 ; 2nt/3
dey ; 2
bne bloop1 ; 2nt/3
rts ; 6