Browse code

(logic.tal) Renamed to bitwise.tal

Devine Lu Linvega authored on 17/08/2022 07:12:39
Showing 2 changed files
1 1
similarity index 66%
2 2
rename from projects/examples/demos/logic.tal
3 3
rename to projects/examples/demos/bitwise.tal
... ...
@@ -1,31 +1,4 @@
1
-( logic )
2
-
3
-%+  { ADD } %-   { SUB }              %/   { DIV }  
4
-%<  { LTH } %>   { GTH }  %=  { EQU } %!   { NEQ } 
5
-%++ { ADD2 } %-- { SUB2 }              %// { DIV2 } 
6
-%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 }  
7
-
8
-%2*  { #10 SFT } %2/  { #01 SFT }
9
-%4*  { #20 SFT } %4/  { #02 SFT }
10
-%8*  { #30 SFT } %8/  { #03 SFT }
11
-%10* { #40 SFT } %10/ { #04 SFT }
12
-%20* { #50 SFT } %20/ { #05 SFT }
13
-
14
-%2**  { #10 SFT2 } %2//  { #01 SFT2 }
15
-%4**  { #20 SFT2 } %4//  { #02 SFT2 }
16
-%8**  { #30 SFT2 } %8//  { #03 SFT2 }
17
-%10** { #40 SFT2 } %10// { #04 SFT2 }
18
-%20** { #50 SFT2 } %20// { #05 SFT2 }
19
-
20
-%RELEASE-MOUSE { #0096 DEO }
21
-%AUTO-X { #01 .Screen/auto DEO }
22
-%AUTO-X-ADDR { #05 .Screen/auto DEO }
23
-%AUTO-NONE { #00 .Screen/auto DEO }
24
-
25
-%RTN { JMP2r }
26
-%TOS { #00 SWP }
27
-
28
-( devices )
1
+( bitwise )
29 2
 
30 3
 |00 @System     [ &vector $2 &wst      $1 &rst    $1 &pad   $4 &r      $2 &g      $2 &b    $2 &debug  $1 &halt $1 ]
31 4
 |10 @Console    [ &vector $2 &read     $1 &pad    $5 &write $1 &error  $1 ]
... ...
@@ -63,13 +36,13 @@
63 36
 
64 37
 	;on-mouse   .Mouse/vector DEO2
65 38
 
66
-	.Screen/width DEI2 2// 
67
-		DUP2 #0040 -- .a-frame/x STZ2 DUP2 #0040 ++ .a-frame/x2 STZ2
68
-		DUP2 #0040 -- .b-frame/x STZ2 #0040 ++ .b-frame/x2 STZ2
39
+	.Screen/width DEI2 #01 SFT2
40
+		DUP2 #0040 SUB2 .a-frame/x STZ2 DUP2 #0040 ADD2 .a-frame/x2 STZ2
41
+		DUP2 #0040 SUB2 .b-frame/x STZ2 #0040 ADD2 .b-frame/x2 STZ2
69 42
 
70
-	.Screen/height DEI2 2// #0020 --
71
-		DUP2 #0010 -- .a-frame/y STZ2 DUP2 #0000 ++ .a-frame/y2 STZ2
72
-		DUP2 .b-frame/y STZ2 #0010 ++ .b-frame/y2 STZ2
43
+	.Screen/height DEI2 #01 SFT2 #0020 SUB2
44
+		DUP2 #0010 SUB2 .a-frame/y STZ2 DUP2 .a-frame/y2 STZ2
45
+		DUP2 .b-frame/y STZ2 #0010 ADD2 .b-frame/y2 STZ2
73 46
 
74 47
 	;redraw JSR2
75 48
 
... ...
@@ -79,7 +52,7 @@ BRK
79 52
 
80 53
 	;draw-cursor JSR2 
81 54
 	
82
-	.Mouse/state DEI #00 ! JMP [ BRK ]
55
+	.Mouse/state DEI #00 NEQ JMP [ BRK ]
83 56
 
84 57
 	.Mouse/x DEI2 .Mouse/y DEI2 .a-frame ;within-rect JSR2 
85 58
 		;on-touch-a JCN2
... ...
@@ -90,29 +63,29 @@ BRK
90 63
 
91 64
 @on-touch-a ( -> )
92 65
 
93
-	.Mouse/x DEI2 .a-frame/x LDZ2 -- 
94
-	10// NIP #07 SWP - STH
66
+	.Mouse/x DEI2 .a-frame/x LDZ2 SUB2
67
+	#04 SFT2 NIP #07 SWP SUB STH
95 68
 
96 69
 	.input/a LDZ 
97 70
 		#01 [ STHr #40 SFT ] SFT EOR 
98 71
 		.input/a STZ
99 72
 
100 73
 	;redraw JSR2
101
-	RELEASE-MOUSE
74
+	#00 .Mouse/state DEO
102 75
 
103 76
 BRK
104 77
 
105 78
 @on-touch-b ( -> )
106 79
 
107
-	.Mouse/x DEI2 .b-frame/x LDZ2 -- 
108
-	10// NIP #07 SWP - STH
80
+	.Mouse/x DEI2 .b-frame/x LDZ2 SUB2
81
+	#04 SFT2 NIP #07 SWP SUB STH
109 82
 
110 83
 	.input/b LDZ 
111 84
 		#01 [ STHr #40 SFT ] SFT EOR 
112 85
 		.input/b STZ
113 86
 
114 87
 	;redraw JSR2
115
-	RELEASE-MOUSE
88
+	#00 .Mouse/state DEO
116 89
 
117 90
 BRK
118 91
 
... ...
@@ -127,82 +100,82 @@ BRK
127 100
 	.input/b LDZ #01 ;draw-byte JSR2
128 101
 
129 102
 	.b-frame/x LDZ2 .Screen/x DEO2
130
-	.Screen/y DEI2 #000d ++ .Screen/y DEO2
103
+	.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
131 104
 	.input LDZ2 AND #03 ;draw-byte JSR2
132 105
 
133 106
 	.b-frame/x LDZ2 .Screen/x DEO2
134
-	.Screen/y DEI2 #000d ++ .Screen/y DEO2
107
+	.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
135 108
 	.input LDZ2 ORA #03 ;draw-byte JSR2
136 109
 
137 110
 	.b-frame/x LDZ2 .Screen/x DEO2
138
-	.Screen/y DEI2 #000d ++ .Screen/y DEO2
111
+	.Screen/y DEI2 #000d ADD2 .Screen/y DEO2
139 112
 	.input LDZ2 EOR #03 ;draw-byte JSR2
140 113
 
141 114
 	( labels )
142
-	AUTO-X-ADDR
143
-	.b-frame/x LDZ2 #0020 -- .Screen/x DEO2
115
+	#05 .Screen/auto DEO
116
+	.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
144 117
 	;names-icn/and .Screen/addr DEO2
145
-	.b-frame/y2 LDZ2 #0004 ++ .Screen/y DEO2
118
+	.b-frame/y2 LDZ2 #0004 ADD2 .Screen/y DEO2
146 119
 	,&draw-label JSR
147
-	.b-frame/y2 LDZ2 #0014 ++ .Screen/y DEO2
120
+	.b-frame/y2 LDZ2 #0014 ADD2 .Screen/y DEO2
148 121
 	,&draw-label JSR
149
-	.b-frame/y2 LDZ2 #0024 ++ .Screen/y DEO2
122
+	.b-frame/y2 LDZ2 #0024 ADD2 .Screen/y DEO2
150 123
 	,&draw-label JSR
151
-	AUTO-NONE
124
+	#00 .Screen/auto DEO
152 125
 
153
-RTN
126
+JMP2r
154 127
 	&draw-label
155
-		.b-frame/x LDZ2 #0020 -- .Screen/x DEO2 
128
+		.b-frame/x LDZ2 #0020 SUB2 .Screen/x DEO2
156 129
 		#03 .Screen/sprite DEOk DEOk DEO
157
-	RTN
130
+	JMP2r
158 131
 
159 132
 @draw-byte ( value -- )
160 133
 
161 134
 	STH STH
162 135
 	#0800
163 136
 	&loop
164
-		DUP #07 SWP -
137
+		#07 OVR SUB
165 138
 		STHkr SWP SFT #01 AND OVRr STHr ;draw-bit JSR2
166 139
 		INC GTHk ,&loop JCN
167 140
 	POP2
168
-	.Screen/y DEI2 #0003 ++ .Screen/y DEO2
169
-	.Screen/x DEI2 #0008 ++ .Screen/x DEO2
141
+	.Screen/y DEI2 #0003 ADD2 .Screen/y DEO2
142
+	.Screen/x DEI2 #0008 ADD2 .Screen/x DEO2
170 143
 	STHr ;draw-hex JSR2
171 144
 	POPr
172 145
 
173
-RTN
146
+JMP2r
174 147
 
175 148
 @draw-bit ( value color -- )
176 149
 
177 150
 	STH STH
178 151
 
179
-	AUTO-X-ADDR
180
-	;button-icns/off [ #00 STHkr 20* ++ ] .Screen/addr DEO2
152
+	#05 .Screen/auto DEO
153
+	;button-icns/off [ #00 STHkr #50 SFT ADD2 ] .Screen/addr DEO2
181 154
 	OVRr STHr .Screen/sprite DEO
182 155
 	OVRr STHr .Screen/sprite DEO
183
-	.Screen/y DEI2 #0008 ++ .Screen/y DEO2
184
-	.Screen/x DEI2 #0010 -- .Screen/x DEO2
156
+	.Screen/y DEI2 #0008 ADD2 .Screen/y DEO2
157
+	.Screen/x DEI2 #0010 SUB2 .Screen/x DEO2
185 158
 	OVRr STHr .Screen/sprite DEO
186 159
 	OVRr STHr .Screen/sprite DEO
187
-	AUTO-NONE
188
-	.Screen/y DEI2 #0008 -- .Screen/y DEO2
160
+	#00 .Screen/auto DEO
161
+	.Screen/y DEI2 #0008 SUB2 .Screen/y DEO2
189 162
 
190
-	POPr POPr
163
+	POP2r
191 164
 
192
-RTN
165
+JMP2r
193 166
 
194 167
 @draw-hex ( value -- )
195 168
 
196
-	AUTO-X
169
+	#01 .Screen/auto DEO
197 170
 	DUP #04 SFT ,&draw JSR
198 171
 	#0f AND ,&draw JSR
199
-	AUTO-X
172
+	#01 .Screen/auto DEO
200 173
 
201
-RTN
174
+JMP2r
202 175
 	&draw
203
-		TOS 8** ;font-hex ++ .Screen/addr DEO2
176
+		#00 SWP #30 SFT2 ;font-hex ADD2 .Screen/addr DEO2
204 177
 		( draw ) #01 .Screen/sprite DEO
205
-	RTN
178
+	JMP2r
206 179
 
207 180
 @draw-cursor ( -- )
208 181
 	
... ...
@@ -215,26 +188,26 @@ RTN
215 188
 	.Mouse/x DEI2 DUP2 .pointer/x STZ2 .Screen/x DEO2 
216 189
 	.Mouse/y DEI2 DUP2 .pointer/y STZ2 .Screen/y DEO2  
217 190
 	( colorize on state )
218
-	#42 [ .Mouse/state DEI #00 ! ] + .Screen/sprite DEO
191
+	#42 [ .Mouse/state DEI #00 NEQ ] ADD .Screen/sprite DEO
219 192
 
220
-RTN
193
+JMP2r
221 194
 
222 195
 @within-rect ( x* y* rect -- flag )
223 196
 	
224 197
 	STH
225
-	( y < rect.y1 ) DUP2 STHkr #02 ADD LDZ2 LTH2 ,&skip JCN
198
+	( y < rect.y1 ) DUP2 STHkr INC INC LDZ2 LTH2 ,&skip JCN
226 199
 	( y > rect.y2 ) DUP2 STHkr #06 ADD LDZ2 GTH2 ,&skip JCN
227 200
 	SWP2
228 201
 	( x < rect.x1 ) DUP2 STHkr LDZ2 LTH2 ,&skip JCN
229 202
 	( x > rect.x2 ) DUP2 STHkr #04 ADD LDZ2 GTH2 ,&skip JCN
230 203
 	POP2 POP2 POPr
231 204
 	#01 
232
-RTN
205
+JMP2r
233 206
 	&skip
234 207
 	POP2 POP2 POPr
235 208
 	#00
236 209
 
237
-RTN
210
+JMP2r
238 211
 
239 212
 @cursor 
240 213
 	80c0 e0f0 f8e0 1000 
... ...
@@ -33,7 +33,7 @@ BRK
33 33
 		;&buf LDA2 ,print JSR #2018 DEO
34 34
 		INC2r
35 35
 		( linebreak )
36
-		STH2kr #0007 AND2 ORA ,&no-lb JCN
36
+		STH2kr #000f AND2 ORA ,&no-lb JCN
37 37
 			#0a18 DEO &no-lb
38 38
 		,&stream JMP &eof
39 39
 	POP2r