Browse code

Store center position in datetime.tal

neauoire authored on 26/09/2021 21:06:18
Showing 1 changed files
... ...
@@ -10,15 +10,18 @@
10 10
 %4// { #02 SFT2 }
11 11
 %2** { #10 SFT2 }
12 12
 
13
+%DIAMETER  { #0080 }
14
+%RADIUS    { DIAMETER 2// }
15
+
13 16
 %TOS     { #00 SWP }
14 17
 %RTN     { JMP2r }
15 18
 %MOD     { DUP2 DIV MUL SUB }
16
-%ABS2    { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 }
17
-%SCALEX  { 2// .Screen/width DEI2 2// ADD2 #0040 SUB2 }
18
-%SCALEY  { 2// .Screen/height DEI2 2// ADD2 #0040 SUB2 }
19
+%ABS2    { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 -- }
20
+%SCALEX  { 2// .Screen/width DEI2 2// ++ RADIUS -- }
21
+%SCALEY  { 2// .Screen/height DEI2 2// ++ RADIUS -- }
19 22
 %12HOURS { DUP #0c GTH #0c MUL SUB }
20
-%LTS2    { #8000 ADD2 SWP2 #8000 ADD2 GTH2 }
21
-%GTS2    { #8000 ADD2 SWP2 #8000 ADD2 LTH2 }
23
+%LTS2    { #8000 ++ SWP2 #8000 ++ GTH2 }
24
+%GTS2    { #8000 ++ SWP2 #8000 ++ LTH2 }
22 25
 %GET-CHAR-SPRITE { 8* TOS ;font-hex ++ }
23 26
 
24 27
 ( devices )
... ...
@@ -34,6 +37,8 @@
34 37
 
35 38
 @color   $1
36 39
 @current $1
40
+@center
41
+	&x $2 &y $2
37 42
 @needles [ &hx $2 &hy $2 &mx $2 &my $2 &sx $2 &sy $2 ]
38 43
 @line    [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ]
39 44
 
... ...
@@ -52,6 +57,10 @@
52 57
 	( vectors ) 
53 58
 	;on-frame .Screen/vector DEO2
54 59
 
60
+	DIAMETER SCALEX .center/x STZ2
61
+	DIAMETER SCALEY .center/y STZ2
62
+
63
+
55 64
 BRK
56 65
 
57 66
 @on-frame ( -> )
... ...
@@ -69,9 +78,9 @@ BRK
69 78
 @draw-clock ( -- )
70 79
 
71 80
 	( clear )
72
-	#0080 SCALEX #0080 SCALEY .needles/sx LDZ2 .needles/sy LDZ2 #00 ;draw-line JSR2
73
-	#0080 SCALEX #0080 SCALEY .needles/mx LDZ2 .needles/my LDZ2 #00 ;draw-line JSR2
74
-	#0080 SCALEX #0080 SCALEY .needles/hx LDZ2 .needles/hy LDZ2 #00 ;draw-line JSR2
81
+	.center/x LDZ2 .center/y LDZ2 .needles/sx LDZ2 .needles/sy LDZ2 #00 ;draw-line JSR2
82
+	.center/x LDZ2 .center/y LDZ2 .needles/mx LDZ2 .needles/my LDZ2 #00 ;draw-line JSR2
83
+	.center/x LDZ2 .center/y LDZ2 .needles/hx LDZ2 .needles/hy LDZ2 #00 ;draw-line JSR2
75 84
 
76 85
 	( place )
77 86
 	#00 .DateTime/second DEI 2** ;table ++ LDA2
... ...
@@ -81,20 +90,20 @@ BRK
81 90
 		TOS 4// DUP2k ++ ++ #0020 ++ SCALEY .needles/my STZ2
82 91
 		TOS 4// DUP2k ++ ++ #0020 ++ SCALEX .needles/mx STZ2
83 92
 	#00 .DateTime/hour DEI 12HOURS #20 SFTk NIP ADD 2** ;table ++ LDA2
84
-		TOS 2// #0040 ++ SCALEY .needles/hy STZ2
85
-		TOS 2// #0040 ++ SCALEX .needles/hx STZ2
93
+		TOS 2// RADIUS ++ SCALEY .needles/hy STZ2
94
+		TOS 2// RADIUS ++ SCALEX .needles/hx STZ2
86 95
 
87 96
 	( needles )
88
-	#0080 SCALEX #0080 SCALEY .needles/sx LDZ2 .needles/sy LDZ2 #02 ;draw-line JSR2
89
-	#0080 SCALEX #0080 SCALEY .needles/mx LDZ2 .needles/my LDZ2 #01 ;draw-line JSR2
90
-	#0080 SCALEX #0080 SCALEY .needles/hx LDZ2 .needles/hy LDZ2 #03 ;draw-line JSR2
97
+	.center/x LDZ2 .center/y LDZ2 .needles/sx LDZ2 .needles/sy LDZ2 #02 ;draw-line JSR2
98
+	.center/x LDZ2 .center/y LDZ2 .needles/mx LDZ2 .needles/my LDZ2 #01 ;draw-line JSR2
99
+	.center/x LDZ2 .center/y LDZ2 .needles/hx LDZ2 .needles/hy LDZ2 #03 ;draw-line JSR2
91 100
 
92 101
 	( circle )
93 102
 	#3c #00 
94 103
 	&loop
95
-		( load ) DUP #00 SWP 2** ;table ++ LDA2
96
-		#00 SWP SCALEY .Screen/y DEO2
97
-		#00 SWP SCALEX .Screen/x DEO2
104
+		( load ) DUP TOS 2** ;table ++ LDA2
105
+		TOS SCALEY .Screen/y DEO2
106
+		TOS SCALEX .Screen/x DEO2
98 107
 		DUP #0f MOD #00 EQU INC .Screen/pixel DEO
99 108
 		INC GTHk ,&loop JCN
100 109
 	POP2
... ...
@@ -150,8 +159,8 @@ RTN
150 159
 @draw-line ( x1 y1 x2 y2 color -- )
151 160
 	
152 161
 	( load ) .color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2
153
-	.line/x0 LDZ2 .line/x LDZ2 SUB2 ABS2 .line/dx STZ2
154
-	.line/y0 LDZ2 .line/y LDZ2 SUB2 ABS2 #0000 SWP2 SUB2 .line/dy STZ2
162
+	.line/x0 LDZ2 .line/x LDZ2 -- ABS2 .line/dx STZ2
163
+	.line/y0 LDZ2 .line/y LDZ2 -- ABS2 #0000 SWP2 -- .line/dy STZ2
155 164
 	#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ++ .line/sx STZ2
156 165
 	#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ++ .line/sy STZ2
157 166
 	.line/dx LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2
... ...
@@ -159,8 +168,8 @@ RTN
159 168
 		.line/x LDZ2 .Screen/x DEO2 
160 169
 		.line/y LDZ2 .Screen/y DEO2 
161 170
 		.color LDZ .Screen/pixel DEO
162
-		[ .line/x LDZ2 .line/x0 LDZ2 EQU2 ] 
163
-		[ .line/y LDZ2 .line/y0 LDZ2 EQU2 ] #0101 EQU2 ,&end JCN
171
+		[ .line/x LDZ2 .line/x0 LDZ2 == ] 
172
+		[ .line/y LDZ2 .line/y0 LDZ2 == ] #0101 == ,&end JCN
164 173
 		.line/e1 LDZ2 2** .line/e2 STZ2
165 174
 		.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
166 175
 			.line/e1 LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2