commit 3ca7ed4fef0a1224ea85b80e7865c0251cc83d81
parent d8cbd22574b436e73e2cdd96ec6b46557e7cddfb
Author: neauoire <aliceffekt@gmail.com>
Date: Sat, 6 Mar 2021 21:30:16 -0800
Progress on left
Diffstat:
1 file changed, 254 insertions(+), 39 deletions(-)
diff --git a/projects/software/left.usm b/projects/software/left.usm
@@ -10,9 +10,14 @@
&Mouse { x 2 y 2 state 1 chord 1 }
&File { pad 8 name 2 length 2 load 2 save 2 }
-&Textarea2d { x1 2 y1 2 x2 2 y2 2 color 1 addr 2 cursor 1 }
+&Point2d { x 2 y 2 }
+&Label2d { x 2 y 2 color 1 addr 2 }
+&Textarea2d { x1 2 y1 2 x2 2 y2 2 color 1 addr 2 cursor 1 sela 2 selb 2 }
+;target Point2d ;pt Point2d ;mouse Point2d
;textarea Textarea2d
+;label Label2d
+;i 1 ;j 2 ;addr 2 ;color 1
|0100 @RESET
@@ -20,18 +25,161 @@
#0300 =dev/file.length
,body =dev/file.load
- #0000 #0000 #0e ,body ,draw-textarea JSR
+ #0064 =textarea.sela #0065 =textarea.selb
+ #0018 =textarea.x1
+
+ ,redraw JSR
BRK
-|2000 @FRAME BRK
+|2000 @FRAME
+
+ ( ctrl )
+
+ ,no-ctrl ~dev/ctrl.buttons #00 EQU JMP? POP2
+
+ ,no-ctrl-left ~dev/ctrl.buttons #40 EQU JMP? POP2
+ ~textarea.sela #0001 ADD2 =textarea.sela
+ ~textarea.selb #0001 ADD2 =textarea.selb
+ ,redraw JSR
+ @no-ctrl-left
+ ,no-ctrl-right ~dev/ctrl.buttons #80 EQU JMP? POP2
+ ~textarea.sela #0001 SUB2 =textarea.sela
+ ~textarea.selb #0001 SUB2 =textarea.selb
+ ,redraw JSR
+ @no-ctrl-right
+
+ @no-ctrl
+
+ ( mouse )
+
+ ,click-end ~dev/mouse.state #00 EQU JMP? POP2
+
+ ~dev/mouse.x #0008 DIV2 #0003 SUB2 =target.x
+ ~dev/mouse.y #0008 DIV2 =target.y
+ ,select-target JSR
+ ,redraw JSR
+
+ @click-end
+
+ ,draw-cursor JSR
+
+BRK
+
+@select-target
+
+ #0000 =j #0000 =pt.x #0000 =pt.y
+
+ @select-target-loop
+
+ ,no-reached ~pt.y ~target.y NEQ2 JMP? POP2
+ ,no-reached ~pt.x ~target.x NEQ2 JMP? POP2
+ ~j #0001 ADD2 =textarea.sela ~j #0002 ADD2 =textarea.selb
+ RTS
+ @no-reached
+
+ ,no-space ,body ~j ADD2 LDR #0a NEQ JMP? POP2
+ ( incr ) ~pt.y #0001 ADD2 =pt.y
+ #0000 =pt.x
+ @no-space
+
+ ( incr ) ~pt.x #0001 ADD2 =pt.x
+ ( incr ) ~j #0001 ADD2 =j
+ ,select-target-loop ,body ~j ADD2 LDR #00 NEQ JMP? POP2
+
+RTS
+
+@redraw
+
+ #0058 #0000 #02 ,body ,draw-textarea JSR
+ ,draw-scrollbar JSR
+ ,draw-titlebar JSR
+ ,draw-lines JSR
+
+ ~dev/screen.width #0028 SUB2 =dev/sprite.x
+ ~dev/screen.height #0008 SUB2 =dev/sprite.y
+ ~textarea.sela ,draw-short JSR
+
+RTS
+
+@draw-lines
+
+ #0000 =j
+ #0000 =dev/sprite.x
+ #0000 =dev/sprite.y
+
+ @draw-lines-loop
+
+ #0000 =dev/sprite.x
+
+ ~j =addr
+ ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr
+ ( draw ) #06 ~pt.y ~j EQU2 ADD =dev/sprite.color
+ ~dev/sprite.x #0008 ADD2 =dev/sprite.x
+ ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =dev/sprite.addr
+ ( draw ) #06 ~pt.y ~j EQU2 ADD =dev/sprite.color
+
+ ( incr ) ~j #0001 ADD2 =j
+ ( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
+
+ ,draw-lines-loop ~j ~dev/screen.height #0008 DIV2 NEQ2 JMP? POP2
+
+RTS
+
+@draw-short ( short )
+
+ =addr
+ ,font_hex #00 ,addr LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr
+ ( draw ) #0e =dev/sprite.color
+ ~dev/sprite.x #0008 ADD2 =dev/sprite.x
+ ,font_hex #00 ,addr LDR #0f AND #08 MUL ADD2 =dev/sprite.addr
+ ( draw ) #0e =dev/sprite.color
+ ~dev/sprite.x #0008 ADD2 =dev/sprite.x
+ ,font_hex #00 ,addr #0001 ADD2 LDR #f0 AND #04 ROR #08 MUL ADD2 =dev/sprite.addr
+ ( draw ) #0e =dev/sprite.color
+ ~dev/sprite.x #0008 ADD2 =dev/sprite.x
+ ,font_hex #00 ,addr #0001 ADD2 LDR #0f AND #08 MUL ADD2 =dev/sprite.addr
+ ( draw ) #0e =dev/sprite.color
+
+RTS
+
+@draw-cursor
+
+ ~mouse.x ~dev/mouse.x NEQU2
+ ~mouse.y ~dev/mouse.y NEQU2
+
+ #0000 EQU2 RTS? ( Return if unchanged )
+
+ ( clear last cursor )
+ ~mouse.x =dev/sprite.x
+ ~mouse.y =dev/sprite.y
+ ,blank_icn =dev/sprite.addr
+ #10 =dev/sprite.color
+
+ ( record mouse positions )
+ ~dev/mouse.x =mouse.x
+ ~dev/mouse.y =mouse.y
+
+ ( draw new cursor )
+ ~mouse.x =dev/sprite.x
+ ~mouse.y =dev/sprite.y
+ ,cursor_icn =dev/sprite.addr
+ #11 =dev/sprite.color
+
+RTS
@draw-textarea ( x y color addr )
+ #0000 =j
+
( load ) =textarea.addr =textarea.color =dev/sprite.y =dev/sprite.x
~textarea.addr
@draw-textarea-left-loop
- ( draw ) DUP2 LDR #00 SWP #0008 MUL2 ,font ADD2 =dev/sprite.addr ~textarea.color =dev/sprite.color
+ ( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =dev/sprite.addr
+
+ ~textarea.color
+ ( selection ) ~j ~textarea.sela #0001 SUB2 GTH2 ~j ~textarea.selb LTH2 #0101 EQU2 #06 MUL ADD
+ =dev/sprite.color
( detect linebreaks )
DUP2 LDR #0a NEQ ,no-return ROT JMP? POP2
@@ -42,49 +190,116 @@ BRK
( incr ) #0001 ADD2
( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
+ ( incr ) ~j #0001 ADD2 =j
DUP2 LDR #00 NEQ ,draw-textarea-left-loop ROT JMP? POP2
POP2
RTS
-@font ( spectrum-zx font )
+@draw-scrollbar
+
+ ~dev/screen.width #0008 SUB2 =dev/sprite.x
+ #0000 =dev/sprite.y
+ ,scrollbar_bg =dev/sprite.addr
+
+ @draw-scrollbar-loop
+ ( draw ) #01 =dev/sprite.color
+ ( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y
+ ,draw-scrollbar-loop ~dev/sprite.y ~dev/screen.height LTH2 JMP? POP2
+
+ ( at )
+ #0000 =dev/sprite.y
+ ,scrollbar_fg =dev/sprite.addr
+ ( draw ) #01 =dev/sprite.color
+
+RTS
+
+@draw-titlebar
+
+ #0018 ~dev/screen.height #0008 SUB2 #07 ,filepath
+
+ ( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x
+ ~label.addr
+ @draw-label-left-loop
+ ( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =dev/sprite.addr ~label.color =dev/sprite.color
+ ( incr ) #0001 ADD2
+ ( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x
+ DUP2 #0001 ADD2 LDR #00 NEQ ,draw-label-left-loop ROT JMP? POP2
+ POP2
+
+RTS
+
+@font_hex ( 0-F )
[
- 0000 0000 0000 0000 0000 2400 7e3c 0000 0000 2400 3c42 0000 0000 6c7c 7c38 1000
- 0010 387c 7c38 1000 0038 387c 6c10 3800 0010 387c 7c10 3800 0000 0018 1800 0000
- 007e 4242 4242 7e00 0000 1824 2418 0000 0018 2442 4224 1800 001e 063a 4a48 3000
- 0038 446c 107c 1000 000c 0808 0838 3800 003e 2222 2266 6600 0000 0822 0022 0800
- 0000 1018 1c18 1000 0000 0818 3818 0800 0008 1c00 001c 0800 0028 2828 2800 2800
- 003e 4a4a 3a0a 0a00 000c 3046 620c 3000 0000 0000 0000 ffff 0010 3800 3810 0038
- 0008 1c2a 0808 0800 0008 0808 2a1c 0800 0000 0804 7e04 0800 0000 1020 7e20 1000
- 0000 4040 7e00 0000 0000 0024 6624 0000 0000 1038 7c00 0000 0000 007c 3810 0000
- 0000 0000 0000 0000 0008 0808 0800 0800 0014 1400 0000 0000 0024 7e24 247e 2400
- 0008 1e28 1c0a 3c08 0042 0408 1020 4200 0030 4832 4c44 3a00 0008 1000 0000 0000
- 0004 0808 0808 0400 0010 0808 0808 1000 0000 1408 3e08 1400 0000 0808 3e08 0800
- 0000 0000 0008 0810 0000 0000 3c00 0000 0000 0000 0000 0800 0000 0204 0810 2000
- 003c 464a 5262 3c00 0018 2808 0808 3e00 003c 4202 3c40 7e00 003c 421c 0242 3c00
- 0008 1828 487e 0800 007e 407c 0242 3c00 003c 407c 4242 3c00 007e 0204 0810 1000
- 003c 423c 4242 3c00 003c 4242 3e02 3c00 0000 0008 0000 0800 0000 0800 0008 0810
- 0000 0810 2010 0800 0000 003e 003e 0000 0000 1008 0408 1000 003c 4202 0c00 0800
- 003c 425a 5442 3c00 0018 2442 7e42 4200 007c 427c 4242 7c00 003c 4240 4042 3c00
- 0078 4442 4244 7800 007e 407c 4040 7e00 003e 4040 7c40 4000 003c 4240 4e42 3c00
- 0042 427e 4242 4200 003e 0808 0808 3e00 0002 0202 4242 3c00 0044 4870 4844 4200
- 0040 4040 4040 7e00 0042 665a 4242 4200 0042 6252 4a46 4200 003c 4242 4242 3c00
- 007c 4242 7c40 4000 003c 4242 524a 3c00 007c 4242 7c44 4200 003c 403c 0242 3c00
- 00fe 1010 1010 1000 0042 4242 4242 3c00 0042 4242 4224 1800 0042 4242 5a66 4200
- 0042 2418 1824 4200 0082 4428 1010 1000 007e 0408 1020 7e00 000c 0808 0808 0c00
- 0040 2010 0804 0200 0018 0808 0808 1800 0008 1422 0000 0000 0000 0000 0000 7e00
- 0008 0400 0000 0000 0000 1c02 1e22 1e00 0020 203c 2222 3c00 0000 1e20 2020 1e00
- 0002 021e 2222 1e00 0000 1c22 3c20 1e00 000c 101c 1010 1000 0000 1c22 221e 021c
- 0020 202c 3222 2200 0008 0018 0808 0400 0008 0008 0808 4830 0020 2428 3028 2400
- 0010 1010 1010 0c00 0000 6854 5454 5400 0000 5864 4444 4400 0000 3844 4444 3800
- 0000 7844 4478 4040 0000 3c44 443c 0406 0000 2c30 2020 2000 0000 3840 3804 7800
- 0010 103c 1010 0c00 0000 4444 4444 3800 0000 4444 2828 1000 0000 4454 5454 2800
- 0000 4428 1028 4400 0000 4444 443c 0438 0000 7c08 1020 7c00 000c 0810 1008 0c00
- 0008 0808 0808 0800 0030 1008 0810 3000 0000 0032 4c00 0000 3c42 99a1 a199 423c
+ 007c 8282 8282 827c 0030 1010 1010 1010
+ 007c 8202 7c80 80fe 007c 8202 1c02 827c
+ 000c 1424 4484 fe04 00fe 8080 7c02 827c
+ 007c 8280 fc82 827c 007c 8202 1e02 0202
+ 007c 8282 7c82 827c 007c 8282 7e02 827c
+ 007c 8202 7e82 827e 00fc 8282 fc82 82fc
+ 007c 8280 8080 827c 00fc 8282 8282 82fc
+ 007c 8280 f080 827c 007c 8280 f080 8080
+]
+
+@font ( specter8-frag font )
+[
+ 0000 0000 0000 0000 0008 0808 0800 0800
+ 0014 1400 0000 0000 0024 7e24 247e 2400
+ 0008 1e28 1c0a 3c08 0000 2204 0810 2200
+ 0030 4832 4c44 3a00 0008 1000 0000 0000
+ 0004 0808 0808 0400 0020 1010 1010 2000
+ 0000 2214 0814 2200 0000 0808 3e08 0800
+ 0000 0000 0000 0810 0000 0000 3e00 0000
+ 0000 0000 0000 0800 0000 0204 0810 2000
+ 003c 464a 5262 3c00 0018 0808 0808 1c00
+ 003c 4202 3c40 7e00 003c 421c 0242 3c00
+ 000c 1424 447e 0400 007e 407c 0242 3c00
+ 003c 407c 4242 3c00 007e 0204 0810 1000
+ 003c 423c 4242 3c00 003c 4242 3e02 3c00
+ 0000 0010 0000 1000 0000 1000 0010 1020
+ 0000 0810 2010 0800 0000 003e 003e 0000
+ 0000 1008 0408 1000 003c 420c 1000 1000
+ 003c 4232 4a42 3c00 003c 4242 7e42 4200
+ 007c 427c 4242 7c00 003c 4240 4042 3c00
+ 007c 4242 4242 7c00 007e 4078 4040 7e00
+ 007e 4078 4040 4000 003c 4240 4642 3c00
+ 0042 427e 4242 4200 001c 0808 0808 1c00
+ 007e 0202 0242 3c00 0042 4478 4442 4200
+ 0040 4040 4040 7e00 0042 665a 4242 4200
+ 0042 6252 4a46 4200 003c 4242 4242 3c00
+ 007c 4242 7c40 4000 003c 4242 4244 3a00
+ 007c 4242 7c44 4200 003e 403c 0242 3c00
+ 007e 0808 0808 1000 0042 4242 4244 3a00
+ 0042 4242 4224 1800 0042 4242 5a66 4200
+ 0042 423c 4242 4200 0042 423e 0242 3c00
+ 007e 020c 3040 7e00 000c 0808 0808 0c00
+ 0040 2010 0804 0200 0030 1010 1010 3000
+ 0008 1400 0000 0000 0000 0000 0000 7e00
+ 0008 0400 0000 0000 0000 3c02 3e42 3a00
+ 0040 407c 4242 7c00 0000 3c42 4042 3c00
+ 0002 023e 4242 3e00 0000 3c42 7e40 3e00
+ 0000 3e40 7840 4000 0000 3c42 3e02 3c00
+ 0040 405c 6242 4200 0008 0018 0808 0400
+ 0008 0018 0808 4830 0040 4244 7844 4200
+ 0010 1010 1010 0c00 0000 6c52 5252 5200
+ 0000 5c62 4242 4200 0000 3c42 4242 3c00
+ 0000 7c42 427c 4040 0000 3e42 423e 0202
+ 0000 5c62 4040 4000 0000 3e40 3c02 7c00
+ 0008 7e08 0808 1000 0000 4242 4244 3a00
+ 0000 4242 4224 1800 0000 5252 5252 2e00
+ 0000 4224 1824 4200 0000 4242 3e02 7c00
+ 0000 7e02 3c40 7e00 000c 0810 1008 0c00
+ 0008 0808 0808 0800 0030 1008 0810 3000
+ 0000 0032 4c00 0000 3c42 99a1 a199 423c
+
]
-@filepath [ examples/app.left.usm ]
+@blank_icn [ 0000 0000 0000 0000 ]
+@cursor_icn [ 80c0 e0f0 f8e0 1000 ]
+@scrollbar_bg [ aa55 aa55 aa55 aa55 ]
+@scrollbar_fg [ ffff ffff ffff ffff ]
+@filepath [ projects/software/left.usm 00 ]
|4000 @body [ ]
@@ -99,4 +314,4 @@ RTS
|FF60 ;dev/file File
|FFF0 .RESET .FRAME .ERROR ( vectors )
-|FFF8 [ 320c 350b fb03 ] ( palette )
+|FFF8 [ a30c a30b af03 ] ( palette )