| ... | ... |
@@ -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/nasu.usm bin/boot.rom |
|
| 23 |
+./bin/assembler projects/software/left.usm bin/boot.rom |
|
| 24 | 24 |
./bin/emulator bin/boot.rom |
| ... | ... |
@@ -3,17 +3,19 @@ |
| 3 | 3 |
) |
| 4 | 4 |
|
| 5 | 5 |
&Console { pad 8 stdio 1 }
|
| 6 |
-&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
|
| 7 |
-&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|
| 6 |
+&Screen { width 2 height 2 pad 4 x 2 y 2 color 1 }
|
|
| 7 |
+&Sprite { pad 8 x 2 y 2 addr 2 color 1 }
|
|
| 8 | 8 |
&Controller { buttons 1 }
|
| 9 |
-&Keyboard { key 1 }
|
|
| 10 |
-&Mouse { x 2 y 2 state 1 chord 1 xt 1 yt 1 }
|
|
| 9 |
+&Keyboard { key 1 }
|
|
| 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 }
|
|
| 14 |
-&Point2d { x 2 y 2 }
|
|
| 15 |
-&Label2d { x 2 y 2 color 1 addr 2 }
|
|
| 16 |
-&Textarea2d { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 sela 2 selb 2 }
|
|
| 13 |
+&Document { eof 2 body 8000 }
|
|
| 14 |
+ |
|
| 15 |
+&Range2d { from 2 to 2 }
|
|
| 16 |
+&Point2d { x 2 y 2 }
|
|
| 17 |
+&Label2d { x 2 y 2 color 1 addr 2 }
|
|
| 18 |
+&Textarea2d { x1 2 y1 2 x2 2 y2 2 addr 2 cursor 1 }
|
|
| 17 | 19 |
|
| 18 | 20 |
;selection Range2d |
| 19 | 21 |
;pt Point2d ;mouse Point2d ;position Point2d ;scroll Point2d |
| ... | ... |
@@ -24,40 +26,51 @@ |
| 24 | 26 |
|0100 @RESET |
| 25 | 27 |
|
| 26 | 28 |
( load file ) |
| 27 |
- ,filepath =dev/file.name #3000 =dev/file.length ,body =dev/file.load |
|
| 29 |
+ ,filepath ,load-file JSR |
|
| 28 | 30 |
|
| 29 | 31 |
( place textarea ) |
| 30 | 32 |
#0018 =textarea.x1 ~dev/screen.height #0008 SUB2 =textarea.y2 |
| 31 | 33 |
|
| 34 |
+ ,select JSR |
|
| 32 | 35 |
,redraw JSR |
| 33 | 36 |
|
| 34 | 37 |
BRK |
| 35 | 38 |
|
| 36 |
-|2000 @FRAME |
|
| 39 |
+@FRAME |
|
| 37 | 40 |
|
| 38 | 41 |
( ctrl ) |
| 39 | 42 |
|
| 40 |
- ,no-ctrl ~dev/ctrl.buttons #00 EQU JMP? POP2 |
|
| 41 |
- |
|
| 42 |
- ,no-ctrl-down ~dev/ctrl.buttons #10 EQU JMP? POP2 |
|
| 43 |
- #aa NOP |
|
| 43 |
+ ,no-ctrl ~dev/ctrl #00 EQU JMP? POP2 |
|
| 44 |
+ |
|
| 45 |
+ ,no-ctrl-down ~dev/ctrl #04 ROR #01 NEQ JMP? POP2 |
|
| 46 |
+ ~position.y #0001 SUB2 =position.y |
|
| 47 |
+ ,select JSR ,redraw JSR ,no-ctrl JMP |
|
| 44 | 48 |
@no-ctrl-down |
| 45 |
- ,no-ctrl-up ~dev/ctrl.buttons #20 EQU JMP? POP2 |
|
| 46 |
- #bb NOP |
|
| 49 |
+ ,no-ctrl-up ~dev/ctrl #04 ROR #02 NEQ JMP? POP2 |
|
| 50 |
+ ~position.y #0001 ADD2 =position.y |
|
| 51 |
+ ,select JSR ,redraw JSR ,no-ctrl JMP |
|
| 47 | 52 |
@no-ctrl-up |
| 48 |
- ,no-ctrl-left ~dev/ctrl.buttons #40 EQU JMP? POP2 |
|
| 49 |
- ~textarea.sela #0001 ADD2 =textarea.sela |
|
| 50 |
- ~textarea.selb #0001 ADD2 =textarea.selb |
|
| 51 |
- ,redraw JSR |
|
| 53 |
+ ,no-ctrl-left ~dev/ctrl #04 ROR #04 NEQ JMP? POP2 |
|
| 54 |
+ ~position.x #0001 SUB2 =position.x |
|
| 55 |
+ ,select JSR ,redraw JSR ,no-ctrl JMP |
|
| 52 | 56 |
@no-ctrl-left |
| 53 |
- ,no-ctrl-right ~dev/ctrl.buttons #80 EQU JMP? POP2 |
|
| 54 |
- ~textarea.sela #0001 SUB2 =textarea.sela |
|
| 55 |
- ~textarea.selb #0001 SUB2 =textarea.selb |
|
| 56 |
- ,redraw JSR |
|
| 57 |
+ ,no-ctrl-right ~dev/ctrl #04 ROR #08 NEQ JMP? POP2 |
|
| 58 |
+ ~position.x #0001 ADD2 =position.x |
|
| 59 |
+ ,select JSR ,redraw JSR ,no-ctrl JMP |
|
| 57 | 60 |
@no-ctrl-right |
| 58 | 61 |
|
| 59 | 62 |
@no-ctrl |
| 60 | 63 |
|
| 64 |
+ ( keys ) |
|
| 65 |
+ |
|
| 66 |
+ ,no-keys ~dev/key #00 EQU JMP? POP2 |
|
| 67 |
+ |
|
| 68 |
+ ~dev/key ~selection.from STR |
|
| 69 |
+ ( release ) #00 =dev/key |
|
| 70 |
+ ,redraw JSR |
|
| 71 |
+ |
|
| 72 |
+ @no-keys |
|
| 73 |
+ |
|
| 61 | 74 |
( mouse ) |
| 62 | 75 |
|
| 63 | 76 |
,click-end ~dev/mouse.state #00 EQU JMP? POP2 |
| ... | ... |
@@ -84,9 +97,9 @@ BRK |
| 84 | 97 |
|
| 85 | 98 |
( select body ) |
| 86 | 99 |
~dev/mouse.y #0008 DIV2 ~scroll.y ADD2 =position.y |
| 87 |
- ~dev/mouse.x ~textarea.x1 SUB2 #0008 DIV2 =position.x |
|
| 100 |
+ ~dev/mouse.x ~textarea.x1 SUB2 #0008 ADD2 #0008 DIV2 =position.x |
|
| 88 | 101 |
|
| 89 |
- ,select-target JSR |
|
| 102 |
+ ,select JSR |
|
| 90 | 103 |
,redraw JSR |
| 91 | 104 |
|
| 92 | 105 |
@click-end |
| ... | ... |
@@ -95,6 +108,18 @@ BRK |
| 95 | 108 |
|
| 96 | 109 |
BRK |
| 97 | 110 |
|
| 111 |
+@load-file ( path ) |
|
| 112 |
+ |
|
| 113 |
+ =dev/file.name #8000 =dev/file.length ,document.body =dev/file.load |
|
| 114 |
+ |
|
| 115 |
+ ( get file length ) |
|
| 116 |
+ ,document.body =document.eof |
|
| 117 |
+ @load-file-loop |
|
| 118 |
+ ( incr ) ~document.eof #0001 ADD2 =document.eof |
|
| 119 |
+ ,load-file-loop ~document.eof LDR #00 NEQ JMP? POP2 |
|
| 120 |
+ |
|
| 121 |
+RTS |
|
| 122 |
+ |
|
| 98 | 123 |
@scroll-up |
| 99 | 124 |
|
| 100 | 125 |
( clamp ) ~scroll.y #0000 EQU2 RTS? |
| ... | ... |
@@ -110,14 +135,20 @@ RTS |
| 110 | 135 |
|
| 111 | 136 |
RTS |
| 112 | 137 |
|
| 113 |
-@select-target |
|
| 138 |
+@select |
|
| 114 | 139 |
|
| 115 |
- ,body =j #0000 =pt.x #0000 =pt.y |
|
| 140 |
+ ,document.body =j #0000 =pt.x #0000 =pt.y |
|
| 116 | 141 |
|
| 117 |
- @select-target-loop |
|
| 142 |
+ @select-loop |
|
| 118 | 143 |
|
| 119 | 144 |
,no-reached ~pt.y ~position.y NEQ2 JMP? POP2 |
| 120 | 145 |
,no-reached ~pt.x ~position.x NEQ2 JMP? POP2 |
| 146 |
+ |
|
| 147 |
+ ,no-ctrl-yes ~dev/ctrl #0f AND #01 NEQ JMP? POP2 |
|
| 148 |
+ ~j =selection.to |
|
| 149 |
+ RTS |
|
| 150 |
+ @no-ctrl-yes |
|
| 151 |
+ |
|
| 121 | 152 |
~j =selection.from |
| 122 | 153 |
~j #0001 ADD2 =selection.to |
| 123 | 154 |
RTS |
| ... | ... |
@@ -130,7 +161,7 @@ RTS |
| 130 | 161 |
|
| 131 | 162 |
( incr ) ~pt.x #0001 ADD2 =pt.x |
| 132 | 163 |
( incr ) ~j #0001 ADD2 =j |
| 133 |
- ,select-target-loop ~j LDR #00 NEQ JMP? POP2 |
|
| 164 |
+ ,select-loop ~j LDR #00 NEQ JMP? POP2 |
|
| 134 | 165 |
|
| 135 | 166 |
RTS |
| 136 | 167 |
|
| ... | ... |
@@ -221,19 +252,20 @@ RTS |
| 221 | 252 |
|
| 222 | 253 |
@draw-textarea ( x y color addr ) |
| 223 | 254 |
|
| 224 |
- ,body =textarea.addr |
|
| 255 |
+ ,document.body =textarea.addr |
|
| 225 | 256 |
|
| 226 | 257 |
( scroll to position ) |
| 227 |
- #0000 =j |
|
| 258 |
+ #0000 =j ( j is linebreaks ) |
|
| 228 | 259 |
@find-scroll-offset |
| 229 |
- ,skip ~scroll.y ~j EQU2 JMP? POP2 |
|
| 260 |
+ ,find-scroll-offset-end ~scroll.y ~j EQU2 JMP? POP2 |
|
| 230 | 261 |
,no-break ~textarea.addr LDR #0a NEQ JMP? POP2 |
| 231 | 262 |
( incr ) ~j #0001 ADD2 =j |
| 232 | 263 |
@no-break |
| 233 | 264 |
( incr ) ~textarea.addr #0001 ADD2 =textarea.addr |
| 234 | 265 |
,find-scroll-offset ~textarea.addr LDR #00 NEQ JMP? POP2 |
| 235 |
- @skip |
|
| 266 |
+ @find-scroll-offset-end |
|
| 236 | 267 |
|
| 268 |
+ ~textarea.addr #0000 ADD2 =textarea.addr |
|
| 237 | 269 |
#0000 =dev/sprite.y |
| 238 | 270 |
~textarea.addr =j |
| 239 | 271 |
|
| ... | ... |
@@ -248,7 +280,7 @@ RTS |
| 248 | 280 |
,font =dev/sprite.addr |
| 249 | 281 |
#01 =dev/sprite.color |
| 250 | 282 |
,fill-clear ~dev/sprite.x ~dev/screen.width #0010 SUB2 LTH2 JMP? POP2 |
| 251 |
- #0008 =dev/sprite.x |
|
| 283 |
+ #0010 =dev/sprite.x |
|
| 252 | 284 |
( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y |
| 253 | 285 |
@no-linebreak |
| 254 | 286 |
|
| ... | ... |
@@ -256,13 +288,15 @@ RTS |
| 256 | 288 |
|
| 257 | 289 |
( get character ) |
| 258 | 290 |
,font #00 ~j LDR #20 SUB #0008 MUL2 ADD2 =dev/sprite.addr |
| 259 |
- ( incr ) ~j #0001 ADD2 =j |
|
| 260 |
- ( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x |
|
| 291 |
+ |
|
| 261 | 292 |
( draw ) #01 |
| 262 |
- ~j ~selection.from #0001 ADD2 GTH2 |
|
| 263 |
- ~j ~selection.to #0002 ADD2 LTH2 #0101 EQU2 |
|
| 293 |
+ ~j ~selection.from #0001 SUB2 GTH2 |
|
| 294 |
+ ~j ~selection.to LTH2 #0101 EQU2 |
|
| 264 | 295 |
#05 MUL ADD =dev/sprite.color |
| 265 | 296 |
|
| 297 |
+ ( incr ) ~j #0001 ADD2 =j |
|
| 298 |
+ ( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x |
|
| 299 |
+ |
|
| 266 | 300 |
,draw-textarea-loop ~j LDR #00 NEQ JMP? POP2 |
| 267 | 301 |
|
| 268 | 302 |
@draw-textarea-end |
| ... | ... |
@@ -308,8 +342,12 @@ RTS |
| 308 | 342 |
DUP2 LDR #00 NEQ ,draw-titlebar-loop ROT JMP? POP2 |
| 309 | 343 |
POP2 |
| 310 | 344 |
|
| 311 |
- ( sel from ) |
|
| 312 |
- ~selection.from ,draw-short JSR |
|
| 345 |
+ ( selection ) |
|
| 346 |
+ ~selection.from ,document.body SUB2 ,draw-short JSR |
|
| 347 |
+ |
|
| 348 |
+ ( length ) |
|
| 349 |
+ ~dev/screen.width #0040 SUB2 =dev/sprite.x |
|
| 350 |
+ ~document.eof ,document.body SUB2 ,draw-short JSR |
|
| 313 | 351 |
|
| 314 | 352 |
RTS |
| 315 | 353 |
|
| ... | ... |
@@ -386,9 +424,10 @@ RTS |
| 386 | 424 |
@arrowdown_icn [ 0010 1010 fe7c 3810 ] |
| 387 | 425 |
@load_icn [ feaa d6aa d4aa f400 ] |
| 388 | 426 |
@save_icn [ fe82 8282 848a f400 ] |
| 389 |
-@filepath [ projects/software/left.usm 00 ] |
|
| 427 |
+@filepath [ test.txt 00 ] |
|
| 428 |
+@filepath1 [ projects/software/left.usm 00 ] |
|
| 390 | 429 |
|
| 391 |
-|4000 @body [ ] |
|
| 430 |
+|4000 ;document Document |
|
| 392 | 431 |
|
| 393 | 432 |
|d000 @ERROR BRK |
| 394 | 433 |
|
| ... | ... |
@@ -401,4 +440,4 @@ RTS |
| 401 | 440 |
|FF60 ;dev/file File |
| 402 | 441 |
|
| 403 | 442 |
|FFF0 .RESET .FRAME .ERROR ( vectors ) |
| 404 |
-|FFF8 [ 6a03 4a0d aa0c ] ( palette ) |
|
| 443 |
+|FFF8 [ a1f3 a14d a16c ] ( palette ) |
| 405 | 444 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,31 @@ |
| 1 |
+This is the first line. |
|
| 2 |
+ This is a tabbed line. |
|
| 3 |
+ |
|
| 4 |
+The previous line is blank. |
|
| 5 |
+ This is another tabbed line. |
|
| 6 |
+ |
|
| 7 |
+This is a very long line, This is a very long line, This is a very long line, This is a very long line. |
|
| 8 |
+ |
|
| 9 |
+This is a text block This is |
|
| 10 |
+is a text block This is a te |
|
| 11 |
+This is a text block This is |
|
| 12 |
+is a text block This is a te |
|
| 13 |
+This is a text block This is |
|
| 14 |
+is a text block This is a te |
|
| 15 |
+This is a text block This is |
|
| 16 |
+is a text block This is a te |
|
| 17 |
+ |
|
| 18 |
+oneword |
|
| 19 |
+two words |
|
| 20 |
+ |
|
| 21 |
+( parens ) |
|
| 22 |
+[ block ] |
|
| 23 |
+{ curlies }
|
|
| 24 |
+ |
|
| 25 |
+Depth1 |
|
| 26 |
+ Depth2 |
|
| 27 |
+ Depth3 |
|
| 28 |
+ Depth4 |
|
| 29 |
+ Depth5 |
|
| 30 |
+ |
|
| 31 |
+This is the last line. |
|
| 0 | 32 |
\ No newline at end of file |