summaryrefslogtreecommitdiff
path: root/PE/extract-various.cpp
blob: 6a73f42a8bc6f0f6c84093bf4b9803749c33e49c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#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, n, changed;
    unsigned short p, t;
    String fn;
    
    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);

	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;
    }

    return 0;
}
CODE_ENDS