diff --git a/cli/lz/example.txt b/cli/lz/example.txt index 1d3fb84..546fcf4 100644 --- a/cli/lz/example.txt +++ b/cli/lz/example.txt @@ -83,4 +83,4 @@ Da ba dee da ba di Da ba dee da ba di Da ba dee da ba di Da ba dee da ba di -Da ba dee da ba di \ No newline at end of file +Da ba dee da ba di diff --git a/cli/lz/lz2.tal b/cli/lz/lz2.tal index 6efdabf..2a626f6 100644 --- a/cli/lz/lz2.tal +++ b/cli/lz/lz2.tal @@ -40,10 +40,12 @@ BRK .input-size LDZ2 .File1/length DEO2 ;&b DUP2 .File1/read DEO2 + .File1/success DEI2 #0000 EQU2 ?&eof LDA decompress/run .File1/success DEI2 ORA ?&stream JMP2r + &eof POP2 JMP2r &b $1 &run ( byte -- ) @@ -115,4 +117,3 @@ JMP2r @sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r @mem - diff --git a/cli/lz/lz_main.c b/cli/lz/lz_main.c index aaeb0c3..230a1e8 100644 --- a/cli/lz/lz_main.c +++ b/cli/lz/lz_main.c @@ -227,6 +227,8 @@ uxn_checksum(unsigned int seed, void *bytes, unsigned int bytes_size) return x << 16 | (y & 0xFFFF); } +// cc lz_main.c -o main && ./main + int main(int argc, char *argv[]) { @@ -253,6 +255,11 @@ main(int argc, char *argv[]) printf("ERROR\n"); printf("!!!%d -> %d\n", i, res); + FILE *out_file; + out_file = fopen("compressed.bin", "wb"); + fwrite(my_byte_buffer, 1, res, out_file); + fclose(out_file); + // Other way char *output2 = malloc(1000000); @@ -262,5 +269,7 @@ main(int argc, char *argv[]) printf("%s\n", output2); + // + return 0; }