Browse code

Sorted examples in devices/ and gui/

neauoire authored on 23/04/2021 15:58:58
Showing 14 changed files
... ...
@@ -32,7 +32,7 @@ else
32 32
 fi
33 33
 
34 34
 echo "Assembling.."
35
-./bin/assembler projects/examples/dev.audio.usm bin/boot.rom
35
+./bin/assembler projects/examples/devices/datetime.usm bin/boot.rom
36 36
 
37 37
 echo "Running.."
38 38
 if [ "${2}" = '--cli' ]; 
39 39
similarity index 100%
40 40
rename from projects/examples/dev.audio.usm
41 41
rename to projects/examples/devices/audio.usm
42 42
similarity index 100%
43 43
rename from projects/examples/dev.console.usm
44 44
rename to projects/examples/devices/console.usm
45 45
similarity index 100%
46 46
rename from projects/examples/dev.controller.buttons.usm
47 47
rename to projects/examples/devices/controller.buttons.usm
48 48
similarity index 100%
49 49
rename from projects/examples/dev.controller.keys.usm
50 50
rename to projects/examples/devices/controller.keys.usm
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
124 135
similarity index 100%
125 136
rename from projects/examples/dev.file.usm
126 137
rename to projects/examples/devices/file.usm
127 138
similarity index 100%
128 139
rename from projects/examples/dev.mouse.usm
129 140
rename to projects/examples/devices/mouse.usm
130 141
similarity index 100%
131 142
rename from projects/examples/gui.animation.usm
132 143
rename to projects/examples/gui/animation.usm
133 144
similarity index 100%
134 145
rename from projects/examples/gui.hover.usm
135 146
rename to projects/examples/gui/hover.usm
136 147
similarity index 100%
137 148
rename from projects/examples/gui.label.usm
138 149
rename to projects/examples/gui/label.usm
139 150
similarity index 100%
140 151
rename from projects/examples/gui.picture.usm
141 152
rename to projects/examples/gui/picture.usm
142 153
similarity index 100%
143 154
rename from projects/examples/gui.shapes.usm
144 155
rename to projects/examples/gui/shapes.usm
145 156
similarity index 100%
146 157
rename from projects/examples/gui.wallpaper.usm
147 158
rename to projects/examples/gui/wallpaper.usm