(lz) Added usage
This commit is contained in:
parent
5ba6a002af
commit
418ac048d0
|
@ -1,6 +1,6 @@
|
||||||
( ulz encoder )
|
( ulz decoder )
|
||||||
|
|
||||||
|10 @Console &vector $2 &read $1 &pad $5 &write $1 &err $1
|
|10 @Console &vector $2 &read $1 &pad $4 &type $1 &write $1 &error $1
|
||||||
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
|a0 @File &vector $2 &success $2 &stat $2 &delete $1 &append $1 &name $2 &length $2 &read $2 &write $2
|
||||||
|
|
||||||
|0000
|
|0000
|
||||||
|
@ -13,12 +13,16 @@
|
||||||
@match-ctl $2
|
@match-ctl $2
|
||||||
@dict-best $2
|
@dict-best $2
|
||||||
@combine $2
|
@combine $2
|
||||||
@dict $2
|
@dict-data $2
|
||||||
@dict-len $2
|
@dict-len $2
|
||||||
|
|
||||||
|0100
|
|0100
|
||||||
|
|
||||||
@ready-src ( -> )
|
@ready-src ( -> )
|
||||||
|
;meta #06 DEO2
|
||||||
|
.Console/type DEI #03 AND ?{
|
||||||
|
;dict/usage <perr>/
|
||||||
|
#010f DEO }
|
||||||
;&await .Console/vector DEO2
|
;&await .Console/vector DEO2
|
||||||
BRK
|
BRK
|
||||||
&await ( -> )
|
&await ( -> )
|
||||||
|
@ -32,6 +36,13 @@
|
||||||
.Console/read DEI .dst skey ?on-ready
|
.Console/read DEI .dst skey ?on-ready
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@meta $1
|
||||||
|
( name ) "Ulzenc 0a
|
||||||
|
( desc ) "ULZ 20 "Encoder 0a
|
||||||
|
( auth ) "By 20 "Devine 20 "Lu 20 "Linvega 0a
|
||||||
|
( date ) "19 20 "Nov 20 "2023 $1
|
||||||
|
( exts ) 00
|
||||||
|
|
||||||
@on-ready ( -> )
|
@on-ready ( -> )
|
||||||
( | load raw )
|
( | load raw )
|
||||||
;src .File/name DEO2
|
;src .File/name DEO2
|
||||||
|
@ -42,6 +53,16 @@
|
||||||
;dst .File/name DEO2
|
;dst .File/name DEO2
|
||||||
.output-ptr LDZ2 ;compressed SUB2 .File/length DEO2
|
.output-ptr LDZ2 ;compressed SUB2 .File/length DEO2
|
||||||
;compressed .File/write DEO2
|
;compressed .File/write DEO2
|
||||||
|
( | summary )
|
||||||
|
;dict/decompressed <pstr>
|
||||||
|
;src <pstr>
|
||||||
|
;dict/spacer <pstr>
|
||||||
|
;dst <pstr>
|
||||||
|
[ LIT2 "( 18 ] DEO
|
||||||
|
.output-ptr LDZ2 ;compressed SUB2 <pdec>
|
||||||
|
;dict/bytes <pstr>
|
||||||
|
[ LIT2 ") 18 ] DEO
|
||||||
|
#0a18 DEO
|
||||||
( halt ) #800f DEO
|
( halt ) #800f DEO
|
||||||
BRK
|
BRK
|
||||||
|
|
||||||
|
@ -64,7 +85,7 @@
|
||||||
POP2 ,&string-len STR2
|
POP2 ,&string-len STR2
|
||||||
( | itterate through the dictionary )
|
( | itterate through the dictionary )
|
||||||
#0000 .match-len STZ2
|
#0000 .match-len STZ2
|
||||||
DUP2 .dict-len LDZ2 SUB2 .dict STZ2
|
DUP2 .dict-len LDZ2 SUB2 .dict-data STZ2
|
||||||
&for1 ( for ; dict_len; dict++, dict_len-- )
|
&for1 ( for ; dict_len; dict++, dict_len-- )
|
||||||
.dict-len LDZ2 #0000 EQU2 ?&end-for1
|
.dict-len LDZ2 #0000 EQU2 ?&end-for1
|
||||||
( Find common prefix length with the string ) #0000
|
( Find common prefix length with the string ) #0000
|
||||||
|
@ -72,18 +93,18 @@
|
||||||
( | If we reach the end of the string, it's the best possible match. )
|
( | If we reach the end of the string, it's the best possible match. )
|
||||||
DUP2 [ LIT2 &string-len $2 ] NEQ2 ?{
|
DUP2 [ LIT2 &string-len $2 ] NEQ2 ?{
|
||||||
DUP2 .match-len STZ2
|
DUP2 .match-len STZ2
|
||||||
.dict LDZ2 .dict-best STZ2
|
.dict-data LDZ2 .dict-best STZ2
|
||||||
POP2 !&done-search }
|
POP2 !&done-search }
|
||||||
( | in[i] != dict[i % dict_len] break; )
|
( | in[i] != dict[i % dict_len] break; )
|
||||||
( a ) ADD2k LDA STH
|
( a ) ADD2k LDA STH
|
||||||
( b ) DUP2 .dict-len LDZ2 DIV2k MUL2 SUB2 .dict LDZ2 ADD2
|
( b ) DUP2 .dict-len LDZ2 DIV2k MUL2 SUB2 .dict-data LDZ2 ADD2
|
||||||
( res ) LDA STHr NEQ ?&end-for2
|
( res ) LDA STHr NEQ ?&end-for2
|
||||||
INC2 ORAk ?&for2
|
INC2 ORAk ?&for2
|
||||||
&end-for2 ( | i > match_len )
|
&end-for2 ( | i > match_len )
|
||||||
DUP2 .match-len LDZ2 LTH2 ?{
|
DUP2 .match-len LDZ2 LTH2 ?{
|
||||||
DUP2 .match-len STZ2
|
DUP2 .match-len STZ2
|
||||||
.dict LDZ2 .dict-best STZ2 }
|
.dict-data LDZ2 .dict-best STZ2 }
|
||||||
POP2 .dict LDZ2 INC2 .dict STZ2
|
POP2 .dict-data LDZ2 INC2 .dict-data STZ2
|
||||||
.dict-len LDZ2 #0001 SUB2 .dict-len STZ2
|
.dict-len LDZ2 #0001 SUB2 .dict-len STZ2
|
||||||
!&for1
|
!&for1
|
||||||
&end-for1
|
&end-for1
|
||||||
|
@ -156,9 +177,33 @@
|
||||||
;&b .File/read DEO2
|
;&b .File/read DEO2
|
||||||
[ LIT &b $1 ] JMP2r
|
[ LIT &b $1 ] JMP2r
|
||||||
|
|
||||||
|
@<pstr> ( str* -- )
|
||||||
|
&w LDAk #18 DEO
|
||||||
|
INC2 & LDAk ?&w
|
||||||
|
POP2 JMP2r
|
||||||
|
|
||||||
|
@<perr> ( str* -- )
|
||||||
|
&w LDAk #19 DEO
|
||||||
|
INC2 & LDAk ?&w
|
||||||
|
POP2 JMP2r
|
||||||
|
|
||||||
|
@<pdec> ( short* -- )
|
||||||
|
#2710 [ LIT2r 00fb ]
|
||||||
|
&w ( -- )
|
||||||
|
DIV2k #000a DIV2k MUL2 SUB2 SWPr EQUk OVR STHkr EQU AND ?{
|
||||||
|
DUP [ LIT "0 ] ADD #19 DEO
|
||||||
|
INCr }
|
||||||
|
POP2 #000a DIV2 SWPr INCr STHkr ?&w
|
||||||
|
POP2r POP2 POP2 JMP2r
|
||||||
|
|
||||||
(
|
(
|
||||||
@|memory )
|
@|memory )
|
||||||
|
|
||||||
|
@dict &usage "usage: 20 "ulzenc.rom 20 "a.ulz 20 "b.bin 0a $1
|
||||||
|
&decompressed "Compressed 20 $1
|
||||||
|
&spacer 20 "-> 20 $1
|
||||||
|
&bytes 20 "bytes $1
|
||||||
|
|
||||||
@raw $4000
|
@raw $4000
|
||||||
|
|
||||||
@compressed $4000
|
@compressed $4000
|
||||||
|
|
Loading…
Reference in New Issue