From f595eb172b200b1b49441e717300b8e1112e44e6 Mon Sep 17 00:00:00 2001 From: Devine Lu Linvega Date: Fri, 17 Mar 2023 10:28:04 -0700 Subject: [PATCH] Added the hx util --- hx/build.sh | 35 +++++++++++++++++++++++++++++++++++ hx/hx.tal | 49 +++++++++++++++++++++++++++++++++++++++++++++++++ hx/test.txt | 1 + 3 files changed, 85 insertions(+) create mode 100755 hx/build.sh create mode 100644 hx/hx.tal create mode 100644 hx/test.txt diff --git a/hx/build.sh b/hx/build.sh new file mode 100755 index 0000000..ad6c847 --- /dev/null +++ b/hx/build.sh @@ -0,0 +1,35 @@ +#!/bin/sh -e + +ASM="uxncli $HOME/roms/drifblim.rom" +EMU="uxncli" +LIN="uxncli $HOME/roms/uxnlin.rom" +APP="$HOME/bin/butler push" + +SRC="hx.tal" +DST="hx.rom" + +CPY="$HOME/roms" +ARG="test.txt" + +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/hx/hx.tal b/hx/hx.tal new file mode 100644 index 0000000..c507b39 --- /dev/null +++ b/hx/hx.tal @@ -0,0 +1,49 @@ +( Usage: uxncli hx.rom file.bin ) + +|10 @Console &vector $2 &read $1 &pad $5 &write $1 &error $1 +|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2 + +|0000 + + @src $40 + +|0100 ( -> ) + + ;await-src .Console/vector DEO2 + +BRK + +@await-src ( -> ) + + .Console/read DEI .src skey ?on-ready + +BRK + +@on-ready ( -> ) + + ;src .File/name DEO2 + #0002 .File/length DEO2 + LIT2r 0000 + &stream + #0000 ,&buf STR2 + ;&buf .File/read DEO2 + .File/success DEI2 #0000 EQU2 ?&eof + ;&buf LDA2 phex #2018 DEO + INC2r + ( linebreak ) + STH2kr #000f AND2 ORA ?&no-lb + #0a18 DEO &no-lb + !&stream &eof + POP2r + #0a18 DEO + #010f DEO + +BRK + &buf $2 + +@skey ( key buf -- proc ) OVR #21 LTH ?&eval #00 SWP sput #00 JMP2r &eval POP2 #01 JMP2r +@scap ( str* -- end* ) LDAk #00 NEQ [ JMP JMP2r ] &w INC2 LDAk ?&w JMP2r +@sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r +@pstr ( str* -- ) &w LDAk #18 DEO INC2 LDAk ?&w POP2 JMP2r +@phex ( short* -- ) SWP phex/b &b DUP #04 SFT phex/c &c #0f AND DUP #09 GTH #27 MUL ADD #30 ADD #18 DEO JMP2r + diff --git a/hx/test.txt b/hx/test.txt new file mode 100644 index 0000000..651f559 --- /dev/null +++ b/hx/test.txt @@ -0,0 +1 @@ +wigjewigjewigjewigjewigjewigjcncmnbegejgiwejgieg