summaryrefslogtreecommitdiff
path: root/PE/rebuildmenus.cpp
blob: 681e9090556c7e6a0586a96e8a39da2467231843 (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
#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