(lz) Ported encoder
This commit is contained in:
parent
59acd90b04
commit
2d260e34fc
|
@ -48,6 +48,8 @@ echo ""
|
|||
echo "================================"
|
||||
|
||||
# ./ulzenc example.txt a.ulz
|
||||
# ./ulzenc example.txt a.ulz
|
||||
rm a.ulz
|
||||
uxncli ulzenc.rom example.txt a.ulz
|
||||
uxncli ~/roms/hx.rom a.ulz
|
||||
|
||||
|
|
|
@ -69,13 +69,13 @@ uxn_lz_compress(const void *input, int input_size)
|
|||
/* CPY */
|
||||
|
||||
if(match_len >= MinMatchLength) {
|
||||
printf("*");
|
||||
/* More numeric range: treat 0 as 4, 1 as 5, etc. */
|
||||
match_ctl = match_len - MinMatchLength;
|
||||
/* CPY2 */
|
||||
if(match_ctl > 0x3F) {
|
||||
*output_ptr++ = match_ctl >> 8 | 0xc0; /* High byte of the length, with both flags set */
|
||||
*output_ptr++ = match_ctl; /* Low byte of the length */
|
||||
/* CPY */
|
||||
*output_ptr++ = match_ctl; /* Low byte of the length */
|
||||
} else
|
||||
*output_ptr++ = match_ctl | 0x80;
|
||||
/* offset(0 is -1, 1 is -2, ...) */
|
||||
|
|
|
@ -38,6 +38,10 @@
|
|||
#4000 .File/length DEO2
|
||||
;raw .File/read DEO2
|
||||
;raw .File/success DEI2 uxn_lz_compress
|
||||
( write )
|
||||
;dst .File/name DEO2
|
||||
.output-ptr LDZ2 ;compressed SUB2 .File/length DEO2
|
||||
;compressed .File/write DEO2
|
||||
( halt ) #800f DEO
|
||||
BRK
|
||||
|
||||
|
@ -91,7 +95,7 @@
|
|||
NEQ ?&end-for2
|
||||
INC2 ORAk ?&for2
|
||||
&end-for2
|
||||
|
||||
|
||||
( i > match_len )
|
||||
DUP2 .match-len LDZ2 LTH2 ?{
|
||||
DUP2 .match-len STZ2
|
||||
|
@ -112,20 +116,22 @@
|
|||
@|opcodes )
|
||||
|
||||
@op-cpy ( in* -- )
|
||||
#2222 phex
|
||||
LIT "* #18 DEO
|
||||
( More numeric range: treat 0 as 4, 1 as 5, etc. )
|
||||
.match-len LDZ2 #0004 SUB2 .match-ctl STZ2
|
||||
( CPY2 )
|
||||
.match-ctl LDZ2 #003f GTH2 ?&cpy2
|
||||
( CPY1 )
|
||||
( *output_ptr++ = match_ctl | 0x80; )
|
||||
.match-ctl LDZ2 #0080 ORA2 <append-byte>
|
||||
.match-ctl LDZ2 NIP #80 ORA <append-byte>
|
||||
!&cpy-resume
|
||||
&cpy2
|
||||
( TODO )
|
||||
.match-ctl LDZ2
|
||||
( match_ctl >> 8 | 0xc0 ) SWP #c0 ORA <append-byte>
|
||||
( match_ctl ) <append-byte>
|
||||
&cpy-resume
|
||||
( *output_ptr++ = in - dict_best - 1; )
|
||||
DUP2 .dict-best LDZ2 #0001 SUB2 SUB2 <append-byte>
|
||||
DUP2 .dict-best LDZ2 SUB2 #0001 SUB2 NIP <append-byte>
|
||||
( in += match_len; Advance input by size of the match )
|
||||
.match-len LDZ2 ADD2
|
||||
( Disable combining previous literal, if any )
|
||||
|
|
Loading…
Reference in New Issue