summaryrefslogtreecommitdiff
path: root/PE
diff options
context:
space:
mode:
Diffstat (limited to 'PE')
-rw-r--r--PE/extract-rooms.cpp284
-rw-r--r--PE/extract-various.cpp330
-rw-r--r--PE/extract.cpp166
-rw-r--r--PE/pepatch.cpp26
-rw-r--r--PE/rebuildmenus.cpp152
-rw-r--r--PE/reinsert.cpp398
-rw-r--r--PE/table.h134
7 files changed, 745 insertions, 745 deletions
diff --git a/PE/extract-rooms.cpp b/PE/extract-rooms.cpp
index a23026f..f2e2e31 100644
--- a/PE/extract-rooms.cpp
+++ b/PE/extract-rooms.cpp
@@ -1,142 +1,142 @@
-#include "Main.h"
-#include "Input.h"
-#include "Output.h"
-#include "table.h"
-
-struct tentry {
- int sector;
- unsigned char u[4];
-};
-
-struct entry {
- int sector;
- int sizes[3];
-};
-
-#define fullsize 206213120
-#define offset 0x83b78
-#define N 438
-
-CODE_BEGINS
-struct entry tab[N];
-
-virtual int startup() throw (GeneralException) {
- int i, j, s, dcount = 1;
- Input * f;
- Output * t;
- int alreadycounted = 0;
- String fn;
- char buff[2048];
- unsigned char b, a1, a2;
- struct tentry te;
- unsigned long orig, pos, truesize, ptr, sig, size;
- int found, empty;
-
- verbosity = M_INFO;
-
- f = new Input("slus_006.62");
- f->seek(offset);
-
- for (i = 0; i < N; i++) {
- 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) << 8);
- tab[i].sizes[2] = (te.u[2] >> 4) | (te.u[3] << 4);
- printm(M_INFO, "entry %3i - offset: %9i, sizes = %4i %4i %4i (%02x %02x %02x %02x)\n", i, tab[i].sector * 2048,
- tab[i].sizes[0], tab[i].sizes[1], tab[i].sizes[2], te.u[0], te.u[1], te.u[2], te.u[3]);
- }
-
- delete f;
-
- f = new Input("pe.img");
-
- for (i = 0; i < N; i++) {
- printm(M_INFO, "Dumping room %i\n", i + 1);
-
- if (!tab[i].sizes[0])
- continue;
-
- f->seek(tab[i].sector * 2048);
- for (j = 0; j < 3; j++) {
- fn.set("rooms/room-%04i-%02i.out", i + 1, j);
-
- t = new Output(fn);
-
- for (s = 0; s < tab[i].sizes[j]; s++) {
- f->read(buff, 2048);
- t->write(buff, 2048);
- }
- delete t;
- }
- }
-
- for (i = 0; i < N; i++) {
- printm(M_INFO, "Dumping script %i\n", i + 1);
-
- found = empty = 0;
-
- if (!tab[i].sizes[0])
- continue;
-
- f->seek((tab[i].sector + tab[i].sizes[0] + tab[i].sizes[1]) * 2048);
- orig = f->tell();
-
- fn.set("scripts/room-%04i.txt", i);
- t = new Output(fn);
-
-#if 0
- f->read(&truesize, 4);
- f->seek(truesize - 4, SEEK_CUR);
-
- while (!found) {
- f->read(&ptr, 4);
- f->seek(-8, SEEK_CUR);
- pos = f->tell();
- if ((ptr >> 24) == 1) {
- ptr &= 0x00ffffff;
- f->seek(orig + ptr);
- f->read(&sig, 4);
- if ((sig & 0xffff) == 0xfe) {
- f->seek(pos);
- f->read(&size, 4);
- pos = ptr + orig;
- found = 1;
- } else if (sig != 0x4f414b41) { /* AKAO */
- delete t;
- empty = 1;
- break;
- }
- }
- f->seek(pos);
- }
-
- if (empty)
- continue;
-#else
- truesize = f->readU32();
- ptr = f->readU32();
- f->seek(orig + ptr + 32, SEEK_SET);
- ptr = f->readU32();
-
- if (!(ptr & 0xfff00000))
- continue;
-
- f->seek(orig + (ptr & 0xfffff) + 8);
- size = f->readU32();
- ptr = f->readU32();
- pos = orig + (ptr & 0xfffff);
- f->seek(pos);
-#endif
-
- printm(M_INFO, "Found %i bytes of text at %i\n", size, pos);
-
- extracttext(f, t, size);
-
- delete t;
- }
-
- delete f;
- return 0;
-}
-CODE_ENDS
+#include "Main.h"
+#include "Input.h"
+#include "Output.h"
+#include "table.h"
+
+struct tentry {
+ int sector;
+ unsigned char u[4];
+};
+
+struct entry {
+ int sector;
+ int sizes[3];
+};
+
+#define fullsize 206213120
+#define offset 0x83b78
+#define N 438
+
+CODE_BEGINS
+struct entry tab[N];
+
+virtual int startup() throw (GeneralException) {
+ int i, j, s, dcount = 1;
+ Input * f;
+ Output * t;
+ int alreadycounted = 0;
+ String fn;
+ char buff[2048];
+ unsigned char b, a1, a2;
+ struct tentry te;
+ unsigned long orig, pos, truesize, ptr, sig, size;
+ int found, empty;
+
+ verbosity = M_INFO;
+
+ f = new Input("slus_006.62");
+ f->seek(offset);
+
+ for (i = 0; i < N; i++) {
+ 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) << 8);
+ tab[i].sizes[2] = (te.u[2] >> 4) | (te.u[3] << 4);
+ printm(M_INFO, "entry %3i - offset: %9i, sizes = %4i %4i %4i (%02x %02x %02x %02x)\n", i, tab[i].sector * 2048,
+ tab[i].sizes[0], tab[i].sizes[1], tab[i].sizes[2], te.u[0], te.u[1], te.u[2], te.u[3]);
+ }
+
+ delete f;
+
+ f = new Input("pe.img");
+
+ for (i = 0; i < N; i++) {
+ printm(M_INFO, "Dumping room %i\n", i + 1);
+
+ if (!tab[i].sizes[0])
+ continue;
+
+ f->seek(tab[i].sector * 2048);
+ for (j = 0; j < 3; j++) {
+ fn.set("rooms/room-%04i-%02i.out", i + 1, j);
+
+ t = new Output(fn);
+
+ for (s = 0; s < tab[i].sizes[j]; s++) {
+ f->read(buff, 2048);
+ t->write(buff, 2048);
+ }
+ delete t;
+ }
+ }
+
+ for (i = 0; i < N; i++) {
+ printm(M_INFO, "Dumping script %i\n", i + 1);
+
+ found = empty = 0;
+
+ if (!tab[i].sizes[0])
+ continue;
+
+ f->seek((tab[i].sector + tab[i].sizes[0] + tab[i].sizes[1]) * 2048);
+ orig = f->tell();
+
+ fn.set("scripts/room-%04i.txt", i);
+ t = new Output(fn);
+
+#if 0
+ f->read(&truesize, 4);
+ f->seek(truesize - 4, SEEK_CUR);
+
+ while (!found) {
+ f->read(&ptr, 4);
+ f->seek(-8, SEEK_CUR);
+ pos = f->tell();
+ if ((ptr >> 24) == 1) {
+ ptr &= 0x00ffffff;
+ f->seek(orig + ptr);
+ f->read(&sig, 4);
+ if ((sig & 0xffff) == 0xfe) {
+ f->seek(pos);
+ f->read(&size, 4);
+ pos = ptr + orig;
+ found = 1;
+ } else if (sig != 0x4f414b41) { /* AKAO */
+ delete t;
+ empty = 1;
+ break;
+ }
+ }
+ f->seek(pos);
+ }
+
+ if (empty)
+ continue;
+#else
+ truesize = f->readU32();
+ ptr = f->readU32();
+ f->seek(orig + ptr + 32, SEEK_SET);
+ ptr = f->readU32();
+
+ if (!(ptr & 0xfff00000))
+ continue;
+
+ f->seek(orig + (ptr & 0xfffff) + 8);
+ size = f->readU32();
+ ptr = f->readU32();
+ pos = orig + (ptr & 0xfffff);
+ f->seek(pos);
+#endif
+
+ printm(M_INFO, "Found %i bytes of text at %i\n", size, pos);
+
+ extracttext(f, t, size);
+
+ delete t;
+ }
+
+ delete f;
+ return 0;
+}
+CODE_ENDS
diff --git a/PE/extract-various.cpp b/PE/extract-various.cpp
index 6f02fba..cd0d8e1 100644
--- a/PE/extract-various.cpp
+++ b/PE/extract-various.cpp
@@ -1,165 +1,165 @@
-#include <Main.h>
-#include <Input.h>
-#include <Output.h>
-#include "table.h"
-
-CODE_BEGINS
-int pos[50];
-
-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, changed;
- unsigned short p, t;
- String fn;
-
- verbosity = M_INFO;
-
- for (c = 0; c < 6;) {
- b = f->readU8();
- if (b <= MAXCHAR) {
- s->writeU8(table[b]);
- } else {
- switch(b) {
- case 0xfe:
- b = f->readU8();
- (*s) << "<PT" << b << ">\n";
- break;
- case 0xff:
- (*s) << "\n<CLOSE>\n";
- c++;
- break;
- default:
- (*s) << String().set("<UNK %02X>", b);
- }
- }
- }
-
- delete f;
- delete s;
-
- f = new Input("dump/0001.out");
-
- c = f->readU32();
-
- for (i = 0; i < c; i++) {
- pos[i] = f->readU32();
- }
- pos[c] = f->GetSize();
-
- for (i = 0; i < c; i++) {
- f->seek(pos[i]);
- size = pos[i + 1] - pos[i];
- fn.set("various/0001/%02i.out", i);
- s = new Output(fn);
- for (j = 0; j < size; j++) {
- b = f->readU8();
- s->writeU8(b);
- }
- delete s;
- }
-
- delete f;
-
-
- f = new Input("various/0001/00.out");
-
- c = f->readU32();
-
- for (i = 0; i < c; i++) {
- pos[i] = f->readU32();
- }
- pos[c] = f->GetSize();
-
- for (i = 0; i < c; i++) {
- f->seek(pos[i]);
- size = pos[i + 1] - pos[i];
- fn.set("various/0001/00/%01i.out", i);
- s = new Output(fn);
- for (j = 0; j < size; j++) {
- b = f->readU8();
- s->writeU8(b);
- }
- delete s;
- }
-
- delete f;
-
- for (i = 0; i < 4; i++) {
- fn.set("various/0001/00/%i.out", i);
- f = new Input(fn);
- fn.set("various/menus%i.txt", i);
- s = new Output(fn);
-
- p = f->readU16();
- f->seek(p * 2, SEEK_CUR);
- (*s) << "<NBPTS " << p << ">\n";
-
- changed = 1;
-
- for (c = 0; c < p;) {
- if (changed) {
- f->seek(c * 2 + 2);
- t = f->readU16();
- f->seek(t);
- }
- if (!(b = f->readU8()) && changed)
- break;
-
- changed = 0;
-
- if (b <= MAXCHAR) {
- s->writeU8(table[b]);
- } else {
- switch(b) {
- case 0xff:
- (*s) << "\n<CLOSE>\n";
- c++;
- changed = 1;
- break;
- default:
- (*s) << String().set("<UNK %02X>", b);
- }
- }
- }
-
- delete f;
- delete s;
- }
-
- f = new Input("dump/0075.out");
-
- for (i = 0; i < 4; i++) {
- Uint32 pos, pos2, size;
-
- f->seek(i * 4);
- pos = f->readU32();
- pos2 = f->readU32();
- f->seek(pos);
-
- if (i == 3) {
- size = f->readU32();
- f->seek(pos);
- } else {
- size = pos2 - pos;
- }
-
- s = new Output(String().set("75/%i.out", i));
-
- copy(f, s, size);
-
- delete s;
-
- if (i == 1) {
- s = new Output("75/text.txt");
- f->seek(pos);
- extracttext(f, s, size);
- delete s;
- }
- }
-
- delete f;
-
- return 0;
-}
-CODE_ENDS
+#include <Main.h>
+#include <Input.h>
+#include <Output.h>
+#include "table.h"
+
+CODE_BEGINS
+int pos[50];
+
+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, changed;
+ unsigned short p, t;
+ String fn;
+
+ verbosity = M_INFO;
+
+ for (c = 0; c < 6;) {
+ b = f->readU8();
+ if (b <= MAXCHAR) {
+ s->writeU8(table[b]);
+ } else {
+ switch(b) {
+ case 0xfe:
+ b = f->readU8();
+ (*s) << "<PT" << b << ">\n";
+ break;
+ case 0xff:
+ (*s) << "\n<CLOSE>\n";
+ c++;
+ break;
+ default:
+ (*s) << String().set("<UNK %02X>", b);
+ }
+ }
+ }
+
+ delete f;
+ delete s;
+
+ f = new Input("dump/0001.out");
+
+ c = f->readU32();
+
+ for (i = 0; i < c; i++) {
+ pos[i] = f->readU32();
+ }
+ pos[c] = f->GetSize();
+
+ for (i = 0; i < c; i++) {
+ f->seek(pos[i]);
+ size = pos[i + 1] - pos[i];
+ fn.set("various/0001/%02i.out", i);
+ s = new Output(fn);
+ for (j = 0; j < size; j++) {
+ b = f->readU8();
+ s->writeU8(b);
+ }
+ delete s;
+ }
+
+ delete f;
+
+
+ f = new Input("various/0001/00.out");
+
+ c = f->readU32();
+
+ for (i = 0; i < c; i++) {
+ pos[i] = f->readU32();
+ }
+ pos[c] = f->GetSize();
+
+ for (i = 0; i < c; i++) {
+ f->seek(pos[i]);
+ size = pos[i + 1] - pos[i];
+ fn.set("various/0001/00/%01i.out", i);
+ s = new Output(fn);
+ for (j = 0; j < size; j++) {
+ b = f->readU8();
+ s->writeU8(b);
+ }
+ delete s;
+ }
+
+ delete f;
+
+ for (i = 0; i < 4; i++) {
+ fn.set("various/0001/00/%i.out", i);
+ f = new Input(fn);
+ fn.set("various/menus%i.txt", i);
+ s = new Output(fn);
+
+ p = f->readU16();
+ f->seek(p * 2, SEEK_CUR);
+ (*s) << "<NBPTS " << p << ">\n";
+
+ changed = 1;
+
+ for (c = 0; c < p;) {
+ if (changed) {
+ f->seek(c * 2 + 2);
+ t = f->readU16();
+ f->seek(t);
+ }
+ if (!(b = f->readU8()) && changed)
+ break;
+
+ changed = 0;
+
+ if (b <= MAXCHAR) {
+ s->writeU8(table[b]);
+ } else {
+ switch(b) {
+ case 0xff:
+ (*s) << "\n<CLOSE>\n";
+ c++;
+ changed = 1;
+ break;
+ default:
+ (*s) << String().set("<UNK %02X>", b);
+ }
+ }
+ }
+
+ delete f;
+ delete s;
+ }
+
+ f = new Input("dump/0075.out");
+
+ for (i = 0; i < 4; i++) {
+ Uint32 pos, pos2, size;
+
+ f->seek(i * 4);
+ pos = f->readU32();
+ pos2 = f->readU32();
+ f->seek(pos);
+
+ if (i == 3) {
+ size = f->readU32();
+ f->seek(pos);
+ } else {
+ size = pos2 - pos;
+ }
+
+ s = new Output(String().set("75/%i.out", i));
+
+ copy(f, s, size);
+
+ delete s;
+
+ if (i == 1) {
+ s = new Output("75/text.txt");
+ f->seek(pos);
+ extracttext(f, s, size);
+ delete s;
+ }
+ }
+
+ delete f;
+
+ return 0;
+}
+CODE_ENDS
diff --git a/PE/extract.cpp b/PE/extract.cpp
index 4fa8b2f..4418fb9 100644
--- a/PE/extract.cpp
+++ b/PE/extract.cpp
@@ -1,83 +1,83 @@
-#include <Main.h>
-#include <Input.h>
-#include <Output.h>
-
-#define INDEX 0x838da
-
-#define N1 100
-#define N2 600
-
-CODE_BEGINS
-int index1[N1];
-int index2[N2];
-
-virtual int startup() throw (GeneralException) {
- Input * s;
- Output * f;
- short int t, b;
- int n1 = 0, n2 = 0, i, j, size;
- String fn;
- char buff[2048];
-
- verbosity = M_INFO;
-
- s = new Input("slus_006.62");
-
- s->seek(INDEX);
-
- while (1) {
- t = s->readU16();
- if (!t)
- break;
- index1[n1++] = t;
- printm(M_INFO, "I1 - %3i - %4i\n", n1, t);
- }
-
- b = index1[n1 - 1];
-
- s->seek(6, SEEK_CUR);
-
- while (1) {
- s->read(&t, 2);
- if (!t)
- break;
- index2[n2++] = t + b;
- printm(M_INFO, "I2 - %3i - %4i\n", n2, t);
- }
-
- delete s;
-
- s = new Input("pe.img");
-
- for (i = 0; i < (n1 - 1); i++) {
- fn.set("dump/%04i.out", i);
- if (!(index1[i + 1] - index1[i]))
- continue;
- 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++) {
- s->read(buff, 2048);
- f->write(buff, 2048);
- }
- delete f;
- }
-
- for (i = 0; i < (n2 - 1); i++) {
- fn.set("musics/song-%04i.out", i);
- if (!(index2[i + 1] - index2[i]))
- continue;
- 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++) {
- s->read(buff, 2048);
- f->write(buff, 2048);
- }
- delete f;
- }
- delete s;
-
- return 0;
-}
-CODE_ENDS
+#include <Main.h>
+#include <Input.h>
+#include <Output.h>
+
+#define INDEX 0x838da
+
+#define N1 100
+#define N2 600
+
+CODE_BEGINS
+int index1[N1];
+int index2[N2];
+
+virtual int startup() throw (GeneralException) {
+ Input * s;
+ Output * f;
+ short int t, b;
+ int n1 = 0, n2 = 0, i, j, size;
+ String fn;
+ char buff[2048];
+
+ verbosity = M_INFO;
+
+ s = new Input("slus_006.62");
+
+ s->seek(INDEX);
+
+ while (1) {
+ t = s->readU16();
+ if (!t)
+ break;
+ index1[n1++] = t;
+ printm(M_INFO, "I1 - %3i - %4i\n", n1, t);
+ }
+
+ b = index1[n1 - 1];
+
+ s->seek(6, SEEK_CUR);
+
+ while (1) {
+ s->read(&t, 2);
+ if (!t)
+ break;
+ index2[n2++] = t + b;
+ printm(M_INFO, "I2 - %3i - %4i\n", n2, t);
+ }
+
+ delete s;
+
+ s = new Input("pe.img");
+
+ for (i = 0; i < (n1 - 1); i++) {
+ fn.set("dump/%04i.out", i);
+ if (!(index1[i + 1] - index1[i]))
+ continue;
+ 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++) {
+ s->read(buff, 2048);
+ f->write(buff, 2048);
+ }
+ delete f;
+ }
+
+ for (i = 0; i < (n2 - 1); i++) {
+ fn.set("musics/song-%04i.out", i);
+ if (!(index2[i + 1] - index2[i]))
+ continue;
+ 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++) {
+ s->read(buff, 2048);
+ f->write(buff, 2048);
+ }
+ delete f;
+ }
+ delete s;
+
+ return 0;
+}
+CODE_ENDS
diff --git a/PE/pepatch.cpp b/PE/pepatch.cpp
index 80e6154..18e11dd 100644
--- a/PE/pepatch.cpp
+++ b/PE/pepatch.cpp
@@ -24,23 +24,23 @@ virtual int startup() throw (GeneralException) {
DialogBox(0, MAKEINTRESOURCE(IDD_ABOUT),
GetActiveWindow(), 0);
-// ShowWindow(CreateDialog(0, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), AboutDlgProc), SW_SHOWDEFAULT);
+// ShowWindow(CreateDialog(0, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), AboutDlgProc), SW_SHOWDEFAULT);
bmp = LoadBitmap(0, MAKEINTRESOURCE(IDB_AYA));
do {
if (!ReadFile(bmp, buffer, 2048, &readed, 0)) {
- DWORD dwErrCode = GetLastError();
- LPVOID lpMsgBuf;
- if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
- FORMAT_MESSAGE_FROM_SYSTEM |
- FORMAT_MESSAGE_IGNORE_INSERTS,
- NULL, GetLastError(),
- MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
- (LPTSTR) &lpMsgBuf, 0, NULL ))
- throw GeneralException("Gave up on reading CD: unknown error");
- String errmsg = (LPCTSTR) lpMsgBuf;
- LocalFree(lpMsgBuf);
- throw GeneralException("Got error " + errmsg);
+ DWORD dwErrCode = GetLastError();
+ LPVOID lpMsgBuf;
+ if (!FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
+ FORMAT_MESSAGE_FROM_SYSTEM |
+ FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, GetLastError(),
+ MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
+ (LPTSTR) &lpMsgBuf, 0, NULL ))
+ throw GeneralException("Gave up on reading CD: unknown error");
+ String errmsg = (LPCTSTR) lpMsgBuf;
+ LocalFree(lpMsgBuf);
+ throw GeneralException("Got error " + errmsg);
}
printm(M_INFO, "Read %i bytes\n", readed);
out->write(buffer, readed);
diff --git a/PE/rebuildmenus.cpp b/PE/rebuildmenus.cpp
index 681e909..bfbda61 100644
--- a/PE/rebuildmenus.cpp
+++ b/PE/rebuildmenus.cpp
@@ -1,76 +1,76 @@
-#include <Main.h>
-#include <Input.h>
-#include <Output.h>
-
-CODE_BEGINS
-virtual int startup(void) throw (GeneralException) {
- int i, j, p, s;
- Handle * inter = new Output("concat.out");
- Handle * f, * out;
- String fname;
-
- inter->writeU32(4);
-
- for (i = 0; i < 4; i++) {
- inter->writeU32(0);
- }
-
- for (i = 0; i < 4; i++) {
- fname = "menus" + String(i) + ".out";
- f = new Input(fname);
- s = f->GetSize();
-
- p = inter->tell();
-
- inter->seek(i * 4 + 4);
- inter->writeU32(p);
- inter->seek(0, SEEK_END);
-
- copy(f, inter);
-
- s &= 3;
-
- if (s) {
- s = 4 - s;
- for (j = 0; j < s; j++)
- inter->writeU8(0);
- }
-
- delete f;
- }
-
- delete inter;
-
- out = new Output("menus.bin");
- out->writeU32(11);
-
- for (i = 0; i < 11; i++) {
- out->writeU32(0);
- }
-
- for (i = 0; i < 11; i++) {
- if (i == 0) {
- fname = "concat.out";
- } else if (i < 10) {
- fname = "../../various/0001/0" + String(i) + ".out";
- } else {
- fname = "../../various/0001/10.out";
- }
- f = new Input(fname);
-
- p = out->tell();
-
- out->seek(i * 4 + 4);
- out->writeU32(p);
- out->seek(0, SEEK_END);
-
- copy(f, out);
-
- delete f;
- }
-
- delete out;
-
- return 0;
-}
-CODE_ENDS
+#include <Main.h>
+#include <Input.h>
+#include <Output.h>
+
+CODE_BEGINS
+virtual int startup(void) throw (GeneralException) {
+ int i, j, p, s;
+ Handle * inter = new Output("concat.out");
+ Handle * f, * out;
+ String fname;
+
+ inter->writeU32(4);
+
+ for (i = 0; i < 4; i++) {
+ inter->writeU32(0);
+ }
+
+ for (i = 0; i < 4; i++) {
+ fname = "menus" + String(i) + ".out";
+ f = new Input(fname);
+ s = f->GetSize();
+
+ p = inter->tell();
+
+ inter->seek(i * 4 + 4);
+ inter->writeU32(p);
+ inter->seek(0, SEEK_END);
+
+ copy(f, inter);
+
+ s &= 3;
+
+ if (s) {
+ s = 4 - s;
+ for (j = 0; j < s; j++)
+ inter->writeU8(0);
+ }
+
+ delete f;
+ }
+
+ delete inter;
+
+ out = new Output("menus.bin");
+ out->writeU32(11);
+
+ for (i = 0; i < 11; i++) {
+ out->writeU32(0);
+ }
+
+ for (i = 0; i < 11; i++) {
+ if (i == 0) {
+ fname = "concat.out";
+ } else if (i < 10) {
+ fname = "../../various/0001/0" + String(i) + ".out";
+ } else {
+ fname = "../../various/0001/10.out";
+ }
+ f = new Input(fname);
+
+ p = out->tell();
+
+ out->seek(i * 4 + 4);
+ out->writeU32(p);
+ out->seek(0, SEEK_END);
+
+ copy(f, out);
+
+ delete f;
+ }
+
+ delete out;
+
+ return 0;
+}
+CODE_ENDS
diff --git a/PE/reinsert.cpp b/PE/reinsert.cpp
index 28b7c75..1ad4441 100644
--- a/PE/reinsert.cpp
+++ b/PE/reinsert.cpp
@@ -1,16 +1,16 @@
-#include <Exceptions.h>
-#include <Input.h>
-#include <Output.h>
-#include <Main.h>
-#include "cdutils.h"
-
-#include "reinsert-res.h"
-#include <windowsx.h>
-
-#define index 0x838da
-
-#define offset 0x83b78
-
+#include <Exceptions.h>
+#include <Input.h>
+#include <Output.h>
+#include <Main.h>
+#include "cdutils.h"
+
+#include "reinsert-res.h"
+#include <windowsx.h>
+
+#define index 0x838da
+
+#define offset 0x83b78
+
BOOL CALLBACK AboutDlgProc(HWND hW, UINT uMsg, WPARAM wParam, LPARAM lParam) {
Base::printm(M_STATUS, "AboutDlgProc: uMsg = %i (0x%x)\n", uMsg, uMsg);
switch (uMsg) {
@@ -56,189 +56,189 @@ void UpdateProgress(HWND Dlg, float percent) {
InvalidateRect(ctrl, NULL, TRUE);
UpdateWindow(Dlg);
}
-
-CODE_BEGINS
-HWND Dlg;
-
-virtual int startup() throw (GeneralException) {
- Handle * ir;
- Handle * iw;
- cdutils * cd;
-
-// new Archive(*argv, ARCHIVE_EXECUTABLE);
-
- verbosity = M_INFO;
-
- ShowWindow(Dlg = CreateDialog(0, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), AboutDlgProc), SW_SHOWDEFAULT);
- UpdateProgress(Dlg, 0);
-
- ir = new Input("PE1.bin");
- iw = new Output("PE1.bin", 0, 0);
- cd = new cdutils(ir, iw);
-
- printm(M_INFO, "Patch du CD1\n");
- patch_img(cd);
-
- delete cd;
- delete iw;
- delete ir;
-
- return 0;
-
- ir = new Input("PE2.bin");
- iw = new Output("PE2.bin", 0, 0);
- cd = new cdutils(ir, iw);
- printm(M_INFO, "Patch du CD2\n");
- patch_img(cd);
-
- delete cd;
- delete iw;
- delete ir;
-}
-
-int patch_img(cdutils * cd) {
- struct cdutils::DirEntry d_slus, d_pe1;
- unsigned char * slus;
- int i, c;
- String s;
- int groupes[100][20];
- int counts[20];
-
- verbosity = M_STATUS;
-
- d_slus = cd->find_path("/SLUS_006.62;1");
-
- if (!d_slus.Sector)
- d_slus = cd->find_path("/SLUS_006.68;1");
-
- d_pe1 = cd->find_path("/PE.IMG;1");
-
- slus = (unsigned char *) malloc(d_slus.Size);
-
- cd->read_datas(slus, GUESS, d_slus.Sector, d_slus.Size);
-
- int fontei = *((short *)(slus + index + 9 * 2));
- Handle * fonte = new Input("fonte.tim");
- printm(M_INFO, "Ecriture de la fonte...\n");
- cd->write_file(fonte, GUESS, fontei + d_pe1.Sector);
- delete fonte;
-
- Handle * pslus = new Input("PE-SLUS00662-patched.exe");
- printm(M_INFO, "Ecriture du SLUS...\n");
- cd->write_file(pslus, GUESS, d_slus.Sector);
- delete pslus;
-
- int menui = *((short *)(slus + index + 69 * 2));
- Handle * menu = new Input("69/0069.out");
- printm(M_INFO, "Ecriture du menu...\n");
- cd->write_file(menu, GUESS, menui + d_pe1.Sector);
- delete menu;
-
- int mapi = *((short *)(slus + index + 71 * 2));
- int smap = *((short *)(slus + index + 72 * 2)) - mapi;
- smap *= 2048;
- Byte * map = (Byte *) malloc(smap);
- printm(M_INFO, "Ecriture de la carte...\n");
- cd->read_datas(map, GUESS, mapi + d_pe1.Sector, smap);
- fonte = new Input("fonte.tim");
- fonte->read(map + 8, fonte->GetSize());
- delete fonte;
- cd->write_datas(map, GUESS, mapi + d_pe1.Sector, smap);
- free(map);
-
-#if 1
- int jour1i = *((short *)(slus + index + 75 * 2));
- int sjour1 = *((short *)(slus + index + 76 * 2)) - jour1i;
- sjour1 *= 2048;
- Byte * jour1 = (Byte *) malloc(sjour1);
- printm(M_INFO, "Ecriture de la fin du jour 1...\n");
- cd->read_datas(jour1, GUESS, jour1i + d_pe1.Sector, sjour1);
- Handle * jour1text = new Input("scripts/c/map.out");
- int sjour1text = jour1text->GetSize();
- if (sjour1text & 3) sjour1text = (sjour1text & (~3)) + 4;
- int pjour1text = *((Uint32 *)(jour1 + 8)) - sjour1text;
- if (pjour1text < 0) throw GeneralException("Texte trop grand!\n");
- *((Uint32 *)(jour1 + 4)) = pjour1text;
- jour1text->read(jour1 + pjour1text, jour1text->GetSize());
- delete jour1text;
- cd->write_datas(jour1, GUESS, jour1i + d_pe1.Sector, sjour1);
- free(jour1);
-#else
- int jour1i = *((short *)(slus + index + 75 * 2));
- Handle * jour1 = new Input("75/0075.out");
- printm(M_INFO, "Ecriture de la fin du jour 1...\n");
- cd->write_file(jour1, GUESS, jour1i + d_pe1.Sector);
- delete jour1;
-#endif
-
- for (i = 1; i <= 20; i++) {
- Input groupe(String().set("groupe-%02i.txt", i));
- c = 0;
- while (1) {
- groupe >> s;
- if (!s.strlen())
- break;
- groupes[c++][i] = s.to_int();
- }
- counts[i] = c;
- }
-
- for (i = 1; i <= 20; i++) {
- Handle * f = new Input(String().set("scripts/c/%02i.out", i));
- unsigned char * script = (unsigned char *) malloc(f->GetSize());
- f->read(script, f->GetSize());
- printm(M_INFO, "Groupe %i...\n", i);
- for (c = 0; c < counts[i]; c++) {
- UpdateProgress(Dlg, i * 5.0);
- LaisserSouffler(Dlg);
- int sector, s1, s2, s3, r, size, size2, sizes[2], tptr, uptr, aptr, asiz, maxsize;
- r = groupes[c][i] - 1;
- unsigned char * room;
-
- sector = *((int *) (slus + offset + r * 8));
- s1 = *(slus + offset + r * 8 + 4);
- s2 = *(slus + offset + r * 8 + 5) | ((*(slus + offset + r * 8 + 6) & 0x0f) << 8);
- s3 = ((*(slus + offset + r * 8 + 6) & 0xf0) >> 4) | (*(slus + offset + r * 8 + 7) << 4);
-
- cd->read_datas((unsigned char *) sizes, GUESS, d_pe1.Sector + sector + s1 + s2, 8);
- size = sizes[0];
- size2 = sizes[1];
-
- room = (unsigned char *) malloc(size);
- cd->read_datas(room, GUESS, d_pe1.Sector + sector + s1 + s2, size);
-
- printm(M_INFO, " Room %i\n", r + 1);
-
- tptr = *((int *) (room + size2 + 32)) & 0xfffff;
- uptr = *((int *) (room + tptr + 4));
- aptr = *((int *) (room + tptr + 12)) & 0xfffff;
- asiz = *((int *) (room + tptr + 8));
- maxsize = aptr - uptr + (asiz | 3);
-// printm(M_INFO, "size2 = 0x%08x\ntptr = 0x%08x\nuptr = 0x%08x\naptr = 0x%08x\nasiz = 0x%08x\nmaxsize = 0x%08x\nsize = 0x%08x\n", size2, tptr, uptr, aptr, asiz, maxsize, f->GetSize());
- if (f->GetSize() > maxsize) {
- printm(M_WARNING, "Script trop grand (%i octets et %i libres)\n", f->GetSize(), maxsize);
- free(room);
- continue;
- }
-
- uptr = (uptr + maxsize - f->GetSize()) & (~3);
-
- memcpy(room + uptr, script, f->GetSize());
-
- *((int *) (room + tptr + 12)) = uptr | 0x01000000;
- *((int *) (room + tptr + 8)) = f->GetSize();
-
- cd->write_datas(room, GUESS, d_pe1.Sector + sector + s1 + s2, size);
-
- free(room);
- }
- delete f;
- free(script);
- }
-
- free(slus);
-
- return 0;
-}
-
-CODE_ENDS
+
+CODE_BEGINS
+HWND Dlg;
+
+virtual int startup() throw (GeneralException) {
+ Handle * ir;
+ Handle * iw;
+ cdutils * cd;
+
+// new Archive(*argv, ARCHIVE_EXECUTABLE);
+
+ verbosity = M_INFO;
+
+ ShowWindow(Dlg = CreateDialog(0, MAKEINTRESOURCE(IDD_ABOUT), GetActiveWindow(), AboutDlgProc), SW_SHOWDEFAULT);
+ UpdateProgress(Dlg, 0);
+
+ ir = new Input("PE1.bin");
+ iw = new Output("PE1.bin", 0, 0);
+ cd = new cdutils(ir, iw);
+
+ printm(M_INFO, "Patch du CD1\n");
+ patch_img(cd);
+
+ delete cd;
+ delete iw;
+ delete ir;
+
+ return 0;
+
+ ir = new Input("PE2.bin");
+ iw = new Output("PE2.bin", 0, 0);
+ cd = new cdutils(ir, iw);
+ printm(M_INFO, "Patch du CD2\n");
+ patch_img(cd);
+
+ delete cd;
+ delete iw;
+ delete ir;
+}
+
+int patch_img(cdutils * cd) {
+ struct cdutils::DirEntry d_slus, d_pe1;
+ unsigned char * slus;
+ int i, c;
+ String s;
+ int groupes[100][20];
+ int counts[20];
+
+ verbosity = M_STATUS;
+
+ d_slus = cd->find_path("/SLUS_006.62;1");
+
+ if (!d_slus.Sector)
+ d_slus = cd->find_path("/SLUS_006.68;1");
+
+ d_pe1 = cd->find_path("/PE.IMG;1");
+
+ slus = (unsigned char *) malloc(d_slus.Size);
+
+ cd->read_datas(slus, GUESS, d_slus.Sector, d_slus.Size);
+
+ int fontei = *((short *)(slus + index + 9 * 2));
+ Handle * fonte = new Input("fonte.tim");
+ printm(M_INFO, "Ecriture de la fonte...\n");
+ cd->write_file(fonte, GUESS, fontei + d_pe1.Sector);
+ delete fonte;
+
+ Handle * pslus = new Input("PE-SLUS00662-patched.exe");
+ printm(M_INFO, "Ecriture du SLUS...\n");
+ cd->write_file(pslus, GUESS, d_slus.Sector);
+ delete pslus;
+
+ int menui = *((short *)(slus + index + 69 * 2));
+ Handle * menu = new Input("69/0069.out");
+ printm(M_INFO, "Ecriture du menu...\n");
+ cd->write_file(menu, GUESS, menui + d_pe1.Sector);
+ delete menu;
+
+ int mapi = *((short *)(slus + index + 71 * 2));
+ int smap = *((short *)(slus + index + 72 * 2)) - mapi;
+ smap *= 2048;
+ Byte * map = (Byte *) malloc(smap);
+ printm(M_INFO, "Ecriture de la carte...\n");
+ cd->read_datas(map, GUESS, mapi + d_pe1.Sector, smap);
+ fonte = new Input("fonte.tim");
+ fonte->read(map + 8, fonte->GetSize());
+ delete fonte;
+ cd->write_datas(map, GUESS, mapi + d_pe1.Sector, smap);
+ free(map);
+
+#if 1
+ int jour1i = *((short *)(slus + index + 75 * 2));
+ int sjour1 = *((short *)(slus + index + 76 * 2)) - jour1i;
+ sjour1 *= 2048;
+ Byte * jour1 = (Byte *) malloc(sjour1);
+ printm(M_INFO, "Ecriture de la fin du jour 1...\n");
+ cd->read_datas(jour1, GUESS, jour1i + d_pe1.Sector, sjour1);
+ Handle * jour1text = new Input("scripts/c/map.out");
+ int sjour1text = jour1text->GetSize();
+ if (sjour1text & 3) sjour1text = (sjour1text & (~3)) + 4;
+ int pjour1text = *((Uint32 *)(jour1 + 8)) - sjour1text;
+ if (pjour1text < 0) throw GeneralException("Texte trop grand!\n");
+ *((Uint32 *)(jour1 + 4)) = pjour1text;
+ jour1text->read(jour1 + pjour1text, jour1text->GetSize());
+ delete jour1text;
+ cd->write_datas(jour1, GUESS, jour1i + d_pe1.Sector, sjour1);
+ free(jour1);
+#else
+ int jour1i = *((short *)(slus + index + 75 * 2));
+ Handle * jour1 = new Input("75/0075.out");
+ printm(M_INFO, "Ecriture de la fin du jour 1...\n");
+ cd->write_file(jour1, GUESS, jour1i + d_pe1.Sector);
+ delete jour1;
+#endif
+
+ for (i = 1; i <= 20; i++) {
+ Input groupe(String().set("groupe-%02i.txt", i));
+ c = 0;
+ while (1) {
+ groupe >> s;
+ if (!s.strlen())
+ break;
+ groupes[c++][i] = s.to_int();
+ }
+ counts[i] = c;
+ }
+
+ for (i = 1; i <= 20; i++) {
+ Handle * f = new Input(String().set("scripts/c/%02i.out", i));
+ unsigned char * script = (unsigned char *) malloc(f->GetSize());
+ f->read(script, f->GetSize());
+ printm(M_INFO, "Groupe %i...\n", i);
+ for (c = 0; c < counts[i]; c++) {
+ UpdateProgress(Dlg, i * 5.0);
+ LaisserSouffler(Dlg);
+ int sector, s1, s2, s3, r, size, size2, sizes[2], tptr, uptr, aptr, asiz, maxsize;
+ r = groupes[c][i] - 1;
+ unsigned char * room;
+
+ sector = *((int *) (slus + offset + r * 8));
+ s1 = *(slus + offset + r * 8 + 4);
+ s2 = *(slus + offset + r * 8 + 5) | ((*(slus + offset + r * 8 + 6) & 0x0f) << 8);
+ s3 = ((*(slus + offset + r * 8 + 6) & 0xf0) >> 4) | (*(slus + offset + r * 8 + 7) << 4);
+
+ cd->read_datas((unsigned char *) sizes, GUESS, d_pe1.Sector + sector + s1 + s2, 8);
+ size = sizes[0];
+ size2 = sizes[1];
+
+ room = (unsigned char *) malloc(size);
+ cd->read_datas(room, GUESS, d_pe1.Sector + sector + s1 + s2, size);
+
+ printm(M_INFO, " Room %i\n", r + 1);
+
+ tptr = *((int *) (room + size2 + 32)) & 0xfffff;
+ uptr = *((int *) (room + tptr + 4));
+ aptr = *((int *) (room + tptr + 12)) & 0xfffff;
+ asiz = *((int *) (room + tptr + 8));
+ maxsize = aptr - uptr + (asiz | 3);
+// printm(M_INFO, "size2 = 0x%08x\ntptr = 0x%08x\nuptr = 0x%08x\naptr = 0x%08x\nasiz = 0x%08x\nmaxsize = 0x%08x\nsize = 0x%08x\n", size2, tptr, uptr, aptr, asiz, maxsize, f->GetSize());
+ if (f->GetSize() > maxsize) {
+ printm(M_WARNING, "Script trop grand (%i octets et %i libres)\n", f->GetSize(), maxsize);
+ free(room);
+ continue;
+ }
+
+ uptr = (uptr + maxsize - f->GetSize()) & (~3);
+
+ memcpy(room + uptr, script, f->GetSize());
+
+ *((int *) (room + tptr + 12)) = uptr | 0x01000000;
+ *((int *) (room + tptr + 8)) = f->GetSize();
+
+ cd->write_datas(room, GUESS, d_pe1.Sector + sector + s1 + s2, size);
+
+ free(room);
+ }
+ delete f;
+ free(script);
+ }
+
+ free(slus);
+
+ return 0;
+}
+
+CODE_ENDS
diff --git a/PE/table.h b/PE/table.h
index a2551fa..24c0a39 100644
--- a/PE/table.h
+++ b/PE/table.h
@@ -1,67 +1,67 @@
-char table[256] = "0123456789+-=*% ABCDEFGHIJKLMNOPQRSTUVWXYZ&!?\"'.abcdefghijklmnopqrstuvwxyz:,/éèêëàâäîïôöùûüç..()#";
-
-#define MAXCHAR 0x60
-
-#ifdef __HANDLE_H__
-void extracttext(Handle * f, Handle * t, int size) {
- int j;
- Uint8 b, a1, a2;
-
- for (j = 0; j < size; j++) {
- b = f->readU8();
-
- if (b <= MAXCHAR) {
- t->writeU8(table[b]);
- } else {
- switch(b) {
- case 0xf7:
- t->writeU8('\n');
- break;
- case 0xf8:
- (*t) << "<PAUSE>\n";
- break;
- case 0xf9:
- (*t) << "\n<TCLOSE>\n";
- break;
- case 0xfa:
- (*t) << "<AYA>";
- break;
- case 0xfb:
- j++;
- j++;
- a1 = f->readU8();
- switch(a1) {
- case 0:
- (*t) << "<TAG0>";
- break;
- case 1:
- (*t) << "<TAG1>";
- break;
- case 9:
- a2 = f->readU8();
- (*t) << "<CHOICES " << a2 << ">\n";
- break;
- case 7:
- a2 = f->readU8();
- (*t) << "<TIMER " << a2 << ">";
- break;
- default:
- (*t) << "<UNKCMD " << a1 << ">";
- break;
- }
- break;
- case 0xfe:
- j++;
- b = f->readU8();
- (*t) << "<PT" << b << ">\n";
- break;
- case 0xff:
- (*t) << "\n<CLOSE>\n";
- break;
- default:
- (*t) << String().set("<UNK %02X>", b);
- }
- }
- }
-}
-#endif
+char table[256] = "0123456789+-=*% ABCDEFGHIJKLMNOPQRSTUVWXYZ&!?\"'.abcdefghijklmnopqrstuvwxyz:,/éèêëàâäîïôöùûüç..()#";
+
+#define MAXCHAR 0x60
+
+#ifdef __HANDLE_H__
+void extracttext(Handle * f, Handle * t, int size) {
+ int j;
+ Uint8 b, a1, a2;
+
+ for (j = 0; j < size; j++) {
+ b = f->readU8();
+
+ if (b <= MAXCHAR) {
+ t->writeU8(table[b]);
+ } else {
+ switch(b) {
+ case 0xf7:
+ t->writeU8('\n');
+ break;
+ case 0xf8:
+ (*t) << "<PAUSE>\n";
+ break;
+ case 0xf9:
+ (*t) << "\n<TCLOSE>\n";
+ break;
+ case 0xfa:
+ (*t) << "<AYA>";
+ break;
+ case 0xfb:
+ j++;
+ j++;
+ a1 = f->readU8();
+ switch(a1) {
+ case 0:
+ (*t) << "<TAG0>";
+ break;
+ case 1:
+ (*t) << "<TAG1>";
+ break;
+ case 9:
+ a2 = f->readU8();
+ (*t) << "<CHOICES " << a2 << ">\n";
+ break;
+ case 7:
+ a2 = f->readU8();
+ (*t) << "<TIMER " << a2 << ">";
+ break;
+ default:
+ (*t) << "<UNKCMD " << a1 << ">";
+ break;
+ }
+ break;
+ case 0xfe:
+ j++;
+ b = f->readU8();
+ (*t) << "<PT" << b << ">\n";
+ break;
+ case 0xff:
+ (*t) << "\n<CLOSE>\n";
+ break;
+ default:
+ (*t) << String().set("<UNK %02X>", b);
+ }
+ }
+ }
+}
+#endif