bubble: more optimizing for speed

This commit is contained in:
Vince Weaver 2024-01-02 01:39:20 -05:00
parent 6c134ee061
commit 028dda2869

View File

@ -13,6 +13,9 @@
; D7E77 = 884343 = 1.1fps ; D7E77 = 884343 = 1.1fps
; DD06E = ?? (made J countdown, why longer?) ; DD06E = ?? (made J countdown, why longer?)
; DB584 = destructive U when plotting ; DB584 = destructive U when plotting
; D57A2 = rotate right instead of left for HPLOT *32 (U)
; D1D53 = same byt for V
; C2679 = optimize sine, don't care about bottom byte in addition
; soft-switches ; soft-switches
@ -202,9 +205,6 @@ rl_smc:
; we want 56789ABC, rotate right by 3 is two iterations faster? ; we want 56789ABC, rotate right by 3 is two iterations faster?
; lda UL
; sta HPLOTYL
lda UL ; 3 lda UL ; 3
lsr UH ; 5 lsr UH ; 5
@ -216,29 +216,32 @@ rl_smc:
lsr UH ; 5 lsr UH ; 5
ror ; 2 ror ; 2
clc ; 2
adc #140 ; 2
tax ; 2
; calculate Ypos
lda VH
sta HPLOTYL
lda VL
lsr HPLOTYL
ror
lsr HPLOTYL
ror
lsr HPLOTYL
ror
.if 0 .if 0
lda UH
asl UL
rol
asl UL
rol
asl UL
rol
asl UL
rol
asl UL
rol
.endif
clc
adc #140
tax
lda VL lda VL
sta HPLOTYL sta HPLOTYL
lda VH lda VH
asl HPLOTYL asl HPLOTYL
rol rol
asl HPLOTYL asl HPLOTYL
@ -249,6 +252,7 @@ rl_smc:
rol rol
asl HPLOTYL asl HPLOTYL
rol rol
.endif
clc clc
adc #96 adc #96
@ -330,61 +334,68 @@ sin:
; i=(i*0x28)>>8; ; i=(i*0x28)>>8;
lda IVL,Y lda IVL,Y ; note, uses absolute as no ZP equiv ; 5
sta STEMP1L sta STEMP1L ; 3
lda IVH,Y lda IVH,Y ; 5
sta STEMP1H ; sta STEMP1H ; 3
already_loaded: already_loaded:
; i2=i<<3; ; i2=i<<3;
asl STEMP1L ; TODO: keep part in accumulator
rol STEMP1H
asl STEMP1L asl STEMP1L ; 5
rol STEMP1H ; rol STEMP1H ; 5
asl STEMP1L rol
rol STEMP1H asl STEMP1L ; 5
; rol STEMP1H ; 5
rol
asl STEMP1L ; 5
; rol STEMP1H ; 5
rol
; i1=i<<5; ; i1=i<<5;
lda STEMP1L ldx STEMP1L ; 3
sta STEMP2L stx STEMP2L ; 3
lda STEMP1H
sta STEMP2H
asl STEMP2L ; lda STEMP1H ; 3
rol STEMP2H ; sta STEMP2H ; 3
asl STEMP2L sta STEMP1H
rol STEMP2H
asl STEMP2L ; 5
; rol STEMP2H ; 5
rol
asl STEMP2L ; 5
; rol STEMP2H ; 5
rol
; i=(i1+i2)>>8; ; i=(i1+i2)>>8;
clc ; We ignore the low byte as we don't need it
lda STEMP1L ; possibly inaccurate as we don't clear carry?
adc STEMP2L
sta STEMP1L
lda STEMP1H adc STEMP1H
adc STEMP2H ; lda STEMP1H ; 3
sta STEMP1H ; adc STEMP2H ; 3
tax ; 2
ldx STEMP1H
; sl=fsinh[i]; ; sl=fsinh[i];
lda sin_lookup,X lda sin_lookup,X ; 4+
asl asl ; 2
sta OUT1L,Y sta OUT1L,Y ; 5
bcs sin_negative bcs sin_negative ; 2/3
sin_positive: sin_positive:
lda #$0 lda #$0 ; 2
beq set_sin_sign beq set_sin_sign ; bra ; 3
sin_negative: sin_negative:
lda #$FF lda #$FF ; 2
set_sin_sign: set_sin_sign:
sta OUT1H,Y sta OUT1H,Y ; 5
rts rts ; 6
;============================= ;=============================
cos: cos: