... | ... |
@@ -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 projects/software/left.usm bin/boot.rom |
|
23 |
+./bin/assembler projects/software/nasu.usm bin/boot.rom |
|
24 | 24 |
./bin/emulator bin/boot.rom |
... | ... |
@@ -10,32 +10,24 @@ |
10 | 10 |
&Mouse { x 2 y 2 state 1 chord 1 xt 1 yt 1 } |
11 | 11 |
&File { pad 8 name 2 length 2 load 2 save 2 } |
12 | 12 |
|
13 |
+&Range2d { from 2 to 2 } |
|
13 | 14 |
&Point2d { x 2 y 2 } |
14 | 15 |
&Label2d { x 2 y 2 color 1 addr 2 } |
15 |
-&Textarea2d { x1 2 y1 2 x2 2 y2 2 color 1 addr 2 cursor 1 sela 2 selb 2 } |
|
16 |
+&Textarea2d { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 sela 2 selb 2 } |
|
16 | 17 |
|
17 |
-;scroll-position Point2d |
|
18 |
-;scroll-target Point2d |
|
19 |
- |
|
20 |
-;selection Point2d |
|
21 |
-;target Point2d ;pt Point2d ;pt2 Point2d ;mouse Point2d |
|
18 |
+;selection Range2d |
|
19 |
+;pt Point2d ;mouse Point2d ;position Point2d ;scroll Point2d |
|
22 | 20 |
;textarea Textarea2d |
23 | 21 |
;label Label2d |
24 |
-;i 1 ;j 2 ;addr 2 ;color 1 |
|
22 |
+;j 2 ;addr 2 |
|
25 | 23 |
|
26 | 24 |
|0100 @RESET |
25 |
+ |
|
26 |
+ ( load file ) |
|
27 |
+ ,filepath =dev/file.name #3000 =dev/file.length ,body =dev/file.load |
|
27 | 28 |
|
28 |
- ,filepath =dev/file.name |
|
29 |
- #0900 =dev/file.length |
|
30 |
- ,body =dev/file.load |
|
31 |
- |
|
32 |
- #0005 =selection.y |
|
33 |
- |
|
34 |
- #02 =textarea.color |
|
35 |
- #0064 =textarea.sela |
|
36 |
- #0065 =textarea.selb |
|
37 |
- #0018 =textarea.x1 |
|
38 |
- ~dev/screen.height #0008 SUB2 =textarea.y2 |
|
29 |
+ ( place textarea ) |
|
30 |
+ #0018 =textarea.x1 ~dev/screen.height #0008 SUB2 =textarea.y2 |
|
39 | 31 |
|
40 | 32 |
,redraw JSR |
41 | 33 |
|
... | ... |
@@ -71,7 +63,7 @@ BRK |
71 | 63 |
,click-end ~dev/mouse.state #00 EQU JMP? POP2 |
72 | 64 |
|
73 | 65 |
( scrollbar ) |
74 |
- ,no-click-scroll ~dev/mouse.x ~dev/screen.width #0008 SUB2 LTH2 JMP? POP |
|
66 |
+ ,no-click-scroll ~dev/mouse.x ~dev/screen.width #0008 SUB2 LTH2 JMP? POP2 |
|
75 | 67 |
|
76 | 68 |
,no-click-scroll-up ~dev/mouse.y #0008 DIV2 #0000 NEQ2 JMP? POP2 |
77 | 69 |
,scroll-up JSR |
... | ... |
@@ -84,15 +76,16 @@ BRK |
84 | 76 |
@no-click-scroll-down |
85 | 77 |
|
86 | 78 |
( on scrollbar ) |
87 |
- #cc NOP |
|
79 |
+ ~dev/mouse.y #0008 SUB2 =scroll.y |
|
80 |
+ ,redraw JSR |
|
81 |
+ ,click-end JMP |
|
88 | 82 |
|
89 | 83 |
@no-click-scroll |
90 | 84 |
|
91 | 85 |
( select body ) |
92 |
- ~dev/mouse.x #0008 DIV2 #0003 SUB2 =target.x |
|
93 |
- ~dev/mouse.y #0008 DIV2 =target.y |
|
86 |
+ ~dev/mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y |
|
87 |
+ ~dev/mouse.x ~textarea.x1 SUB2 #0008 DIV2 =position.x |
|
94 | 88 |
|
95 |
- ~dev/mouse.y #0008 DIV2 ~scroll-position.y ADD2 =selection.y |
|
96 | 89 |
,select-target JSR |
97 | 90 |
,redraw JSR |
98 | 91 |
|
... | ... |
@@ -104,40 +97,40 @@ BRK |
104 | 97 |
|
105 | 98 |
@scroll-up |
106 | 99 |
|
107 |
- ~scroll-position.y #0000 EQU2 RTS? |
|
108 |
- |
|
109 |
- ( decr ) ~scroll-position.y #0001 SUB2 =scroll-position.y |
|
100 |
+ ( clamp ) ~scroll.y #0000 EQU2 RTS? |
|
101 |
+ ( decr ) ~scroll.y #0001 SUB2 =scroll.y |
|
110 | 102 |
,redraw JSR |
111 | 103 |
|
112 | 104 |
RTS |
113 | 105 |
|
114 | 106 |
@scroll-down |
115 | 107 |
|
116 |
- ( incr ) ~scroll-position.y #0001 ADD2 =scroll-position.y |
|
108 |
+ ( incr ) ~scroll.y #0001 ADD2 =scroll.y |
|
117 | 109 |
,redraw JSR |
118 | 110 |
|
119 | 111 |
RTS |
120 | 112 |
|
121 | 113 |
@select-target |
122 | 114 |
|
123 |
- #0000 =j #0000 =pt.x #0000 =pt.y |
|
115 |
+ ,body =j #0000 =pt.x #0000 =pt.y |
|
124 | 116 |
|
125 | 117 |
@select-target-loop |
126 | 118 |
|
127 |
- ,no-reached ~pt.y ~target.y NEQ2 JMP? POP2 |
|
128 |
- ,no-reached ~pt.x ~target.x NEQ2 JMP? POP2 |
|
129 |
- ~j #0001 ADD2 =textarea.sela ~j #0002 ADD2 =textarea.selb |
|
119 |
+ ,no-reached ~pt.y ~position.y NEQ2 JMP? POP2 |
|
120 |
+ ,no-reached ~pt.x ~position.x NEQ2 JMP? POP2 |
|
121 |
+ ~j =selection.from |
|
122 |
+ ~j #0001 ADD2 =selection.to |
|
130 | 123 |
RTS |
131 | 124 |
@no-reached |
132 | 125 |
|
133 |
- ,no-space ,body ~j ADD2 LDR #0a NEQ JMP? POP2 |
|
126 |
+ ,no-space ~j LDR #0a NEQ JMP? POP2 |
|
134 | 127 |
( incr ) ~pt.y #0001 ADD2 =pt.y |
135 | 128 |
#0000 =pt.x |
136 | 129 |
@no-space |
137 | 130 |
|
138 | 131 |
( incr ) ~pt.x #0001 ADD2 =pt.x |
139 | 132 |
( incr ) ~j #0001 ADD2 =j |
140 |
- ,select-target-loop ,body ~j ADD2 LDR #00 NEQ JMP? POP2 |
|
133 |
+ ,select-target-loop ~j LDR #00 NEQ JMP? POP2 |
|
141 | 134 |
|
142 | 135 |
RTS |
143 | 136 |
|
... | ... |
@@ -148,13 +141,17 @@ RTS |
148 | 141 |
,draw-titlebar JSR |
149 | 142 |
,draw-lines JSR |
150 | 143 |
|
151 |
- ~dev/screen.width #0028 SUB2 =dev/sprite.x |
|
152 |
- ~dev/screen.height #0008 SUB2 =dev/sprite.y |
|
153 |
- ~textarea.sela ,draw-short JSR |
|
144 |
+ ( save/load icons ) |
|
154 | 145 |
|
155 |
- ~dev/screen.width #0050 SUB2 =dev/sprite.x |
|
156 | 146 |
~dev/screen.height #0008 SUB2 =dev/sprite.y |
157 |
- ~scroll-position.y ,draw-short JSR |
|
147 |
+ |
|
148 |
+ ~dev/screen.width #0018 SUB2 =dev/sprite.x |
|
149 |
+ ,load_icn =dev/sprite.addr |
|
150 |
+ #02 =dev/sprite.color |
|
151 |
+ |
|
152 |
+ ~dev/screen.width #0010 SUB2 =dev/sprite.x |
|
153 |
+ ,save_icn =dev/sprite.addr |
|
154 |
+ #02 =dev/sprite.color |
|
158 | 155 |
|
159 | 156 |
RTS |
160 | 157 |
|
... | ... |
@@ -168,12 +165,12 @@ RTS |
168 | 165 |
|
169 | 166 |
#0000 =dev/sprite.x |
170 | 167 |
|
171 |
- ~scroll-position.y ~j ADD2 =addr |
|
168 |
+ ~scroll.y ~j ADD2 =addr |
|
172 | 169 |
,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr |
173 |
- ( draw ) #08 ~addr ~selection.y EQU2 ADD =dev/sprite.color |
|
170 |
+ ( draw ) #02 ~addr ~position.y EQU2 ADD =dev/sprite.color |
|
174 | 171 |
~dev/sprite.x #0008 ADD2 =dev/sprite.x |
175 | 172 |
,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =dev/sprite.addr |
176 |
- ( draw ) #08 ~addr ~selection.y EQU2 ADD =dev/sprite.color |
|
173 |
+ ( draw ) #02 ~addr ~position.y EQU2 ADD =dev/sprite.color |
|
177 | 174 |
( incr ) ~j #0001 ADD2 =j |
178 | 175 |
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y |
179 | 176 |
,draw-lines-loop ~j ~dev/screen.height #0008 DIV2 NEQ2 JMP? POP2 |
... | ... |
@@ -229,22 +226,22 @@ RTS |
229 | 226 |
( scroll to position ) |
230 | 227 |
#0000 =j |
231 | 228 |
@find-scroll-offset |
229 |
+ ,skip ~scroll.y ~j EQU2 JMP? POP2 |
|
232 | 230 |
,no-break ~textarea.addr LDR #0a NEQ JMP? POP2 |
233 | 231 |
( incr ) ~j #0001 ADD2 =j |
234 | 232 |
@no-break |
235 |
- ,skip ~scroll-position.y ~j EQU2 JMP? POP2 |
|
236 | 233 |
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr |
237 | 234 |
,find-scroll-offset ~textarea.addr LDR #00 NEQ JMP? POP2 |
238 | 235 |
@skip |
239 | 236 |
|
240 | 237 |
#0000 =dev/sprite.y |
241 |
- #0000 =j |
|
238 |
+ ~textarea.addr =j |
|
242 | 239 |
|
243 | 240 |
#0018 =dev/sprite.x |
244 | 241 |
|
245 | 242 |
@draw-textarea-loop |
246 | 243 |
|
247 |
- ,no-linebreak ~textarea.addr ~j ADD2 LDR #0a NEQ JMP? POP2 |
|
244 |
+ ,no-linebreak ~j LDR #0a NEQ JMP? POP2 |
|
248 | 245 |
( fill clear ) |
249 | 246 |
@fill-clear |
250 | 247 |
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x |
... | ... |
@@ -258,21 +255,20 @@ RTS |
258 | 255 |
,draw-textarea-end ~dev/sprite.y ~dev/screen.height #0010 SUB2 GTH2 JMP? POP2 |
259 | 256 |
|
260 | 257 |
( get character ) |
261 |
- ~dev/sprite.y #0008 DIV2 ~scroll-position.y ADD2 =target.y ( current line ) |
|
262 |
- ,font #00 ~textarea.addr ~j ADD2 LDR #20 SUB #0008 MUL2 ADD2 =dev/sprite.addr |
|
258 |
+ ,font #00 ~j LDR #20 SUB #0008 MUL2 ADD2 =dev/sprite.addr |
|
263 | 259 |
( incr ) ~j #0001 ADD2 =j |
264 | 260 |
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x |
265 |
- ( draw ) #01 ~target.y ~selection.y EQU2 #0d MUL ADD =dev/sprite.color |
|
261 |
+ ( draw ) #01 |
|
262 |
+ ~j ~selection.from #0001 ADD2 GTH2 |
|
263 |
+ ~j ~selection.to #0002 ADD2 LTH2 #0101 EQU2 |
|
264 |
+ #05 MUL ADD =dev/sprite.color |
|
266 | 265 |
|
267 |
- ,draw-textarea-loop ~textarea.addr ~j ADD2 LDR #00 NEQ JMP? POP2 |
|
266 |
+ ,draw-textarea-loop ~j LDR #00 NEQ JMP? POP2 |
|
268 | 267 |
|
269 | 268 |
@draw-textarea-end |
270 | 269 |
|
271 |
- |
|
272 |
- |
|
273 | 270 |
RTS |
274 | 271 |
|
275 |
- |
|
276 | 272 |
@draw-scrollbar |
277 | 273 |
|
278 | 274 |
~dev/screen.width #0008 SUB2 =dev/sprite.x |
... | ... |
@@ -289,7 +285,7 @@ RTS |
289 | 285 |
( draw ) #08 =dev/sprite.color |
290 | 286 |
|
291 | 287 |
( at ) |
292 |
- ~scroll-position.y #0008 ADD2 =dev/sprite.y |
|
288 |
+ ~scroll.y #0008 ADD2 =dev/sprite.y |
|
293 | 289 |
,scrollbar_fg =dev/sprite.addr |
294 | 290 |
( draw ) #08 =dev/sprite.color |
295 | 291 |
|
... | ... |
@@ -301,7 +297,7 @@ RTS |
301 | 297 |
|
302 | 298 |
@draw-titlebar |
303 | 299 |
|
304 |
- #0018 ~dev/screen.height #0008 SUB2 #01 ,filepath |
|
300 |
+ #0018 ~dev/screen.height #0008 SUB2 #09 ,filepath |
|
305 | 301 |
|
306 | 302 |
( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x |
307 | 303 |
~label.addr |
... | ... |
@@ -312,6 +308,9 @@ RTS |
312 | 308 |
DUP2 LDR #00 NEQ ,draw-titlebar-loop ROT JMP? POP2 |
313 | 309 |
POP2 |
314 | 310 |
|
311 |
+ ( sel from ) |
|
312 |
+ ~selection.from ,draw-short JSR |
|
313 |
+ |
|
315 | 314 |
RTS |
316 | 315 |
|
317 | 316 |
@font_hex ( 0-F TODO: should pull from @font instead.. ) |
... | ... |
@@ -385,6 +384,8 @@ RTS |
385 | 384 |
@scrollbar_fg [ ffff ffff ffff ffff ] |
386 | 385 |
@arrowup_icn [ 0010 387c fe10 1010 ] |
387 | 386 |
@arrowdown_icn [ 0010 1010 fe7c 3810 ] |
387 |
+@load_icn [ feaa d6aa d4aa f400 ] |
|
388 |
+@save_icn [ fe82 8282 848a f400 ] |
|
388 | 389 |
@filepath [ projects/software/left.usm 00 ] |
389 | 390 |
|
390 | 391 |
|4000 @body [ ] |
... | ... |
@@ -400,4 +401,4 @@ RTS |
400 | 401 |
|FF60 ;dev/file File |
401 | 402 |
|
402 | 403 |
|FFF0 .RESET .FRAME .ERROR ( vectors ) |
403 |
-|FFF8 [ 6a0c 4a0b aa03 ] ( palette ) |
|
404 |
+|FFF8 [ 6a03 4a0d aa0c ] ( palette ) |