Browse code

Minor optimizations to demos

neauoire authored on 12/05/2021 18:58:31
Showing 5 changed files
... ...
@@ -42,7 +42,7 @@ then
42 42
 fi
43 43
 
44 44
 echo "Assembling.."
45
-./bin/uxnasm projects/demos/bifurcan.usm bin/boot.rom
45
+./bin/uxnasm projects/demos/drum-rack.usm bin/boot.rom
46 46
 
47 47
 echo "Running.."
48 48
 if [ "${2}" = '--cli' ]; 
... ...
@@ -56,9 +56,9 @@
56 56
 |0100 ( -> )
57 57
 	
58 58
 	( theme ) 
59
-	#4ff2 .System/r DEO2 
60
-	#2f8c .System/g DEO2 
61
-	#afb6 .System/b DEO2
59
+	#0fe5 .System/r DEO2 
60
+	#0fc5 .System/g DEO2 
61
+	#0f25 .System/b DEO2
62 62
 
63 63
 	( vectors )
64 64
 	;on-control .Controller/vector DEO2
... ...
@@ -142,7 +142,7 @@
142 142
 		( draw mixer )
143 143
 		OVR #04 / ;draw-mixer JSR2
144 144
 		( incr ) SWP #01 + SWP
145
-		DUP2 < ,&draw-pads JCN
145
+		LTHk ,&draw-pads JCN
146 146
 	POP2
147 147
 
148 148
 	;draw-octave JSR2
... ...
@@ -160,7 +160,7 @@ BRK
160 160
 		( output ) .Audio0/output STHr #10 * + DEI 
161 161
 		;draw-monitor JSR2
162 162
 		( incr ) SWP #01 + SWP
163
-		DUP2 < ,&loop JCN
163
+		LTHk ,&loop JCN
164 164
 	POP2
165 165
 
166 166
 BRK
... ...
@@ -359,7 +359,7 @@ RTN
359 359
 		.Screen/x DEI2 #0001 ++ .Screen/x DEO2
360 360
 		( draw ) #02 .Screen/color DEO
361 361
 		( incr ) SWP #01 + SWP
362
-		DUP2 < ,&loop JCN
362
+		LTHk ,&loop JCN
363 363
 	POP2
364 364
 	POP2r
365 365
 
... ...
@@ -476,7 +476,7 @@ RTN
476 476
 		.Screen/x DEI2 #0002 -- .Screen/x DEO2
477 477
 		.Screen/y DEI2 #0002 ++ .Screen/y DEO2
478 478
 		( incr ) SWP #01 + SWP
479
-		DUP2 < ,&loop JCN
479
+		LTHk ,&loop JCN
480 480
 	POP2
481 481
 
482 482
 	POPr
... ...
@@ -494,7 +494,7 @@ RTN
494 494
 		( draw ) DUPr STHr .Screen/color DEO
495 495
 		( incr ) .Screen/addr DEI2 #0008 ++ .Screen/addr DEO2  
496 496
 		( incr ) SWP2 #0008 ++ SWP2
497
-		OVR2 OVR2 << ,&loop JCN
497
+		LTH2k ,&loop JCN
498 498
 	POP2 POP2 
499 499
 	POPr
500 500
 
... ...
@@ -77,7 +77,7 @@ BRK
77 77
 	&clear-loop
78 78
 		OVR2 #0000 SWP2 STA2
79 79
 		SWP2 #0002 ++ SWP2
80
-		OVR2 OVR2 !! ,&clear-loop JCN
80
+		NEQ2k ,&clear-loop JCN
81 81
 	POP2 POP2
82 82
 
83 83
 	;run-grid JSR2
... ...
@@ -88,7 +88,7 @@ BRK
88 88
 		OVR2 DUP2 LDA2 
89 89
 		SWP2 #2000 -- STA2
90 90
 		SWP2 #0002 ++ SWP2
91
-		OVR2 OVR2 !! ,&copy-loop JCN
91
+		NEQ2k ,&copy-loop JCN
92 92
 	POP2 POP2
93 93
 
94 94
 	;draw-grid JSR2
... ...
@@ -154,10 +154,10 @@ BRK
154 154
 			OVR TOS #0002 ** .anchor/x LDZ2 ++ .Screen/x DEO2
155 155
 			OVR DUPr STHr ,get-cell JSR INCR .Screen/color DEO
156 156
 			SWP INCR SWP
157
-			DUP2 ! ,&hor JCN
157
+			NEQk ,&hor JCN
158 158
 		POP2 POPr
159 159
 		SWP INCR SWP
160
-		DUP2 ! ,&ver JCN
160
+		NEQk ,&ver JCN
161 161
 	POP2
162 162
 
163 163
 RTN
... ...
@@ -214,10 +214,10 @@ RTN
214 214
 			( state ) STH2r ;get-cell JSR2
215 215
 			,run-cell JSR
216 216
 			SWP INCR SWP
217
-			DUP2 ! ,&hor JCN
217
+			NEQk ,&hor JCN
218 218
 		POP2 POPr
219 219
 		SWP INCR SWP
