Ulzdec is writing output
This commit is contained in:
parent
3813c6b83e
commit
dc119c1026
|
@ -11,7 +11,7 @@ if [[ "$*" == *"--lint"* ]]
|
||||||
then
|
then
|
||||||
$LIN decoder.tal
|
$LIN decoder.tal
|
||||||
clang-format -i lz_main.c
|
clang-format -i lz_main.c
|
||||||
clang-format -i ulzcdec.c
|
clang-format -i ulzdec.c
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
|
@ -29,17 +29,18 @@ $ASM ulzdec.tal ulzdec.rom
|
||||||
echo ""
|
echo ""
|
||||||
echo "C Decoder"
|
echo "C Decoder"
|
||||||
echo ""
|
echo ""
|
||||||
./ulzdec compressed.bin
|
./ulzdec a.ulz b.bin
|
||||||
|
cat b.bin
|
||||||
|
|
||||||
# Uxn Decoding
|
# Uxn Decoding
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "Uxn Decoder"
|
echo "Uxn Decoder"
|
||||||
echo ""
|
echo ""
|
||||||
uxncli ulzdec.rom compressed.bin decompressed.txt && cat decompressed.txt
|
uxncli ulzdec.rom a.ulz b.bin && cat b.bin
|
||||||
|
|
||||||
rm ./main
|
rm ./main
|
||||||
rm ./ulzdec
|
rm ./ulzdec
|
||||||
rm ./compressed.bin
|
rm ./a.ulz
|
||||||
rm ./decompressed.txt
|
rm ./b.bin
|
||||||
rm ./ulzdec.rom
|
rm ./ulzdec.rom
|
||||||
|
|
|
@ -253,7 +253,7 @@ main(int argc, char *argv[])
|
||||||
printf("!!!%d -> %d\n", (int)i, (int)res);
|
printf("!!!%d -> %d\n", (int)i, (int)res);
|
||||||
|
|
||||||
FILE *out_file;
|
FILE *out_file;
|
||||||
out_file = fopen("compressed.bin", "wb");
|
out_file = fopen("a.ulz", "wb");
|
||||||
fwrite(my_byte_buffer, 1, res, out_file);
|
fwrite(my_byte_buffer, 1, res, out_file);
|
||||||
fclose(out_file);
|
fclose(out_file);
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ decode_ulz(FILE *src)
|
||||||
{
|
{
|
||||||
char c, *copy;
|
char c, *copy;
|
||||||
short i, length;
|
short i, length;
|
||||||
|
mem = malloc(0x10000), ptr = mem;
|
||||||
while((c = getc(src)) != EOF) {
|
while((c = getc(src)) != EOF) {
|
||||||
if(c & 0x80) { /* DICT */
|
if(c & 0x80) { /* DICT */
|
||||||
if(c & 0x40)
|
if(c & 0x40)
|
||||||
|
@ -36,17 +37,17 @@ int
|
||||||
main(int argc, char *argv[])
|
main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
char *res;
|
char *res;
|
||||||
FILE *src;
|
FILE *src, *dst;
|
||||||
if(argc == 2 && argv[1][0] == '-' && argv[1][1] == 'v')
|
if(argv[1][0] == '-' && argv[1][1] == 'v')
|
||||||
return !fprintf(stdout, "Ulzdec - ULZ Decoder, 15 Nov 2023.\n");
|
return !fprintf(stdout, "Ulzdec - ULZ Decoder, 15 Nov 2023.\n");
|
||||||
if(argc != 2)
|
if(argc != 3)
|
||||||
return error("usage", "ulzdec [-v] compressed.bin");
|
return error("usage", "ulzdec [-v] a.ulz b.bin");
|
||||||
if(!(src = fopen(argv[1], "rb")))
|
if(!(src = fopen(argv[1], "rb")))
|
||||||
return !error("Invalid input", argv[1]);
|
return !error("Invalid input file", argv[1]);
|
||||||
mem = malloc(0x10000);
|
|
||||||
ptr = mem;
|
|
||||||
decode_ulz(src);
|
decode_ulz(src);
|
||||||
*(ptr) = 0;
|
if(!(dst = fopen(argv[2], "wb")))
|
||||||
printf("%s\n", mem);
|
return !error("Invalid output file", argv[1]);
|
||||||
|
fwrite(mem, ptr - mem, 1, dst);
|
||||||
|
printf("Decompressed %s -> %s(%d bytes).\n", argv[1], argv[2], ptr - mem);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
Loading…
Reference in New Issue