(clock.tal) Minor optimizations

This commit is contained in:
Devine Lu Linvega 2021-11-16 12:10:48 -05:00
parent 0114af1a10
commit c7759f6212
1 changed files with 32 additions and 28 deletions

View File

@ -1,8 +1,8 @@
( Dev/Time ) ( Dev/Time )
%+ { ADD } %- { SUB } %/ { DIV } %+ { ADD } %- { SUB } %* { MUL } %/ { DIV }
%< { LTH } %> { GTH } %= { EQU } %! { NEQ } %< { LTH } %> { GTH } %= { EQU } %! { NEQ }
%++ { ADD2 } %-- { SUB2 } %// { DIV2 } %++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 }
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } %<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }
%8* { #30 SFT } %8* { #30 SFT }
@ -17,8 +17,8 @@
%RTN { JMP2r } %RTN { JMP2r }
%MOD { DUP2 DIV MUL SUB } %MOD { DUP2 DIV MUL SUB }
%ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 -- } %ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 -- }
%SCALEX { 2// .Screen/width DEI2 2// ++ RADIUS -- } %SCALEX { 2// .center/x LDZ2 ++ RADIUS -- }
%SCALEY { 2// .Screen/height DEI2 2// ++ RADIUS -- } %SCALEY { 2// .center/y LDZ2 ++ RADIUS -- }
%12HOURS { DUP #0c GTH #0c MUL SUB } %12HOURS { DUP #0c GTH #0c MUL SUB }
%LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 } %LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 }
%GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 } %GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 }
@ -39,27 +39,29 @@
@current $1 @current $1
@center @center
&x $2 &y $2 &x $2 &y $2
@needles [ &hx $2 &hy $2 &mx $2 &my $2 &sx $2 &sy $2 ] @needles
@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ] &hx $2 &hy $2 &mx $2 &my $2 &sx $2 &sy $2
@line
&x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2
( program ) ( program )
|0100 ( -> ) |0100 ( -> )
( theme ) ( theme )
#e0f8 .System/r DEO2 #0ff8 .System/r DEO2
#e008 .System/g DEO2 #0f08 .System/g DEO2
#e008 .System/b DEO2 #0f08 .System/b DEO2
#00f0 .Screen/width DEO2 #00f0 .Screen/width DEO2
#00f0 .Screen/height DEO2 #0120 .Screen/height DEO2
( vectors ) ( vectors )
;on-frame .Screen/vector DEO2 ;on-frame .Screen/vector DEO2
DIAMETER SCALEX .center/x STZ2 ( center )
DIAMETER SCALEY .center/y STZ2 .Screen/width DEI2 2// .center/x STZ2
.Screen/height DEI2 2// .center/y STZ2
BRK BRK
@ -77,12 +79,8 @@ BRK
@draw-clock ( -- ) @draw-clock ( -- )
( clear ) ( clear ) #00 ;draw-needles JSR2
.center/x LDZ2 .center/y LDZ2 .needles/sx LDZ2 .needles/sy LDZ2 #00 ;draw-line JSR2
.center/x LDZ2 .center/y LDZ2 .needles/mx LDZ2 .needles/my LDZ2 #00 ;draw-line JSR2
.center/x LDZ2 .center/y LDZ2 .needles/hx LDZ2 .needles/hy LDZ2 #00 ;draw-line JSR2
( place )
#00 .DateTime/second DEI 2** ;table ++ LDA2 #00 .DateTime/second DEI 2** ;table ++ LDA2
TOS SCALEY .needles/sy STZ2 TOS SCALEY .needles/sy STZ2
TOS SCALEX .needles/sx STZ2 TOS SCALEX .needles/sx STZ2
@ -93,10 +91,7 @@ BRK
TOS 2// RADIUS ++ SCALEY .needles/hy STZ2 TOS 2// RADIUS ++ SCALEY .needles/hy STZ2
TOS 2// RADIUS ++ SCALEX .needles/hx STZ2 TOS 2// RADIUS ++ SCALEX .needles/hx STZ2
( needles ) ( draw ) #01 ;draw-needles JSR2
.center/x LDZ2 .center/y LDZ2 .needles/sx LDZ2 .needles/sy LDZ2 #02 ;draw-line JSR2
.center/x LDZ2 .center/y LDZ2 .needles/mx LDZ2 .needles/my LDZ2 #01 ;draw-line JSR2
.center/x LDZ2 .center/y LDZ2 .needles/hx LDZ2 .needles/hy LDZ2 #03 ;draw-line JSR2
( circle ) ( circle )
#3c #00 #3c #00
@ -110,13 +105,22 @@ BRK
RTN RTN
@draw-needles ( mul -- )
STH
.center/x LDZ2 .center/y LDZ2 .needles/sx LDZ2 .needles/sy LDZ2 #02 STHkr * ;draw-line JSR2
.center/x LDZ2 .center/y LDZ2 .needles/mx LDZ2 .needles/my LDZ2 #01 STHkr * ;draw-line JSR2
.center/x LDZ2 .center/y LDZ2 .needles/hx LDZ2 .needles/hy LDZ2 #01 STHr * ;draw-line JSR2
RTN
@draw-display ( -- ) @draw-display ( -- )
( auto x ) #01 .Screen/auto DEO ( auto x ) #01 .Screen/auto DEO
( date ) ( date )
.Screen/height DEI2 2// #0058 -- .Screen/y DEO2 .center/y LDZ2 #0058 -- .Screen/y DEO2
.Screen/width DEI2 2// #0014 -- .Screen/x DEO2 .center/x LDZ2 #0014 -- .Screen/x DEO2
.DateTime/month DEI INC .DateTime/month DEI INC
DUP #0a DIV GET-CHAR-SPRITE .Screen/addr DEO2 DUP #0a DIV GET-CHAR-SPRITE .Screen/addr DEO2
#03 .Screen/sprite DEO #03 .Screen/sprite DEO
@ -130,8 +134,8 @@ RTN
#03 .Screen/sprite DEO #03 .Screen/sprite DEO
( time ) ( time )
.Screen/height DEI2 2// #0050 ++ .Screen/y DEO2 .center/y LDZ2 #0050 ++ .Screen/y DEO2
.Screen/width DEI2 2// #0020 -- .Screen/x DEO2 .center/x LDZ2 #0020 -- .Screen/x DEO2
.DateTime/hour DEI .DateTime/hour DEI
DUP #0a DIV GET-CHAR-SPRITE .Screen/addr DEO2 DUP #0a DIV GET-CHAR-SPRITE .Screen/addr DEO2
#01 .Screen/sprite DEO #01 .Screen/sprite DEO
@ -169,7 +173,7 @@ RTN
.line/y LDZ2 .Screen/y DEO2 .line/y LDZ2 .Screen/y DEO2
.color LDZ .Screen/pixel DEO .color LDZ .Screen/pixel DEO
[ .line/x LDZ2 .line/x0 LDZ2 == ] [ .line/x LDZ2 .line/x0 LDZ2 == ]
[ .line/y LDZ2 .line/y0 LDZ2 == ] #0101 == ,&end JCN [ .line/y LDZ2 .line/y0 LDZ2 == ] AND ,&end JCN
.line/e1 LDZ2 2** .line/e2 STZ2 .line/e1 LDZ2 2** .line/e2 STZ2
.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN .line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
.line/e1 LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2 .line/e1 LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2
@ -184,7 +188,7 @@ RTN
RTN RTN
@table ( 60 positions on a circle in bytes ) @table ( 60 positions on a circle )
8000 8d00 9a02 a706 b40b c011 cb18 d520 8000 8d00 9a02 a706 b40b c011 cb18 d520
df2a e734 ee40 f44b f958 fd65 ff72 ff80 df2a e734 ee40 f44b f958 fd65 ff72 ff80
ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df