... | ... |
@@ -157,6 +157,18 @@ skipcomment(char *w, int *cap) |
157 | 157 |
return 0; |
158 | 158 |
} |
159 | 159 |
|
160 |
+int |
|
161 |
+skipbinary(char *w, int *cap) |
|
162 |
+{ |
|
163 |
+ if(w[0] == ']') { |
|
164 |
+ *cap = 0; |
|
165 |
+ return 1; |
|
166 |
+ } |
|
167 |
+ if(w[0] == '[') *cap = 1; |
|
168 |
+ if(*cap) return 1; |
|
169 |
+ return 0; |
|
170 |
+} |
|
171 |
+ |
|
160 | 172 |
int |
161 | 173 |
skipstring(char *w, int *cap, Uint16 *addr) |
162 | 174 |
{ |
... | ... |
@@ -195,13 +207,15 @@ capturestring(char *w, int *cap) |
195 | 207 |
int |
196 | 208 |
pass1(FILE *f) |
197 | 209 |
{ |
198 |
- int ccmnt = 0, cstrg = 0; |
|
210 |
+ int ccmnt = 0, cstrg = 0, cbits = 0; |
|
199 | 211 |
Uint16 addr = 0; |
200 | 212 |
char w[64]; |
201 | 213 |
while(fscanf(f, "%s", w) == 1) { |
202 | 214 |
if(skipcomment(w, &ccmnt)) continue; |
203 | 215 |
if(skipstring(w, &cstrg, &addr)) continue; |
204 |
- if(w[0] == '@') { |
|
216 |
+ if(skipbinary(w, &cbits)) |
|
217 |
+ addr += w[0] != '[' && w[0] != ']' ? 2 : 0; |
|
218 |
+ else if(w[0] == '@') { |
|
205 | 219 |
if(!makelabel(w + 1, addr, 0)) |
206 | 220 |
return error("Pass1 failed", w); |
207 | 221 |
} else if(w[0] == ';') { |
... | ... |
@@ -233,7 +247,7 @@ pass1(FILE *f) |
233 | 247 |
int |
234 | 248 |
pass2(FILE *f) |
235 | 249 |
{ |
236 |
- int ccmnt = 0, cstrg = 0; |
|
250 |
+ int ccmnt = 0, cstrg = 0, cbits = 0; |
|
237 | 251 |
char w[64]; |
238 | 252 |
while(fscanf(f, "%s", w) == 1) { |
239 | 253 |
Uint8 op = 0; |
... | ... |
@@ -242,7 +256,8 @@ pass2(FILE *f) |
242 | 256 |
if(skipcomment(w, &ccmnt)) continue; |
243 | 257 |
if(capturestring(w, &cstrg)) continue; |
244 | 258 |
/* clang-format off */ |
245 |
- if(w[0] == '|') p.ptr = shex(w + 1); |
|
259 |
+ if(skipbinary(w, &cbits)) { if(w[0] != '[' && w[0] != ']') { pushshort(shex(w), 0); } } |
|
260 |
+ else if(w[0] == '|') p.ptr = shex(w + 1); |
|
246 | 261 |
else if((op = findopcode(w)) || scmp(w, "BRK")) pushbyte(op, 0); |
247 | 262 |
else if(w[0] == ':') fscanf(f, "%s", w); |
248 | 263 |
else if(w[0] == ';') fscanf(f, "%s", w); |
... | ... |
@@ -13,11 +13,6 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr |
13 | 13 |
clang-format -i uxn.h |
14 | 14 |
clang-format -i uxn.c |
15 | 15 |
|
16 |
-# Cli |
|
17 |
-clang-format -i cli.c |
|
18 |
-# rm -f ./bin/cli |
|
19 |
-# cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werror=implicit-int -Werror=incompatible-pointer-types -Werror=int-conversion -Wvla -g -Og -fsanitize=address -fsanitize=undefined uxn.c cli.c -o bin/cli |
|
20 |
- |
|
21 | 16 |
# Emulator |
22 | 17 |
clang-format -i emulator.c |
23 | 18 |
rm -f ./bin/emulator |
... | ... |
@@ -264,12 +264,15 @@ Uint8 |
264 | 264 |
spritew(Device *d, Memory *m, Uint8 b) |
265 | 265 |
{ |
266 | 266 |
d->mem[d->ptr++] = b; |
267 |
- if(d->ptr > 6) { |
|
267 |
+ if(d->ptr > 7) { |
|
268 | 268 |
Uint16 x = (d->mem[2] << 8) + d->mem[3]; |
269 | 269 |
Uint16 y = (d->mem[0] << 8) + d->mem[1]; |
270 | 270 |
Uint8 *chr = &m->dat[(d->mem[4] << 8) + d->mem[5]]; |
271 |
- drawchr(pixels, x, y, chr); |
|
272 |
- if(d->mem[6]) |
|
271 |
+ if(!d->mem[6]) |
|
272 |
+ drawchr(pixels, x, y, chr); |
|
273 |
+ else |
|
274 |
+ drawicn(pixels, x, y, chr, d->mem[6], 0); |
|
275 |
+ if(d->mem[7]) |
|
273 | 276 |
REQDRAW = 1; |
274 | 277 |
d->ptr = 0; |
275 | 278 |
} |
276 | 279 |
deleted file mode 100644 |
... | ... |
@@ -1,17 +0,0 @@ |
1 |
-( conditional jump ) |
|
2 |
- |
|
3 |
-|0100 @RESET |
|
4 |
- |
|
5 |
-#06 #05 GTH ,there ROT JMP? POP2 |
|
6 |
- |
|
7 |
-@here ( when lesser or equal ) |
|
8 |
- #ee |
|
9 |
- BRK |
|
10 |
- |
|
11 |
-@there ( when greater ) |
|
12 |
- #ff |
|
13 |
- BRK |
|
14 |
- |
|
15 |
-|c000 @FRAME BRK |
|
16 |
-|d000 @ERROR BRK |
|
17 |
-|FFFA .RESET .FRAME .ERROR |
... | ... |
@@ -2,20 +2,96 @@ |
2 | 2 |
|
3 | 3 |
:dev/w fff9 ( const write port ) |
4 | 4 |
|
5 |
+;x 2 ;y 2 ;color 1 |
|
6 |
+ |
|
5 | 7 |
|0100 @RESET |
6 | 8 |
|
7 |
- #00 =dev/w ( set dev/write to sprite ) |
|
8 |
- ,string ( add string pointer to stack ) |
|
9 |
- @loop |
|
10 |
- DUP2 LDR IOW ( write pointer value to console ) |
|
11 |
- #0001 ADD2 ( increment string pointer ) |
|
12 |
- DUP2 LDR #00 NEQ ,loop ROT JMP? POP2 ( while *ptr!=0 goto loop ) |
|
9 |
+ ( print to console ) |
|
10 |
+ ,string ,displaycli JSR |
|
11 |
+ |
|
12 |
+ ( print to screen ) |
|
13 |
+ #0008 =x #0030 =y #01 =color |
|
14 |
+ ,string ,displaygui JSR |
|
15 |
+ #0010 =x #0038 =y #02 =color |
|
16 |
+ ,string ,displaygui JSR |
|
17 |
+ #0018 =x #0040 =y #03 =color |
|
18 |
+ ,string ,displaygui JSR |
|
19 |
+ |
|
13 | 20 |
|
14 | 21 |
BRK |
15 | 22 |
|
16 |
-@string " Hello World " ( add string to memory ) |
|
23 |
+@string " Hello Merveilles " ( add string to memory ) |
|
24 |
+ |
|
25 |
+@displaycli |
|
26 |
+ #00 =dev/w ( set dev/write to console ) |
|
27 |
+ @cliloop |
|
28 |
+ DUP2 LDR IOW ( write pointer value to console ) |
|
29 |
+ #0001 ADD2 ( increment string pointer ) |
|
30 |
+ DUP2 LDR #00 NEQ ,cliloop ROT JMP? POP2 ( while *ptr!=0 goto loop ) |
|
31 |
+ RTS |
|
32 |
+ |
|
33 |
+@displaygui |
|
34 |
+ #02 =dev/w ( set dev/write to sprite ) |
|
35 |
+ @displayguiloop |
|
36 |
+ DUP2 LDR ,printchar JSR |
|
37 |
+ #0001 ADD2 |
|
38 |
+ ~x #0008 ADD2 =x |
|
39 |
+ DUP2 LDR #00 NEQ ,displayguiloop ROT JMP? POP2 |
|
40 |
+ RTS |
|
41 |
+ |
|
42 |
+@printchar |
|
43 |
+ ~color #01 ROT ,getchar JSR ~x ~y ,puticon JSR |
|
44 |
+ RTS |
|
45 |
+ |
|
46 |
+@getchar |
|
47 |
+ #00 SWP #0008 MUL2 ,SPRITESHEET ADD2 |
|
48 |
+ RTS |
|
49 |
+ |
|
50 |
+@puticon |
|
51 |
+ IOW2 ( y short ) |
|
52 |
+ IOW2 ( x short ) |
|
53 |
+ IOW2 ( sprite address ) |
|
54 |
+ IOW2 ( redraw byte ) |
|
55 |
+ RTS |
|
56 |
+ |
|
57 |
+|0300 @SPRITESHEET ( first 128 characters of the spectrum-zx font ) |
|
58 |
+ |
|
59 |
+[ |
|
60 |
+ 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 |
|
61 |
+ 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 |
|
62 |
+ 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000 |
|
63 |
+ 0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800 |
|
64 |
+ 0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800 |
|
65 |
+ 003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038 |
|
66 |
+ 0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000 |
|
67 |
+ 0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000 |
|
68 |
+ 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400 |
|
69 |
+ 0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000 |
|
70 |
+ 0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800 |
|
71 |
+ 0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000 |
|
72 |
+ 003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00 |
|
73 |
+ 0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 |
|
74 |
+ 003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810 |
|
75 |
+ 0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800 |
|
76 |
+ 003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00 |
|
77 |
+ 0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00 |
|
78 |
+ 0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200 |
|
79 |
+ 0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00 |
|
80 |
+ 007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00 |
|
81 |
+ 00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200 |
|
82 |
+ 0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00 |
|
83 |
+ 0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00 |
|
84 |
+ 0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00 |
|
85 |
+ 0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c |
|
86 |
+ 0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400 |
|
87 |
+ 0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800 |
|
88 |
+ 0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800 |
|
89 |
+ 0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800 |
|
90 |
+ 0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00 |
|
91 |
+ 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c |
|
92 |
+] |
|
17 | 93 |
|
18 |
-|c000 @FRAME BRK |
|
19 |
-|d000 @ERROR BRK |
|
94 |
+|c000 @FRAME |
|
95 |
+|d000 @ERROR |
|
20 | 96 |
|
21 | 97 |
|FFFA .RESET .FRAME .ERROR |
22 | 98 |
\ No newline at end of file |
... | ... |
@@ -31,8 +31,8 @@ BRK |
31 | 31 |
|
32 | 32 |
|0200 @SPRITESHEET |
33 | 33 |
|
34 |
-@cursor_icn .80c0 .e0f0 .f8e0 .1000 .0000 .0000 .0000 .0000 |
|
35 |
-@star_icn .1054 .28c6 .2854 .1000 .0000 .0000 .0000 .0000 |
|
34 |
+@cursor_icn [ 80c0 e0f0 f8e0 1000 0000 0000 0000 0000 ] |
|
35 |
+@star_icn [ 1054 28c6 2854 1000 0000 0000 0000 0000 ] |
|
36 | 36 |
|
37 | 37 |
BRK |
38 | 38 |
|