51 | 51 |
similarity index 77% |
52 | 52 |
rename from projects/demos/clock.usm |
53 | 53 |
rename to projects/examples/devices/datetime.usm |
... | ... |
@@ -1,33 +1,37 @@ |
1 | 1 |
( Dev/Time ) |
2 | 2 |
|
3 |
-%RTN { JMP2r } |
|
4 |
-%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 } |
|
5 |
-%SCALEX { #0002 DIV2 .Screen/width DEI2 #0002 DIV2 ADD2 #0040 SUB2 } |
|
6 |
-%SCALEY { #0002 DIV2 .Screen/height DEI2 #0002 DIV2 ADD2 #0040 SUB2 } |
|
3 |
+%RTN { JMP2r } |
|
4 |
+%MOD { DUP2 DIV MUL SUB } |
|
5 |
+%ABS2 { DUP2 #000f SFT2 EQU #04 JNZ #ffff MUL2 } |
|
6 |
+%SCALEX { #0002 DIV2 .Screen/width DEI2 #0002 DIV2 ADD2 #0040 SUB2 } |
|
7 |
+%SCALEY { #0002 DIV2 .Screen/height DEI2 #0002 DIV2 ADD2 #0040 SUB2 } |
|
7 | 8 |
%12HOURS { DUP #0c GTH #0c MUL SUB } |
8 |
-%MOD { DUP2 DIV MUL SUB } |
|
9 | 9 |
|
10 | 10 |
( devices ) |
11 | 11 |
|
12 |
-|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |
|
13 |
-|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |
|
14 |
-|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ] |
|
12 |
+|00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] |
|
13 |
+|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] |
|
14 |
+|a0 @DateTime [ &year $2 &month $1 &day $1 &hour $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 &refresh $1 ] |
|
15 | 15 |
|
16 | 16 |
( variables ) |
17 | 17 |
|
18 | 18 |
|0000 |
19 | 19 |
|
20 |
-@current [ &second $1 ] |
|
20 |
+@color $1 |
|
21 |
+@current $1 |
|
21 | 22 |
@needles [ &hx $2 &hy $2 &mx $2 &my $2 &sx $2 &sy $2 ] |
22 |
-@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ] |
|
23 |
-@color [ &byte $1 ] |
|
23 |
+@line [ &x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 &dx $2 &dy $2 &e1 $2 &e2 $2 ] |
|
24 | 24 |
|
25 | 25 |
( program ) |
26 | 26 |
|
27 | 27 |
|0100 |
28 | 28 |
|
29 |
- ( theme ) #0ff8 .System/r DEO2 #0f08 .System/g DEO2 #0f08 .System/b DEO2 |
|
30 |
- ( vectors ) ;on-frame .Screen/vector DEO2 |
|
29 |
+ ( theme ) |
|
30 |
+ #0ff8 .System/r DEO2 |
|
31 |
+ #0f08 .System/g DEO2 |
|
32 |
+ #0f08 .System/b DEO2 |
|
33 |
+ ( vectors ) |
|
34 |
+ ;on-frame .Screen/vector DEO2 |
|
31 | 35 |
|
32 | 36 |
BRK |
33 | 37 |
|
... | ... |
@@ -36,8 +40,8 @@ BRK |
36 | 40 |
#00 .DateTime/refresh DEO |
37 | 41 |
|
38 | 42 |
( only draw once per second ) |
39 |
- .DateTime/second DEI .current/second PEK NEQ #01 JNZ BRK |
|
40 |
- .DateTime/second DEI .current/second POK |
|
43 |
+ .DateTime/second DEI .current PEK NEQ #01 JNZ [ BRK ] |
|
44 |
+ .DateTime/second DEI .current POK |
|
41 | 45 |
|
42 | 46 |
( clear ) |
43 | 47 |
#0080 SCALEX #0080 SCALEY .needles/sx PEK2 .needles/sy PEK2 #00 ;draw-line JSR2 |
... | ... |
@@ -71,7 +75,12 @@ BRK |
71 | 75 |
DUP2 LTH ,&loop JNZ |
72 | 76 |
POP2 |
73 | 77 |
|
74 |
- ( display ) |
|
78 |
+ ;draw-display JSR2 |
|
79 |
+ |
|
80 |
+BRK |
|
81 |
+ |
|
82 |
+@draw-display ( -- ) |
|
83 |
+ |
|
75 | 84 |
.Screen/height DEI2 #0002 DIV2 #0048 ADD2 .Screen/y DEO2 |
76 | 85 |
.Screen/width DEI2 #0002 DIV2 |
77 | 86 |
DUP2 #0020 SUB2 .Screen/x DEO2 |
... | ... |
@@ -94,7 +103,7 @@ BRK |
94 | 103 |
#22 .Screen/color DEO |
95 | 104 |
POP2 |
96 | 105 |
|
97 |
-BRK |
|
106 |
+RTN |
|
98 | 107 |
|
99 | 108 |
@draw-line ( x1 y1 x2 y2 color -- ) |
100 | 109 |
|
... | ... |
@@ -105,8 +114,11 @@ BRK |
105 | 114 |
#ffff #00 .line/y PEK2 .line/y0 PEK2 LTS2 #0002 MUL2 ADD2 .line/sy POK2 |
106 | 115 |
.line/dx PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 |
107 | 116 |
&loop |
108 |
- .line/x PEK2 .Screen/x DEO2 .line/y PEK2 .Screen/y DEO2 .color PEK .Screen/color DEO |
|
109 |
- .line/x PEK2 .line/x0 PEK2 EQU2 .line/y PEK2 .line/y0 PEK2 EQU2 #0101 EQU2 ,&end JNZ |
|
117 |
+ .line/x PEK2 .Screen/x DEO2 |
|
118 |
+ .line/y PEK2 .Screen/y DEO2 |
|
119 |
+ .color PEK .Screen/color DEO |
|
120 |
+ [ .line/x PEK2 .line/x0 PEK2 EQU2 ] |
|
121 |
+ [ .line/y PEK2 .line/y0 PEK2 EQU2 ] #0101 EQU2 ,&end JNZ |
|
110 | 122 |
.line/e1 PEK2 #0002 MUL2 .line/e2 POK2 |
111 | 123 |
.line/e2 PEK2 .line/dy PEK2 LTS2 ,&skipy JNZ |
112 | 124 |
.line/e1 PEK2 .line/dy PEK2 ADD2 .line/e1 POK2 |
... | ... |
@@ -117,7 +129,6 @@ BRK |
117 | 129 |
.line/y PEK2 .line/sy PEK2 ADD2 .line/y POK2 |
118 | 130 |
&skipx |
119 | 131 |
;&loop JMP2 |
120 |
- |
|
121 | 132 |
&end |
122 | 133 |
|
123 | 134 |
RTN |