(lz) Removed debug routines
This commit is contained in:
parent
2d260e34fc
commit
d7ba04f2f2
|
@ -51,7 +51,7 @@ echo "================================"
|
|||
# ./ulzenc example.txt a.ulz
|
||||
rm a.ulz
|
||||
uxncli ulzenc.rom example.txt a.ulz
|
||||
uxncli ~/roms/hx.rom a.ulz
|
||||
uxncli ulzdec.rom a.ulz b.bin && cat b.bin
|
||||
|
||||
rm ./ulzdec
|
||||
rm ./ulzenc
|
||||
|
|
|
@ -31,14 +31,9 @@ uxn_lz_compress(const void *input, int input_size)
|
|||
string_len = (int)(end - in);
|
||||
if(string_len > 0x3FFF + MinMatchLength)
|
||||
string_len = 0x3FFF + MinMatchLength;
|
||||
|
||||
printf("DEBUG1: %04x %04x ", dict_len, string_len);
|
||||
|
||||
/* Iterate through the dictionary */
|
||||
match_len = 0;
|
||||
dict = in - dict_len;
|
||||
|
||||
printf("[%c]", in[0]);
|
||||
for(; dict_len; dict++, dict_len--) {
|
||||
/* Find common prefix length with the string */
|
||||
/* If we reach the end of the string, this is the best possible match. End. */
|
||||
|
@ -49,27 +44,17 @@ uxn_lz_compress(const void *input, int input_size)
|
|||
goto done_search;
|
||||
}
|
||||
/* Dictionary repeats if we hit the end */
|
||||
/* printf("(#%d, %04x, %c, %c)", i, in-raw, in[i], dict[i % dict_len]); */
|
||||
if(in[i] != dict[i % dict_len]){
|
||||
if(in[i] != dict[i % dict_len])
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(i > match_len) {
|
||||
match_len = i;
|
||||
dict_best = dict;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
done_search:
|
||||
|
||||
printf("-> %04x \n", match_len);
|
||||
|
||||
|
||||
/* CPY */
|
||||
|
||||
if(match_len >= MinMatchLength) {
|
||||
printf("*");
|
||||
/* More numeric range: treat 0 as 4, 1 as 5, etc. */
|
||||
match_ctl = match_len - MinMatchLength;
|
||||
/* CPY2 */
|
||||
|
@ -82,12 +67,9 @@ uxn_lz_compress(const void *input, int input_size)
|
|||
*output_ptr++ = in - dict_best - 1;
|
||||
in += match_len; /* Advance input by size of the match */
|
||||
combine = 0; /* Disable combining previous literal, if any */
|
||||
|
||||
}
|
||||
|
||||
/* LIT */
|
||||
else{
|
||||
/* printf("LIT:%d\n", combine); */
|
||||
/* Combine with previous literal */
|
||||
if(combine) {
|
||||
if(++*combine == 127)
|
||||
|
@ -103,10 +85,8 @@ uxn_lz_compress(const void *input, int input_size)
|
|||
|
||||
/* Write 1 literal byte from the input to the output. */
|
||||
*output_ptr++ = *in++;
|
||||
/* printf(">> %d\n", in-raw); */
|
||||
}
|
||||
}
|
||||
|
||||
return (int)(output_ptr - mem);
|
||||
}
|
||||
|
||||
|
|
|
@ -64,19 +64,9 @@
|
|||
( | size of the string to search for )
|
||||
SUB2k #3fff #0004 ADD2 LTH2k ?{ SWP2 }
|
||||
POP2 ,&string-len STR2
|
||||
|
||||
( | debug )
|
||||
.dict-len LDZ2 phex #2018 DEO ,&string-len LDR2 phex #2018 DEO
|
||||
|
||||
( | itterate through the dictionary )
|
||||
#0000 .match-len STZ2
|
||||
DUP2 .dict-len LDZ2 SUB2 .dict STZ2
|
||||
|
||||
LIT "[ #18 DEO
|
||||
LDAk #18 DEO
|
||||
LIT "] #18 DEO
|
||||
#0a18 DEO
|
||||
|
||||
&for1 ( for ; dict_len; dict++, dict_len-- )
|
||||
.dict-len LDZ2 #0000 EQU2 ?&end-for1
|
||||
|
||||
|
@ -116,7 +106,6 @@
|
|||
@|opcodes )
|
||||
|
||||
@op-cpy ( in* -- )
|
||||
LIT "* #18 DEO
|
||||
( More numeric range: treat 0 as 4, 1 as 5, etc. )
|
||||
.match-len LDZ2 #0004 SUB2 .match-ctl STZ2
|
||||
( CPY2 )
|
||||
|
@ -180,23 +169,6 @@
|
|||
;&b .File/read DEO2
|
||||
[ LIT &b $1 ] JMP2r
|
||||
|
||||
@phex ( short* -- )
|
||||
SWP phex/b
|
||||
&b ( -- )
|
||||
DUP #04 SFT phex/c
|
||||
&c ( -- )
|
||||
#0f AND DUP #09 GTH #27 MUL ADD [ LIT "0 ] ADD #18 DEO
|
||||
JMP2r
|
||||
|
||||
@BREAK
|
||||
#0a18 DEO
|
||||
#010e DEO #010f DEO BRK
|
||||
|
||||
@DEBUG1
|
||||
LIT "> #18 DEO
|
||||
DUP phex/b #0a18 DEO
|
||||
JMP2r
|
||||
|
||||
(
|
||||
@|memory )
|
||||
|
||||
|
|
Loading…
Reference in New Issue