2023-11-15 18:14:46 -05:00
|
|
|
( ulz decoder )
|
2023-11-15 17:46:18 -05:00
|
|
|
|
|
|
|
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &err $1
|
|
|
|
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
2023-11-15 18:14:46 -05:00
|
|
|
|00 @src $30 @dst $30 @ptr $1
|
2023-11-15 17:46:18 -05:00
|
|
|
|
|
|
|
|0100
|
2023-11-15 18:14:46 -05:00
|
|
|
|
2023-11-15 17:46:18 -05:00
|
|
|
@ready-src ( -> ) ;&await .Console/vector DEO2 BRK
|
|
|
|
&await ( -> ) .Console/read DEI .src skey ?ready-dst BRK
|
|
|
|
@ready-dst ( -> ) ;&await .Console/vector DEO2 BRK
|
|
|
|
&await ( -> ) .Console/read DEI .dst skey ?on-ready BRK
|
|
|
|
|
|
|
|
@on-ready ( -> )
|
2023-11-15 18:05:49 -05:00
|
|
|
;src decode_ulz
|
2023-11-15 18:14:46 -05:00
|
|
|
( export )
|
2023-11-15 17:46:18 -05:00
|
|
|
;dst .File/name DEO2
|
2023-11-15 18:14:46 -05:00
|
|
|
;mem
|
|
|
|
DUP2 .ptr LDZ2 SUB2 .File/length DEO2
|
|
|
|
.File/write DEO2
|
2023-11-15 17:46:18 -05:00
|
|
|
( halt ) #800f DEO
|
2023-11-15 18:14:46 -05:00
|
|
|
BRK
|
2023-11-15 17:46:18 -05:00
|
|
|
|
2023-11-15 18:05:49 -05:00
|
|
|
@decode_ulz ( str* -- )
|
2023-11-15 17:46:18 -05:00
|
|
|
;mem .ptr STZ2
|
|
|
|
.File/name DEO2
|
2023-11-15 18:14:46 -05:00
|
|
|
&stream ( -- )
|
2023-11-15 18:05:49 -05:00
|
|
|
#0001 .File/length DEO2
|
2023-11-15 17:46:18 -05:00
|
|
|
;&b
|
|
|
|
DUP2 .File/read DEO2
|
2023-11-15 18:05:49 -05:00
|
|
|
.File/success DEI2 ORA ?{ POP2 JMP2r }
|
|
|
|
[ LIT &b $1 ] decode_ulz_byte
|
|
|
|
!&stream
|
|
|
|
|
|
|
|
@decode_ulz_byte ( byte -- )
|
2023-11-15 19:42:27 -05:00
|
|
|
DUP #80 AND ?op-cpy
|
2023-11-15 18:12:21 -05:00
|
|
|
|
2023-11-15 18:05:49 -05:00
|
|
|
@op-lit ( byte -- )
|
|
|
|
#00 SWP INC2
|
|
|
|
DUP2 .File/length DEO2
|
|
|
|
.ptr LDZ2
|
|
|
|
DUP2 .File/read DEO2
|
|
|
|
ADD2 .ptr STZ2
|
|
|
|
JMP2r
|
2023-11-15 18:12:21 -05:00
|
|
|
|
2023-11-15 19:42:27 -05:00
|
|
|
@op-cpy ( byte -- )
|
2023-11-15 17:46:18 -05:00
|
|
|
#7f AND
|
2023-11-15 19:33:49 -05:00
|
|
|
DUP #40 AND ?&long
|
|
|
|
#00 SWP !©
|
|
|
|
&long ( byte -- )
|
2023-11-15 18:12:21 -05:00
|
|
|
#3f AND getc
|
2023-11-15 19:33:49 -05:00
|
|
|
© ( length* -- )
|
2023-11-15 18:42:42 -05:00
|
|
|
.ptr LDZ2 #00 getc INC2 SUB2 STH2
|
|
|
|
#0004 ADD2 #0000
|
2023-11-15 18:27:08 -05:00
|
|
|
&l ( -- )
|
2023-11-15 18:42:42 -05:00
|
|
|
( get ) DUP2 STH2kr ADD2 LDA
|
2023-11-15 18:27:08 -05:00
|
|
|
( put ) .ptr LDZ2 STAk INC2 .ptr STZ2 POP
|
2023-11-15 17:46:18 -05:00
|
|
|
INC2 GTH2k ?&l
|
2023-11-15 18:42:42 -05:00
|
|
|
POP2 POP2 POP2r
|
2023-11-15 18:27:08 -05:00
|
|
|
JMP2r
|
2023-11-15 17:46:18 -05:00
|
|
|
|
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
|
|
|
@skey ( key buf -- proc ) OVR #21 LTH ?&eval #00 SWP sput #00 JMP2r &eval POP2 #01 JMP2r
|
2023-11-15 18:14:46 -05:00
|
|
|
@scap ( str* -- end* ) &w INC2 & LDAk ?&w JMP2r
|
|
|
|
@sput ( chr str* -- ) scap/ INC2k #00 ROT ROT STA STA JMP2r
|
2023-11-15 18:12:21 -05:00
|
|
|
@getc ( -- b ) #0001 .File/length DEO2 ;&b .File/read DEO2 [ LIT &b $1 ] JMP2r
|
2023-11-15 17:46:18 -05:00
|
|
|
|
|
|
|
@mem
|