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 .input-size LDZ2 .File1/length DEO2
;&b ;&b
DUP2 .File1/read DEO2 DUP2 .File1/read DEO2
.File1/success DEI2 #0000 EQU2 ?&eof
LDA decompress/run LDA decompress/run
.File1/success DEI2 ORA ?&stream .File1/success DEI2 ORA ?&stream
JMP2r JMP2r
&eof POP2 JMP2r
&b $1 &b $1
&run ( byte -- ) &run ( byte -- )
@ -115,4 +117,3 @@ JMP2r
@sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r @sput ( chr str* -- ) scap INC2k #00 ROT ROT STA STA JMP2r
@mem @mem

View File

@ -227,6 +227,8 @@ uxn_checksum(unsigned int seed, void *bytes, unsigned int bytes_size)
return x << 16 | (y & 0xFFFF); return x << 16 | (y & 0xFFFF);
} }
// cc lz_main.c -o main && ./main
int int
main(int argc, char *argv[]) main(int argc, char *argv[])
{ {
@ -253,6 +255,11 @@ main(int argc, char *argv[])
printf("ERROR\n"); printf("ERROR\n");
printf("!!!%d -> %d\n", i, res); 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 // Other way
char *output2 = malloc(1000000); char *output2 = malloc(1000000);
@ -262,5 +269,7 @@ main(int argc, char *argv[])
printf("%s\n", output2); printf("%s\n", output2);
//
return 0; return 0;
} }