uxn

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

commit dd6adb3f739c8ab0decfcaf01c00ca67ff54387e
parent c7759f6212bbc508dd5e827357d3edb3b5a199c2
Author: Devine Lu Linvega <aliceffekt@gmail.com>
Date:   Tue, 16 Nov 2021 13:00:51 -0500

(clock.tal) Fixed issue with hour needle

Diffstat:
Mprojects/examples/devices/datetime.tal | 68+++++++++++++++++++++++++++++++++-----------------------------------
1 file changed, 33 insertions(+), 35 deletions(-)

diff --git a/projects/examples/devices/datetime.tal b/projects/examples/devices/datetime.tal @@ -19,7 +19,7 @@ %ABS2 { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 -- } %SCALEX { 2// .center/x LDZ2 ++ RADIUS -- } %SCALEY { 2// .center/y LDZ2 ++ RADIUS -- } -%12HOURS { DUP #0c GTH #0c MUL SUB } +%12HOURS { #0c MOD } %LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 } %GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 } %GET-CHAR-SPRITE { 8* TOS ;font-hex ++ } @@ -35,14 +35,13 @@ |0000 -@color $1 @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 + &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 &color $1 ( program ) @@ -53,6 +52,7 @@ #0f08 .System/g DEO2 #0f08 .System/b DEO2 + ( resize ) #00f0 .Screen/width DEO2 #0120 .Screen/height DEO2 @@ -63,13 +63,25 @@ .Screen/width DEI2 2// .center/x STZ2 .Screen/height DEI2 2// .center/y STZ2 + ( circle ) + #3c00 + &loop + ( load ) DUP TOS 2** ;table ++ LDA2 + TOS #0010 ** #001c // .center/x LDZ2 ++ #0049 -- .Screen/x DEO2 + TOS #0010 ** #001c // .center/y LDZ2 ++ #0049 -- .Screen/y DEO2 + DUP #0f MOD #00 EQU INC .Screen/pixel DEO + INC GTHk ,&loop JCN + POP2 + BRK @on-frame ( -> ) ( only draw once per second ) .DateTime/second DEI .current LDZ = ,&skip JCN - ;draw-clock JSR2 + ( clear ) #00 ,draw-needles JSR + ( update ) ,update-needles JSR + ( draw ) #01 ,draw-needles JSR ;draw-display JSR2 &skip @@ -77,40 +89,26 @@ BRK BRK -@draw-clock ( -- ) +@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 - ( clear ) #00 ;draw-needles JSR2 +@update-needles ( -- ) #00 .DateTime/second DEI 2** ;table ++ LDA2 TOS SCALEY .needles/sy STZ2 TOS SCALEX .needles/sx STZ2 #00 .DateTime/minute DEI 2** ;table ++ LDA2 - TOS 4// DUP2k ++ ++ #0020 ++ SCALEY .needles/my STZ2 - TOS 4// DUP2k ++ ++ #0020 ++ SCALEX .needles/mx STZ2 + TOS #0020 ** RADIUS ++ #0024 // SCALEY #0007 ++ .needles/my STZ2 + TOS #0020 ** RADIUS ++ #0024 // SCALEX #0007 ++ .needles/mx STZ2 #00 .DateTime/hour DEI 12HOURS #20 SFTk NIP ADD 2** ;table ++ LDA2 - TOS 2// RADIUS ++ SCALEY .needles/hy STZ2 - TOS 2// RADIUS ++ SCALEX .needles/hx STZ2 - - ( draw ) #01 ;draw-needles JSR2 - - ( circle ) - #3c #00 - &loop - ( load ) DUP TOS 2** ;table ++ LDA2 - TOS SCALEY .Screen/y DEO2 - TOS SCALEX .Screen/x DEO2 - DUP #0f MOD #00 EQU INC .Screen/pixel DEO - INC GTHk ,&loop JCN - POP2 - -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 + TOS 4// DUP2k ++ ++ #0020 ++ SCALEY .needles/hy STZ2 + TOS 4// DUP2k ++ ++ #0020 ++ SCALEX .needles/hx STZ2 RTN @@ -119,7 +117,7 @@ RTN ( auto x ) #01 .Screen/auto DEO ( date ) - .center/y LDZ2 #0058 -- .Screen/y DEO2 + .center/y LDZ2 #0068 -- .Screen/y DEO2 .center/x LDZ2 #0014 -- .Screen/x DEO2 .DateTime/month DEI INC DUP #0a DIV GET-CHAR-SPRITE .Screen/addr DEO2 @@ -134,7 +132,7 @@ RTN #03 .Screen/sprite DEO ( time ) - .center/y LDZ2 #0050 ++ .Screen/y DEO2 + .center/y LDZ2 #0060 ++ .Screen/y DEO2 .center/x LDZ2 #0020 -- .Screen/x DEO2 .DateTime/hour DEI DUP #0a DIV GET-CHAR-SPRITE .Screen/addr DEO2 @@ -162,7 +160,7 @@ RTN @draw-line ( x1 y1 x2 y2 color -- ) - ( load ) .color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2 + ( load ) .line/color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2 .line/x0 LDZ2 .line/x LDZ2 -- ABS2 .line/dx STZ2 .line/y0 LDZ2 .line/y LDZ2 -- ABS2 #0000 SWP2 -- .line/dy STZ2 #ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ++ .line/sx STZ2 @@ -171,7 +169,7 @@ RTN &loop .line/x LDZ2 .Screen/x DEO2 .line/y LDZ2 .Screen/y DEO2 - .color LDZ .Screen/pixel DEO + .line/color LDZ .Screen/pixel DEO [ .line/x LDZ2 .line/x0 LDZ2 == ] [ .line/y LDZ2 .line/y0 LDZ2 == ] AND ,&end JCN .line/e1 LDZ2 2** .line/e2 STZ2