(clock.tal) Fixed issue with hour needle

This commit is contained in:
Devine Lu Linvega 2021-11-16 13:00:51 -05:00
parent c7759f6212
commit dd6adb3f73
1 changed files with 34 additions and 36 deletions

View File

@ -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,34 +89,6 @@ BRK
BRK
@draw-clock ( -- )
( clear ) #00 ;draw-needles JSR2
#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
#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
@ -114,12 +98,26 @@ RTN
RTN
@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 #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 4// DUP2k ++ ++ #0020 ++ SCALEY .needles/hy STZ2
TOS 4// DUP2k ++ ++ #0020 ++ SCALEX .needles/hx STZ2
RTN
@draw-display ( -- )
( 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