Browse code

Moved some demos to /old

neauoire authored on 14/03/2022 17:21:36
Showing 8 changed files
... ...
@@ -39,11 +39,7 @@ while [ $# -gt 0 ]; do
39 39
 done
40 40
 
41 41
 echo "Cleaning.."
42
-rm -f ./bin/uxnasm
43
-rm -f ./bin/uxnemu
44
-rm -f ./bin/uxncli
45
-rm -f ./bin/launcher.rom
46
-rm -f ./bin/asma.rom
42
+rm -f ./bin/*
47 43
 
48 44
 # When clang-format is present
49 45
 
50 46
deleted file mode 100644
... ...
@@ -1,119 +0,0 @@
1
-( Project by Alex Schroeder - https://alexschroeder.ch )
2
-
3
-%RTN { JMP2r }
4
-%INCR { SWP INC SWP }
5
-%CELL { #1000 }
6
-%NEXT { #2000 }
7
-
8
-( devices )
9
-
10
-|00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
11
-|20 @Screen     [ &vector $2 &width    $2 &height $2 &pad   $2 &x      $2 &y      $2 &addr $2 &pixel $1 &sprite $1 ]
12
-|b0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour  $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
13
-
14
-|0000
15
-
16
-( program )
17
-
18
-@seed [ &x $1 &w $2 &s $2 ]
19
-
20
-|0100 ( -> )
21
-
22
-	( theme ) 
23
-	#2aac .System/r DEO2 
24
-	#269b .System/g DEO2 
25
-	#378d .System/b DEO2
26
-
27
-	;seed-line JSR2
28
-
29
-	( run for a few generations ) 
30
-	#00 #ff
31
-	&loop
32
-		OVR #00 SWP ;print-line JSR2
33
-		;compute-next JSR2
34
-		;copy-next JSR2
35
-		( incr ) INCR
36
-		( loop ) LTHk ,&loop JCN
37
-	POP2
38
-
39
-BRK
40
-
41
-@print-line ( y -- )
42
-
43
-	( set ) .Screen/y DEO2
44
-	( loop through cells ) 
45
-	#00 #ff
46
-	&loop
47
-		( copy ) OVR #00 SWP DUP2
48
-		( pos  ) .Screen/x DEO2
49
-		( addr ) CELL ADD2
50
-		( draw ) LDA .Screen/pixel DEO
51
-		( incr ) INCR
52
-		( loop ) LTHk ,&loop JCN
53
-	POP2
54
-
55
-RTN
56
-
57
-@compute-next ( -- )
58
-
59
-	( loop through 62 cells ) 
60
-	#01 #fe
61
-	&loop
62
-		OVR DUP DUP ( three copies of the counter )
63
-		#01 SUB #00 SWP CELL ADD2 LDA
64
-		SWP
65
-		INC #00 SWP CELL ADD2 LDA
66
-		( the cell dies if the neighbors are either both dead or both alive, i.e. Rule 90 )
67
-		NEQ
68
-		( one copy of the counter and the life value )
69
-		SWP #00 SWP NEXT ADD2 STA
70
-		( incr ) INCR
71
-		( loop ) LTHk ,&loop JCN
72
-	POP2
73
-
74
-RTN
75
-
76
-@copy-next ( -- )
77
-
78
-	( loop through cells ) 
79
-	#00 #ff
80
-	&loop
81
-		OVR DUP ( two copies of the counter )
82
-		#00 SWP NEXT ADD2 LDA ( one copy of the counter and the value )
83
-		SWP #00 SWP CELL ADD2 STA
84
-		( incr ) INCR
85
-		( loop ) LTHk ,&loop JCN
86
-	POP2
87
-
88
-RTN
89
-
90
-@seed-line ( -- )
91
-
92
-	.DateTime/second DEI .seed/x STZ 
93
-	#0000 .seed/w STZ2 
94
-	#e2a9 .seed/s STZ2
95
-	( loop through cells ) 
96
-	#01 #fe
97
-	&loop
98
-		OVR ( one copy of the counter )
99
-		;rand JSR2
100
-		#10 AND ( pick a bit )
101
-		SWP #00 SWP CELL ADD2 STA
102
-		( incr ) INCR
103
-		( loop ) LTHk ,&loop JCN
104
-	POP2
105
-
106
-RTN
107
-
108
-( https://en.wikipedia.org/wiki/Middle-square_method )
109
-
110
-@rand ( -- 1 )
111
-
112
-	.seed/x LDZ #00 SWP DUP2 MUL2
113
-	.seed/w LDZ2 .seed/s LDZ2 ADD2
114
-	DUP2 .seed/w STZ2
115
-	ADD2
116
-	#04 SFT SWP #40 SFT ADD
117
-	DUP .seed/x STZ
118
-
119
-RTN
120 0
\ No newline at end of file
... ...
@@ -1,42 +1,10 @@
1
-( Dev/Time )
2
-
3
-%+  { ADD } %-   { SUB }  %*  { MUL } %/   { DIV }  
4
-%<  { LTH } %>   { GTH }  %=  { EQU } %!   { NEQ } 
5
-%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } 
6
-%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } 
7
-
8
-%4*   { #20 SFT }
9
-%10*  { #40 SFT }
10
-%2**  { #10 SFT2 } %2// { #01 SFT2 }
11
-%4//  { #02 SFT2 }
12
-%10** { #40 SFT2 }
13
-%20** { #50 SFT2 }
14
-
15
-%TOS     { #00 SWP }
16
-%RTN     { JMP2r }
17
-%MOD     { DUP2 DIV MUL SUB }
18
-%ABS2    { DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 -- }
19
-%LTS2    { #8000 ++ SWP2 #8000 ++ GTH2 }
20
-%GTS2    { #8000 ++ SWP2 #8000 ++ LTH2 }
21
-
22
-%RADIUS  { #0040 }
23
-%SCALEX  { 2// .center/x LDZ2 ++ RADIUS -- }
24
-%SCALEY  { 2// .center/y LDZ2 ++ RADIUS -- }
25
-%12HOURS { #0c MOD }
26
-
27
-%IS-UC { DUP #40 > SWP #5b < AND }
28
-%IS-LC { DUP #60 > SWP #7b < AND }
29
-%IS-NUM { DUP #2f > SWP #3a < AND }
30
-
31
-( devices )
1
+( Clock )
32 2
 
33 3
 |00 @System     [ &vector $2 &pad      $6 &r      $2 &g     $2 &b      $2 ]
34 4
 |10 @Console    [ &vector $2 &read     $1 &pad    $5 &write $1 &error  $1 ]
35 5
 |20 @Screen     [ &vector $2 &width    $2 &height $2 &auto  $1 &pad    $1 &x      $2 &y      $2 &addr $2 &pixel $1 &sprite $1 ]
36 6
 |b0 @DateTime   [ &year   $2 &month    $1 &day    $1 &hour  $1 &minute $1 &second $1 &dotw $1 &doty $2 &isdst $1 ]
37 7
 
38
-( variables )
39
-
40 8
 |0000
41 9
 
42 10
 @last 
... ...
@@ -58,34 +26,27 @@
58 26
 	&x0 $2 &y0 $2 &x $2 &y $2 &sx $2 &sy $2 
59 27
 	&dx $2 &dy $2 &e1 $2 &e2 $2 &color $1
60 28
 
61
-( program )
62
-
63 29
 |0100 ( -> )
64 30
 	
65 31
 	( theme ) 
66 32
 	#0ff8 .System/r DEO2 
67 33
 	#0f08 .System/g DEO2 
68 34
 	#0f08 .System/b DEO2
69
-
70 35
 	( resize )
71 36
 	#00f0 .Screen/width DEO2
72 37
 	#0120 .Screen/height DEO2
73
-
74 38
 	( vectors ) 
75 39
 	;on-frame .Screen/vector DEO2
76
-
77 40
 	( center )
78
-	.Screen/width DEI2 2// 
41
+	.Screen/width DEI2 #01 SFT2 
79 42
 		DUP2 .center/x STZ2
80
-		DUP2 #0028 -- .date/x STZ2
81
-		#0020 -- .time/x STZ2
82
-	.Screen/height DEI2 2// 
43
+		DUP2 #0028 SUB2 .date/x STZ2
44
+		#0020 SUB2 .time/x STZ2
45
+	.Screen/height DEI2 #01 SFT2 
83 46
 		DUP2 .center/y STZ2
84
-		DUP2 #0078 -- .date/y STZ2
85
-		#006c ++ .time/y STZ2
86
-
47
+		DUP2 #0078 SUB2 .date/y STZ2
48
+		#006c ADD2 .time/y STZ2
87 49
 	;draw-watchface JSR2
88
-
89 50
 	( time buffer )
90 51
 	LIT ': 
91 52
 		DUP .buf/s1 STZ
... ...
@@ -97,7 +58,7 @@
97 58
 
98 59
 	( once per second )
99 60
 	.DateTime/second DEI 
100
-	DUP .last/sec LDZ = ,&same-sec JCN
61
+	DUP .last/sec LDZ EQU ,&same-sec JCN
101 62
 		( make time )
102 63
 		.DateTime/hour DEI .buf/h ;decimal JSR2
103 64
 		.DateTime/minute DEI .buf/m ;decimal JSR2
... ...
@@ -116,14 +77,14 @@
116 77
 
117 78
 	( once per day )
118 79
 	.DateTime/day DEI 
119
-	DUP .last/day LDZ = ,&same-day JCN
80
+	DUP .last/day LDZ EQU ,&same-day JCN
120 81
 		( make date )
121 82
 		DUP .buf/d ;decimal JSR2
122 83
 		( draw label )
123 84
 		.date/x LDZ2 .Screen/x DEO2
124 85
 		.date/y LDZ2 .Screen/y DEO2
125
-		.DateTime/dotw DEI 4* TOS ;week-txt ++ ;draw-text JSR2
126
-		.DateTime/month DEI 4* TOS ;month-txt ++ ;draw-text JSR2
86
+		[ #00 .DateTime/dotw DEI #20 SFT ] ;week-txt ADD2 ;draw-text JSR2
87
+		[ #00 .DateTime/month DEI #20 SFT ] ;month-txt ADD2 ;draw-text JSR2
127 88
 		;buf/d ;draw-text JSR2
128 89
 		DUP .last/day STZ
129 90
 		&same-day
... ...
@@ -136,20 +97,20 @@ BRK
136 97
 	STH
137 98
 	.center/x LDZ2 .center/y LDZ2 
138 99
 		OVR2 OVR2
139
-		.needles/zx LDZ2 .needles/zy LDZ2 #02 STHkr * ;draw-line JSR2
100
+		.needles/zx LDZ2 .needles/zy LDZ2 #02 STHkr MUL ;draw-line JSR2
140 101
 		OVR2 OVR2
141
-		.needles/sx LDZ2 .needles/sy LDZ2 #02 STHkr * ;draw-line JSR2
102
+		.needles/sx LDZ2 .needles/sy LDZ2 #02 STHkr MUL ;draw-line JSR2
142 103
 		OVR2 OVR2
143
-		.needles/mx LDZ2 .needles/my LDZ2 #01 STHkr * ;draw-line JSR2
104
+		.needles/mx LDZ2 .needles/my LDZ2 #01 STHkr MUL ;draw-line JSR2
144 105
 		OVR2 OVR2
145
-		.needles/hx LDZ2 .needles/hy LDZ2 #01 STHr * ;draw-line JSR2
106
+		.needles/hx LDZ2 .needles/hy LDZ2 #01 STHr MUL ;draw-line JSR2
146 107
 		( middle )
147
-		#0001 -- .Screen/y DEO2 
148
-		#0001 -- .Screen/x DEO2
108
+		#0001 SUB2 .Screen/y DEO2 
109
+		#0001 SUB2 .Screen/x DEO2
149 110
 		;middle-icn .Screen/addr DEO2
150 111
 		#0a .Screen/sprite DEO
151 112
 
152
-RTN
113
+JMP2r
153 114
 
154 115
 @draw-text ( addr* -- )
155 116
 
... ...
@@ -157,68 +118,68 @@ RTN
157 118
 	.Screen/y DEI2 ,&anchor-y STR2
158 119
 	&while
159 120
 		LDAk
160
-		DUP IS-LC ,&lc JCN
161
-		DUP IS-UC ,&uc JCN
162
-		DUP IS-NUM ,&num JCN
163
-		DUP LIT '/ = ,&slash JCN
164
-		DUP LIT ': = ,&colon JCN
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
165 126
 		POP ;font/blank
166 127
 		&end
167 128
 		.Screen/addr DEO2
168 129
 		#03 .Screen/sprite DEOk DEO
169 130
 		[ LIT2 &anchor-y $2 ] .Screen/y DEO2
170
-		.Screen/x DEI2k #0008 ++ ROT DEO2
131
+		.Screen/x DEI2k #0008 ADD2 ROT DEO2
171 132
 		INC2 LDAk ,&while JCN
172 133
 	POP2
173 134
 	( auto none ) #00 .Screen/auto DEO
174
-	.Screen/x DEI2k #0008 ++ ROT DEO2
135
+	.Screen/x DEI2k #0008 ADD2 ROT DEO2
175 136
 
176
-RTN
177
-	&lc #61 - TOS 10** ;font/lc ++ ,&end JMP
178
-	&uc #41 - TOS 10** ;font/uc ++ ,&end JMP
179
-	&num #30 - TOS 10** ;font/num ++ ,&end JMP
137
+JMP2r
138
+	&lc #61 SUB #00 SWP #40 SFT2 ;font/lc ADD2 ,&end JMP
139
+	&uc #41 SUB #00 SWP #40 SFT2 ;font/uc ADD2 ,&end JMP
140
+	&num #30 SUB #00 SWP #40 SFT2 ;font/num ADD2 ,&end JMP
180 141
 	&slash POP ;font/slash ,&end JMP
181 142
 	&colon POP ;font/colon ,&end JMP
182 143
 
183 144
 @draw-line ( x1* y1* x2* y2* color -- )
184 145
 	
185 146
 	( load ) .line/color STZ .line/y0 STZ2 .line/x0 STZ2 .line/y STZ2 .line/x STZ2
186
-	.line/x0 LDZ2 .line/x LDZ2 -- ABS2 .line/dx STZ2
187
-	.line/y0 LDZ2 .line/y LDZ2 -- ABS2 #0000 SWP2 -- .line/dy STZ2
188
-	#ffff #00 .line/x LDZ2 .line/x0 LDZ2 LTS2 2** ++ .line/sx STZ2
189
-	#ffff #00 .line/y LDZ2 .line/y0 LDZ2 LTS2 2** ++ .line/sy STZ2
190
-	.line/dx LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2
147
+	.line/x0 LDZ2 .line/x LDZ2 SUB2 ;abs2 JSR2 .line/dx STZ2
148
+	.line/y0 LDZ2 .line/y LDZ2 SUB2 ;abs2 JSR2 #0000 SWP2 SUB2 .line/dy STZ2
149
+	#ffff #00 .line/x LDZ2 .line/x0 LDZ2 ;lts2 JSR2 #10 SFT2 ADD2 .line/sx STZ2
150
+	#ffff #00 .line/y LDZ2 .line/y0 LDZ2 ;lts2 JSR2 #10 SFT2 ADD2 .line/sy STZ2
151
+	.line/dx LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
191 152
 	&loop
192 153
 		.line/x LDZ2 .Screen/x DEO2 
193 154
 		.line/y LDZ2 .Screen/y DEO2 
194 155
 		.line/color LDZ .Screen/pixel DEO
195
-		[ .line/x LDZ2 .line/x0 LDZ2 == ] 
196
-		[ .line/y LDZ2 .line/y0 LDZ2 == ] AND ,&end JCN
197
-		.line/e1 LDZ2 2** .line/e2 STZ2
198
-		.line/e2 LDZ2 .line/dy LDZ2 LTS2 ,&skipy JCN
199
-			.line/e1 LDZ2 .line/dy LDZ2 ++ .line/e1 STZ2
200
-			.line/x LDZ2 .line/sx LDZ2 ++ .line/x STZ2
156
+		[ .line/x LDZ2 .line/x0 LDZ2 EQU2 ] 
157
+		[ .line/y LDZ2 .line/y0 LDZ2 EQU2 ] AND ,&end JCN
158
+		.line/e1 LDZ2 #10 SFT2 .line/e2 STZ2
159
+		.line/e2 LDZ2 .line/dy LDZ2 ;lts2 JSR2 ,&skipy JCN
160
+			.line/e1 LDZ2 .line/dy LDZ2 ADD2 .line/e1 STZ2
161
+			.line/x LDZ2 .line/sx LDZ2 ADD2 .line/x STZ2
201 162
 		&skipy
202
-		.line/e2 LDZ2 .line/dx LDZ2 GTS2 ,&skipx JCN
203
-			.line/e1 LDZ2 .line/dx LDZ2 ++ .line/e1 STZ2
204
-			.line/y LDZ2 .line/sy LDZ2 ++ .line/y STZ2
163
+		.line/e2 LDZ2 .line/dx LDZ2 ;gts2 JSR2 ,&skipx JCN
164
+			.line/e1 LDZ2 .line/dx LDZ2 ADD2 .line/e1 STZ2
165
+			.line/y LDZ2 .line/sy LDZ2 ADD2 .line/y STZ2
205 166
 		&skipx
206 167
 		;&loop JMP2
207 168
 	&end
208 169
 
209
-RTN
170
+JMP2r
210 171
 
211 172
 @draw-watchface ( -- )
212 173
 
213 174
 	#3c00 
214 175
 	&loop
215 176
 		( dots )
216
-		#00 OVR 2** ;table ++ LDA2 
177
+		#00 OVR #10 SFT2 ;table ADD2 LDA2 
217 178
 			#0018 ;circle JSR2
218 179
 			.Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO
219 180
 		( markers )
220
-		DUP #05 MOD ,&no-marker JCN
221
-			#00 OVR 2** ;table ++ LDA2 
181
+		DUP #05 ;mod JSR2 ,&no-marker JCN
182
+			#00 OVR #10 SFT2 ;table ADD2 LDA2 
222 183
 			STH2k #0018 ;circle JSR2 SWP2
223 184
 			STH2r #001c ;circle JSR2 SWP2
224 185
 				#01 ;draw-line JSR2
... ...
@@ -226,39 +187,47 @@ RTN
226 187
 		INC GTHk ;&loop JCN2
227 188
 	POP2
228 189
 
229
-RTN
190
+JMP2r
230 191
 
231 192
 @make-needles ( -- )
232 193
 
233
-	[ #00 .DateTime/second DEI #1e + #3c MOD ] 2** ;table ++ LDA2
194
+	[ #00 .DateTime/second DEI #1e ADD #3c ;mod JSR2 ] #10 SFT2 ;table ADD2 LDA2
234 195
 		#00a0 ,circle JSR .needles/zx STZ2 .needles/zy STZ2
235
-	[ #00 .DateTime/second DEI ] 2** ;table ++ LDA2
196
+	[ #00 .DateTime/second DEI ] #10 SFT2 ;table ADD2 LDA2
236 197
 		#0020 ,circle JSR .needles/sx STZ2 .needles/sy STZ2 
237
-	[ #00 .DateTime/minute DEI ] 2** ;table ++ LDA2
198
+	[ #00 .DateTime/minute DEI ] #10 SFT2 ;table ADD2 LDA2
238 199
 		#0022 ,circle JSR .needles/mx STZ2 .needles/my STZ2 
239
-	[ #00 .DateTime/hour DEI 12HOURS #20 SFTk NIP ADD ]
240
-	( minute offset ) [ #00 .DateTime/minute DEI #0f / ++ ] 2** ;table ++ LDA2
200
+	[ #00 .DateTime/hour DEI #0c ;mod JSR2 #20 SFTk NIP ADD ]
201
+	( minute offset ) [ #00 .DateTime/minute DEI #0f DIV ADD2 ] #10 SFT2 ;table ADD2 LDA2
241 202
 		#002a ,circle JSR .needles/hx STZ2 .needles/hy STZ2
242 203
 
243
-RTN
204
+JMP2r
244 205
 
245 206
 @circle ( cx cy radius* -- y* x* )
246 207
 
247 208
 	STH2 SWP
248
-	TOS 10** STH2kr // .center/x LDZ2 ++ #0800 STH2kr // -- 
209
+	#00 SWP #40 SFT2 STH2kr DIV2 .center/x LDZ2 ADD2 #0800 STH2kr DIV2 SUB2
249 210
 	STH2 SWP2r
250
-	TOS 10** STH2kr // .center/y LDZ2 ++ #0800 STH2kr // --
211
+	#00 SWP #40 SFT2 STH2kr DIV2 .center/y LDZ2 ADD2 #0800 STH2kr DIV2 SUB2
251 212
 	POP2r STH2r
252 213
 
253
-RTN
214
+JMP2r
254 215
 
255 216
 @decimal ( value* zp-label -- )
256 217
 
257 218
 	STH
258
-	DUP #0a DIV #30 + STHkr STZ
259
-	#0a MOD #30 + STHr INC STZ
260
-
261
-RTN
219
+	DUP #0a DIV #30 ADD STHkr STZ
220
+	#0a ;mod JSR2 #30 ADD STHr INC STZ
221
+
222
+JMP2r
223
+
224
+@mod DUP2 DIV MUL SUB JMP2r
225
+@abs2 DUP2 #0f SFT2 EQU #05 JCN #0000 SWP2 SUB2 JMP2r
226
+@lts2 #8000 ADD2 SWP2 #8000 ADD2 GTH2 JMP2r
227
+@gts2 #8000 ADD2 SWP2 #8000 ADD2 LTH2 JMP2r
228
+@is-uc DUP #40 GTH SWP #5b LTH AND JMP2r
229
+@is-lc DUP #60 GTH SWP #7b LTH AND JMP2r
230
+@is-num DUP #2f GTH SWP #3a LTH AND JMP2r
262 231
 
263 232
 @week-txt
264 233
 	"Sun $1 "Mon $1 "Tue $1 "Wed $1 "Thu $1 "Fri $1 
265 234
similarity index 100%
266 235
rename from projects/examples/demos/asma-piano.tal
267 236
rename to projects/examples/old/asma-piano.tal
268 237
similarity index 100%
269 238
rename from projects/examples/demos/darena.tal
270 239
rename to projects/examples/old/darena.tal
271 240
similarity index 100%
272 241
rename from projects/examples/demos/dungeon.tal
273 242
rename to projects/examples/old/dungeon.tal
274 243
similarity index 100%
275 244
rename from projects/examples/demos/prng.tal
276 245
rename to projects/examples/old/prng.tal
277 246
similarity index 100%
278 247
rename from projects/examples/demos/rule110.tal
279 248
rename to projects/examples/old/rule110.tal