... | ... |
@@ -25,6 +25,7 @@ Build the assembler and emulator by running the `build.sh` script. The assembler |
25 | 25 |
./build.sh |
26 | 26 |
--debug # Add debug flags to compiler |
27 | 27 |
--format # Format source code |
28 |
+ --install # Copy to ~/bin |
|
28 | 29 |
``` |
29 | 30 |
|
30 | 31 |
If you wish to build the emulator without graphics mode: |
... | ... |
@@ -2,6 +2,7 @@ |
2 | 2 |
|
3 | 3 |
format=0 |
4 | 4 |
console=0 |
5 |
+install=0 |
|
5 | 6 |
debug=0 |
6 | 7 |
norun=0 |
7 | 8 |
|
... | ... |
@@ -17,6 +18,11 @@ while [ $# -gt 0 ]; do |
17 | 18 |
shift |
18 | 19 |
;; |
19 | 20 |
|
21 |
+ --install) |
|
22 |
+ install=1 |
|
23 |
+ shift |
|
24 |
+ ;; |
|
25 |
+ |
|
20 | 26 |
--debug) |
21 | 27 |
debug=1 |
22 | 28 |
shift |
... | ... |
@@ -101,7 +107,7 @@ ${CC} ${CFLAGS} src/uxnasm.c -o bin/uxnasm |
101 | 107 |
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/devices/mouse.c src/devices/controller.c src/devices/screen.c src/devices/audio.c src/uxnemu.c ${UXNEMU_LDFLAGS} -o bin/uxnemu |
102 | 108 |
${CC} ${CFLAGS} ${CORE} src/devices/system.c src/devices/file.c src/devices/datetime.c src/uxncli.c -o bin/uxncli |
103 | 109 |
|
104 |
-if [ -d "$HOME/bin" ] |
|
110 |
+if [ $install = 1 ] |
|
105 | 111 |
then |
106 | 112 |
echo "Installing in $HOME/bin" |
107 | 113 |
cp bin/uxnemu bin/uxnasm bin/uxncli $HOME/bin/ |
... | ... |
@@ -19,7 +19,7 @@ |
19 | 19 |
%LTS2 { #8000 ++ SWP2 #8000 ++ GTH2 } |
20 | 20 |
%GTS2 { #8000 ++ SWP2 #8000 ++ LTH2 } |
21 | 21 |
|
22 |
-%RADIUS { #0040 } |
|
22 |
+%RADIUS { #0040 } |
|
23 | 23 |
%SCALEX { 2// .center/x LDZ2 ++ RADIUS -- } |
24 | 24 |
%SCALEY { 2// .center/y LDZ2 ++ RADIUS -- } |
25 | 25 |
%12HOURS { #0c MOD } |
... | ... |
@@ -144,7 +144,8 @@ BRK |
144 | 144 |
OVR2 OVR2 |
145 | 145 |
.needles/hx LDZ2 .needles/hy LDZ2 #01 STHr * ;draw-line JSR2 |
146 | 146 |
( middle ) |
147 |
- #0001 -- .Screen/y DEO2 #0001 -- .Screen/x DEO2 |
|
147 |
+ #0001 -- .Screen/y DEO2 |
|
148 |
+ #0001 -- .Screen/x DEO2 |
|
148 | 149 |
;middle-icn .Screen/addr DEO2 |
149 | 150 |
#0a .Screen/sprite DEO |
150 | 151 |
|
... | ... |
@@ -153,6 +154,7 @@ RTN |
153 | 154 |
@draw-text ( addr* -- ) |
154 | 155 |
|
155 | 156 |
( auto addr ) #06 .Screen/auto DEO |
157 |
+ .Screen/y DEI2 ,&anchor-y STR2 |
|
156 | 158 |
&while |
157 | 159 |
LDAk |
158 | 160 |
DUP IS-LC ,&lc JCN |
... | ... |
@@ -163,13 +165,13 @@ RTN |
163 | 165 |
POP ;font/blank |
164 | 166 |
&end |
165 | 167 |
.Screen/addr DEO2 |
166 |
- #0303 .Screen/sprite DEO .Screen/sprite DEO |
|
167 |
- .Screen/y DEI2 #0010 -- .Screen/y DEO2 |
|
168 |
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2 |
|
168 |
+ #03 .Screen/sprite DEOk DEO |
|
169 |
+ [ LIT2 &anchor-y $2 ] .Screen/y DEO2 |
|
170 |
+ .Screen/x DEI2k #0008 ++ ROT DEO2 |
|
169 | 171 |
INC2 LDAk ,&while JCN |
170 | 172 |
POP2 |
171 | 173 |
( auto none ) #00 .Screen/auto DEO |
172 |
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2 |
|
174 |
+ .Screen/x DEI2k #0008 ++ ROT DEO2 |
|
173 | 175 |
|
174 | 176 |
RTN |
175 | 177 |
&lc #61 - TOS 10** ;font/lc ++ ,&end JMP |
... | ... |
@@ -211,12 +213,12 @@ RTN |
211 | 213 |
#3c00 |
212 | 214 |
&loop |
213 | 215 |
( dots ) |
214 |
- DUP TOS 2** ;table ++ LDA2 |
|
216 |
+ #00 OVR 2** ;table ++ LDA2 |
|
215 | 217 |
#0018 ;circle JSR2 |
216 | 218 |
.Screen/x DEO2 .Screen/y DEO2 #01 .Screen/pixel DEO |
217 | 219 |
( markers ) |
218 | 220 |
DUP #05 MOD ,&no-marker JCN |
219 |
- DUP TOS 2** ;table ++ LDA2 |
|
221 |
+ #00 OVR 2** ;table ++ LDA2 |
|
220 | 222 |
STH2k #0018 ;circle JSR2 SWP2 |
221 | 223 |
STH2r #001c ;circle JSR2 SWP2 |
222 | 224 |
#01 ;draw-line JSR2 |
... | ... |
@@ -243,9 +245,9 @@ RTN |
243 | 245 |
@circle ( cx cy radius* -- y* x* ) |
244 | 246 |
|
245 | 247 |
STH2 SWP |
246 |
- TOS 10** STH2kr // .center/x LDZ2 ++ #0080 10** STH2kr // -- |
|
248 |
+ TOS 10** STH2kr // .center/x LDZ2 ++ #0800 STH2kr // -- |
|
247 | 249 |
STH2 SWP2r |
248 |
- TOS 10** STH2kr // .center/y LDZ2 ++ #0080 10** STH2kr // -- |
|
250 |
+ TOS 10** STH2kr // .center/y LDZ2 ++ #0800 STH2kr // -- |
|
249 | 251 |
POP2r STH2r |
250 | 252 |
|
251 | 253 |
RTN |
... | ... |
@@ -30,11 +30,14 @@ |
30 | 30 |
%GET-ITERATORS { SWP2k POP NIP } |
31 | 31 |
%GET-ITER { OVR2 NIP OVR SWP } |
32 | 32 |
|
33 |
+%AUTO-NONE { #00 .Screen/auto DEO } |
|
34 |
+%AUTO-X { #01 .Screen/auto DEO } |
|
35 |
+ |
|
33 | 36 |
( devices ) |
34 | 37 |
|
35 | 38 |
|00 @System [ &vector $2 &wst $1 &rst $1 &pad $4 &r $2 &g $2 &b $2 ] |
36 | 39 |
|10 @Console [ &vector $2 &read $1 &pad $5 &write $1 &error $1 ] |
37 |
-|20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 ] |
|
40 |
+|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 |
|
38 | 41 |
|30 @Audio0 [ &vector $2 &position $2 &output $1 &pad $3 &adsr $2 &length $2 &addr $2 &volume $1 &pitch $1 ] |
39 | 42 |
|80 @Controller [ &vector $2 &button $1 &key $1 ] |
40 | 43 |
|90 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &wheel $1 ] |
... | ... |
@@ -201,14 +204,16 @@ BRK |
201 | 204 |
( draw cell count ) |
202 | 205 |
.anchor/x LDZ2 .Screen/x DEO2 |
203 | 206 |
.anchor/y LDZ2 HEIGHT DUP ADD TOS ++ .Screen/y DEO2 |
207 |
+ AUTO-X |
|
204 | 208 |
.world/count LDZ2 #03 ;draw-short JSR2 |
209 |
+ AUTO-NONE |
|
205 | 210 |
|
206 | 211 |
HEIGHT #00 |
207 | 212 |
&ver |
208 |
- DUP TOS 2** .anchor/y LDZ2 ++ .Screen/y DEO2 |
|
213 |
+ #00 OVR 2** .anchor/y LDZ2 ++ .Screen/y DEO2 |
|
209 | 214 |
WIDTH #00 |
210 | 215 |
&hor |
211 |
- DUP TOS 2** .anchor/x LDZ2 ++ .Screen/x DEO2 |
|
216 |
+ #00 OVR 2** .anchor/x LDZ2 ++ .Screen/x DEO2 |
|
212 | 217 |
GET-ITER ,get-cell JSR INC .Screen/pixel DEO |
213 | 218 |
INC GTHk ,&hor JCN |
214 | 219 |
POP2 |
... | ... |
@@ -267,18 +272,18 @@ RTN |
267 | 272 |
|
268 | 273 |
@draw-short ( short* color -- ) |
269 | 274 |
|
270 |
- STH SWP |
|
271 |
- DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 |
|
272 |
- ( draw ) STHkr .Screen/sprite DEO |
|
273 |
- #0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 |
|
274 |
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2 |
|
275 |
- ( draw ) STHkr .Screen/sprite DEO |
|
276 |
- DUP #04 SFT TOS 8** ;font-hex ++ .Screen/addr DEO2 |
|
277 |
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2 |
|
278 |
- ( draw ) STHkr .Screen/sprite DEO |
|
279 |
- #0f AND TOS 8** ;font-hex ++ .Screen/addr DEO2 |
|
280 |
- .Screen/x DEI2 #0008 ++ .Screen/x DEO2 |
|
281 |
- ( draw ) STHr .Screen/sprite DEO |
|
275 |
+ ;draw-char/color STA |
|
276 |
+ SWP ,draw-byte JSR |
|
277 |
+ |
|
278 |
+@draw-byte ( byte -- ) |
|
279 |
+ |
|
280 |
+ DUP #04 SFT ,draw-char JSR |
|
281 |
+ #0f AND |
|
282 |
+ |
|
283 |
+@draw-char ( char -- ) |
|
284 |
+ |
|
285 |
+ TOS 8** ;font-hex ++ .Screen/addr DEO2 |
|
286 |
+ [ LIT &color $1 ] .Screen/sprite DEO |
|
282 | 287 |
|
283 | 288 |
RTN |
284 | 289 |
|
... | ... |
@@ -365,7 +365,7 @@ RTN |
365 | 365 |
.wave-view/y1 LDZ2 #0010 ++ .Screen/y DEO2 |
366 | 366 |
#03 .Screen/pixel DEO |
367 | 367 |
&no-dot |
368 |
- DUP TOS .Audio0/addr DEI2 ++ LDA |
|
368 |
+ #00 OVR .Audio0/addr DEI2 ++ LDA |
|
369 | 369 |
2/ |
370 | 370 |
TOS 4// .wave-view/y1 LDZ2 ++ .Screen/y DEO2 |
371 | 371 |
.Screen/x DEI2 INC2 .Screen/x DEO2 |
... | ... |
@@ -1,13 +1,14 @@ |
1 |
-( wireworld ) |
|
2 |
- |
|
3 | 1 |
( |
4 |
- #00 empty - black |
|
5 |
- #01 conductor - yellow |
|
6 |
- #02 electron tail - red |
|
7 |
- #03 electron head - blue |
|
8 |
- |
|
9 |
- RULES |
|
10 |
- |
|
2 |
+ wireworld |
|
3 |
+ |
|
4 |
+ A - conductor |
|
5 |
+ B - tail |
|
6 |
+ Sel - head |
|
7 |
+ Start - clear |
|
8 |
+ mouse1 - paint |
|
9 |
+ mouse2 - erase |
|
10 |
+ |
|
11 |
+ RULES: |
|
11 | 12 |
- electron head(3), becomes electron tail(2) |
12 | 13 |
- electron tail(2), becomes conductor(1) |
13 | 14 |
- conductor(1), becomes electron head(3) |
... | ... |
@@ -18,6 +19,8 @@ |
18 | 19 |
%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } |
19 | 20 |
%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } |
20 | 21 |
|
22 |
+%!~ { NEQk NIP } |
|
23 |
+ |
|
21 | 24 |
%2* { #10 SFT } %2/ { #01 SFT } %2** { #10 SFT2 } %2// { #01 SFT2 } |
22 | 25 |
%4* { #20 SFT } %4/ { #02 SFT } %4** { #20 SFT2 } %4// { #02 SFT2 } |
23 | 26 |
%8* { #30 SFT } %8/ { #03 SFT } %8** { #30 SFT2 } %8// { #03 SFT2 } |
... | ... |
@@ -77,33 +80,11 @@ BRK |
77 | 80 |
.timer/frame LDZk |
78 | 81 |
#03 AND ,&no-run JCN |
79 | 82 |
;run JSR2 |
80 |
- ( Swap worlds ) |
|
81 |
- ;get-addr/current LDA2k ;run/future LDA2 STH2k |
|
82 |
- ++ SWP2 STA2 #0000 STH2r -- ;run/future STA2 |
|
83 |
- ;redraw JSR2 |
|
84 | 83 |
&no-run |
85 | 84 |
LDZk INC SWP STZ |
86 | 85 |
|
87 | 86 |
BRK |
88 | 87 |
|
89 |
-@on-button ( -> ) |
|
90 |
- |
|
91 |
- .Controller/button DEI |
|
92 |
- DUP #01 ! ,&no-a JCN #01 .color STZ &no-a |
|
93 |
- DUP #02 ! ,&no-b JCN #02 .color STZ &no-b |
|
94 |
- DUP #04 ! ,&no-select JCN #03 .color STZ &no-select |
|
95 |
- DUP #08 ! ,&no-start JCN #00 .color STZ &no-start |
|
96 |
- DUP #0c ! ,&no-both JCN |
|
97 |
- ;world LENGTH 2** ;mclr JSR2 |
|
98 |
- ;redraw JSR2 |
|
99 |
- &no-both |
|
100 |
- POP |
|
101 |
- ( space ) |
|
102 |
- .Controller/key DEI #20 ! ,&no-space JCN |
|
103 |
- .timer/play LDZk #00 = SWP STZ &no-space |
|
104 |
- |
|
105 |
-BRK |
|
106 |
- |
|
107 | 88 |
@on-mouse ( -> ) |
108 | 89 |
|
109 | 90 |
;pointer-icn .Screen/addr DEO2 |
... | ... |
@@ -125,16 +106,33 @@ BRK |
125 | 106 |
|
126 | 107 |
BRK |
127 | 108 |
|
109 |
+@on-button ( -> ) |
|
110 |
+ |
|
111 |
+ .Controller/button DEI |
|
112 |
+ [ #01 ] !~ ,&no-a JCN #01 .color STZ &no-a |
|
113 |
+ [ #02 ] !~ ,&no-b JCN #02 .color STZ &no-b |
|
114 |
+ [ #04 ] !~ ,&no-select JCN #03 .color STZ &no-select |
|
115 |
+ [ #08 ] !~ ,&no-start JCN |
|
116 |
+ ;world LENGTH 2** ;mclr JSR2 |
|
117 |
+ ,redraw JSR |
|
118 |
+ &no-start |
|
119 |
+ POP |
|
120 |
+ ( space ) |
|
121 |
+ .Controller/key DEI #20 ! ,&no-space JCN |
|
122 |
+ .timer/play LDZk #00 = SWP STZ &no-space |
|
123 |
+ |
|
124 |
+BRK |
|
125 |
+ |
|
128 | 126 |
@redraw ( -- ) |
129 | 127 |
|
130 | 128 |
;cell-icn .Screen/addr DEO2 |
131 | 129 |
HEIGHT #00 |
132 | 130 |
&ver |
133 |
- DUP TOS 4** .Screen/y DEO2 |
|
131 |
+ #00 OVR 4** .Screen/y DEO2 |
|
134 | 132 |
STHk |
135 | 133 |
WIDTH #00 |
136 | 134 |
&hor |
137 |
- DUP TOS 4** .Screen/x DEO2 |
|
135 |
+ #00 OVR 4** .Screen/x DEO2 |
|
138 | 136 |
DUP STHkr ,get-addr JSR LDA .Screen/sprite DEO |
139 | 137 |
INC GTHk ,&hor JCN |
140 | 138 |
POP2 |
... | ... |
@@ -159,6 +157,10 @@ RTN |
159 | 157 |
POPr |
160 | 158 |
INC GTHk ,&ver JCN |
161 | 159 |
POP2 |
160 |
+ ( Swap worlds ) |
|
161 |
+ ;get-addr/current LDA2k ;run/future LDA2 STH2k ++ SWP2 STA2 |
|
162 |
+ #0000 STH2r -- ;run/future STA2 |
|
163 |
+ ,redraw JSR |
|
162 | 164 |
|
163 | 165 |
RTN |
164 | 166 |
|
... | ... |
@@ -232,7 +232,7 @@ BRK |
232 | 232 |
@push-input ( key -- ) |
233 | 233 |
|
234 | 234 |
DUP #50 + .Audio0/pitch DEO |
235 |
- DUP TOS ;keypad/series ++ LDA ;draw-keypad JSR2 |
|
235 |
+ #00 OVR ;keypad/series ++ LDA ;draw-keypad JSR2 |
|
236 | 236 |
( hex/dec ) |
237 | 237 |
TOS .input/value LDZ2 #00 [ #0a #10 .input/mode LDZ JMP SWP POP ] ** |
238 | 238 |
++ .input/value STZ2 |
... | ... |
@@ -454,7 +454,7 @@ RTN |
454 | 454 |
#08 #00 |
455 | 455 |
&loop |
456 | 456 |
.input-frame/x LDZ2 #0018 ++ .Screen/x DEO2 |
457 |
- DUP TOS 8** .input-frame/y LDZ2 ++ #004c -- .Screen/y DEO2 |
|
457 |
+ #00 OVR 8** .input-frame/y LDZ2 ++ #004c -- .Screen/y DEO2 |
|
458 | 458 |
( color ) DUP #08 .stack/length LDZ - #01 - > STH |
459 | 459 |
( value ) DUP 2* .stack/items + [ #10 .stack/length LDZ 2* - - ] LDZ2 |
460 | 460 |
STHr ;draw-number JSR2 |
... | ... |
@@ -493,9 +493,9 @@ RTN |
493 | 493 |
STH |
494 | 494 |
#10 #00 |
495 | 495 |
&loop |
496 |
- ( color ) DUP TOS ;keypad/color ++ LDA STH |
|
496 |
+ ( color ) #00 OVR ;keypad/color ++ LDA STH |
|
497 | 497 |
( state ) DUP OVRr STHr = STH |
498 |
- ( layout ) DUP TOS ;keypad/layout ++ LDA |
|
498 |
+ ( layout ) #00 OVR ;keypad/layout ++ LDA |
|
499 | 499 |
( layout addr ) TOS 8** ;font-hex ++ STH2 |
500 | 500 |
( x ) DUP 4MOD TOS 10** STH2 |
501 | 501 |
( y ) DUP 4/ TOS 10** |
... | ... |
@@ -514,7 +514,7 @@ RTN |
514 | 514 |
#08 #00 |
515 | 515 |
&loop |
516 | 516 |
( state ) DUP STHkr = STH |
517 |
- ( glyph ) DUP TOS 8** ;mod-icns ++ STH2 |
|
517 |
+ ( glyph ) #00 OVR 8** ;mod-icns ++ STH2 |
|
518 | 518 |
( y ) DUP 4/ TOS 10** .modpad-frame/y LDZ2 ++ STH2 |
519 | 519 |
( x ) DUP 4MOD TOS 10** .modpad-frame/x LDZ2 ++ STH2 |
520 | 520 |
STH2r STH2r STH2r STHr #03 ;draw-key JSR2 |
... | ... |
@@ -309,7 +309,7 @@ RTN |
309 | 309 |
DUP INC .browser/lines LDZ > ,&end JCN |
310 | 310 |
( has file ) |
311 | 311 |
.browser/x LDZ2 .Screen/x DEO2 |
312 |
- DUP TOS 10** .browser/y LDZ2 ++ .Screen/y DEO2 |
|
312 |
+ #00 OVR 10** .browser/y LDZ2 ++ .Screen/y DEO2 |
|
313 | 313 |
DUP .browser/scroll LDZ + ;get-entry JSR2 |
314 | 314 |
DUP2 ;get-type JSR2 ;draw-type JSR2 |
315 | 315 |
#01 STHkr * ;draw-str JSR2 |