220
-		DUP2 ! ,&ver JCN
220
+		NEQk ,&ver JCN
221 221
 	POP2
222 222
 
223 223
 RTN 
... ...
@@ -1,9 +1,6 @@
1 1
 ( polycat )
2 2
 
3 3
 %RTN { JMP2r }
4
-%+ { ADD2 } %- { SUB2 } 
5
-%* { MUL2 } %/ { DIV2 } 
6
-%> { GTH2 }
7 4
 
8 5
 ( devices )
9 6
 
... ...
@@ -28,8 +25,8 @@
28 25
 	#0caf .System/b DEO2
29 26
 
30 27
 	( find center )
31
-	.Screen/width DEI2 #0002 / #0008 - .cat/x STZ2
32
-	.Screen/height DEI2 #0004 / #0003 * #0018 - .cat/y STZ2
28
+	.Screen/width DEI2 #0002 DIV2 #0008 SUB2 .cat/x STZ2
29
+	.Screen/height DEI2 #0004 DIV2 #0003 MUL2 #0018 SUB2 .cat/y STZ2
33 30
 
34 31
 	( vectors )
35 32
 	;on-mouse .Mouse/vector DEO2
... ...
@@ -44,8 +41,8 @@ BRK
44 41
 	
45 42
 	;draw-cursor JSR2
46 43
 
47
-	.Mouse/x DEI2 .cat/x LDZ2 > #20 MUL
48
-	.Mouse/y DEI2 .cat/y LDZ2 > #40 MUL
44
+	.Mouse/x DEI2 .cat/x LDZ2 GTH2 #20 MUL
45
+	.Mouse/y DEI2 .cat/y LDZ2 GTH2 #40 MUL
49 46
 		ADD #00 SWP ;draw-eye JSR2
50 47
 
51 48
 BRK
... ...
@@ -67,11 +64,11 @@ BRK
67 64
 
68 65
 	( ears )
69 66
 	.cat/y LDZ2 .Screen/y DEO2
70
-	.cat/x LDZ2 DUP2 STH2 #0008 - .Screen/x DEO2
67
+	.cat/x LDZ2 DUP2 STH2 #0008 SUB2 .Screen/x DEO2
71 68
 	;ears .Screen/addr DEO2
72 69
 	#41 .Screen/color DEO
73 70
 	STH2r .Screen/x DEO2
74
-	;ears #0010 + .Screen/addr DEO2
71
+	;ears #0010 ADD2 .Screen/addr DEO2
75 72
 	#41 .Screen/color DEO
76 73
 
77 74
 	#0000 ,draw-eye JSR
... ...
@@ -81,24 +78,24 @@ RTN
81 78
 
82 79
 @draw-eye ( quad* -- )
83 80
 	
84
-	.cat/y LDZ2 #0008 + .Screen/y DEO2
85
-	.cat/x LDZ2 DUP2 STH2 #0008 - .Screen/x DEO2
86
-	DUP2 ;eye + .Screen/addr DEO2
81
+	.cat/y LDZ2 #0008 ADD2 .Screen/y DEO2
82
+	.cat/x LDZ2 DUP2 STH2 #0008 SUB2 .Screen/x DEO2
83
+	DUP2 ;eye ADD2 .Screen/addr DEO2
87 84
 	( draw ) #41 .Screen/color DEO
88 85
 	STH2r .Screen/x DEO2
89
-	;eye #0010 + + .Screen/addr DEO2
86
+	;eye #0010 ADD2 ADD2 .Screen/addr DEO2
90 87
 	( draw ) #41 .Screen/color DEO
91 88
 
92 89
 RTN
93 90
 
94 91
 @draw-tail ( frame* -- )
95 92
 
96
-	.cat/y LDZ2 #0010 + .Screen/y DEO2
97
-	.cat/x LDZ2 DUP2 STH2 #0008 - .Screen/x DEO2
93
+	.cat/y LDZ2 #0010 ADD2 .Screen/y DEO2
94
+	.cat/x LDZ2 DUP2 STH2 #0008 SUB2 .Screen/x DEO2
98 95
 	;body .Screen/addr DEO2
99 96
 	( draw ) #41 .Screen/color DEO
100 97
 	STH2r .Screen/x DEO2
101
-	#0010 * ;body #0010 + + .Screen/addr DEO2
98
+	#0010 MUL2 ;body #0010 ADD2 ADD2 .Screen/addr DEO2
102 99
 	( draw ) #41 .Screen/color DEO
103 100
 
104 101
 RTN
... ...
@@ -126,17 +123,17 @@ RTN
126 123
 
127 124
 @draw-ground ( -- )
128 125
 
129
-	.cat/y LDZ2 #0018 + .Screen/y DEO2
130
-	.cat/x LDZ2 #0010 - .Screen/x DEO2
126
+	.cat/y LDZ2 #0018 ADD2 .Screen/y DEO2
127
+	.cat/x LDZ2 #0010 SUB2 .Screen/x DEO2
131 128
 	;ground .Screen/addr DEO2
132 129
 
133 130
 	#00 #10
