From f9e8faa8c3a92ddc09caf6de1bf0c50c24259e8e Mon Sep 17 00:00:00 2001 From: neauoire Date: Mon, 17 Jan 2022 12:06:50 -0800 Subject: [PATCH] (proquints.tal) Added a proquints encoder --- projects/utils/proquints.tal | 113 +++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 projects/utils/proquints.tal diff --git a/projects/utils/proquints.tal b/projects/utils/proquints.tal new file mode 100644 index 0000000..e886eb4 --- /dev/null +++ b/projects/utils/proquints.tal @@ -0,0 +1,113 @@ +( + converts a binary file to a proquints, identifiers that are readable, and pronounceable. + usage: uxncli proquints.rom file.bin ) + +%+ { ADD } %- { SUB } %* { MUL } %/ { DIV } +%< { LTH } %> { GTH } %= { EQU } %! { NEQ } +%++ { ADD2 } %-- { SUB2 } %** { MUL2 } %// { DIV2 } +%<< { LTH2 } %>> { GTH2 } %== { EQU2 } %!! { NEQ2 } + +%HALT { #010f DEO } +%EMIT { #18 DEO } +%PRINT { ;print-str JSR2 #0a EMIT } +%DEBUG { ;print-hex/byte JSR2 #0a EMIT } +%DEBUG2 { ;print-hex JSR2 #0a EMIT } + +( devices ) + +|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 + +( variables ) + +|0000 + + @length $2 + @src $30 + +|0100 ( -> ) + + ;on-console .Console/vector DEO2 + +BRK + +@on-console ( -> ) + + ( starting ) + [ LIT &trap $1 ] ,&started JCN + ;src #0020 ;mclr JSR2 + #01 ,&trap STR + &started + ( append ) + .Console/read DEI #20 < ,&validate JCN + ;src ;slen JSR2 #0030 == ,&validate JCN + ;src .Console/read DEI ;sput JSR2 BRK + &validate + ( load ) + ;src .File/name DEO2 + #fff0 ;data -- .File/length DEO2 + ;data .File/read DEO2 + ( save length ) + .File/success DEI2 .length STZ2 + ,parse JSR + #00 ,&trap STR + +BRK + +@parse ( -- ) + + .length LDZ2 ;data ++ ;data + &loop + LDA2k ,proquint JSR + INC2 INC2 GTH2k ,&loop JCN + POP2 POP2 + HALT + +JMP2r + +@proquint ( short* -- ) + + ( c1 ) DUP2 #0c ,&emit-con JSR + ( v1 ) DUP2 #0a ,&emit-vow JSR + ( c2 ) DUP2 #06 ,&emit-con JSR + ( v2 ) DUP2 #03 ,&emit-vow JSR + ( c3 ) #00 ,&emit-con JSR + #20 EMIT + +JMP2r + &emit-con SFT2 #000f AND2 ;&con ADD2 LDA EMIT JMP2r + &con "bdfghjklmnprstvz + &emit-vow SFT2 #0003 AND2 ;&vow ADD2 LDA EMIT JMP2r + &vow "aiou + +@slen ( str* -- len* ) + + DUP2 ,scap JSR SWP2 -- + +JMP2r + +@scap ( str* -- end* ) + + LDAk #00 ! JMP JMP2r + &while + INC2 LDAk ,&while JCN + +JMP2r + +@sput ( str* char -- ) + + ROT ROT ,scap JSR STA + +JMP2r + +@mclr ( addr* len* -- ) + + OVR2 ++ SWP2 + &loop + STH2k #00 STH2r STA + INC2 GTH2k ,&loop JCN + POP2 POP2 + +JMP2r + +@data