uxn

Varvara Ordinator, written in ANSI C(SDL2)
git clone https://git.eamoncaddigan.net/uxn.git
Log | Files | Refs | README | LICENSE

commit 39c157e65aa646f1debb169a62f324b0e332464b
parent 3ca7ed4fef0a1224ea85b80e7865c0251cc83d81
Author: neauoire <aliceffekt@gmail.com>
Date:   Sun,  7 Mar 2021 12:32:19 -0800

Progress on left

Diffstat:
Mbuild.sh | 2+-
Mprojects/software/left.usm | 165++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------
2 files changed, 122 insertions(+), 45 deletions(-)

diff --git a/build.sh b/build.sh @@ -20,5 +20,5 @@ cc -std=c89 -DDEBUG -Wall -Wno-unknown-pragmas -Wpedantic -Wshadow -Wextra -Werr # cc uxn.c emulator.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -Wno-unknown-pragmas -L/usr/local/lib -lSDL2 -o bin/emulator # run -./bin/assembler projects/software/nasu.usm bin/boot.rom +./bin/assembler projects/software/left.usm bin/boot.rom ./bin/emulator bin/boot.rom diff --git a/projects/software/left.usm b/projects/software/left.usm @@ -7,14 +7,19 @@ &Sprite { pad 8 x 2 y 2 addr 2 color 1 } &Controller { buttons 1 } &Keyboard { key 1 } -&Mouse { x 2 y 2 state 1 chord 1 } +&Mouse { x 2 y 2 state 1 chord 1 xt 1 yt 1 } &File { pad 8 name 2 length 2 load 2 save 2 } &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 +;scroll-position Point2d +;scroll-target Point2d + + +;selection Point2d +;target Point2d ;pt Point2d ;pt2 Point2d ;mouse Point2d ;textarea Textarea2d ;label Label2d ;i 1 ;j 2 ;addr 2 ;color 1 @@ -25,8 +30,13 @@ #0300 =dev/file.length ,body =dev/file.load - #0064 =textarea.sela #0065 =textarea.selb + #0005 =selection.y + + #02 =textarea.color + #0064 =textarea.sela + #0065 =textarea.selb #0018 =textarea.x1 + ~dev/screen.height #0008 SUB2 =textarea.y2 ,redraw JSR @@ -38,6 +48,12 @@ BRK ,no-ctrl ~dev/ctrl.buttons #00 EQU JMP? POP2 + ,no-ctrl-down ~dev/ctrl.buttons #10 EQU JMP? POP2 + #aa NOP + @no-ctrl-down + ,no-ctrl-up ~dev/ctrl.buttons #20 EQU JMP? POP2 + #bb NOP + @no-ctrl-up ,no-ctrl-left ~dev/ctrl.buttons #40 EQU JMP? POP2 ~textarea.sela #0001 ADD2 =textarea.sela ~textarea.selb #0001 ADD2 =textarea.selb @@ -55,8 +71,29 @@ BRK ,click-end ~dev/mouse.state #00 EQU JMP? POP2 + ( scrollbar ) + ,no-click-scroll ~dev/mouse.x ~dev/screen.width #0008 SUB2 LTH2 JMP? POP + + ,no-click-scroll-up ~dev/mouse.y #0008 DIV2 #0000 NEQ2 JMP? POP2 + ,scroll-up JSR + ,click-end JMP + @no-click-scroll-up + + ,no-click-scroll-down ~dev/mouse.y #0008 DIV2 #0008 MUL2 ~dev/screen.height #0008 SUB2 NEQ2 JMP? POP2 + ,scroll-down JSR + ,click-end JMP + @no-click-scroll-down + + ( on scrollbar ) + #cc NOP + + @no-click-scroll + + ( select body ) ~dev/mouse.x #0008 DIV2 #0003 SUB2 =target.x ~dev/mouse.y #0008 DIV2 =target.y + + ~dev/mouse.y #0008 DIV2 ~scroll-position.y ADD2 =selection.y ,select-target JSR ,redraw JSR @@ -66,6 +103,22 @@ BRK BRK +@scroll-up + + ~scroll-position.y #0000 EQU2 RTS? + + ( decr ) ~scroll-position.y #0001 SUB2 =scroll-position.y + ,redraw JSR + +RTS + +@scroll-down + + ( incr ) ~scroll-position.y #0001 ADD2 =scroll-position.y + ,redraw JSR + +RTS + @select-target #0000 =j #0000 =pt.x #0000 =pt.y @@ -91,7 +144,7 @@ RTS @redraw - #0058 #0000 #02 ,body ,draw-textarea JSR + ,draw-textarea JSR ,draw-scrollbar JSR ,draw-titlebar JSR ,draw-lines JSR @@ -100,6 +153,10 @@ RTS ~dev/screen.height #0008 SUB2 =dev/sprite.y ~textarea.sela ,draw-short JSR + ~dev/screen.width #0050 SUB2 =dev/sprite.x + ~dev/screen.height #0008 SUB2 =dev/sprite.y + ~scroll-position.y ,draw-short JSR + RTS @draw-lines @@ -112,16 +169,14 @@ RTS #0000 =dev/sprite.x - ~j =addr + ~scroll-position.y ~j ADD2 =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 + ( draw ) #08 ~addr ~selection.y 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 - + ( draw ) #08 ~addr ~selection.y 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 @@ -164,39 +219,51 @@ RTS ~mouse.x =dev/sprite.x ~mouse.y =dev/sprite.y ,cursor_icn =dev/sprite.addr - #11 =dev/sprite.color + #13 =dev/sprite.color RTS @draw-textarea ( x y color addr ) + ,body =textarea.addr + + ( scroll to position ) #0000 =j + @find-scroll-offset + ,no-break ~textarea.addr LDR #0a NEQ JMP? POP2 + ( incr ) ~j #0001 ADD2 =j + @no-break + ,skip ~scroll-position.y ~j EQU2 JMP? POP2 + ( incr ) ~textarea.addr #0001 ADD2 =textarea.addr + ,find-scroll-offset ~textarea.addr LDR #00 NEQ JMP? POP2 + @skip - ( load ) =textarea.addr =textarea.color =dev/sprite.y =dev/sprite.x - ~textarea.addr - @draw-textarea-left-loop - ( draw ) DUP2 LDR #00 SWP #20 SUB #0008 MUL2 ,font ADD2 =dev/sprite.addr + #0000 =dev/sprite.y - ~textarea.color - ( selection ) ~j ~textarea.sela #0001 SUB2 GTH2 ~j ~textarea.selb LTH2 #0101 EQU2 #06 MUL ADD - =dev/sprite.color + ( draw ) + @draw-textarea-ver + #0018 =dev/sprite.x + @draw-textarea-hor - ( detect linebreaks ) - DUP2 LDR #0a NEQ ,no-return ROT JMP? POP2 - ~textarea.x1 =dev/sprite.x - ( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y - ( decr ) ~dev/sprite.x #0008 SUB2 =dev/sprite.x - @no-return + ( get character ) + ~dev/sprite.y #0008 DIV2 ~scroll-position.y ADD2 =target.y + ~dev/sprite.x #0018 SUB2 #0008 DIV2 =target.x - ( incr ) #0001 ADD2 - ( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x - ( incr ) ~j #0001 ADD2 =j + ,font #00 - DUP2 LDR #00 NEQ ,draw-textarea-left-loop ROT JMP? POP2 - POP2 + #45 + + #0008 MUL2 ADD2 =dev/sprite.addr + + #01 ~target.y ~selection.y EQU2 #0d MUL ADD =dev/sprite.color + ( incr ) ~dev/sprite.x #0008 ADD2 =dev/sprite.x + ,draw-textarea-hor ~dev/sprite.x ~dev/screen.width #0010 SUB2 LTH2 JMP? POP2 + ( incr ) ~dev/sprite.y #0008 ADD2 =dev/sprite.y + ,draw-textarea-ver ~dev/sprite.y ~dev/screen.height #0010 SUB2 LTH2 JMP? POP2 RTS + @draw-scrollbar ~dev/screen.width #0008 SUB2 =dev/sprite.x @@ -204,42 +271,50 @@ RTS ,scrollbar_bg =dev/sprite.addr @draw-scrollbar-loop - ( draw ) #01 =dev/sprite.color + ( draw ) #08 =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 + ,arrowup_icn =dev/sprite.addr + ( draw ) #08 =dev/sprite.color + + ( at ) + ~scroll-position.y #0008 ADD2 =dev/sprite.y ,scrollbar_fg =dev/sprite.addr - ( draw ) #01 =dev/sprite.color + ( draw ) #08 =dev/sprite.color + + ~dev/screen.height #0008 SUB2 =dev/sprite.y + ,arrowdown_icn =dev/sprite.addr + ( draw ) #08 =dev/sprite.color RTS @draw-titlebar - #0018 ~dev/screen.height #0008 SUB2 #07 ,filepath + #0018 ~dev/screen.height #0008 SUB2 #01 ,filepath ( load ) =label.addr =label.color =dev/sprite.y =dev/sprite.x ~label.addr - @draw-label-left-loop + @draw-titlebar-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 + DUP2 LDR #00 NEQ ,draw-titlebar-loop ROT JMP? POP2 POP2 RTS -@font_hex ( 0-F ) +@font_hex ( 0-F TODO: should pull from @font instead.. ) [ - 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 + 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 + 003c 4242 7e42 4200 007c 427c 4242 7c00 + 003c 4240 4042 3c00 007c 4242 4242 7c00 + 007e 4078 4040 7e00 007e 4078 4040 4000 ] @font ( specter8-frag font ) @@ -299,6 +374,8 @@ RTS @cursor_icn [ 80c0 e0f0 f8e0 1000 ] @scrollbar_bg [ aa55 aa55 aa55 aa55 ] @scrollbar_fg [ ffff ffff ffff ffff ] +@arrowup_icn [ 0010 387c fe10 1010 ] +@arrowdown_icn [ 0010 1010 fe7c 3810 ] @filepath [ projects/software/left.usm 00 ] |4000 @body [ ] @@ -314,4 +391,4 @@ RTS |FF60 ;dev/file File |FFF0 .RESET .FRAME .ERROR ( vectors ) -|FFF8 [ a30c a30b af03 ] ( palette ) +|FFF8 [ 6a0c 4a0b aa03 ] ( palette )