... | ... |
@@ -100,6 +100,8 @@ A device that works like a NES controller, each button is a bit from a single by |
100 | 100 |
|
101 | 101 |
- Line routine |
102 | 102 |
- Getting rid of IOR/IOW would be nice.. |
103 |
+- Example of button pointing to a subroutine |
|
104 |
+- Labels should not have the trailing space |
|
103 | 105 |
|
104 | 106 |
### Misc TODOs |
105 | 107 |
|
... | ... |
@@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr |
20 | 20 |
# cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator |
21 | 21 |
|
22 | 22 |
# run |
23 |
-./bin/assembler examples/pattern.usm bin/boot.rom |
|
23 |
+./bin/assembler examples/window.usm bin/boot.rom |
|
24 | 24 |
./bin/emulator bin/boot.rom |
... | ... |
@@ -320,13 +320,13 @@ consolew(Device *d, Memory *m, Uint8 b) |
320 | 320 |
Uint8 |
321 | 321 |
screenr(Device *d, Memory *m, Uint8 b) |
322 | 322 |
{ |
323 |
+ loadtheme(m->dat + 0xfff0); |
|
323 | 324 |
switch(b) { |
324 | 325 |
case 0: return (HOR * 8 >> 8) & 0xff; |
325 | 326 |
case 1: return HOR * 8 & 0xff; |
326 | 327 |
case 2: return (VER * 8 >> 8) & 0xff; |
327 | 328 |
case 3: return VER * 8 & 0xff; |
328 | 329 |
} |
329 |
- loadtheme(m->dat + 0xfff0); |
|
330 | 330 |
(void)m; |
331 | 331 |
return d->mem[b]; |
332 | 332 |
} |
333 | 333 |
similarity index 76% |
334 | 334 |
rename from examples/pattern.usm |
335 | 335 |
rename to examples/window.usm |
... | ... |
@@ -3,77 +3,85 @@ |
3 | 3 |
:dev/r fff8 ( std read port ) |
4 | 4 |
:dev/w fff9 ( std write port ) |
5 | 5 |
|
6 |
-;color 1 ;x1 2 ;x2 2 ;y1 2 ;y2 2 |
|
7 |
- |
|
8 |
-;mousex 2 ;mousey 2 |
|
9 |
-;lastx 2 ;lasty 2 |
|
10 |
-;state 1 |
|
6 |
+( window ) ;wx1 2 ;wy1 2 ;wx2 2 ;wy2 2 |
|
7 |
+( drawing ) ;color 1 ;x1 2 ;x2 2 ;y1 2 ;y2 2 |
|
8 |
+( mouse ) ;mousex 2 ;mousey 2 ;state 1 |
|
11 | 9 |
|
12 | 10 |
|0100 @RESET |
13 | 11 |
|
14 |
- ( fill background ) |
|
15 |
- #01 =dev/r |
|
16 |
- #02 =dev/w |
|
17 |
- ,fill-sprite JSR |
|
18 |
- |
|
19 |
- ( draw rect ) |
|
20 |
- #01 =dev/w |
|
21 |
- #00 =color |
|
22 |
- #00 IOR2 #0002 DIV2 #0060 SUB2 |
|
23 |
- #02 IOR2 #0002 DIV2 #0030 SUB2 |
|
24 |
- #00 IOR2 #0002 DIV2 #0060 ADD2 |
|
25 |
- #02 IOR2 #0002 DIV2 #0030 ADD2 ,fill-rect JSR |
|
26 |
- #01 =color |
|
27 |
- #00 IOR2 #0002 DIV2 #0060 SUB2 |
|
28 |
- #02 IOR2 #0002 DIV2 #0030 SUB2 |
|
29 |
- #00 IOR2 #0002 DIV2 #0060 ADD2 |
|
30 |
- #02 IOR2 #0002 DIV2 #0030 ADD2 ,line-rect JSR |
|
31 |
- #01 =color |
|
32 |
- #00 IOR2 #0002 DIV2 #0060 SUB2 #0002 ADD2 |
|
33 |
- #02 IOR2 #0002 DIV2 #0030 SUB2 #0002 ADD2 |
|
34 |
- #00 IOR2 #0002 DIV2 #0060 ADD2 #0002 SUB2 |
|
35 |
- #02 IOR2 #0002 DIV2 #0030 ADD2 #0002 SUB2 ,line-rect JSR |
|
12 |
+ ,paint-background JSR |
|
13 |
+ #0020 #0020 #00d0 #0080 ,paint-window JSR |
|
14 |
+ #0040 #0040 #00f0 #0070 ,paint-window JSR |
|
15 |
+ #0060 #004c #00c0 #007a ,paint-window JSR |
|
36 | 16 |
|
37 | 17 |
#05 =dev/r ( set dev/read mouse ) |
38 |
- #02 =dev/w ( set dev/read mouse ) |
|
39 |
- |
|
40 |
- #01 =color |
|
41 |
- ,text1 #0028 #0030 ,draw-label JSR |
|
42 |
- |
|
43 |
- #01 ,checkon_icn #0028 #0050 ,draw-sprite JSR |
|
44 |
- ,text2 #0038 #0050 ,draw-label JSR |
|
45 |
- |
|
46 |
- #01 ,checkoff_icn #0028 #0060 ,draw-sprite JSR |
|
47 |
- ,text3 #0038 #0060 ,draw-label JSR |
|
18 |
+ #02 =dev/w ( set dev/write sprite ) |
|
48 | 19 |
|
49 | 20 |
BRK |
50 | 21 |
|
51 | 22 |
|c000 @FRAME |
52 | 23 |
|
53 | 24 |
( clear last cursor ) |
54 |
- #10 ,clear_icn ~lastx ~lasty ,draw-sprite JSR |
|
25 |
+ #10 ,clear_icn ~mousex ~mousey ,draw-sprite JSR |
|
55 | 26 |
( record mouse positions ) |
56 | 27 |
#00 IOR2 =mousex #02 IOR2 =mousey |
57 | 28 |
( record mouse state ) |
58 | 29 |
#04 IOR #11 ADD =state |
30 |
+ |
|
31 |
+ #04 IOR #01 NEQ ,no-touch ROT JMP? POP2 |
|
32 |
+ ,on-touch JSR |
|
33 |
+ @no-touch |
|
34 |
+ |
|
59 | 35 |
( draw mouse ) |
60 | 36 |
~state ,cursor_icn ~mousex ~mousey ,draw-sprite JSR |
61 |
- ( update last pos ) |
|
62 |
- ~mousex =lastx ~mousey =lasty |
|
63 | 37 |
|
64 | 38 |
BRK |
65 | 39 |
|
66 |
-@fill-sprite |
|
40 |
+@paint-background ( nil ) |
|
41 |
+ |
|
42 |
+ #01 =dev/r ( read screen for size ) |
|
43 |
+ #02 =dev/w ( write to sprite ) |
|
44 |
+ |
|
67 | 45 |
#0000 |
68 |
- @fill-sprite-loop-hor |
|
46 |
+ @paint-background-loop-hor |
|
69 | 47 |
#0000 |
70 |
- @fill-sprite-loop |
|
48 |
+ @paint-background-loop |
|
71 | 49 |
( draw ) OVR2 IOW2 DUP2 IOW2 ,texture IOW2 #01 IOW |
72 | 50 |
( incr ) #0008 ADD2 DUP2 |
73 |
- #00 IOR2 LTH2 ,fill-sprite-loop ROT JMP? POP2 |
|
51 |
+ #00 IOR2 LTH2 ,paint-background-loop ROT JMP? POP2 |
|
74 | 52 |
POP2 |
75 | 53 |
( incr ) #0008 ADD2 DUP2 |
76 |
- #02 IOR2 LTH2 ,fill-sprite-loop-hor ROT JMP? POP2 |
|
54 |
+ #02 IOR2 LTH2 ,paint-background-loop-hor ROT JMP? POP2 |
|
55 |
+ POP2 |
|
56 |
+ |
|
57 |
+RTS |
|
58 |
+ |
|
59 |
+@paint-window ( wx1 wy1 wx2 wy2 ) |
|
60 |
+ |
|
61 |
+ =wy2 =wx2 =wy1 =wx1 |
|
62 |
+ |
|
63 |
+ #01 =dev/r ( read screen for size ) |
|
64 |
+ #01 =dev/w ( write to screen ) |
|
65 |
+ |
|
66 |
+ ( Draw background ) |
|
67 |
+ #01 =color |
|
68 |
+ ~wx1 #0003 ADD2 ~wy1 #0003 ADD2 ~wx2 #0003 ADD2 ~wy2 #0003 ADD2 ,fill-rect JSR |
|
69 |
+ #02 =color |
|
70 |
+ ~wx1 ~wy1 ~wx2 ~wy2 ,fill-rect JSR |
|
71 |
+ ( draw outline ) |
|
72 |
+ #01 =color |
|
73 |
+ ~wx1 ~wy1 ~wx2 ~wy2 ,line-rect JSR |
|
74 |
+ #02 =color |
|
75 |
+ ~wx1 #0002 ADD2 ~wy1 #0002 ADD2 ~wx2 #0002 SUB2 ~wy2 #0002 SUB2 ,line-rect JSR |
|
76 |
+ |
|
77 |
+ #02 =dev/w |
|
78 |
+ #09 =color |
|
79 |
+ ,text1 ~wx1 #0008 ADD2 ~wy1 #0008 ADD2 ,draw-label JSR |
|
80 |
+ |
|
81 |
+RTS |
|
82 |
+ |
|
83 |
+@on-touch |
|
84 |
+ |
|
77 | 85 |
RTS |
78 | 86 |
|
79 | 87 |
@fill-rect ( x1 y1 x2 y2 ) |
... | ... |
@@ -111,7 +119,7 @@ RTS |
111 | 119 |
IOW ( layer-color ) |
112 | 120 |
RTS |
113 | 121 |
|
114 |
-@draw-label ( x1 y1 text ) |
|
122 |
+@draw-label ( text x1 y1 ) |
|
115 | 123 |
=y1 =x1 |
116 | 124 |
@draw-label-loop |
117 | 125 |
( draw ) ~x1 ~y1 IOW2 IOW2 DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 IOW2 ~color IOW |
... | ... |
@@ -126,9 +134,11 @@ RTS |
126 | 134 |
@checkoff_icn [ 7e81 8181 8181 817e ] |
127 | 135 |
@checkon_icn [ 7e81 99bd bd99 817e ] |
128 | 136 |
|
129 |
-@text1 " Hello World " ( add string to memory ) |
|
137 |
+@text1 " Planet " ( add string to memory ) |
|
130 | 138 |
@text2 " To Jupiter " |
131 | 139 |
@text3 " To Neptune " |
140 |
+@text4 " To Nereid " |
|
141 |
+@text5 " Theme " |
|
132 | 142 |
|
133 | 143 |
@font ( spectrum-zx font ) |
134 | 144 |
[ |
... | ... |
@@ -167,5 +177,5 @@ RTS |
167 | 177 |
] |
168 | 178 |
|
169 | 179 |
|d000 @ERROR BRK |
170 |
-|FFF0 [ f1c3 f12e f12a ] ( palette ) |
|
180 |
+|FFF0 [ 31ff e1ff b10f ] ( palette ) |
|
171 | 181 |
|FFFA .RESET .FRAME .ERROR |