... | ... |
@@ -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/dev.mouse.usm bin/boot.rom |
|
23 |
+./bin/assembler examples/gui.hover.usm bin/boot.rom |
|
24 | 24 |
./bin/emulator bin/boot.rom |
25 | 25 |
new file mode 100644 |
... | ... |
@@ -0,0 +1,109 @@ |
1 |
+( draw routines ) |
|
2 |
+ |
|
3 |
+&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 } |
|
4 |
+&Sprite { pad 8 x 2 y 2 addr 2 color 1 } |
|
5 |
+&Mouse { x 2 y 2 state 1 chord 1 } |
|
6 |
+ |
|
7 |
+&Label2d { x 2 y 2 color 1 addr 2 } |
|
8 |
+&Picture2d { x 2 y 2 width 2 height 2 color 1 addr 2 } |
|
9 |
+&Rect2d { x1 2 y1 2 x2 2 y2 2 } |
|
10 |
+&Point2d { x 2 y 2 } |
|
11 |
+ |
|
12 |
+;color 1 |
|
13 |
+;cursor 2 |
|
14 |
+;mouse Point2d |
|
15 |
+;rect Rect2d ;r1 Rect2d ;r2 Rect2d ;r3 Rect2d |
|
16 |
+ |
|
17 |
+|0100 @RESET |
|
18 |
+ |
|
19 |
+ #0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1 |
|
20 |
+ #0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1 |
|
21 |
+ #0048 #0048 #0080 #0098 =r3.y2 =r3.x2 =r3.y1 =r3.x1 |
|
22 |
+ |
|
23 |
+BRK |
|
24 |
+ |
|
25 |
+ |
|
26 |
+|0200 @FRAME |
|
27 |
+ |
|
28 |
+ ,pointer_icn =cursor |
|
29 |
+ |
|
30 |
+ #01 =color |
|
31 |
+ |
|
32 |
+ ~dev/mouse.x ~r1.x1 GTH2 ~dev/mouse.x ~r1.x2 LTH2 #0101 EQU2 |
|
33 |
+ ~dev/mouse.y ~r1.y1 GTH2 ~dev/mouse.y ~r1.y2 LTH2 #0101 EQU2 |
|
34 |
+ #0101 NEQ2 ,skip1 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip1 |
|
35 |
+ ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ~color ,line-rect JSR |
|
36 |
+ |
|
37 |
+ #01 =color |
|
38 |
+ |
|
39 |
+ ~dev/mouse.x ~r2.x1 GTH2 ~dev/mouse.x ~r2.x2 LTH2 #0101 EQU2 |
|
40 |
+ ~dev/mouse.y ~r2.y1 GTH2 ~dev/mouse.y ~r2.y2 LTH2 #0101 EQU2 |
|
41 |
+ #0101 NEQ2 ,skip2 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip2 |
|
42 |
+ ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ~color ,line-rect JSR |
|
43 |
+ |
|
44 |
+ #01 =color |
|
45 |
+ |
|
46 |
+ ~dev/mouse.x ~r3.x1 GTH2 ~dev/mouse.x ~r3.x2 LTH2 #0101 EQU2 |
|
47 |
+ ~dev/mouse.y ~r3.y1 GTH2 ~dev/mouse.y ~r3.y2 LTH2 #0101 EQU2 |
|
48 |
+ #0101 NEQ2 ,skip3 ROT JMP? POP2 #02 =color ,hand_icn =cursor @skip3 |
|
49 |
+ ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ~color ,line-rect JSR |
|
50 |
+ |
|
51 |
+ ,draw-cursor JSR |
|
52 |
+ |
|
53 |
+BRK |
|
54 |
+ |
|
55 |
+@draw-cursor |
|
56 |
+ |
|
57 |
+ ~mouse.x ~dev/mouse.x NEQU2 |
|
58 |
+ ~mouse.y ~dev/mouse.y NEQU2 |
|
59 |
+ |
|
60 |
+ #0000 EQU2 RTS? ( Return if unchanged ) |
|
61 |
+ |
|
62 |
+ ( clear last cursor ) |
|
63 |
+ #10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR |
|
64 |
+ ( record mouse positions ) |
|
65 |
+ ~dev/mouse.x =mouse.x ~dev/mouse.y =mouse.y |
|
66 |
+ #11 ~cursor ~mouse.x ~mouse.y ,draw-sprite JSR |
|
67 |
+ |
|
68 |
+RTS |
|
69 |
+ |
|
70 |
+@line-rect ( x1 y1 x2 y2 color ) |
|
71 |
+ |
|
72 |
+ ( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1 |
|
73 |
+ @line-rect-hor |
|
74 |
+ ( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x |
|
75 |
+ ( draw ) ~rect.y1 =dev/screen.y ~color =dev/screen.color |
|
76 |
+ ( draw ) ~rect.y2 =dev/screen.y ~color =dev/screen.color |
|
77 |
+ ,line-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP? POP2 |
|
78 |
+ ~rect.y1 =dev/screen.y |
|
79 |
+ @line-rect-ver |
|
80 |
+ ( draw ) ~rect.x1 =dev/screen.x ~color =dev/screen.color |
|
81 |
+ ( draw ) ~rect.x2 =dev/screen.x ~color =dev/screen.color |
|
82 |
+ ( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y |
|
83 |
+ ,line-rect-ver ~dev/screen.y ~rect.y2 #0001 ADD2 LTH2 JMP? POP2 |
|
84 |
+ |
|
85 |
+RTS |
|
86 |
+ |
|
87 |
+@draw-sprite |
|
88 |
+ |
|
89 |
+ =dev/sprite.y |
|
90 |
+ =dev/sprite.x |
|
91 |
+ =dev/sprite.addr |
|
92 |
+ =dev/sprite.color |
|
93 |
+ |
|
94 |
+RTS |
|
95 |
+ |
|
96 |
+@clear_icn [ 0000 0000 0000 0000 ] |
|
97 |
+@pointer_icn [ 80c0 e0f0 f8e0 1000 ] |
|
98 |
+@hand_icn [ 4040 4070 f8f8 f870 ] |
|
99 |
+ |
|
100 |
+@text [ Label Text ] <1 .00 ( add characters to memory ) |
|
101 |
+ |
|
102 |
+|d000 @ERROR BRK |
|
103 |
+ |
|
104 |
+|FF10 ;dev/screen Screen |
|
105 |
+|FF20 ;dev/sprite Sprite |
|
106 |
+|FF50 ;dev/mouse Mouse |
|
107 |
+ |
|
108 |
+|FFF0 .RESET .FRAME .ERROR ( vectors ) |
|
109 |
+|FFF8 [ 0f0f 0fff 0ff0 ] ( palette ) |
|
0 | 110 |
\ No newline at end of file |
... | ... |
@@ -39,16 +39,16 @@ BRK |
39 | 39 |
|
40 | 40 |
( load ) =color =rect.y2 =rect.x2 DUP2 =dev/screen.y =rect.y1 DUP2 =dev/screen.x =rect.x1 |
41 | 41 |
@line-rect-hor |
42 |
+ ( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x |
|
42 | 43 |
( draw ) ~rect.y1 =dev/screen.y ~color =dev/screen.color |
43 | 44 |
( draw ) ~rect.y2 =dev/screen.y ~color =dev/screen.color |
44 |
- ( incr ) ~dev/screen.x #0001 ADD2 =dev/screen.x |
|
45 | 45 |
,line-rect-hor ~dev/screen.x ~rect.x2 LTH2 JMP? POP2 |
46 | 46 |
~rect.y1 =dev/screen.y |
47 | 47 |
@line-rect-ver |
48 | 48 |
( draw ) ~rect.x1 =dev/screen.x ~color =dev/screen.color |
49 | 49 |
( draw ) ~rect.x2 =dev/screen.x ~color =dev/screen.color |
50 | 50 |
( incr ) ~dev/screen.y #0001 ADD2 =dev/screen.y |
51 |
- ,line-rect-ver ~dev/screen.y ~rect.y2 LTH2 JMP? POP2 |
|
51 |
+ ,line-rect-ver ~dev/screen.y ~rect.y2 #0001 ADD2 LTH2 JMP? POP2 |
|
52 | 52 |
|
53 | 53 |
RTS |
54 | 54 |
|
55 | 55 |
deleted file mode 100644 |
... | ... |
@@ -1,184 +0,0 @@ |
1 |
-( blank ) |
|
2 |
- |
|
3 |
-:dev/r fff8 ( std read port ) |
|
4 |
-:dev/w fff9 ( std write port ) |
|
5 |
- |
|
6 |
-&Point2d { x 2 y 2 } |
|
7 |
-&Rect2d { x1 2 y1 2 x2 2 y2 2 } |
|
8 |
- |
|
9 |
-;pos Point2d |
|
10 |
-;mouse Point2d |
|
11 |
-;rect Rect2d ;r1 Rect2d ;r2 Rect2d ;r3 Rect2d |
|
12 |
- |
|
13 |
-;drag Point2d |
|
14 |
- |
|
15 |
-;color 1 ;state 1 ;cursor 2 |
|
16 |
- |
|
17 |
-|0100 @RESET |
|
18 |
- |
|
19 |
- #05 =dev/r ( set dev/read mouse ) |
|
20 |
- #02 =dev/w ( set dev/write to sprite ) |
|
21 |
- |
|
22 |
- ( create a rect ) |
|
23 |
- #0020 #0030 #0060 #0060 =r1.y2 =r1.x2 =r1.y1 =r1.x1 |
|
24 |
- #0058 #0050 #0090 #0080 =r2.y2 =r2.x2 =r2.y1 =r2.x1 |
|
25 |
- #0048 #0048 #0080 #0098 =r3.y2 =r3.x2 =r3.y1 =r3.x1 |
|
26 |
- |
|
27 |
-BRK |
|
28 |
- |
|
29 |
-|c000 @FRAME |
|
30 |
- |
|
31 |
- ( clear last cursor ) |
|
32 |
- #10 ,clear_icn ~mouse.x ~mouse.y ,draw-sprite JSR |
|
33 |
- ( record mouse positions ) |
|
34 |
- #00 IOR2 =mouse.x #02 IOR2 =mouse.y |
|
35 |
- ( record mouse state ) |
|
36 |
- #04 IOR #11 ADD =state |
|
37 |
- ( detect click ) |
|
38 |
- #04 IOR #01 NEQ ,no-click ROT JMP? POP2 |
|
39 |
- ,on-click JSR |
|
40 |
- @no-click |
|
41 |
- |
|
42 |
- ,cursor_icn =cursor |
|
43 |
- |
|
44 |
- #02 =color |
|
45 |
- #00 IOR2 ( get x ) ~r1.x2 GTH2 ,outside0 ROT JMP? POP2 |
|
46 |
- #00 IOR2 ( get x ) ~r1.x1 LTH2 ,outside0 ROT JMP? POP2 |
|
47 |
- #02 IOR2 ( get y ) ~r1.y2 GTH2 ,outside0 ROT JMP? POP2 |
|
48 |
- #02 IOR2 ( get y ) ~r1.y1 LTH2 ,outside0 ROT JMP? POP2 |
|
49 |
- #03 =color |
|
50 |
- ,hand_icn =cursor |
|
51 |
- @outside0 |
|
52 |
- ~r1.x1 ~r1.y1 ~r1.x2 ~r1.y2 ,fill-rect JSR |
|
53 |
- ,text1 ~r1.x1 ~r1.y2 #0001 ADD2 ,draw-label JSR |
|
54 |
- |
|
55 |
- #02 =color |
|
56 |
- #00 IOR2 ( get x ) ~r2.x2 GTH2 ,outside1 ROT JMP? POP2 |
|
57 |
- #00 IOR2 ( get x ) ~r2.x1 LTH2 ,outside1 ROT JMP? POP2 |
|
58 |
- #02 IOR2 ( get y ) ~r2.y2 GTH2 ,outside1 ROT JMP? POP2 |
|
59 |
- #02 IOR2 ( get y ) ~r2.y1 LTH2 ,outside1 ROT JMP? POP2 |
|
60 |
- #03 =color |
|
61 |
- ,hand_icn =cursor |
|
62 |
- @outside1 |
|
63 |
- ~r2.x1 ~r2.y1 ~r2.x2 ~r2.y2 ,line-rect JSR |
|
64 |
- ,text2 ~r2.x1 ~r2.y2 #0001 ADD2 ,draw-label JSR |
|
65 |
- |
|
66 |
- #02 =color |
|
67 |
- #00 IOR2 ( get x ) ~r3.x2 GTH2 ,outside2 ROT JMP? POP2 |
|
68 |
- #00 IOR2 ( get x ) ~r3.x1 LTH2 ,outside2 ROT JMP? POP2 |
|
69 |
- #02 IOR2 ( get y ) ~r3.y2 GTH2 ,outside2 ROT JMP? POP2 |
|
70 |
- #02 IOR2 ( get y ) ~r3.y1 LTH2 ,outside2 ROT JMP? POP2 |
|
71 |
- #03 =color |
|
72 |
- ,hand_icn =cursor |
|
73 |
- @outside2 |
|
74 |
- ~r3.x1 ~r3.y1 ~r3.x2 ~r3.y2 ,line-rect JSR |
|
75 |
- ,text3 ~r3.x1 ~r3.y2 #0001 ADD2 ,draw-label JSR |
|
76 |
- |
|
77 |
- ( draw mouse ) |
|
78 |
- #02 =dev/w ( set dev/write to sprite ) |
|
79 |
- ~state ~cursor ~mouse.x ~mouse.y ,draw-sprite JSR |
|
80 |
- |
|
81 |
-BRK |
|
82 |
- |
|
83 |
-@on-click |
|
84 |
- |
|
85 |
- #aa NOP |
|
86 |
- |
|
87 |
-RTS |
|
88 |
- |
|
89 |
-@draw-sprite |
|
90 |
- IOW2 ( y byte ) |
|
91 |
- IOW2 ( x byte ) |
|
92 |
- IOW2 ( sprite address ) |
|
93 |
- IOW ( layer-color ) |
|
94 |
- RTS |
|
95 |
- |
|
96 |
-@fill-rect ( x1 y1 x2 y2 ) |
|
97 |
- #01 =dev/w ( set dev/write to sprite ) |
|
98 |
- =rect.y2 =rect.x2 ( stash x1 y1 ) =rect.y1 DUP2 WSR2 =rect.x1 |
|
99 |
- @fill-rect-ver |
|
100 |
- RSW2 DUP2 =rect.x1 WSR2 |
|
101 |
- @fill-rect-hor |
|
102 |
- ( draw ) ~rect.x1 ~rect.y1 IOW2 IOW2 ~color IOW |
|
103 |
- ( incr ) ~rect.x1 #0001 ADD2 DUP2 =rect.x1 |
|
104 |
- ~rect.x2 LTH2 ,fill-rect-hor ROT JMP? POP2 |
|
105 |
- ~rect.y1 #0001 ADD2 DUP2 =rect.y1 |
|
106 |
- ~rect.y2 LTH2 ,fill-rect-ver ROT JMP? POP2 |
|
107 |
- RSW2 POP2 |
|
108 |
-RTS |
|
109 |
- |
|
110 |
-@line-rect ( x1 y1 x2 y2 ) |
|
111 |
- #01 =dev/w ( set dev/write to sprite ) |
|
112 |
- =rect.y2 =rect.x2 ( stash x1 y1 ) DUP2 WSR2 =rect.y1 DUP2 WSR2 =rect.x1 |
|
113 |
- @line-rect-hor |
|
114 |
- ( draw ) ~rect.x1 ~rect.y1 IOW2 IOW2 ~color IOW |
|
115 |
- ( draw ) ~rect.x1 ~rect.y2 IOW2 IOW2 ~color IOW |
|
116 |
- ( incr ) ~rect.x1 #0001 ADD2 DUP2 =rect.x1 |
|
117 |
- ~rect.x2 #0001 ADD2 LTH2 ,line-rect-hor ROT JMP? POP2 |
|
118 |
- ( restore rect.x1 rect.y1 ) RSW2 =rect.x1 RSW2 =rect.y1 |
|
119 |
- @line-rect-ver |
|
120 |
- ( incr ) ~rect.y1 #0001 ADD2 DUP2 =rect.y1 |
|
121 |
- ( draw ) ~rect.x1 ~rect.y1 IOW2 IOW2 ~color IOW |
|
122 |
- ( draw ) ~rect.x2 ~rect.y1 IOW2 IOW2 ~color IOW |
|
123 |
- ~rect.y2 #0001 SUB2 LTH2 ,line-rect-ver ROT JMP? POP2 |
|
124 |
-RTS |
|
125 |
- |
|
126 |
-@draw-label ( text x1 y1 ) |
|
127 |
- #02 =dev/w ( set dev/write to sprite ) |
|
128 |
- =pos.y =pos.x |
|
129 |
- @draw-label-loop |
|
130 |
- ( draw ) ~pos.x ~pos.y IOW2 IOW2 DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 IOW2 ~color IOW |
|
131 |
- ( incr ) #0001 ADD2 |
|
132 |
- ( incr ) ~pos.x #0008 ADD2 =pos.x |
|
133 |
- DUP2 LDR #00 NEQ ,draw-label-loop ROT JMP? POP2 |
|
134 |
- POP2 |
|
135 |
-RTS |
|
136 |
- |
|
137 |
-@clear_icn [ 0000 0000 0000 0000 ] |
|
138 |
-@cursor_icn [ 80c0 e0f0 f8e0 1000 ] |
|
139 |
-@hand_icn [ 4040 4070 f8f8 f870 ] |
|
140 |
- |
|
141 |
-@font ( spectrum-zx font ) |
|
142 |
-[ |
|
143 |
- 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000 |
|
144 |
- 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000 |
|
145 |
- 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000 |
|
146 |
- 0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800 |
|
147 |
- 0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800 |
|
148 |
- 003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038 |
|
149 |
- 0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000 |
|
150 |
- 0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000 |
|
151 |
- 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400 |
|
152 |
- 0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000 |
|
153 |
- 0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800 |
|
154 |
- 0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000 |
|
155 |
- 003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00 |
|
156 |
- 0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000 |
|
157 |
- 003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810 |
|
158 |
- 0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800 |
|
159 |
- 003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00 |
|
160 |
- 0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00 |
|
161 |
- 0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200 |
|
162 |
- 0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00 |
|
163 |
- 007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00 |
|
164 |
- 00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200 |
|
165 |
- 0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00 |
|
166 |
- 0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00 |
|
167 |
- 0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00 |
|
168 |
- 0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c |
|
169 |
- 0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400 |
|
170 |
- 0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800 |
|
171 |
- 0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800 |
|
172 |
- 0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800 |
|
173 |
- 0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00 |
|
174 |
- 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c |
|
175 |
-] |
|
176 |
- |
|
177 |
-@text1 [ catapult ] <1 .00 |
|
178 |
-@text2 [ helicopt ] <1 .00 |
|
179 |
-@text3 [ submarin ] <1 .00 |
|
180 |
- |
|
181 |
-|d000 @ERROR BRK |
|
182 |
- |
|
183 |
-|FFF0 .RESET .FRAME .ERROR |
|
184 |
-|FFF8 [ e2af eab2 e652 ] ( palette ) |