uxn

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

commit b43f973adb0eae2880143242be77557d21fd6008
parent 400c49e96b836d5b1000305434ef17a7b9a5ee96
Author: Andrew Alderwick <andrew@alderwick.co.uk>
Date:   Wed, 21 Apr 2021 13:37:59 +0100

Port dev.file.usm

Diffstat:
Mbuild.sh | 2+-
Aprojects/examples/dev.file.usm | 202+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 203 insertions(+), 1 deletion(-)

diff --git a/build.sh b/build.sh @@ -32,7 +32,7 @@ else fi echo "Assembling.." -./bin/assembler projects/examples/dev.controller.buttons.usm bin/boot.rom +./bin/assembler projects/examples/dev.file.usm bin/boot.rom echo "Running.." if [ "${2}" = '--cli' ]; diff --git a/projects/examples/dev.file.usm b/projects/examples/dev.file.usm @@ -0,0 +1,202 @@ +( Dev/File ) + +%RTN { JMP2r } +%STEP8 { #0033 SFT2 } +%++ { #01 ADD } + +%->MS/STAT { .Mouse/state IOW } +%<-MS/STAT { .Mouse/state IOR } +%->SC/COLR { .Screen/color IOW } +%=>SC/ADDR { .Screen/addr IOW2 } +%=>SC/X { .Screen/x IOW2 } +%=>SC/Y { .Screen/y IOW2 } +%<=SC/X { .Screen/x IOR2 } +%<=MS/X { .Mouse/x IOR2 } +%<=MS/Y { .Mouse/y IOR2 } + +%MEMORY { #1000 } + +@loadbtn [ &x $2 &y $2 ] +@output [ &x $2 &y $2 ] +@pointer [ &x $2 &y $2 ] +@label [ &x $2 &y $2 &color $1 &addr $2 ] + +( program ) + +|0100 + + ( theme ) + #804b .System/r IOW2 + #804b .System/g IOW2 + #e0bb .System/b IOW2 + + ( vectors ) + ;on-mouse .Mouse/vector IOW2 + + #0020 .loadbtn/x STR + #0020 .loadbtn/y STR + #0020 .output/x STR + #0030 .output/y STR + + .loadbtn/x LDR .loadbtn/y LDR #26 ;load_txt ;draw-label JSR2 + + ;draw-file JSR2 + +BRK + +@on-mouse ( -> ) + + .loadbtn/x LDR .loadbtn/y LDR #26 ;load_txt ;draw-label JSR2 + .loadbtn/x LDR #0028 ADD2 .loadbtn/y LDR #23 ;srcpath ;draw-label JSR2 + + <-MS/STAT #00 EQU ,&touch-end JNZ + + <=MS/Y STEP8 .loadbtn/y LDR NEQ2 ,&no-touch-load JNZ + .loadbtn/x LDR .loadbtn/y LDR #27 ;load_txt ;draw-label JSR2 + ;srcpath #0100 ;load-file JSR2 + ( release ) #00 ->MS/STAT + &no-touch-load + + &touch-end + + ;draw-cursor JSR2 + +BRK + +@draw-file ( -- ) + + #00 #10 + &ver + ( pos-y ) OVR #00 SWP #0008 MUL2 .output/y LDR ADD2 =>SC/Y + #00 #10 + &hor + ( pos-x ) OVR #00 SWP #0008 MUL2 .output/x LDR ADD2 =>SC/X + ( get x,y ) SWP2 OVR STH SWP2 OVR STHr + ( get id ) #10 MUL ADD + ( get data ) #00 SWP MEMORY ADD2 PEK2 + ( get sprite ) #20 SUB #00 SWP #0008 MUL2 ;font ADD2 =>SC/ADDR + ( draw ) #2d ->SC/COLR + ( incr ) SWP ++ SWP + DUP2 NEQ ,&hor JNZ + POP2 + ( incr ) SWP ++ SWP + DUP2 NEQ ,&ver JNZ + POP2 + +RTN + +@load-file ( path length -- ) + + .File/length IOW2 .File/name IOW2 MEMORY .File/load IOW2 + .File/success IOR2 #0000 EQU2 ,&no-success JNZ + + ;draw-file JSR2 + .output/x LDR .output/y LDR #0088 ADD2 #23 ;done_txt ;draw-label JSR2 + ( release ) #00 ->MS/STAT + + &no-success + +RTN + +@draw-cursor ( -- ) + + ( clear last cursor ) + ;clear_icn =>SC/ADDR + .pointer/x LDR =>SC/X + .pointer/y LDR =>SC/Y + #30 ->SC/COLR + + ( record pointer positions ) + <=MS/X .pointer/x STR <=MS/Y .pointer/y STR + + ( draw new cursor ) + ;cursor_icn =>SC/ADDR + .pointer/x LDR =>SC/X + .pointer/y LDR =>SC/Y + #32 <-MS/STAT #00 NEQ ADD ->SC/COLR + +RTN + +@draw-label ( x y color addr -- ) + + ( load ) .label/addr STR .label/color POK =>SC/Y =>SC/X + .label/addr LDR + &loop + ( draw ) DUP2 PEK2 #20 SUB #00 SWP #0008 MUL2 ;font ADD2 =>SC/ADDR .label/color PEK ->SC/COLR + ( incr ) #0001 ADD2 + ( incr ) <=SC/X #0008 ADD2 =>SC/X + DUP2 PEK2 #00 NEQ ,&loop JNZ + POP2 + +RTN + +@clear_icn [ 0000 0000 0000 0000 ] +@cursor_icn [ 80c0 e0f0 f8e0 1000 ] + +@done_txt [ 4c4f 4144 2053 5543 4345 5353 2100 ] ( LOAD SUCCESS! ) +@load_txt [ 4c4f 4144 00 ] ( LOAD ) +@save_txt [ 5341 5645 00 ] ( SAVE ) + +@srcpath [ 5245 4144 4d45 2e6d 6400 ] ( README.md ) +@dstpath [ 6269 6e2f 6578 706f 7274 2e6d 6400 ] ( bin/export.md ) + +@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 +] + +( devices ) + +|ff00 @System [ &vector $2 &pad $6 &r $2 &g $2 &b $2 ] +|ff10 @Console [ &pad $8 &char $1 &byte $1 &short $2 &string $2 ] +|ff20 @Screen [ &vector $2 &width $2 &height $2 &pad $2 &x $2 &y $2 &addr $2 &color $1 ] +|ff40 @Controller [ &vector $2 &button $1 &key $1 ] +|ff60 @Mouse [ &vector $2 &x $2 &y $2 &state $1 &chord $1 ] +|ff70 @File [ &vector $2 &success $2 &offset $2 &pad $2 &name $2 &length $2 &load $2 &save $2 ]