... | ... |
@@ -140,6 +140,8 @@ makevariable(char *id, Uint16 *addr, FILE *f) |
140 | 140 |
char wv[64]; |
141 | 141 |
Uint8 origin; |
142 | 142 |
fscanf(f, "%s", wv); |
143 |
+ if(!sihx(wv)) |
|
144 |
+ return error("Variable value is invalid", wv); |
|
143 | 145 |
origin = *addr; |
144 | 146 |
*addr += shex(wv); |
145 | 147 |
return makelabel(id, origin, shex(wv)); |
... | ... |
@@ -19,5 +19,5 @@ rm -f ./bin/emulator |
19 | 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 emulator.c -L/usr/local/lib -lSDL2 -o bin/emulator |
20 | 20 |
|
21 | 21 |
# run |
22 |
-./bin/assembler examples/controller.usm bin/boot.rom |
|
22 |
+./bin/assembler examples/drag.usm bin/boot.rom |
|
23 | 23 |
./bin/emulator bin/boot.rom |
... | ... |
@@ -252,8 +252,10 @@ screenw(Device *d, Memory *m, Uint8 b) |
252 | 252 |
(d->mem[2] << 8) + d->mem[3], |
253 | 253 |
(d->mem[0] << 8) + d->mem[1], |
254 | 254 |
d->mem[4]); |
255 |
- if(d->mem[5]) |
|
255 |
+ if(d->mem[5] == 1) |
|
256 | 256 |
REQDRAW = 1; |
257 |
+ if(d->mem[5] == 2) |
|
258 |
+ clear(pixels); |
|
257 | 259 |
d->ptr = 0; |
258 | 260 |
} |
259 | 261 |
(void)m; |
5 | 5 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,69 @@ |
1 |
+( drag ) |
|
2 |
+ |
|
3 |
+:dev/r fff8 ( std read port ) |
|
4 |
+:dev/w fff9 ( std write port ) |
|
5 |
+ |
|
6 |
+;drawx 2 ;drawy 2 ;x 2 ;y 2 ;w 2 ;h 2 ;color 1 |
|
7 |
+ |
|
8 |
+|0100 @RESET |
|
9 |
+ |
|
10 |
+ #05 =dev/r ( set dev/read mouse ) |
|
11 |
+ #01 =dev/w ( set dev/write to screen ) |
|
12 |
+ |
|
13 |
+BRK |
|
14 |
+ |
|
15 |
+|c000 @FRAME |
|
16 |
+ |
|
17 |
+ ( get touch ) |
|
18 |
+ #04 IOR #01 NEQ ,frame-end ROT JMP? POP2 |
|
19 |
+ |
|
20 |
+ ( clear ) |
|
21 |
+ #00 =color |
|
22 |
+ ~x ~y #0060 #0040 ,fillrect JSR |
|
23 |
+ |
|
24 |
+ ( fill rect x y w h ) |
|
25 |
+ #01 =color |
|
26 |
+ #00 IOR2 ( get mouse-x ) =x |
|
27 |
+ #02 IOR2 ( get mouse-y ) =y |
|
28 |
+ ~x ~y #0060 #0040 ,fillrect JSR |
|
29 |
+ |
|
30 |
+ ,redraw JSR |
|
31 |
+ |
|
32 |
+ @frame-end |
|
33 |
+ |
|
34 |
+BRK |
|
35 |
+ |
|
36 |
+@fillrect |
|
37 |
+ =h =w =y =x ( store values in variables ) |
|
38 |
+ ~x =drawx ~y =drawy ( store draw pos in variables ) |
|
39 |
+ @fillrectrow |
|
40 |
+ ~x =drawx |
|
41 |
+ @fillrectcol |
|
42 |
+ ( draw ) ~drawx ~drawy IOW2 IOW2 ~color IOW #00 IOW |
|
43 |
+ ~drawx #0001 ADD2 =drawx |
|
44 |
+ ~drawx ~w ~x ADD2 LTH2 ,fillrectcol ROT JMP? POP2 |
|
45 |
+ ~drawy #0001 ADD2 =drawy |
|
46 |
+ ~drawy ~h ~y ADD2 LTH2 ,fillrectrow ROT JMP? POP2 |
|
47 |
+ RTS |
|
48 |
+ |
|
49 |
+@getmouse |
|
50 |
+ #00 IOR2 ( get mouse x ) |
|
51 |
+ #02 IOR2 ( get mouse y ) |
|
52 |
+ RTS |
|
53 |
+ |
|
54 |
+@redraw |
|
55 |
+ #0000 IOW2 |
|
56 |
+ #0000 IOW2 |
|
57 |
+ #00 IOW |
|
58 |
+ #01 IOW |
|
59 |
+ RTS |
|
60 |
+ |
|
61 |
+@clear |
|
62 |
+ #0000 IOW2 |
|
63 |
+ #0000 IOW2 |
|
64 |
+ #00 IOW |
|
65 |
+ #02 IOW |
|
66 |
+ RTS |
|
67 |
+ |
|
68 |
+|d000 @ERROR BRK |
|
69 |
+|FFFA .RESET .FRAME .ERROR |
... | ... |
@@ -1,4 +1,4 @@ |
1 |
-( comment ) |
|
1 |
+( hello world ) |
|
2 | 2 |
|
3 | 3 |
:dev/w fff9 ( const write port ) |
4 | 4 |
|
... | ... |
@@ -32,11 +32,11 @@ BRK |
32 | 32 |
|
33 | 33 |
@displaygui |
34 | 34 |
#02 =dev/w ( set dev/write to sprite ) |
35 |
- @displayguiloop |
|
35 |
+ @guiloop |
|
36 | 36 |
DUP2 LDR ,printchar JSR |
37 | 37 |
#0001 ADD2 |
38 | 38 |
~x #0008 ADD2 =x |
39 |
- DUP2 LDR #00 NEQ ,displayguiloop ROT JMP? POP2 |
|
39 |
+ DUP2 LDR #00 NEQ ,guiloop ROT JMP? POP2 |
|
40 | 40 |
RTS |
41 | 41 |
|
42 | 42 |
@printchar |