clock.tal (8920B)
1 ( simple graphical clock ) 2 3 |00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] 4 |10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ] 5 |20 @Screen [ &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] 6 |c0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ] 7 8 |0000 9 10 @last 11 &day $1 &sec $1 12 @center 13 &x $2 &y $2 14 @date 15 &x $2 &y $2 16 @time 17 &x $2 &y $2 18 @needles 19 &hx $2 &hy $2 20 &mx $2 &my $2 21 &sx $2 &sy $2 22 &zx $2 &zy $2 23 @buf 24 &d $3 &h $2 &s1 $1 &m $2 &s2 $1 &s $3 25 @line 26 &x $2 &y $2 &dx $2 &dy $2 &e1 $2 27 28 |0100 ( -> ) 29 30 ( theme ) 31 #0ff8 .System/r DEO2 32 #0f08 .System/g DEO2 33 #0f08 .System/b DEO2 34 ( resize ) 35 #00d0 .Screen/width DEO2 36 #0120 .Screen/height DEO2 37 ( vectors ) 38 ;on-frame .Screen/vector DEO2 39 ( center ) 40 .Screen/width DEI2 #01 SFT2 41 DUP2 .center/x STZ2 42 DUP2 #0028 SUB2 .date/x STZ2 43 #0020 SUB2 .time/x STZ2 44 .Screen/height DEI2 #01 SFT2 45 DUP2 .center/y STZ2 46 DUP2 #0078 SUB2 .date/y STZ2 47 #006c ADD2 .time/y STZ2 48 ;draw-watchface JSR2 49 ( time buffer ) 50 LIT ": 51 DUP .buf/s1 STZ 52 .buf/s2 STZ 53 54 ( continue ) 55 56 @on-frame ( -> ) 57 58 ( once per second ) 59 .DateTime/second DEI 60 DUP .last/sec LDZ EQU ,&same-sec JCN 61 ( make time ) 62 .DateTime/hour DEI .buf/h ;decimal JSR2 63 .DateTime/minute DEI .buf/m ;decimal JSR2 64 DUP .buf/s ;decimal JSR2 65 ( draw label ) 66 .time/x LDZ2 .Screen/x DEO2 67 .time/y LDZ2 .Screen/y DEO2 68 ;buf/h ;draw-text JSR2 69 ( draw needles ) 70 #00 ;draw-needles JSR2 71 ;make-needles JSR2 72 #01 ;draw-needles JSR2 73 DUP .last/sec STZ 74 &same-sec 75 POP 76 77 ( once per day ) 78 .DateTime/day DEI 79 DUP .last/day LDZ EQU ,&same-day JCN 80 ( make date ) 81 DUP .buf/d ;decimal JSR2 82 ( draw label ) 83 .date/x LDZ2 .Screen/x DEO2 84 .date/y LDZ2 .Screen/y DEO2 85 [ #00 .DateTime/dotw DEI #20 SFT ] ;week-txt ADD2 ;draw-text JSR2 86 [ #00 .DateTime/month DEI #20 SFT ] ;month-txt ADD2 ;draw-text JSR2 87 ;buf/d ;draw-text JSR2 88 DUP .last/day STZ 89 &same-day 90 POP 91 92 BRK 93 94 @draw-needles ( draw -- ) 95 96 STH 97 .center/x LDZ2 .center/y LDZ2 98 OVR2 OVR2 99 .needles/mx LDZ2 .needles/my LDZ2 #01 STHkr MUL 100 ;draw-line JSR2 101 OVR2 OVR2 102 .needles/hx LDZ2 .needles/hy LDZ2 #01 STHkr MUL 103 ;draw-line JSR2 104 .needles/sx LDZ2 .needles/sy LDZ2 105 .needles/zx LDZ2 .needles/zy LDZ2 #02 STHr MUL 106 ;draw-line JSR2 107 108 ( middle ) 109 #0001 SUB2 .Screen/y DEO2 110 #0001 SUB2 .Screen/x DEO2 111 ;middle-icn .Screen/addr DEO2 112 #0a .Screen/sprite DEO 113 114 JMP2r 115 116 @draw-text ( addr* -- ) 117 118 ( auto addr ) #15 .Screen/auto DEO 119 &while 120 LDAk 121 DUP ;is-lc JSR2 ,&lc JCN 122 DUP ;is-uc JSR2 ,&uc JCN 123 DUP ;is-num JSR2 ,&num JCN 124 DUP LIT "/ EQU ,&slash JCN 125 DUP LIT ": EQU ,&colon JCN 126 POP ;font/blank 127 &end 128 .Screen/addr DEO2 129 #03 .Screen/sprite DEO 130 INC2 LDAk ,&while JCN 131 POP2 132 #00 .Screen/sprite DEO 133 ( auto none ) #00 .Screen/auto DEO 134 135 JMP2r 136 &lc #61 SUB #00 SWP #40 SFT2 ;font/lc ADD2 ,&end JMP 137 &uc #41 SUB #00 SWP #40 SFT2 ;font/uc ADD2 ,&end JMP 138 &num #30 SUB #00 SWP #40 SFT2 ;font/num ADD2 ,&end JMP 139 &slash POP ;font/slash ,&end JMP 140 &colon POP ;font/colon ,&end JMP 141 142 @draw-line ( x1* y1* x2* y2* color -- ) 143 144 ( load ) STH ,&y STR2 ,&x STR2 .line/y STZ2 .line/x STZ2 145 ,&x LDR2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2 146 #0000 ,&y LDR2 .line/y LDZ2 SUB2 ;abs2 JSR2 SUB2 .line/dy STZ2 147 #ffff #00 .line/x LDZ2 ,&x LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sx STR2 148 #ffff #00 .line/y LDZ2 ,&y LDR2 ;lts2 JSR2 DUP2 ADD2 ADD2 ,&sy STR2 149 .line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 150 &loop 151 .line/x LDZ2 DUP2 .Screen/x DEO2 [ LIT2 &x $2 ] EQU2 152 .line/y LDZ2 DUP2 .Screen/y DEO2 [ LIT2 &y $2 ] EQU2 153 STHkr .Screen/pixel DEO 154 AND ,&end JCN 155 .line/e1 LDZ2 DUP2 ADD2 DUP2 156 .line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN 157 .line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2 158 .line/x LDZ2 [ LIT2 &sx $2 ] ADD2 .line/x STZ2 159 &skipy 160 .line/dx LDZ2 ;gts2 JSR2 ,&skipx JCN 161 .line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2 162 .line/y LDZ2 [ LIT2 &sy $2 ] ADD2 .line/y STZ2 163 &skipx 164 ,&loop JMP 165 &end 166 POPr 167 168 JMP2r 169 170 @draw-watchface ( -- ) 171 172 #3c00 173 &loop 174 ( dots ) 175 #00 OVRk ADD2 ;table ADD2 LDA2 176 #0018 ;circle JSR2 177 .Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO 178 ( markers ) 179 DUP #05 ;mod JSR2 ,&no-marker JCN 180 #00 OVRk ADD2 ;table ADD2 LDA2 181 STH2k #0018 ;circle JSR2 SWP2 182 STH2r #001c ;circle JSR2 SWP2 183 #01 ;draw-line JSR2 184 &no-marker 185 INC GTHk ;&loop JCN2 186 POP2 187 188 JMP2r 189 190 @make-needles ( -- ) 191 192 [ #00 .DateTime/second DEI #1e ADD #3c ;mod JSR2 ] DUP2 ADD2 ;table ADD2 LDA2 193 #00a0 ,circle JSR .needles/zx STZ2 .needles/zy STZ2 194 [ #00 .DateTime/second DEI ] DUP2 ADD2 ;table ADD2 LDA2 195 #0020 ,circle JSR .needles/sx STZ2 .needles/sy STZ2 196 [ #00 .DateTime/minute DEI ] DUP2 ADD2 ;table ADD2 LDA2 197 #0022 ,circle JSR .needles/mx STZ2 .needles/my STZ2 198 [ #00 .DateTime/hour DEI #0c ;mod JSR2 #20 SFTk NIP ADD ] 199 ( minute offset ) [ #00 .DateTime/minute DEI #0f DIV ADD2 ] DUP2 ADD2 ;table ADD2 LDA2 200 #002a ,circle JSR .needles/hx STZ2 .needles/hy STZ2 201 202 JMP2r 203 204 @circle ( cx cy radius* -- y* x* ) 205 206 STH2 SWP 207 #00 SWP #40 SFT2 STH2kr DIV2 .center/x LDZ2 ADD2 #0800 STH2kr DIV2 SUB2 208 STH2 SWP2r 209 #00 SWP #40 SFT2 STH2kr DIV2 .center/y LDZ2 ADD2 #0800 STH2kr DIV2 SUB2 210 POP2r STH2r 211 212 JMP2r 213 214 @decimal ( value* zp-label -- ) 215 216 STH 217 DUP #0a DIV #30 ADD STHkr STZ 218 #0a ;mod JSR2 #30 ADD STHr INC STZ 219 220 JMP2r 221 222 @mod DIVk MUL SUB JMP2r 223 @abs2 DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 JMP2r 224 @lts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 GTH2 JMP2r 225 @gts2 #8000 STH2k ADD2 SWP2 STH2r ADD2 LTH2 JMP2r 226 @is-uc DUP #40 GTH SWP #5b LTH AND JMP2r 227 @is-lc DUP #60 GTH SWP #7b LTH AND JMP2r 228 @is-num DUP #2f GTH SWP #3a LTH AND JMP2r 229 230 @week-txt 231 "Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1 232 "Sat $1 233 234 @month-txt 235 "Jan $1 "Feb $1 "Mar $1 "Apr $1 "May $1 "Jun $1 236 "Jul $1 "Aug $1 "Sep $1 "Oct $1 "Nov $1 "Dec $1 237 238 @table ( 60 positions on a circle ) 239 8000 8d00 9a02 a706 b40b c011 cb18 d520 240 df2a e734 ee40 f44b f958 fd65 ff72 ff80 241 ff8d fd9a f9a7 f4b4 eec0 e7cb dfd5 d5df 242 cbe7 c0ee b4f4 a7f9 9afd 8dff 80ff 72ff 243 65fd 58f9 4bf4 40ee 34e7 2adf 20d5 18cb 244 11c0 0bb4 06a7 029a 008d 0080 0072 0265 245 0658 0b4b 113f 1834 202a 2a20 3418 3f11 246 4b0b 5806 6502 7200 247 248 @middle-icn 249 40e0 4000 0000 0000 250 251 @font 252 &num 253 0018 2442 4242 4242 4242 4242 4224 1800 254 0008 1828 0808 0808 0808 0808 0808 1c00 255 0018 2442 4202 0202 0408 1020 4040 7e00 256 0018 2442 0202 0438 0402 0202 0204 7800 257 000c 0c14 1414 2424 2444 447e 0404 0e00 258 007e 4040 4040 5864 4202 0202 0204 7800 259 000c 1020 4040 5864 4242 4242 4224 1800 260 007e 4202 0204 0404 0808 0810 1010 1000 261 0018 2442 4242 2418 2442 4242 4224 1800 262 0018 2442 4242 4242 261a 0202 0408 3000 263 &uc 264 0010 1028 2844 4444 8282 fe82 8282 0000 265 00f8 4442 4242 4478 4442 4242 44f8 0000 266 003c 4282 8280 8080 8080 8282 423c 0000 267 00f8 4442 4242 4242 4242 4242 44f8 0000 268 00fc 4240 4040 4878 4840 4040 42fc 0000 269 80fe 4240 4040 447c 4440 4040 40e0 0000 270 003a 4682 8080 8e82 8282 8282 463a 0000 271 00ee 4444 4444 447c 4444 4444 44ee 0000 272 0038 1010 1010 1010 1010 1010 1038 0000 273 000e 0404 0404 0404 0404 4444 2810 0000 274 00ee 4448 4850 5060 5050 4848 44ee 0000 275 00e0 4040 4040 4040 4040 4040 42fe 0000 276 0082 c6c6 c6aa aaaa 9292 9282 8282 0000 277 00e2 4262 6262 5252 4a4a 4646 42e2 0000 278 0038 4482 8282 8282 8282 8282 4438 0000 279 00f8 4442 4242 4244 7840 4040 40f0 0000 280 0038 4482 8282 8282 8282 829a 643a 0000 281 00f8 4442 4242 4478 4844 4442 42e2 0000 282 0010 2844 4440 2010 0804 4444 2810 0000 283 00fe 9210 1010 1010 1010 1010 1038 0000 284 00ee 4444 4444 4444 4444 4444 4438 0000 285 0082 8282 8282 8244 4444 2828 1010 0000 286 0082 8292 9292 9292 92ba aa44 4444 0000 287 0042 4242 2424 1818 1824 2442 4242 0000 288 0082 8282 4444 2828 1010 1010 1038 0000 289 007e 4204 0408 0810 1020 2040 427e 0000 290 &lc 291 0000 0000 0030 0808 3848 4848 4834 0000 292 0060 2020 202c 3222 2222 2222 322c 0000 293 0000 0000 001c 2240 4040 4040 221c 0000 294 000c 0404 0434 4c44 4444 4444 4c36 0000 295 0000 0000 0018 2424 3c20 2020 2418 0000 296 000c 1210 1038 1010 1010 1010 1038 0000 297 0000 0000 0034 4a48 4830 4038 4444 4438 298 00c0 4040 4058 6444 4444 4444 44ee 0000 299 0010 0000 0030 1010 1010 1010 1038 0000 300 0008 0000 0018 0808 0808 0808 0808 2810 301 0060 2020 2022 2224 2438 2424 2272 0000 302 0030 1010 1010 1010 1010 1010 1038 0000 303 0000 0000 00a4 da92 9292 9292 9292 0000 304 0000 0000 00d8 6444 4444 4444 44ee 0000 305 0000 0000 0038 4482 8282 8282 4438 0000 306 0000 0000 00d8 6442 4242 4242 6458 40e0 307 0000 0000 0034 4c84 8484 8484 4c34 040e 308 0000 0000 0068 3420 2020 2020 2070 0000 309 0000 0000 0018 2424 1008 0424 2418 0000 310 0010 1010 107c 1010 1010 1010 1408 0000 311 0000 0000 00cc 4444 4444 4444 4c36 0000 312 0000 0000 00ee 4444 4428 2828 1010 0000 313 0000 0000 0092 9292 9292 92aa 4444 0000 314 0000 0000 00ee 4428 1010 1028 44ee 0000 315 0000 0000 00ee 4444 4448 2828 1010 2040 316 0000 0000 007c 4408 0810 2020 447c 0000 317 &colon 318 0000 0000 0010 1000 0000 0000 1010 0000 319 &slash 320 0202 0404 0808 1010 2020 4040 8080 0000 321 &blank 322 0000 0000 0000 0000 0000 0000 0000 0000 323