(lz) Progress

This commit is contained in:
neauoire 2023-11-18 13:14:23 -08:00
parent 9101bda743
commit 1c7c5440ee
1 changed files with 43 additions and 28 deletions

View File

@ -39,6 +39,46 @@
.output-ptr LDZ2 INC2k .output-ptr STZ2 STA
JMP2r
@op-cpy ( in* -- )
( 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>
!&cpy-resume
&cpy2
( TODO )
&cpy-resume
( *output_ptr++ = in - dict_best - 1; )
DUP2 .dict-best LDZ2 #0001 SUB2 SUB2 <append-byte>
( in += match_len; Advance input by size of the match )
.match-len LDZ2 ADD2
( Disable combining previous literal, if any )
#0000 .combine STZ2
!uxn_lz_compress/w
@op-lit ( in* -- )
.combine LDZ2 ORA ?&combine
( start a new literal )
( Store this address, and later use it to increment the literal size. )
( combine = output_ptr++; )
.output-ptr LDZ2
INC2k .output-ptr STZ2
.combine STZ2
( *combine = 0; )
#00 .combine LDZ2 LDA2 STA
( *output_ptr++ = *in++; )
LDAk <append-byte>
INC2 !uxn_lz_compress/w
&combine ( -- )
( if ++*combine == 127 )
.combine LDZ2 LDA INC DUP #7f NEQ ?{ POP #00 }
.combine LDZ2 STA
LDAk <append-byte>
INC2 !uxn_lz_compress/w
@uxn_lz_compress ( input* length* -- )
ADD2k NIP2 SWP2
&w ( -- )
@ -79,34 +119,9 @@
POP2
&done-search ( -- )
( CPY )
.match-len LDZ2 #0004 LTH2 ?&no-cpy
( 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>
!&cpy-resume
&cpy2
( TODO )
&cpy-resume
( *output_ptr++ = in - dict_best - 1; )
DUP2 .dict-best LDZ2 #0001 SUB2 SUB2 <append-byte>
&no-cpy
( LIT )
phex #2018 DEO
phex #0a18 DEO
( TODO: remove me!! ) INC2 NEQ2k ?&w
( CPY ) .match-len LDZ2 #0003 GTH2 ?op-cpy
( LIT ) op-lit
NEQ2k ?&w
JMP2r
(