summaryrefslogtreecommitdiff
path: root/PE/extract-various.cpp
diff options
context:
space:
mode:
authorpixel <pixel>2003-09-06 00:40:35 +0000
committerpixel <pixel>2003-09-06 00:40:35 +0000
commita75df1a6b4c2788b80b3916e072ff945ee03748f (patch)
tree6c2d4b2ee281dfe561fd90dc85713bc0a34ed604 /PE/extract-various.cpp
parent44adf768555ecd211f90cbf4d87b44ba42044d86 (diff)
Fixed Parasite Eve
Diffstat (limited to 'PE/extract-various.cpp')
-rw-r--r--PE/extract-various.cpp109
1 files changed, 56 insertions, 53 deletions
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 <stdio.h>
+#include <Main.h>
+#include <Input.h>
+#include <Output.h>
#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, "<PT%i>\n", b);
+ b = f->readU8();
+ (*s) << "<PT" << b << ">\n";
break;
case 0xff:
- fprintf(s, "\n<CLOSE>\n");
+ (*s) << "\n<CLOSE>\n";
c++;
break;
default:
- fprintf(s, "<UNK %02X>", b);
+ (*s) << String().set("<UNK %02X>", 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<CLOSE>\n");
+ (*s) << "\n<CLOSE>\n";
c++;
changed = 1;
break;
default:
- fprintf(s, "<UNK %02X>", b);
+ (*s) << String().set("<UNK %02X>", b);
}
}
}
- fclose(f);
- fclose(s);
+ delete f;
+ delete s;
}
+
+ return 0;
}
+CODE_ENDS