2023-11-15 18:14:46 -05:00
|
|
|
( ulz decoder )
|
2023-11-15 17:46:18 -05:00
|
|
|
|
2023-11-19 13:47:41 -05:00
|
|
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
2023-11-15 17:46:18 -05:00
|
|
|
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
2024-06-05 14:32:20 -04:00
|
|
|
|000
|
2023-11-19 12:52:22 -05:00
|
|
|
|
2023-11-19 13:47:41 -05:00
|
|
|
@src $30
|
|
|
|
@dst $30
|
|
|
|
@ptr $1
|
2023-11-15 17:46:18 -05:00
|
|
|
|
2024-06-05 14:32:20 -04:00
|
|
|
|100
|
2023-11-15 18:14:46 -05:00
|
|
|
|
2023-11-19 13:47:41 -05:00
|
|
|
@on-reset ( -> )
|
|
|
|
;meta #06 DEO2
|
2024-06-05 14:32:20 -04:00
|
|
|
.Console/type DEI #03 AND ?{ ;dict/usage <perr>/
|
2023-11-19 13:47:41 -05:00
|
|
|
#010f DEO }
|
2023-11-19 12:52:22 -05:00
|
|
|
;&await .Console/vector DEO2
|
|
|
|
BRK
|
|
|
|
&await ( -> )
|
2024-06-05 14:32:20 -04:00
|
|
|
.Console/read DEI .src skey ?ready-dst
|
|
|
|
BRK
|
2023-11-19 12:52:22 -05:00
|
|
|
|
|
|
|
@ready-dst ( -> )
|
|
|
|
;&await .Console/vector DEO2
|
|
|
|
BRK
|
|
|
|
&await ( -> )
|
2024-06-05 14:32:20 -04:00
|
|
|
.Console/read DEI .dst skey ?on-ready
|
|
|
|
BRK
|
2023-11-15 17:46:18 -05:00
|
|
|
|
2023-11-19 13:47:41 -05:00
|
|
|
@meta $1
|
|
|
|
( name ) "Ulzdec 0a
|
|
|
|
( desc ) "ULZ 20 "Decoder 0a
|
|
|
|
( auth ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
|
2024-06-05 14:32:20 -04:00
|
|
|
( date ) "5 20 "Jun 20 "2024 $1
|
2023-11-19 13:47:41 -05:00
|
|
|
( exts ) 00
|
|
|
|
|
2023-11-15 17:46:18 -05:00
|
|
|
@on-ready ( -> )
|
2023-11-19 13:47:41 -05:00
|
|
|
;src <decode_ulz>
|
|
|
|
( | export )
|
|
|
|
;dst .File/name DEO2
|
2023-11-19 13:54:45 -05:00
|
|
|
.ptr LDZ2 ;mem SUB2 .File/length DEO2
|
|
|
|
;mem .File/write DEO2
|
|
|
|
( | summary )
|
|
|
|
;dict/decompressed <pstr>
|
|
|
|
;src <pstr>
|
|
|
|
;dict/spacer <pstr>
|
|
|
|
;dst <pstr>
|
|
|
|
[ LIT2 "( 18 ] DEO
|
|
|
|
.ptr LDZ2 ;mem SUB2 <pdec>
|
|
|
|
;dict/bytes <pstr>
|
|
|
|
[ LIT2 ") 18 ] DEO
|
|
|
|
#0a18 DEO
|
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-19 13:47:41 -05:00
|
|
|
@<decode_ulz> ( str* -- )
|
2023-11-15 17:46:18 -05:00
|
|
|
;mem .ptr STZ2
|
|
|
|
.File/name DEO2
|
2024-06-05 14:32:20 -04:00
|
|
|
&>stream ( -- )
|
2023-11-15 18:05:49 -05:00
|
|
|
#0001 .File/length DEO2
|
2023-11-19 12:52:22 -05:00
|
|
|
;&b DUP2 .File/read DEO2
|
|
|
|
.File/success DEI2 ORA ?{ POP2 JMP2r }
|
2023-11-19 13:47:41 -05:00
|
|
|
[ LIT &b $1 ] <decode_ulz_byte>
|
2024-06-05 14:32:20 -04:00
|
|
|
!&>stream
|
2023-11-15 18:05:49 -05:00
|
|
|
|
2023-11-19 13:47:41 -05:00
|
|
|
@<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 -- )
|
2023-11-19 12:52:22 -05:00
|
|
|
#00 SWP INC2 DUP2 .File/length DEO2
|
|
|
|
.ptr LDZ2 DUP2 .File/read DEO2
|
|
|
|
ADD2 .ptr STZ2
|
2023-11-15 18:05:49 -05:00
|
|
|
JMP2r
|
2023-11-15 18:12:21 -05:00
|
|
|
|
2023-11-15 19:42:27 -05:00
|
|
|
@op-cpy ( byte -- )
|
2023-11-19 12:52:22 -05:00
|
|
|
#7f AND DUP #40 AND ?{ #00 SWP !© }
|
2023-11-15 18:12:21 -05:00
|
|
|
#3f AND getc
|
2023-11-19 12:52:22 -05:00
|
|
|
© ( length* -- )
|
2024-06-05 14:32:20 -04:00
|
|
|
.ptr LDZ2 #00 getc INC2 SUB2 ,&offset STR2
|
|
|
|
#0004 ADD2 #0000
|
2023-11-19 13:47:41 -05:00
|
|
|
&l ( length* i* -- )
|
2024-06-05 14:32:20 -04:00
|
|
|
( get ) DUP2 [ LIT2 &offset $2 ] ADD2 LDA
|
|
|
|
( put ) .ptr LDZ2 STAk INC2 .ptr STZ2
|
|
|
|
POP INC2 GTH2k ?&l
|
2023-11-19 12:52:22 -05:00
|
|
|
POP2 POP2 JMP2r
|
2023-11-15 17:46:18 -05:00
|
|
|
|
|
|
|
(
|
|
|
|
@|stdlib )
|
|
|
|
|
2023-11-19 12:52:22 -05:00
|
|
|
@skey ( key buf -- proc )
|
2024-06-05 14:32:20 -04:00
|
|
|
OVR #21 LTH ?{
|
|
|
|
#00 SWP sput #00 JMP2r }
|
|
|
|
POP2 #01 JMP2r
|
2023-11-19 12:52:22 -05:00
|
|
|
|
|
|
|
@scap ( str* -- end* )
|
2024-06-05 14:32:20 -04:00
|
|
|
INC2 & LDAk ?scap
|
2023-11-19 12:52:22 -05:00
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@sput ( chr str* -- )
|
|
|
|
scap/ INC2k #00 ROT ROT STA
|
|
|
|
STA
|
|
|
|
JMP2r
|
|
|
|
|
|
|
|
@getc ( -- b )
|
|
|
|
#0001 .File/length DEO2
|
|
|
|
;&b .File/read DEO2
|
|
|
|
[ LIT &b $1 ] JMP2r
|
2023-11-15 17:46:18 -05:00
|
|
|
|
2023-11-19 13:54:45 -05:00
|
|
|
@<pstr> ( str* -- )
|
2024-06-05 14:32:20 -04:00
|
|
|
LDAk #18 DEO
|
|
|
|
INC2 & LDAk ?<pstr>
|
2023-11-19 13:54:45 -05:00
|
|
|
POP2 JMP2r
|
|
|
|
|
2023-11-19 13:47:41 -05:00
|
|
|
@<perr> ( str* -- )
|
2024-06-05 14:32:20 -04:00
|
|
|
LDAk #19 DEO
|
|
|
|
INC2 & LDAk ?<perr>
|
2023-11-19 13:47:41 -05:00
|
|
|
POP2 JMP2r
|
|
|
|
|
2023-11-19 13:54:45 -05:00
|
|
|
@<pdec> ( short* -- )
|
|
|
|
#2710 [ LIT2r 00fb ]
|
2024-06-05 14:32:20 -04:00
|
|
|
&>w ( -- )
|
2023-11-19 13:54:45 -05:00
|
|
|
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{
|
|
|
|
DUP [ LIT "0 ] ADD #19 DEO
|
|
|
|
INCr }
|
2024-06-05 14:32:20 -04:00
|
|
|
POP2 #000a DIV2 SWPr INCr STHkr ?&>w
|
2023-11-19 13:54:45 -05:00
|
|
|
POP2r POP2 POP2 JMP2r
|
2024-06-05 14:32:20 -04:00
|
|
|
( @
|
|
|
|
| mem )
|
2023-11-19 13:54:45 -05:00
|
|
|
|
2023-11-19 13:47:41 -05:00
|
|
|
@dict &usage "usage: 20 "ulzdec.rom 20 "a.bin 20 "b.ulz 0a $1
|
2023-11-19 13:54:45 -05:00
|
|
|
&decompressed "Decompressed 20 $1
|
|
|
|
&spacer 20 "-> 20 $1
|
|
|
|
&bytes 20 "bytes $1
|
2023-11-19 13:47:41 -05:00
|
|
|
|
2023-11-15 17:46:18 -05:00
|
|
|
@mem
|
2023-11-19 12:52:22 -05:00
|
|
|
|