mode7: minor optimizations

This commit is contained in:
Vince Weaver
2017-12-31 17:20:40 -05:00
parent 008c3b3d1f
commit 62fba23449

View File

@@ -28,6 +28,9 @@ NUMSTARS EQU 16
lda #0 ; 2 lda #0 ; 2
sta DRAW_PAGE ; 3 sta DRAW_PAGE ; 3
sta RANDOM_POINTER ; 3 sta RANDOM_POINTER ; 3
; always multiply with low byte as zero
sta NUM2L ; 3
ldy #(NUMSTARS-1) ; 2 ldy #(NUMSTARS-1) ; 2
init_stars: init_stars:
@@ -118,62 +121,59 @@ no_adjust:
lda star_x,Y ; 4 lda star_x,Y ; 4
sta NUM2H ; 3 sta NUM2H ; 3
lda #0 ; 2
sta NUM2L ; 3 sec ; don't reuse old values ; 2
sec ; don't reuse old values jsr multiply ; 6+?
jsr multiply
; integer result in X ; integer result in X
txa txa ; 2
clc clc ; 2
adc #20 adc #20 ; center on screen ; 2
sta XPOS sta XPOS ; save for later ; 3
; calculate y value, stars[i].y/stars[i].z ; calculate y value, stars[i].y/stars[i].z
; 1/stars[i].z is still in NUM1H:NUM1L ; 1/stars[i].z is still in NUM1H:NUM1L
ldy XX ldy XX ; reload index ; 3
lda star_y,Y lda star_y,Y ; load integer part of star_ ; 4
sta NUM2H sta NUM2H ; 3
lda #0 clc ; reuse old values ; 2
sta NUM2L jsr multiply ; 6+
clc ; reuse old values
jsr multiply
; integer result in X ; integer result in X
txa txa ; 2
clc clc ; 2
adc #20 adc #20 ; center the value ; 2
tay ; Y is YPOS tay ; Y is YPOS ; 2
sty YPOS ; put Y value in Y to plot sty YPOS ; put Y value in Y to plot ; 3
;============================ ;============================
; Check Limits ; Check Limits
;============================ ;============================
lda XPOS ; ldy YPOS
bmi new_star bmi new_star ; 2nt/3
cmp #40 cpy #40 ; 2
bpl new_star bpl new_star ; if < 0 or > 40 then done ; 2nt/3
ldy YPOS lda XPOS ; 3
bmi new_star bmi new_star ; 2nt/3
cpy #40 cmp #40 ; 2
bpl new_star bpl new_star ; if < 0 or > 40 then done ; 2nt/3
; FIXME: sort out all of these jumps to be more efficient ; FIXME: sort out all of these jumps to be more efficient
jmp plot_star bmi plot_star ; 2
new_star: new_star:
ldy XX ldy XX ; 3
jsr random_star jsr random_star ; 6
jmp plot_star_continue jmp plot_star_continue ; 3
plot_star: plot_star:
;================================ ;================================