From 50dbdbd466572928a619554e5c756bd52c415597 Mon Sep 17 00:00:00 2001 From: Pixel Date: Sun, 14 Jul 2002 17:00:53 +0000 Subject: Plop --- VP/Makefile | 8 +++++- VP/decomp-slz.cpp | 57 +++++++++++++++++++++++++++++++++++++++++ VP/unarc.cpp | 76 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 VP/decomp-slz.cpp create mode 100644 VP/unarc.cpp (limited to 'VP') diff --git a/VP/Makefile b/VP/Makefile index 608cf7e..9e723d3 100755 --- a/VP/Makefile +++ b/VP/Makefile @@ -3,13 +3,19 @@ CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -pedantic-errors -Werror -I.. CXX=g++ -TARGET = main_dump VP-CD1.sqr +TARGET = main_dump VP-CD1.sqr decomp-slz unarc all: ${TARGET} main_dump: main_dump.o ../fileutils.o ../fileutils.h ../cdutils.o ../cdutils.h ../generic.o ../generic.h Makefile ${CXX} ${LDFLAGS} main_dump.o ../yazedc.o ../fileutils.o ../cdutils.o ../generic.o -o main_dump +decomp-slz: decomp-slz.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h ../lzss.o ../lzss.h Makefile + ${CXX} ${LDFLAGS} decomp-slz.o ../fileutils.o ../generic.o ../lzss.o -o decomp-slz + +unarc: unarc.o ../fileutils.o ../fileutils.h ../generic.o ../generic.h Makefile + ${CXX} ${LDFLAGS} unarc.o ../fileutils.o ../generic.o -o unarc + clean: rm -f *.o ${TARGET} diff --git a/VP/decomp-slz.cpp b/VP/decomp-slz.cpp new file mode 100644 index 0000000..fa09411 --- /dev/null +++ b/VP/decomp-slz.cpp @@ -0,0 +1,57 @@ +#include +#include + +#include "lzss.h" +#include "fileutils.h" +#include "generic.h" + +int main(int argc, char ** argv) { + int sig, l, d, v; + FILE * fin = stdin, * fout = stdout; + + switch (argc) { + case 3: + if (!(fout = fopen(argv[2], "w"))) { + printm(M_ERROR, "Error opening file %s.\n", argv[3]); + exit(-1); + } + case 2: + if (!(fin = fopen(argv[1], "r"))) { + printm(M_ERROR, "Error opening file %s.\n", argv[2]); + exit(-1); + } + break; + case 1: + break; + default: + printm(M_BARE, "Usage: %s [filein] [fileout]\n", argv[0]); + exit(-1); + } + + verbosity = M_STATUS; + + fread(&sig, 1, 4, fin); + fread(&d, 1, 4, fin); + fread(&l, 1, 4, fin); + switch (sig) { + case 0x05a4c53: + printm(M_STATUS, "Detected a SLZ-type 0 file.\n"); + fread(&v, 1, 4, fin); + copy(fin, fout, d); + exit(0); + case 0x15a4c53: + scheme = schemes[VP_1]; + printm(M_STATUS, "Detected a SLZ-type 1 file.\n"); + break; + case 0x25a4c53: + scheme = schemes[VP_2]; + printm(M_STATUS, "Detected a SLZ-type 2 file.\n"); + break; + default: + printm(M_ERROR, "Not a SLZ file.\n"); + exit(-1); + } + + lzss_decomp(fin, fout, l); + exit(0); +} diff --git a/VP/unarc.cpp b/VP/unarc.cpp new file mode 100644 index 0000000..5699260 --- /dev/null +++ b/VP/unarc.cpp @@ -0,0 +1,76 @@ +#include +#include +#include + +#include "fileutils.h" +#include "generic.h" + +#define THRESHOLD 2000 + +int main(int argc, char ** argv) { + int h, o, n, * index, * sizes, i, d; + char temp[100]; + + verbosity = M_INFO; + + if (argc != 2) { + printm(M_BARE, "Usage: unarc \n"); + exit(-1); + } + + if ((h = open(argv[1], O_RDONLY)) < 0) { + printm(M_ERROR, "Unable to open archive file: %s\n", argv[1]); + exit(-1); + } + + read(h, &n, 4); + + printm(M_STATUS, "Archive claims to have %i files, checking integrity.\n", n); + + if (n > THRESHOLD) { + printm(M_ERROR, "Archive has more than %i files, that doesn't make sense to me.\n", THRESHOLD); + exit(-1); + } + + index = (int *) malloc(n * sizeof(int)); + sizes = (int *) malloc(n * sizeof(int)); + + for (i = 0; i < n; i++) { + lseek(h, (i + 1) * 8 + 4, SEEK_SET); + read(h, &(sizes[i]), 4); + printm(M_INFO, "File #%i size = %i = 0x%08x\n", i, sizes[i], sizes[i]); + } + + index[0] = (n + 1) * 8; + i = 0; + printm(M_INFO, "Index #%i = %i = 0x%08x\n", i, index[i], index[i]); + + for (i = 1; i < n; i++) { + index[i] = index[i - 1] + sizes[i - 1]; + printm(M_INFO, "Index #%i = %i = 0x%08x\n", i, index[i], index[i]); + } + + d = filesize(h) - index[n - 1] - sizes[n - 1]; + + printm(M_INFO, "Archive size: %i, last index: %i, last file size: %i, difference = %i\n", filesize(h), index[n - 1], sizes[n - 1], d); + + if ((d < 0) || (d > 2048)) { + printm(M_ERROR, "Archive incoherent.\n"); + exit(-1); + } + + printm(M_STATUS, "Archive seems to be ok, extracting.\n"); + + for (i = 0; i < n; i++) { + sprintf(temp, "%04i.out", i); + o = open(temp, O_WRONLY | O_CREAT | O_TRUNC, 0666); + + printm(M_INFO, "Extracting %s\n", temp); + + lseek(h, index[i], SEEK_SET); + copy(h, o, sizes[i]); + close(o); + } + + exit(0); +} -- cgit v1.2.3