uxn

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

proquints.tal (1686B)


      1 ( 
      2 	converts a binary file to a proquints, identifiers that are readable, and pronounceable.
      3 	usage: uxncli proquints.rom file.bin )
      4 
      5 
      6 ( devices )
      7 
      8 |10 @Console    &vector $2 &read     $1 &pad    $5 &write  $1 &error  $1
      9 |a0 @File       &vector $2 &success  $2 &stat   $2 &delete $1 &append $1 &name    $2 &length  $2 &read   $2 &write $2
     10 
     11 ( variables )
     12 
     13 |0000
     14 
     15 	@length $2
     16 	@src $30
     17 
     18 |0100 ( -> )
     19 
     20 	;on-console .Console/vector DEO2
     21 
     22 BRK
     23 
     24 @on-console ( -> )
     25 
     26 	( starting )
     27 	[ LIT &trap $1 ] ,&started JCN
     28 		;src #0020 ;mclr JSR2
     29 		#01 ,&trap STR
     30 		&started
     31 	( append )
     32 	.Console/read DEI #20 LTH ,&validate JCN
     33 	;src ;slen JSR2 #0030 EQU2 ,&validate JCN
     34 		;src .Console/read DEI ;sput JSR2 BRK
     35 		&validate
     36 	( load )
     37 	;src .File/name DEO2
     38 	#fff0 ;data SUB2 .File/length DEO2
     39 	;data .File/read DEO2
     40 	( save length )
     41 	.File/success DEI2 .length STZ2
     42 	,parse JSR
     43 	#00 ,&trap STR
     44 
     45 BRK
     46 
     47 @parse ( -- )
     48 	
     49 	.length LDZ2 ;data ADD2 ;data
     50 	&loop
     51 		LDA2k ,proquint JSR
     52 		INC2 INC2 GTH2k ,&loop JCN
     53 	POP2 POP2
     54 	#010f DEO
     55 
     56 JMP2r
     57 
     58 @proquint ( short* -- )
     59 
     60 	( c1 ) DUP2 #0c ,&emit-con JSR
     61 	( v1 ) DUP2 #0a ,&emit-vow JSR
     62 	( c2 ) DUP2 #06 ,&emit-con JSR
     63 	( v2 ) DUP2 #03 ,&emit-vow JSR
     64 	( c3 ) #00 ,&emit-con JSR
     65 	#2018 DEO
     66 
     67 JMP2r
     68 	&emit-con SFT2 #000f AND2 ;&con ADD2 LDA #18 DEO JMP2r
     69 	&con "bdfghjklmnprstvz 
     70 	&emit-vow SFT2 #0003 AND2 ;&vow ADD2 LDA #18 DEO JMP2r
     71 	&vow "aiou 
     72 
     73 @slen ( str* -- len* )
     74 
     75 	DUP2 ,scap JSR SWP2 SUB2
     76 
     77 JMP2r
     78 
     79 @scap ( str* -- end* )
     80 
     81 	LDAk #00 NEQ JMP JMP2r
     82 	&while 
     83 		INC2 LDAk ,&while JCN
     84 
     85 JMP2r
     86 
     87 @sput ( str* char -- )
     88 
     89 	ROT ROT ,scap JSR STA
     90 
     91 JMP2r
     92 
     93 @mclr ( addr* len* -- )
     94 
     95 	OVR2 ADD2 SWP2
     96 	&loop
     97 		STH2k #00 STH2r STA
     98 		INC2 GTH2k ,&loop JCN
     99 	POP2 POP2
    100 
    101 JMP2r
    102 
    103 @data