Fixed EOF issue

This commit is contained in:
neauoire 2023-11-14 19:53:02 -08:00
parent 6080a8f68d
commit 94a8c7c8c8
3 changed files with 12 additions and 2 deletions

View File

@ -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

View File

@ -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;
}