From 1c7c5440eea5bf44fee5a48ccb8f898fa0c73dd3 Mon Sep 17 00:00:00 2001 From: neauoire Date: Sat, 18 Nov 2023 13:14:23 -0800 Subject: [PATCH] (lz) Progress --- cli/lz/ulzenc.tal | 71 ++++++++++++++++++++++++++++------------------- 1 file changed, 43 insertions(+), 28 deletions(-) diff --git a/cli/lz/ulzenc.tal b/cli/lz/ulzenc.tal index 89c1500..2aa680d 100644 --- a/cli/lz/ulzenc.tal +++ b/cli/lz/ulzenc.tal @@ -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 + !&cpy-resume + &cpy2 + ( TODO ) + &cpy-resume + ( *output_ptr++ = in - dict_best - 1; ) + DUP2 .dict-best LDZ2 #0001 SUB2 SUB2 + ( 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 + INC2 !uxn_lz_compress/w +&combine ( -- ) + ( if ++*combine == 127 ) + .combine LDZ2 LDA INC DUP #7f NEQ ?{ POP #00 } + .combine LDZ2 STA + LDAk + 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 - !&cpy-resume - &cpy2 - ( TODO ) - &cpy-resume - ( *output_ptr++ = in - dict_best - 1; ) - DUP2 .dict-best LDZ2 #0001 SUB2 SUB2 - - - &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 (