summaryrefslogtreecommitdiff
path: root/PE/extract-rooms.cpp
diff options
context:
space:
mode:
authorpixel <pixel>2004-11-27 21:44:15 +0000
committerpixel <pixel>2004-11-27 21:44:15 +0000
commit50f0dd331f8168fb5b2cd60c70178fad627b7fb6 (patch)
tree65fcec7bd507791f0db8a3af1b60ad9ac631f4a7 /PE/extract-rooms.cpp
parentf1df76865d1751469deff19e62255d50a814f183 (diff)
Large dos2unix commit...
Diffstat (limited to 'PE/extract-rooms.cpp')
-rw-r--r--PE/extract-rooms.cpp284
1 files changed, 142 insertions, 142 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