134 131
 	&loop
135 132
 		( draw ) #21 .Screen/color DEO
136
-		( sety ) .Screen/addr DEI2 #0008 + .Screen/addr DEO2
137
-		( setx ) .Screen/x DEI2 #0008 + .Screen/x DEO2
133
+		( sety ) .Screen/addr DEI2 #0008 ADD2 .Screen/addr DEO2
134
+		( setx ) .Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
138 135
 		( incr ) SWP #01 ADD SWP
139
-		DUP2 LTH ,&loop JCN
136
+		LTHk ,&loop JCN
140 137
 	POP2
141 138
 
142 139
 RTN
... ...
@@ -125,7 +125,7 @@ RTN
125 125
 	&draw-hor
126 126
 		( draw ) #01 .Screen/color DEO
127 127
 		( incr ) SWP2 #0002 ADD2 DUP2 .Screen/x DEO2 SWP2
128
-		OVR2 OVR2 LTH2 ,&draw-hor JCN
128
+		LTH2k ,&draw-hor JCN
129 129
 	POP2 POP2
130 130
 
131 131
 	( draw ver line )
... ...
@@ -134,7 +134,7 @@ RTN
134 134
 	&draw-ver
135 135
 		( draw ) #02 .Screen/color DEO
136 136
 		( incr ) SWP2 #0002 ADD2 DUP2 .Screen/y DEO2 SWP2
137
-		OVR2 OVR2 LTH2 ,&draw-ver JCN
137
+		LTH2k ,&draw-ver JCN
138 138
 	POP2 POP2
139 139
 
140 140
 	( draw blending modes )
... ...
@@ -145,7 +145,7 @@ RTN
145 145
 		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
146 146
 		( draw ) OVR .Screen/color DEO
147 147
 		( incr ) SWP #01 ADD SWP
148
-		DUP2 LTH ,&draw-pixel1 JCN
148
+		LTHk ,&draw-pixel1 JCN
149 149
 	POP POP
150 150
 	#0018 .Screen/y DEO2
151 151
 	#00 #08
... ...
@@ -153,7 +153,7 @@ RTN
153 153
 		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
154 154
 		( draw ) OVR #08 ADD .Screen/color DEO
155 155
 		( incr ) SWP #01 ADD SWP
156
-		DUP2 LTH ,&draw-pixel2 JCN
156
+		LTHk ,&draw-pixel2 JCN
157 157
 	POP POP
158 158
 	#0020 .Screen/y DEO2
159 159
 	#00 #08
... ...
@@ -161,7 +161,7 @@ RTN
161 161
 		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
162 162
 		( draw ) OVR #20 ADD .Screen/color DEO
163 163
 		( incr ) SWP #01 ADD SWP
164
-		DUP2 LTH ,&draw-icn1 JCN
164
+		LTHk ,&draw-icn1 JCN
165 165
 	POP POP
166 166
 	#0028 .Screen/y DEO2
167 167
 	#00 #08
... ...
@@ -169,7 +169,7 @@ RTN
169 169
 		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
170 170
 		( draw ) OVR #28 ADD .Screen/color DEO
171 171
 		( incr ) SWP #01 ADD SWP
172
-		DUP2 LTH ,&draw-icn2 JCN
172
+		LTHk ,&draw-icn2 JCN
173 173
 	POP POP
174 174
 	#0030 .Screen/y DEO2
175 175
 	#00 #08
... ...
@@ -177,7 +177,7 @@ RTN
177 177
 		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
178 178
 		( draw ) OVR #40 ADD .Screen/color DEO
179 179
 		( incr ) SWP #01 ADD SWP
180
-		DUP2 LTH ,&draw-chr1 JCN
180
+		LTHk ,&draw-chr1 JCN
181 181
 	POP POP
182 182
 	#0038 .Screen/y DEO2
183 183
 	#00 #08
... ...
@@ -185,7 +185,7 @@ RTN
185 185
 		( move ) OVR #08 MUL #00 SWP #0010 ADD2 .Screen/x DEO2
186 186
 		( draw ) OVR #48 ADD .Screen/color DEO
187 187
 		( incr ) SWP #01 ADD SWP
188
-		DUP2 LTH ,&draw-chr2 JCN
188
+		LTHk ,&draw-chr2 JCN
189 189
 	POP POP
190 190
 
191 191
 RTN
... ...
@@ -293,10 +293,10 @@ RTN
293 293
 			( save ) OVR2 .Screen/x DEO2
294 294
 			( draw ) .color LDZ .Screen/color DEO
295 295
 			( incr ) SWP2 #0001 ADD2 SWP2
296
-			OVR2 OVR2 LTH2 ,&hor JCN
296
+			LTH2k ,&hor JCN
297 297
 		POP2 POP2 STH2r STH2r
298 298
 		( incr ) SWP2 #0001 ADD2 SWP2
299
-		OVR2 OVR2 LTH2 ,&ver JCN
299
+		LTH2k ,&ver JCN
300 300
 	POP2 POP2 POP2 POP2
301 301
 
302 302
 RTN