pt3: more inner loop optimizations

This commit is contained in:
Vince Weaver 2019-05-16 14:45:25 -04:00
parent 1a895382f2
commit 6a38f9a56a
3 changed files with 82 additions and 83 deletions

View File

@ -8,6 +8,8 @@
I've only validated 3 so far. I've only validated 3 so far.
6. Merge mockingboard output to register calc, instead of setting 6. Merge mockingboard output to register calc, instead of setting
all 13 registers then walking through and outputting them all 13 registers then walking through and outputting them
7. Clear out the channel data with a memset() instead of explicitly
setting values?
some further out things some further out things

View File

@ -92,6 +92,10 @@ draw_fire_frame:
fire_fb_update: fire_fb_update:
; FIXME: optimize
; original = ??? (complex)
; -X : move
ldy #39 ; 2 ldy #39 ; 2
fire_fb_update_loop: fire_fb_update_loop:
@ -99,130 +103,124 @@ fire_fb_update_loop:
jsr random16 ; 40 jsr random16 ; 40
cpy #13 ; 2 ; get random number Q
bcs fire_b ; bge ; 2/3
fire_a:
lda A_VOLUME ; 3
jmp fire_vol ; 3
fire_b:
cpy #26 ; 2
bcs fire_c ; bge ; 2/3
lda B_VOLUME ; 3
jmp fire_vol ; 3
fire_c:
lda C_VOLUME ; 3
fire_vol:
and #$f ; 2
sta FIRE_VOLUME ; 3
; get random number
lda SEEDL ; 3 lda SEEDL ; 3
and #$3 ; 2 and #$3 ; 2
sta FIRE_Q ; 3 sta FIRE_Q ; 3
; 0..12 = A volume, 13-25 = B volume, 26-39 = C volume
lda A_VOLUME ; 3
cpy #13 ; 2
bcc fire_vol ; blt ; 2/3
lda B_VOLUME ; 3
cpy #26 ; 2
bcc fire_vol ; blt ; 2/3
lda C_VOLUME ; 3
fire_vol:
and #$f ; 2
; adjust fire height with volume ; adjust fire height with volume
lda FIRE_VOLUME cmp #$8 ; 2
cmp #$8 bcs fire_medium ; bge ; 2/3
bcs fire_medium ; bge
fire_low: fire_low:
; Q=1 3/4 of time ; Q=1 3/4 of time
lda FIRE_Q lda FIRE_Q ; 3
beq fire_height_done beq fire_height_done ; 2/3
fire_low_br: fire_low_br:
lda #1 lda #1 ; 2
jmp fire_height_done jmp fire_height_done ; 3
fire_medium: fire_medium:
cmp #$d cmp #$d ; 2
bcs fire_high ; blt bcs fire_high ; blt ; 2/3
; Q=1 1/2 of time ; Q=1 1/2 of time
lda FIRE_Q lda FIRE_Q ; 3
and #$1 and #$1 ; 2
jmp fire_height_done jmp fire_height_done ; 3
fire_high: fire_high:
; Q=1 1/4 of time ; Q=1 1/4 of time
lda FIRE_Q lda FIRE_Q ; 3
cmp #1 cmp #1 ; 2
beq fire_height_done beq fire_height_done ; 2/3
fire_high_br: fire_high_br:
lda #0 lda #0 ; 2
fire_height_done: fire_height_done:
sta FIRE_Q sta FIRE_Q ; 3
sty FIRE_Y sty FIRE_Y ; 3
; ;
cpy #0 cpy #0 ; 2
beq fire_r_same beq fire_r_same ; 2/3
cpy #39 cpy #39 ; 2
beq fire_r_same beq fire_r_same ; 2/3
lda #$2 ; 2
bit SEEDH ; 3
lda #$2 bne fire_r_same ; 2/3
bit SEEDH lda SEEDH ; 3
bne fire_r_same and #$1 ; 2
lda SEEDH beq r_up ; 2/3
and #$1
beq r_up
r_down: r_down:
dey dey ; 2
jmp fire_r_same jmp fire_r_same ; 3
r_up: r_up:
iny iny ; 2
fire_r_same: fire_r_same:
; get next line color ; get next line color
lda (FIRE_FB2_L),Y lda (FIRE_FB2_L),Y ; 5+
ldy FIRE_Y ldy FIRE_Y ; 3
;
; adjust it ; adjust it
sec sec ; 2
sbc FIRE_Q sbc FIRE_Q ; 3
; saturate to 0 ; saturate to 0
bpl fb_positive bpl fb_positive ; 2/3
lda #0 lda #0 ; 2
fb_positive: fb_positive:
; store out ; store out
sta (FIRE_FB_L),Y ; store out sta (FIRE_FB_L),Y ; store out ; 6
dey dey ; 2
bpl fire_fb_update_loop bpl fire_fb_update_loop ; 2/3
done_fire_fb_update_loop: done_fire_fb_update_loop:
; complicated adjustment ; complicated adjustment
clc clc ; 2
lda FIRE_FB_L lda FIRE_FB_L ; 3
adc #40 adc #40 ; 2
sta FIRE_FB_L sta FIRE_FB_L ; 3
lda FIRE_FB_H lda FIRE_FB_H ; 3
adc #0 adc #0 ; 2
sta FIRE_FB_H sta FIRE_FB_H ; 3
clc clc ; 2
lda FIRE_FB2_L lda FIRE_FB2_L ; 3
adc #40 adc #40 ; 2
sta FIRE_FB2_L sta FIRE_FB2_L ; 3
lda FIRE_FB2_H lda FIRE_FB2_H ; 3
adc #0 adc #0 ; 2
sta FIRE_FB2_H sta FIRE_FB2_H ; 3
inx inx ; 2
cpx #(FIRE_YSIZE-1) cpx #(FIRE_YSIZE-1) ; 2
beq fire_update_done beq fire_update_done ; 2/3
jmp fire_fb_update jmp fire_fb_update ; 3
fire_update_done: fire_update_done:

View File

@ -124,9 +124,8 @@ FIRE_FB2_L EQU $A6
FIRE_FB2_H EQU $A7 FIRE_FB2_H EQU $A7
FIRE_FB_LINE EQU $A8 FIRE_FB_LINE EQU $A8
FIRE_Q EQU $A9 FIRE_Q EQU $A9
FIRE_VOLUME EQU $AA FIRE_Y EQU $AA
FIRE_Y EQU $AB FIRE_X EQU $AB
FIRE_X EQU $AC
; More zero-page addresses ; More zero-page addresses
; we try not to conflict with anything DOS, MONITOR or BASIC related ; we try not to conflict with anything DOS, MONITOR or BASIC related