From a75df1a6b4c2788b80b3916e072ff945ee03748f Mon Sep 17 00:00:00 2001 From: pixel Date: Sat, 6 Sep 2003 00:40:35 +0000 Subject: Fixed Parasite Eve --- MSVC/Tools/master.mak | 8 +--- PE/compil.lex | 5 +++ PE/extract-rooms.cpp | 116 ++++++++++++++++++++++++++----------------------- PE/extract-various.cpp | 109 ++++++++++++++++++++++++---------------------- PE/extract.cpp | 63 +++++++++++++++------------ PE/nmakefile | 2 +- Xenogears/nmakefile | 2 +- 7 files changed, 161 insertions(+), 144 deletions(-) diff --git a/MSVC/Tools/master.mak b/MSVC/Tools/master.mak index 644be13..07cf981 100644 --- a/MSVC/Tools/master.mak +++ b/MSVC/Tools/master.mak @@ -140,15 +140,9 @@ _RMDIR=deltree /y $(_CL) $(_CDFLAGS) $*.cpp $(_LINK) $(_LFLAGS) $(_LIBS) $*.obj -.c.exe: - if not exist $(_OUTDIR) md $(_OUTDIR) - $(_CL) $(_CDFLAGS) $*.c - $(_LINK) $(_LFLAGS) $(_LIBS) $*.obj - -.lex.exe: +.lex.c: if not exist $(_OUTDIR) md $(_OUTDIR) $(_LEX) -o$*.c $*.lex - $(_CL) $(CDFLAGS) $*.c #default compile and link for c++ files building an obj #note: name.cpp and name.obj must match diff --git a/PE/compil.lex b/PE/compil.lex index e59c6b1..f5c6d22 100644 --- a/PE/compil.lex +++ b/PE/compil.lex @@ -1,3 +1,4 @@ + #include #define yputc(a) putc(a, yyout) #include "table.h" @@ -72,6 +73,10 @@ %% +int yywrap(void) { + return 0; +} + int main(int argc, char ** argv) { if ((argc < 2) || (argc > 3)) { fprintf(stderr, "Usage: %s [input]\n", argv[0]); diff --git a/PE/extract-rooms.cpp b/PE/extract-rooms.cpp index 92bfb6f..3af349e 100644 --- a/PE/extract-rooms.cpp +++ b/PE/extract-rooms.cpp @@ -1,4 +1,6 @@ -#include +#include "Main.h" +#include "Input.h" +#include "Output.h" #include "table.h" struct tentry { @@ -15,159 +17,163 @@ struct entry { #define offset 0x83b78 #define N 437 +CODE_BEGINS struct entry tab[N]; -int main(void) { +virtual int startup() throw (GeneralException) { int i, j, s, dcount = 1; - FILE * f, * t; + Input * f; + Output * t; int alreadycounted = 0; - char fn[50], buff[2048]; + String fn; + char buff[2048]; unsigned char b, a1, a2; struct tentry te; unsigned long orig, pos, truesize, ptr, sig, size; int found, empty; - f = fopen("slus_006.62", "r"); - fseek(f, offset, SEEK_SET); + f = new Input("slus_006.62"); + f->seek(offset); for (i = 0; i < N; i++) { - fread(&te, sizeof(struct tentry), 1, f); + f->read(&te, sizeof(struct tentry)); tab[i].sector = te.sector; tab[i].sizes[0] = te.u[0]; tab[i].sizes[1] = te.u[1] | (te.u[2] & 0xf); tab[i].sizes[2] = (te.u[2] >> 4) | (te.u[3] << 4); - printf("entry %3i - offset: %9i, sizes = %4i %4i %4i\n", i, tab[i].sector * 2048, + printm(M_INFO, "entry %3i - offset: %9i, sizes = %4i %4i %4i\n", i, tab[i].sector * 2048, tab[i].sizes[0], tab[i].sizes[1], tab[i].sizes[2]); } - fclose(f); + delete f; - f = fopen("pe.img", "r"); + f = new Input("pe.img"); for (i = 0; i < N; i++) { - fprintf(stderr, "Dumping room %i\n", i); + printm(M_INFO, "Dumping room %i\n", i); if (!tab[i].sizes[0]) continue; - fseek(f, tab[i].sector * 2048, SEEK_SET); + f->seek(tab[i].sector * 2048); for (j = 0; j < 3; j++) { - sprintf(fn, "rooms/room-%04i-%02i.out", i, j); + fn.set("rooms/room-%04i-%02i.out", i, j); - t = fopen(fn, "w"); + t = new Output(fn); for (s = 0; s < tab[i].sizes[j]; s++) { - fread(buff, 2048, 1, f); - fwrite(buff, 2048, 1, t); + f->read(buff, 2048); + t->write(buff, 2048); } - - fclose(t); + delete t; } } for (i = 0; i < N; i++) { - fprintf(stderr, "Dumping script %i\n", i); + printm(M_INFO, "Dumping script %i\n", i); found = empty = 0; if (!tab[i].sizes[0]) continue; - fseek(f, (tab[i].sector + tab[i].sizes[0] + tab[i].sizes[1]) * 2048, SEEK_SET); - orig = ftell(f); + f->seek((tab[i].sector + tab[i].sizes[0] + tab[i].sizes[1]) * 2048); + orig = f->tell(); - sprintf(fn, "scripts/room-%04i.txt", i); - t = fopen(fn, "w"); + fn.set("scripts/room-%04i.txt", i); + t = new Output(fn); - fread(&truesize, 4, 1, f); - fseek(f, truesize - 4, SEEK_CUR); + f->read(&truesize, 4); + f->seek(truesize - 4, SEEK_CUR); while (!found) { - fread(&ptr, 4, 1, f); - fseek(f, -8, SEEK_CUR); - pos = ftell(f); + f->read(&ptr, 4); + f->seek(-8, SEEK_CUR); + pos = f->tell(); if ((ptr >> 24) == 1) { ptr &= 0x00ffffff; - fseek(f, orig + ptr, SEEK_SET); - fread(&sig, 4, 1, f); + f->seek(orig + ptr); + f->read(&sig, 4); if ((sig & 0xffff) == 0xfe) { - fseek(f, pos, SEEK_SET); - fread(&size, 4, 1, f); + f->seek(pos); + f->read(&size, 4); pos = ptr + orig; found = 1; } else if (sig != 0x4f414b41) { /* AKAO */ - fclose(t); + delete t; empty = 1; break; } } - fseek(f, pos, SEEK_SET); + f->seek(pos); } if (empty) continue; - fprintf(stderr, "Found %i bytes of text at %i\n", size, pos); + printm(M_INFO, "Found %i bytes of text at %i\n", size, pos); for (j = 0; j < size; j++) { - b = fgetc(f); + b = f->readU8(); if (b <= MAXCHAR) { - fputc(table[b], t); + t->writeU8(table[b]); } else { switch(b) { case 0xf7: - fputc('\n', t); + t->writeU8('\n'); break; case 0xf8: - fprintf(t, "\n"); + (*t) << "\n"; break; case 0xf9: - fprintf(t, "\n\n"); + (*t) << "\n\n"; break; case 0xfa: - fprintf(t, ""); + (*t) << ""; break; case 0xfb: j++; j++; - a1 = fgetc(f); + a1 = f->readU8(); switch(a1) { case 0: - fprintf(t, ""); + (*t) << ""; break; case 1: - fprintf(t, ""); + (*t) << ""; break; case 9: - a2 = fgetc(f); - fprintf(t, "\n", a2); + a2 = f->readU8(); + (*t) << "\n"; break; case 7: - a2 = fgetc(f); - fprintf(t, "", a2); + a2 = f->readU8(); + (*t) << ""; break; default: - fprintf(t, "", a1); + (*t) << ""; break; } break; case 0xfe: j++; - b = fgetc(f); - fprintf(t, "\n", b); + b = f->readU8(); + (*t) << "\n"; break; case 0xff: - fprintf(t, "\n\n"); + (*t) << "\n\n"; break; default: - fprintf(t, "", b); + (*t) << String().set("", b); } } } - fclose(t); + delete t; } - + + delete f; return 0; } +CODE_ENDS \ No newline at end of file diff --git a/PE/extract-various.cpp b/PE/extract-various.cpp index 7bc01d7..6a73f42 100644 --- a/PE/extract-various.cpp +++ b/PE/extract-various.cpp @@ -1,126 +1,129 @@ -#include +#include +#include +#include #include "table.h" +CODE_BEGINS int pos[50]; -int main(void) { - FILE * f = fopen("dump/0000.out", "r"); - FILE * s = fopen("various/various.txt", "w"); +virtual int startup() throw (GeneralException) { + Input * f = new Input("dump/0000.out"); + Output * s = new Output("various/various.txt"); unsigned int c, b, i, j, size, n, changed; unsigned short p, t; - char fn[50]; + String fn; for (c = 0; c < 6;) { - b = fgetc(f); + b = f->readU8(); if (b <= MAXCHAR) { - fputc(table[b], s); + s->writeU8(table[b]); } else { switch(b) { case 0xfe: - b = fgetc(f); - fprintf(s, "\n", b); + b = f->readU8(); + (*s) << "\n"; break; case 0xff: - fprintf(s, "\n\n"); + (*s) << "\n\n"; c++; break; default: - fprintf(s, "", b); + (*s) << String().set("", b); } } } - fclose(f); - fclose(s); + delete f; + delete s; + f = new Input("dump/0001.out"); - f = fopen("dump/0001.out", "r"); - - fread(&c, 4, 1, f); + c = f->readU32(); for (i = 0; i < c; i++) { - fread(&(pos[i]), 4, 1, f); + pos[i] = f->readU32(); } - fseek(f, 0, SEEK_END); - pos[c] = ftell(f); + pos[c] = f->GetSize(); for (i = 0; i < c; i++) { - fseek(f, pos[i], SEEK_SET); + f->seek(pos[i]); size = pos[i + 1] - pos[i]; - sprintf(fn, "various/0001/%02i.out", i); - s = fopen(fn, "w"); + fn.set("various/0001/%02i.out", i); + s = new Output(fn); for (j = 0; j < size; j++) { - b = fgetc(f); - fputc(b, s); + b = f->readU8(); + s->writeU8(b); } - fclose(s); + delete s; } - fclose(f); + delete f; - f = fopen("various/0001/00.out", "r"); + f = new Input("various/0001/00.out"); - fread(&c, 4, 1, f); + c = f->readU32(); for (i = 0; i < c; i++) { - fread(&(pos[i]), 4, 1, f); + pos[i] = f->readU32(); } - fseek(f, 0, SEEK_END); - pos[c] = ftell(f); + pos[c] = f->GetSize(); for (i = 0; i < c; i++) { - fseek(f, pos[i], SEEK_SET); + f->seek(pos[i]); size = pos[i + 1] - pos[i]; - sprintf(fn, "various/0001/00/%01i.out", i); - s = fopen(fn, "w"); + fn.set("various/0001/00/%01i.out", i); + s = new Output(fn); for (j = 0; j < size; j++) { - b = fgetc(f); - fputc(b, s); + b = f->readU8(); + s->writeU8(b); } - fclose(s); + delete s; } - fclose(f); + delete f; for (i = 0; i < 4; i++) { - sprintf(fn, "various/0001/00/%i.out", i); - f = fopen(fn, "r"); - sprintf(fn, "various/menus%i.txt", i); - s = fopen(fn, "w"); + fn.set("various/0001/00/%i.out", i); + f = new Input(fn); + fn.set("various/menus%i.txt", i); + s = new Output(fn); - fread(&p, 2, 1, f); - fseek(f, p * 2, SEEK_CUR); + p = f->readU16(); + f->seek(p * 2, SEEK_CUR); changed = 1; for (c = 0; c < p;) { if (changed) { - fseek(f, c * 2 + 2, SEEK_SET); - fread(&t, 2, 1, f); - fseek(f, t, SEEK_SET); + f->seek(c * 2 + 2); + t = f->readU16(); + f->seek(t); } - if (!(b = fgetc(f)) && changed) + if (!(b = f->readU8()) && changed) break; changed = 0; if (b <= MAXCHAR) { - fputc(table[b], s); + s->writeU8(table[b]); } else { switch(b) { case 0xff: - fprintf(s, "\n\n"); + (*s) << "\n\n"; c++; changed = 1; break; default: - fprintf(s, "", b); + (*s) << String().set("", b); } } } - fclose(f); - fclose(s); + delete f; + delete s; } + + return 0; } +CODE_ENDS diff --git a/PE/extract.cpp b/PE/extract.cpp index 001964a..2891ae8 100644 --- a/PE/extract.cpp +++ b/PE/extract.cpp @@ -1,72 +1,81 @@ -#include +#include +#include +#include #define INDEX 0x838da #define N1 100 #define N2 600 +CODE_BEGINS int index1[N1]; int index2[N2]; -int main(void) { - FILE * s, * f; +virtual int startup() throw (GeneralException) { + Input * s; + Output * f; short int t, b; int n1 = 0, n2 = 0, i, j, size; - char fn[50], buff[2048]; + String fn; + char buff[2048]; - s = fopen("slus_006.62", "r"); + s = new Input("slus_006.62"); - fseek(s, INDEX, SEEK_SET); + s->seek(INDEX); while (1) { - fread(&t, 2, 1, s); + t = s->readU16(); if (!t) break; index1[n1++] = t; - fprintf(stderr, "I1 - %3i - %4i\n", n1, t); + printm(M_INFO, "I1 - %3i - %4i\n", n1, t); } b = index1[n1 - 1]; - fseek(s, 6, SEEK_CUR); + s->seek(6, SEEK_CUR); while (1) { - fread(&t, 2, 1, s); + s->read(&t, 2); if (!t) break; index2[n2++] = t + b; - fprintf(stderr, "I2 - %3i - %4i\n", n2, t); + printm(M_INFO, "I2 - %3i - %4i\n", n2, t); } - fclose(s); + delete s; - s = fopen("pe.img", "r"); + s = new Input("pe.img"); for (i = 0; i < (n1 - 1); i++) { - sprintf(fn, "dump/%04i.out", i); + fn.set("dump/%04i.out", i); if (!(index1[i + 1] - index1[i])) continue; - f = fopen(fn, "w"); - fprintf(stderr, "Dumping %3i sectors at %4i (%8i) into %s\n", index1[i + 1] - index1[i], index1[i], index1[i] * 2048, fn); - fseek(s, index1[i] * 2048, SEEK_SET); + f = new Output(fn); + printm(M_INFO, "Dumping %3i sectors at %4i (%8i) into " + fn + "\n", index1[i + 1] - index1[i], index1[i], index1[i] * 2048); + s->seek(index1[i] * 2048); for (j = index1[i]; j < index1[i + 1]; j++) { - fread(buff, 2048, 1, s); - fwrite(buff, 2048, 1, f); + s->read(buff, 2048); + f->write(buff, 2048); } - fclose(f); + delete f; } for (i = 0; i < (n2 - 1); i++) { - sprintf(fn, "musics/song-%04i.out", i); + fn.set("musics/song-%04i.out", i); if (!(index2[i + 1] - index2[i])) continue; - f = fopen(fn, "w"); - fprintf(stderr, "Music - Dumping %3i sectors at %4i into %s\n", index2[i + 1] - index2[i], index2[i], fn); - fseek(s, index2[i] * 2048, SEEK_SET); + f = new Output(fn); + printm(M_INFO, "Music - Dumping %3i sectors at %4i into " + fn + "\n", index2[i + 1] - index2[i], index2[i]); + s->seek(index2[i] * 2048); for (j = index2[i]; j < index2[i + 1]; j++) { - fread(buff, 2048, 1, s); - fwrite(buff, 2048, 1, f); + s->read(buff, 2048); + f->write(buff, 2048); } - fclose(f); + delete f; } + delete s; + + return 0; } +CODE_ENDS \ No newline at end of file diff --git a/PE/nmakefile b/PE/nmakefile index f508ab3..61ad9a0 100644 --- a/PE/nmakefile +++ b/PE/nmakefile @@ -5,7 +5,7 @@ _LIBS = "..\MSVC\Baltisot - generic\Debug\Baltisot - generic.lib" "..\MSVC\PSX-B #------------------------------------------------------------------ -TARGETS = extract.exe extract-rooms.exe extract-various.exe reinsert.exe +TARGETS = extract.exe extract-rooms.exe extract-various.exe reinsert.exe compil.c compil.exe all : $(TARGETS) diff --git a/Xenogears/nmakefile b/Xenogears/nmakefile index 8d25cf2..cc1b19c 100644 --- a/Xenogears/nmakefile +++ b/Xenogears/nmakefile @@ -5,7 +5,7 @@ _LIBS = "..\MSVC\Baltisot - generic\Debug\Baltisot - generic.lib" "..\MSVC\PSX-B #------------------------------------------------------------------ -TARGETS = decrypt.exe main_dump.exe script-dec.exe script-comp.exe compil.exe reinsert.exe +TARGETS = decrypt.exe main_dump.exe script-dec.exe script-comp.exe compil.c compil.exe reinsert.exe all : $(TARGETS) -- cgit v1.2.3