Browse code

(proquints.tal) Added a proquints encoder

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