uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit c7759f6212bbc508dd5e827357d3edb3b5a199c2
parent 0114af1a10254de26f95aad0645729a7dfb7eb02
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Tue, 16 Nov 2021 12:10:48 -0500

(clock.tal) Minor optimizations

Diffstat:
Mprojects/examples/devices/datetime.tal | 60++++++++++++++++++++++++++++++++----------------------------
1 file changed, 32 insertions(+), 28 deletions(-)

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