From 50ae649a5c92e50c0fff46520644b8609ee5eddb Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 17 Mar 2023 20:50:51 -0700 Subject: [PATCH] Added soroban --- {checksum => cli/checksum}/build.sh | 0 .../checksum}/checksum-original.tal | 0 {checksum => cli/checksum}/checksum.c | 0 {checksum => cli/checksum}/checksum.tal | 0 {checksum => cli/checksum}/test.txt | 0 {format-c => cli/format-c}/build.sh | 0 {format-c => cli/format-c}/format-c.tal | 0 {format-c => cli/format-c}/test.txt | 0 {hx => cli/hx}/build.sh | 0 {hx => cli/hx}/hx.tal | 0 {hx => cli/hx}/test.txt | 0 {lz => cli/lz}/a-1.bin | Bin {lz => cli/lz}/a-2.bin | 0 {lz => cli/lz}/a.bin | Bin {lz => cli/lz}/lz.tal | 0 {lz => cli/lz}/lz2.tal | 0 {lz => cli/lz}/target.txt | 0 {opctest => cli/opctest}/build.sh | 0 {opctest => cli/opctest}/opctest.tal | 0 gui/soroban/build.sh | 35 ++ gui/soroban/soroban.tal | 344 ++++++++++++++++++ 21 files changed, 379 insertions(+) rename {checksum => cli/checksum}/build.sh (100%) rename {checksum => cli/checksum}/checksum-original.tal (100%) rename {checksum => cli/checksum}/checksum.c (100%) rename {checksum => cli/checksum}/checksum.tal (100%) rename {checksum => cli/checksum}/test.txt (100%) rename {format-c => cli/format-c}/build.sh (100%) rename {format-c => cli/format-c}/format-c.tal (100%) rename {format-c => cli/format-c}/test.txt (100%) rename {hx => cli/hx}/build.sh (100%) rename {hx => cli/hx}/hx.tal (100%) rename {hx => cli/hx}/test.txt (100%) rename {lz => cli/lz}/a-1.bin (100%) rename {lz => cli/lz}/a-2.bin (100%) rename {lz => cli/lz}/a.bin (100%) rename {lz => cli/lz}/lz.tal (100%) rename {lz => cli/lz}/lz2.tal (100%) rename {lz => cli/lz}/target.txt (100%) rename {opctest => cli/opctest}/build.sh (100%) rename {opctest => cli/opctest}/opctest.tal (100%) create mode 100755 gui/soroban/build.sh create mode 100644 gui/soroban/soroban.tal diff --git a/checksum/build.sh b/cli/checksum/build.sh similarity index 100% rename from checksum/build.sh rename to cli/checksum/build.sh diff --git a/checksum/checksum-original.tal b/cli/checksum/checksum-original.tal similarity index 100% rename from checksum/checksum-original.tal rename to cli/checksum/checksum-original.tal diff --git a/checksum/checksum.c b/cli/checksum/checksum.c similarity index 100% rename from checksum/checksum.c rename to cli/checksum/checksum.c diff --git a/checksum/checksum.tal b/cli/checksum/checksum.tal similarity index 100% rename from checksum/checksum.tal rename to cli/checksum/checksum.tal diff --git a/checksum/test.txt b/cli/checksum/test.txt similarity index 100% rename from checksum/test.txt rename to cli/checksum/test.txt diff --git a/format-c/build.sh b/cli/format-c/build.sh similarity index 100% rename from format-c/build.sh rename to cli/format-c/build.sh diff --git a/format-c/format-c.tal b/cli/format-c/format-c.tal similarity index 100% rename from format-c/format-c.tal rename to cli/format-c/format-c.tal diff --git a/format-c/test.txt b/cli/format-c/test.txt similarity index 100% rename from format-c/test.txt rename to cli/format-c/test.txt diff --git a/hx/build.sh b/cli/hx/build.sh similarity index 100% rename from hx/build.sh rename to cli/hx/build.sh diff --git a/hx/hx.tal b/cli/hx/hx.tal similarity index 100% rename from hx/hx.tal rename to cli/hx/hx.tal diff --git a/hx/test.txt b/cli/hx/test.txt similarity index 100% rename from hx/test.txt rename to cli/hx/test.txt diff --git a/lz/a-1.bin b/cli/lz/a-1.bin similarity index 100% rename from lz/a-1.bin rename to cli/lz/a-1.bin diff --git a/lz/a-2.bin b/cli/lz/a-2.bin similarity index 100% rename from lz/a-2.bin rename to cli/lz/a-2.bin diff --git a/lz/a.bin b/cli/lz/a.bin similarity index 100% rename from lz/a.bin rename to cli/lz/a.bin diff --git a/lz/lz.tal b/cli/lz/lz.tal similarity index 100% rename from lz/lz.tal rename to cli/lz/lz.tal diff --git a/lz/lz2.tal b/cli/lz/lz2.tal similarity index 100% rename from lz/lz2.tal rename to cli/lz/lz2.tal diff --git a/lz/target.txt b/cli/lz/target.txt similarity index 100% rename from lz/target.txt rename to cli/lz/target.txt diff --git a/opctest/build.sh b/cli/opctest/build.sh similarity index 100% rename from opctest/build.sh rename to cli/opctest/build.sh diff --git a/opctest/opctest.tal b/cli/opctest/opctest.tal similarity index 100% rename from opctest/opctest.tal rename to cli/opctest/opctest.tal diff --git a/gui/soroban/build.sh b/gui/soroban/build.sh new file mode 100755 index 0000000..68de3b6 --- /dev/null +++ b/gui/soroban/build.sh @@ -0,0 +1,35 @@ +#!/bin/sh -e + +ASM="uxncli $HOME/roms/drifblim.rom" +EMU="uxnemu" +LIN="uxncli $HOME/roms/uxnlin.rom" +APP="$HOME/bin/butler push" + +SRC="soroban.tal" +DST="soroban.rom" + +CPY="$HOME/roms" +ARG="" + +echo ">> Cleaning" +rm -rf bin +mkdir bin + +if [[ "$*" == *"--lint"* ]] +then + echo ">> Linting $SRC" + $LIN $SRC +fi + +echo ">> Assembling $SRC" +$ASM $SRC $DST + +if [[ "$*" == *"--save"* ]] +then + echo ">> Saving $DST" + cp $DST $CPY +fi + +echo ">> Running $DST" +$EMU $DST $ARG + diff --git a/gui/soroban/soroban.tal b/gui/soroban/soroban.tal new file mode 100644 index 0000000..7eb7d04 --- /dev/null +++ b/gui/soroban/soroban.tal @@ -0,0 +1,344 @@ +( uxnemu soroban.rom ) + +|00 @System &vector $2 &pad $6 &r $2 &g $2 &b $2 +|10 @Console &vector $2 &read $1 &pad $5 &write $1 +|20 @Screen &vector $2 &width $2 &height $2 &auto $1 &pad $1 &x $2 &y $2 &addr $2 &pixel $1 &sprite $1 +|80 @Controller &vector $2 &button $1 &key $1 +|90 @Mouse &vector $2 &x $2 &y $2 &state $1 &chord $1 +|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 + +|0000 + + @cursor &x $2 &y $2 + @rods $a $1 + +|0100 ( -> ) + + ( meta ) + ;meta #f0 DEO2 + + ( theme ) + #e1cc .System/r DEO2 + #e03b .System/g DEO2 + #e009 .System/b DEO2 + load-theme + + ( size ) + #0148 .Screen/width DEO2 + #0078 .Screen/height DEO2 + + ( unlock ) + ;on-mouse .Mouse/vector DEO2 + ;on-console .Console/vector DEO2 + redraw + +BRK + +( +@|vectors ) + +@on-console ( -> ) + + .Console/read DEI + DUP #20 GTH ?&no-lb + #00 ,&id STR POP BRK + &no-lb + LIT "0 SUB [ LIT &id $1 ] set-rod + ,&id LDR INC ,&id STR + +BRK + +@on-mouse ( -> ) + + ( clear last cursor ) + #40 draw-cursor + + ( draw new cursor ) + .Mouse/x DEI2 .cursor/x STZ2 + .Mouse/y DEI2 .cursor/y STZ2 + ;cursor-icn .Screen/addr DEO2 + #41 .Mouse/state DEI #00 NEQ ADD draw-cursor + + ( route ) + .Mouse/x DEI2 #0008 SUB2 #0018 DIV2 NIP + .Mouse/y DEI2 #0008 SUB2 #03 SFT2 NIP + .Mouse/state DEI + DUP #01 EQU ?&on-mouse-touch + DUP #01 GTH ?&on-mouse-alt + POP POP2 + +BRK + +&on-mouse-alt ( x y state -> ) + + POP2 + #00 SWP set-rod + #00 .Mouse/state DEO + +BRK + +&on-mouse-touch ( x y state -> ) + + POP + ( release ) #00 .Mouse/state DEO + DUP #03 LTH ?&on-touch-godama + #04 SUB #05 LTH ?&on-touch-ichidama-inc + #ff SWP mod-rod + +BRK + +&on-touch-godama ( x y -> ) + + POP + #05 SWP mod-rod + +BRK + +&on-touch-ichidama-inc ( x -> ) + + #01 SWP mod-rod + +BRK + +( +@|core ) + +@get-rod ( id -- value ) + + .rods ADD LDZ + +JMP2r + +@mod-rod ( mod id -- ) + + STHk get-rod ADD STHr + +@set-rod ( value id -- ) + + STH + #0a DIVk MUL SUB + STHkr .rods ADD STZ + STHr + +!draw-rod + +( +@|drawing ) + +@redraw ( -- ) + + ( frame ) + #d5 .Screen/auto DEO + #0000 .Screen/x DEO2 + #0000 .Screen/y DEO2 + ;frame-chr .Screen/addr DEO2 + #81 .Screen/sprite DEO + .Screen/width DEI2 #0008 SUB2 .Screen/x DEO2 + #0000 .Screen/y DEO2 + ;frame-chr .Screen/addr DEO2 + #91 .Screen/sprite DEO + + ( bottom ) + #01 .Screen/auto DEO + #0000 .Screen/x DEO2 + ;fill-icn .Screen/addr DEO2 + .Screen/height DEI2 #0008 SUB2 .Screen/y DEO2 + .Screen/width DEI2 #03 SFT2 NIP #00 + &f + #03 .Screen/sprite DEO + INC GTHk ?&f + POP2 + + ( rods ) + #0d00 + &l + DUP draw-rod + INC GTHk ?&l + POP2 + +JMP2r + +@draw-rod ( id -- ) + + DUP .rods ADD LDZ SWP + + ( position ) + #00 OVR #0018 MUL2 #0008 ADD2 .Screen/x DEO2 + #0000 .Screen/y DEO2 + + ( set special ) + INC INC #03 DIVk MUL SUB #00 EQU ,&special STR + #26 .Screen/auto DEO + + ( top ) + ;rod-icn/top .Screen/addr DEO2 + #81 .Screen/sprite DEO + #01 .Screen/sprite DEO + ;rod-icn/rod .Screen/addr DEO2 + #01 .Screen/sprite DEO + ;rod-icn/rod .Screen/addr DEO2 + #01 .Screen/sprite DEO + + ( middle ) + [ LIT2 00 &special $1 ] #0030 MUL2 ;rod-icn/spacer ADD2 + .Screen/addr DEO2 + #81 .Screen/sprite DEO + + ( bottom ) + #0800 + &l + ;rod-icn/rod .Screen/addr DEO2 + #01 .Screen/sprite DEO + INC GTHk ?&l + POP2 + ;rod-icn/top .Screen/addr DEO2 + #a1 .Screen/sprite DEO + + ( num ) + #00 .Screen/auto DEO + .Screen/x DEI2k #0008 ADD2 ROT DEO2 + .Screen/y DEI2k #0002 SUB2 ROT DEO2 + #00 OVR #30 SFT2 ;num-icn ADD2 .Screen/addr DEO2 + #0d .Screen/sprite DEO + .Screen/x DEI2k #0008 SUB2 ROT DEO2 + .Screen/y DEI2k INC2 INC2 ROT DEO2 + +@draw-beads ( value -- ) + + STH + + ( godama ) + #26 .Screen/auto DEO + #00 STHkr #04 GTH #0b MUL #0006 ADD2 .Screen/y DEO2 + ;bead-icn .Screen/addr DEO2 + #85 .Screen/sprite DEOk DEO + + ( ichidama ) + #0027 .Screen/y DEO2 + #0400 + &l + ( red ichidama ) + ( first bead ) DUP #00 EQU + ( 3rd rod ) ;draw-rod/special LDA AND + #00 SWP #0060 MUL2 ;bead-icn ADD2 .Screen/addr DEO2 + ( offset ) + #00 + OVR #05 DIVk MUL SUB + STHkr #05 DIVk MUL SUB + EQU #000c MUL2 STH2 + .Screen/y DEI2k STH2r ADD2 ROT DEO2 + ( location ) + #85 .Screen/sprite DEOk DEO + .Screen/y DEI2k #0003 SUB2 ROT DEO2 + INC GTHk ?&l + POP2 + POPr + +JMP2r + +@draw-cursor ( color -- ) + + #00 .Screen/auto DEO + .cursor/x LDZ2 .Screen/x DEO2 + .cursor/y LDZ2 .Screen/y DEO2 + .Screen/sprite DEO + +JMP2r + +( +@|utils ) + +@load-theme ( -- ) + + ;&path .File/name DEO2 + #0002 .File/length DEO2 + ;&r .File/read DEO2 + ;&g .File/read DEO2 + ;&b .File/read DEO2 + .File/success DEI2 ORA #01 JCN JMP2r + LIT2 &r $2 .System/r DEO2 + LIT2 &g $2 .System/g DEO2 + LIT2 &b $2 .System/b DEO2 + +JMP2r + &path ".theme $1 + +( +@|etc ) + +@meta =&end =appicon &body + ( name ) "Soroban $1 + ( version ) "Ver. 20 "1.01 $1 + ( details ) "Graphical 20 "Japanese 20 "Soroban $1 + ( author ) "Devine 20 "Lu 20 "Linvega 20 7f 20 "2022 $1 + &end $1 + +( +@|spritesheet ) + +@cursor-icn + 80c0 e0f0 f8e0 1000 + +@fill-icn + ffff ffff ffff ffff + +@bead-icn + 0000 0000 030f 3f7f 0000 0000 0003 0f3f 0018 3cff ffff ffff 0000 003c ffff ffff + 0000 0000 c0f0 fcfe 0000 0000 00c0 f0fc 7f3f 0f03 0000 0000 3f0f 0300 0000 0000 + ffff ffff ff3c 1800 ffff ffff 3c00 0000 fefc f0c0 0000 0000 fcf0 c000 0000 0000 + ( special ) + 0000 0000 030c 3040 0000 0000 0003 0f3f 1818 3cc3 0000 0000 0000 003c ffff ffff + 0000 0000 c030 0c02 0000 0000 00c0 f0fc 4030 0c03 0000 0000 3f0f 0300 0000 0000 + 0000 0000 c33c 1818 ffff ffff 3c00 0000 020c 30c0 0000 0000 fcf0 c000 0000 0000 + +@rod-icn + &top + ffff ffff ffff 0000 ffff ffff ff00 0000 ffff ffff ffff 3c18 ffff ffff ff3c 1800 + ffff ffff ffff 0000 ffff ffff ff00 0000 + &rod + 0000 0000 0000 0000 1818 1818 1818 1818 0000 0000 0000 0000 + &spacer + 00ff ffff ffff ff00 0000 ffff ffff 0000 3cff ffff ffff ff3c 003c ffff ffff 3c00 + 00ff ffff ffff ff00 0000 ffff ffff 0000 + ( marker ) + 00ff ffff ffff ff00 0000 ffff ffff 0000 3cff ffff ffff ff3c 183c ffe7 e7ff 3c18 + 00ff ffff ffff ff00 0000 ffff ffff 0000 + +@frame-chr + ffff ffff ffff fcfc ffff ffff fffc f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 + fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 + fcff ffff ffff fffc f8fc ffff ffff fcf8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 + fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 + fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 + fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 + fcfc fcfc fcfc fcfc f8f8 f8f8 f8f8 f8f8 fcfc ffff ffff ffff f8f8 fcff ffff ffff + +@num-icn + 3c66 6e76 6666 3c00 + 1838 1818 1818 7e00 + 3c66 060c 1830 7e00 + 7e0c 180c 0666 3c00 + 0c1c 3c6c 7e0c 0c00 + 7e60 7c06 0666 3c00 + 3c60 607c 6666 3c00 + 7e06 0c18 3030 3000 + 3c66 663c 6666 3c00 + 3c66 663e 060c 3800 + +@appicon +0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 00ff 0000 0000 0000 00ff +0000 0000 0000 00ff 0000 0000 0000 00ff 0000 0000 0000 0080 0000 0000 0000 0000 +0000 0000 0000 0000 0101 0101 0101 0101 ff88 8888 889c be9c ff20 71fb 7120 2020 +ff82 c2e2 c287 8f87 ff08 0808 081c be1c c0c0 c0c0 c0c0 c0c0 0000 0000 0000 0000 +0000 0000 0000 0000 0101 0101 0101 0101 88ff 889c be9c 889c 20ff 2070 f870 2123 +827f 8282 8282 c7ef 08ff 081c 3e1c 089c c0c0 c0c0 c0c0 c0c0 0000 0000 0000 0000 +0000 0000 0000 0000 0101 0101 0101 0101 be9c 889c be9c 8888 2120 71fb 7120 71fb +c782 c7ef c782 c7ef 3e1c 089c 3e1c 089c c0c0 c0c0 c0c0 c0c0 0000 0000 0000 0000 +0000 0000 0000 0000 0101 0101 0101 0100 8888 9cbe 9c88 ffff 7120 71fb 7120 ffff +c782 c7ef c782 ffff 3e1c 0888 0808 ffff c0c0 c0c0 c0c0 c080 0000 0000 0000 0000 +0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 +0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000 0000