roto: add some cycle counts

This commit is contained in:
Vince Weaver 2021-01-06 14:45:33 -05:00
parent 400ebb29a5
commit c7b3f6f384
2 changed files with 274 additions and 228 deletions

View File

@ -34,7 +34,8 @@ rotozoom:
sta CAH ; 3 sta CAH ; 3
lda fixed_sin+1,Y ; load integer half ; 4 lda fixed_sin+1,Y ; load integer half ; 4
sta CAL ; 3 sta CAL ; 3
;===========
; 27
; sa = sin(theta)*scale; ; sa = sin(theta)*scale;
lda ANGLE ; 3 lda ANGLE ; 3
@ -44,179 +45,201 @@ rotozoom:
sta SAH ; 3 sta SAH ; 3
lda fixed_sin+1,Y ; load integer half ; 4 lda fixed_sin+1,Y ; load integer half ; 4
sta SAL ; 3 sta SAL ; 3
;==========
; 21
; cca = -20*ca; ; cca = -20*ca;
; csa = -20*sa; ; csa = -20*sa;
lda #0 lda #0 ; 2
sta CCAL sta CCAL ; 3
sta CCAH sta CCAH ; 3
sta CSAL sta CSAL ; 3
sta CSAH sta CSAH ; 3
;===========
; 14
ldx #20 ldx #20 ; 2
mul20_loop: mul20_loop:
sec sec ; 2
lda CCAL lda CCAL ; 3
sbc CAL sbc CAL ; 3
sta CCAL sta CCAL ; 3
lda CCAH lda CCAH ; 3
sbc CAH sbc CAH ; 3
sta CCAH sta CCAH ; 3
;===========
; 20
sec sec ; 2
lda CSAL lda CSAL ; 3
sbc SAL sbc SAL ; 3
sta CSAL sta CSAL ; 3
lda CSAH lda CSAH ; 3
sbc SAH sbc SAH ; 3
sta CSAH sta CSAH ; 3
;===========
; 20
dex dex ; 2
bne mul20_loop bne mul20_loop ;2nt/3
;===================
; total=2+(45*20)-1
; 901 cycles
; yca=cca+ycenter; ; yca=cca+ycenter;
lda CCAL lda CCAL ; 3
sta YCAL sta YCAL ; 3
clc clc ; 2
lda CCAH lda CCAH ; 3
adc #20 adc #20 ; 2
sta YCAH sta YCAH ; 3
;===========
; 16
; ysa=csa+xcenter; ; ysa=csa+xcenter;
lda CSAL lda CSAL ; 3
sta YSAL sta YSAL ; 3
clc clc ; 2
lda CSAH lda CSAH ; 3
adc #20 adc #20 ; 2
sta YSAH sta YSAH ; 3
;===========
; 16
; for(yy=0;yy<40;yy++) { ; for(yy=0;yy<40;yy++) {
lda #0 lda #0 ; 2
sta YY sta YY ; 3
rotozoom_yloop: rotozoom_yloop:
; xp=cca+ysa; ; xp=cca+ysa;
clc clc ; 2
lda YSAL lda YSAL ; 3
adc CCAL adc CCAL ; 3
sta XPL sta XPL ; 3
lda YSAH lda YSAH ; 3
adc CCAH adc CCAH ; 3
sta XPH sta XPH ; 3
;==========
; 20
; yp=yca-csa; ; yp=yca-csa;
sec sec ; 2
lda YCAL lda YCAL ; 3
sbc CSAL sbc CSAL ; 3
sta YPL sta YPL ; 3
lda YCAH lda YCAH ; 3
sbc CSAH sbc CSAH ; 3
sta YPH sta YPH ; 3
;===========
; 20
; for(xx=0;xx<40;xx++) { ; for(xx=0;xx<40;xx++) {
lda #0 lda #0 ; 2
sta XX sta XX ; 3
rotozoom_xloop: rotozoom_xloop:
; if ((xp<0) || (xp>39)) color=0; ; if ((xp<0) || (xp>39)) color=0;
; else if ((yp<0) || (yp>39)) color=0; ; else if ((yp<0) || (yp>39)) color=0;
; else color=scrn_page(xp,yp,PAGE2); ; else color=scrn_page(xp,yp,PAGE2);
lda #0 lda #0 ; 2
ldx XPH
bmi rotozoom_set_color ldx XPH ; 3
cpx #40 bmi rotozoom_set_color ; 2nt/3
bcs rotozoom_set_color cpx #40 ; 2
ldx YPH bcs rotozoom_set_color ; 2nt/3
bmi rotozoom_set_color
cpx #40 ldx YPH ; 3
bcs rotozoom_set_color bmi rotozoom_set_color ; 2nt/3
cpx #40 ; 2
bcs rotozoom_set_color ; 2nt/3
; scrn(xp,yp) ; scrn(xp,yp)
lda XPH lda XPH ; 3
sta XPOS sta XPOS ; 3
lda YPH lda YPH ; 3
sta YPOS sta YPOS ; 3
jsr scrn jsr scrn ; 6+??
rotozoom_set_color: rotozoom_set_color:
; color_equals(color); ; color_equals(color);
jsr SETCOL jsr SETCOL ; 6+??
; plot(xx,yy); ; plot(xx,yy);
lda XX lda XX ; 3
sta XPOS sta XPOS ; 3
lda YY lda YY ; 3
sta YPOS sta YPOS ; 3
jsr plot jsr plot ; 6+??
; xp=xp+ca; ; xp=xp+ca;
clc clc ; 2
lda CAL lda CAL ; 3
adc XPL adc XPL ; 3
sta XPL sta XPL ; 3
lda CAH lda CAH ; 3
adc XPH adc XPH ; 3
sta XPH sta XPH ; 3
; yp=yp-sa; ; yp=yp-sa;
sec sec ; 2
lda YPL lda YPL ; 3
sbc SAL sbc SAL ; 3
sta YPL sta YPL ; 3
lda YPH lda YPH ; 3
sbc SAH sbc SAH ; 3
sta YPH sta YPH ; 3
rotozoom_end_xloop: rotozoom_end_xloop:
inc XX inc XX ; 5
lda XX lda XX ; 3
cmp #40 cmp #40 ; 2
bne rotozoom_xloop bne rotozoom_xloop ; 2nt/3
; yca+=ca; ; yca+=ca;
clc clc ; 2
lda YCAL lda YCAL ; 3
adc CAL adc CAL ; 3
sta YCAL sta YCAL ; 3
lda YCAH lda YCAH ; 3
adc CAH adc CAH ; 3
sta YCAH sta YCAH ; 3
;===========
; 20
; ysa+=sa; ; ysa+=sa;
clc clc ; 2
lda YSAL lda YSAL ; 3
adc SAL adc SAL ; 3
sta YSAL sta YSAL ; 3
lda YSAH lda YSAH ; 3
adc SAH adc SAH ; 3
sta YSAH sta YSAH ; 3
;==========
; 20
rotozoom_end_yloop: rotozoom_end_yloop:
inc YY inc YY ; 5
lda YY lda YY ; 3
cmp #40 cmp #40 ; 2
beq done_rotozoom beq done_rotozoom ; 2nt/3
jmp rotozoom_yloop ; too far jmp rotozoom_yloop ; too far ; 3
done_rotozoom: done_rotozoom:
rts rts ; 6

View File

@ -34,7 +34,8 @@ rotozoom:
sta CAH ; 3 sta CAH ; 3
lda fixed_sin+1,Y ; load integer half ; 4 lda fixed_sin+1,Y ; load integer half ; 4
sta CAL ; 3 sta CAL ; 3
;===========
; 27
; sa = sin(theta)*scale; ; sa = sin(theta)*scale;
lda ANGLE ; 3 lda ANGLE ; 3
@ -44,179 +45,201 @@ rotozoom:
sta SAH ; 3 sta SAH ; 3
lda fixed_sin+1,Y ; load integer half ; 4 lda fixed_sin+1,Y ; load integer half ; 4
sta SAL ; 3 sta SAL ; 3
;==========
; 21
; cca = -20*ca; ; cca = -20*ca;
; csa = -20*sa; ; csa = -20*sa;
lda #0 lda #0 ; 2
sta CCAL sta CCAL ; 3
sta CCAH sta CCAH ; 3
sta CSAL sta CSAL ; 3
sta CSAH sta CSAH ; 3
;===========
; 14
ldx #20 ldx #20 ; 2
mul20_loop: mul20_loop:
sec sec ; 2
lda CCAL lda CCAL ; 3
sbc CAL sbc CAL ; 3
sta CCAL sta CCAL ; 3
lda CCAH lda CCAH ; 3
sbc CAH sbc CAH ; 3
sta CCAH sta CCAH ; 3
;===========
; 20
sec sec ; 2
lda CSAL lda CSAL ; 3
sbc SAL sbc SAL ; 3
sta CSAL sta CSAL ; 3
lda CSAH lda CSAH ; 3
sbc SAH sbc SAH ; 3
sta CSAH sta CSAH ; 3
;===========
; 20
dex dex ; 2
bne mul20_loop bne mul20_loop ;2nt/3
;===================
; total=2+(45*20)-1
; 901 cycles
; yca=cca+ycenter; ; yca=cca+ycenter;
lda CCAL lda CCAL ; 3
sta YCAL sta YCAL ; 3
clc clc ; 2
lda CCAH lda CCAH ; 3
adc #20 adc #20 ; 2
sta YCAH sta YCAH ; 3
;===========
; 16
; ysa=csa+xcenter; ; ysa=csa+xcenter;
lda CSAL lda CSAL ; 3
sta YSAL sta YSAL ; 3
clc clc ; 2
lda CSAH lda CSAH ; 3
adc #20 adc #20 ; 2
sta YSAH sta YSAH ; 3
;===========
; 16
; for(yy=0;yy<40;yy++) { ; for(yy=0;yy<40;yy++) {
lda #0 lda #0 ; 2
sta YY sta YY ; 3
rotozoom_yloop: rotozoom_yloop:
; xp=cca+ysa; ; xp=cca+ysa;
clc clc ; 2
lda YSAL lda YSAL ; 3
adc CCAL adc CCAL ; 3
sta XPL sta XPL ; 3
lda YSAH lda YSAH ; 3
adc CCAH adc CCAH ; 3
sta XPH sta XPH ; 3
;==========
; 20
; yp=yca-csa; ; yp=yca-csa;
sec sec ; 2
lda YCAL lda YCAL ; 3
sbc CSAL sbc CSAL ; 3
sta YPL sta YPL ; 3
lda YCAH lda YCAH ; 3
sbc CSAH sbc CSAH ; 3
sta YPH sta YPH ; 3
;===========
; 20
; for(xx=0;xx<40;xx++) { ; for(xx=0;xx<40;xx++) {
lda #0 lda #0 ; 2
sta XX sta XX ; 3
rotozoom_xloop: rotozoom_xloop:
; if ((xp<0) || (xp>39)) color=0; ; if ((xp<0) || (xp>39)) color=0;
; else if ((yp<0) || (yp>39)) color=0; ; else if ((yp<0) || (yp>39)) color=0;
; else color=scrn_page(xp,yp,PAGE2); ; else color=scrn_page(xp,yp,PAGE2);
lda #0 lda #0 ; 2
ldx XPH
bmi rotozoom_set_color ldx XPH ; 3
cpx #40 bmi rotozoom_set_color ; 2nt/3
bcs rotozoom_set_color cpx #40 ; 2
ldx YPH bcs rotozoom_set_color ; 2nt/3
bmi rotozoom_set_color
cpx #40 ldx YPH ; 3
bcs rotozoom_set_color bmi rotozoom_set_color ; 2nt/3
cpx #40 ; 2
bcs rotozoom_set_color ; 2nt/3
; scrn(xp,yp) ; scrn(xp,yp)
lda XPH lda XPH ; 3
sta XPOS sta XPOS ; 3
lda YPH lda YPH ; 3
sta YPOS sta YPOS ; 3
jsr scrn jsr scrn ; 6+??
rotozoom_set_color: rotozoom_set_color:
; color_equals(color); ; color_equals(color);
jsr SETCOL jsr SETCOL ; 6+??
; plot(xx,yy); ; plot(xx,yy);
lda XX lda XX ; 3
sta XPOS sta XPOS ; 3
lda YY lda YY ; 3
sta YPOS sta YPOS ; 3
jsr plot jsr plot ; 6+??
; xp=xp+ca; ; xp=xp+ca;
clc clc ; 2
lda CAL lda CAL ; 3
adc XPL adc XPL ; 3
sta XPL sta XPL ; 3
lda CAH lda CAH ; 3
adc XPH adc XPH ; 3
sta XPH sta XPH ; 3
; yp=yp-sa; ; yp=yp-sa;
sec sec ; 2
lda YPL lda YPL ; 3
sbc SAL sbc SAL ; 3
sta YPL sta YPL ; 3
lda YPH lda YPH ; 3
sbc SAH sbc SAH ; 3
sta YPH sta YPH ; 3
rotozoom_end_xloop: rotozoom_end_xloop:
inc XX inc XX ; 5
lda XX lda XX ; 3
cmp #40 cmp #40 ; 2
bne rotozoom_xloop bne rotozoom_xloop ; 2nt/3
; yca+=ca; ; yca+=ca;
clc clc ; 2
lda YCAL lda YCAL ; 3
adc CAL adc CAL ; 3
sta YCAL sta YCAL ; 3
lda YCAH lda YCAH ; 3
adc CAH adc CAH ; 3
sta YCAH sta YCAH ; 3
;===========
; 20
; ysa+=sa; ; ysa+=sa;
clc clc ; 2
lda YSAL lda YSAL ; 3
adc SAL adc SAL ; 3
sta YSAL sta YSAL ; 3
lda YSAH lda YSAH ; 3
adc SAH adc SAH ; 3
sta YSAH sta YSAH ; 3
;==========
; 20
rotozoom_end_yloop: rotozoom_end_yloop:
inc YY inc YY ; 5
lda YY lda YY ; 3
cmp #40 cmp #40 ; 2
beq done_rotozoom beq done_rotozoom ; 2nt/3
jmp rotozoom_yloop ; too far jmp rotozoom_yloop ; too far ; 3
done_rotozoom: done_rotozoom:
rts rts ; 6