summaryrefslogtreecommitdiff
path: root/PE
diff options
context:
space:
mode:
authorpixel <pixel>2003-09-05 23:50:16 +0000
committerpixel <pixel>2003-09-05 23:50:16 +0000
commit44adf768555ecd211f90cbf4d87b44ba42044d86 (patch)
tree662018d76d3f2f19ed58ea8e94c54445fc2a47e4 /PE
parent7ff77f49e9577ff5b63d7f2e2ce7651257bf1d63 (diff)
Continuing toying
Diffstat (limited to 'PE')
-rw-r--r--PE/Makefile27
-rw-r--r--PE/compil.lex93
-rw-r--r--PE/extract-rooms.cpp173
-rw-r--r--PE/extract-various.cpp126
-rw-r--r--PE/extract.cpp72
-rw-r--r--PE/groupe-01.txt31
-rw-r--r--PE/groupe-02.txt11
-rw-r--r--PE/groupe-03.txt10
-rw-r--r--PE/groupe-04.txt12
-rw-r--r--PE/groupe-05.txt27
-rw-r--r--PE/groupe-06.txt34
-rw-r--r--PE/groupe-07.txt1
-rw-r--r--PE/groupe-08.txt8
-rw-r--r--PE/groupe-09.txt52
-rw-r--r--PE/groupe-10.txt5
-rw-r--r--PE/groupe-11.txt25
-rw-r--r--PE/groupe-12.txt5
-rw-r--r--PE/groupe-13.txt69
-rw-r--r--PE/groupe-14.txt9
-rw-r--r--PE/groupe-15.txt2
-rw-r--r--PE/groupe-16.txt2
-rw-r--r--PE/groupe-17.txt19
-rw-r--r--PE/groupe-18.txt1
-rw-r--r--PE/groupe-19.txt74
-rw-r--r--PE/groupe-20.txt2
-rw-r--r--PE/nmakefile13
-rw-r--r--PE/reinsert.cpp151
-rw-r--r--PE/table.h3
28 files changed, 1057 insertions, 0 deletions
diff --git a/PE/Makefile b/PE/Makefile
new file mode 100644
index 0000000..d12149e
--- /dev/null
+++ b/PE/Makefile
@@ -0,0 +1,27 @@
+#!/usr/bin/make -f
+
+CPPFLAGS=-Wall -g -O3 -mcpu=i686 -pedantic -I../includes -DHAVE_ZLIB `baltisot-config --cflags`
+CXX=g++
+CC=gcc
+LEX=flex -l
+
+LIBS=-lz
+#-lefence
+LDFLAGS=${LIBS} `baltisot-config --libs`
+#`pkg-config --libs glib-2.0`
+
+TARGET = reinsert compil extract extract-various extract-rooms
+
+all: ${TARGET}
+
+reinsert: reinsert.o ../includes/cdutils.h ../includes/yazedc.h ../lib/lib.a Makefile
+ ${CXX} ${LDFLAGS} reinsert.o ../lib/lib.a -o reinsert
+
+compil: compil.o
+ ${CC} ${LDFLAGS} compil.o -o compil
+
+compil.c: compil.lex
+ ${LEX} -ocompil.c compil.lex
+
+clean:
+ rm -f *.o ${TARGET} compil.c
diff --git a/PE/compil.lex b/PE/compil.lex
new file mode 100644
index 0000000..e59c6b1
--- /dev/null
+++ b/PE/compil.lex
@@ -0,0 +1,93 @@
+ #define yputc(a) putc(a, yyout)
+ #include "table.h"
+
+%%
+
+"<PT"[[:digit:]]+">\n" {
+ int d = atoi(yytext + 3);
+ yputc(0xfe);
+ yputc(d);
+}
+
+"\n<CLOSE>\n" {
+ yputc(0xff);
+}
+
+"<UNK "[[:xdigit:]]{2}">" {
+ int d = strtoul(yytext + 5, NULL, 16);
+ yputc(d);
+}
+
+"<TAG0>" {
+ yputc(0xfb);
+ yputc(0);
+}
+
+"<TAG1>" {
+ yputc(0xfb);
+ yputc(1);
+}
+
+"<CHOICES "[[:digit:]]+">\n" {
+ int d = atoi(yytext + 9);
+ yputc(0xfb);
+ yputc(9);
+ yputc(d);
+}
+
+"<TIMER "[[:digit:]]+">" {
+ int d = atoi(yytext + 7);
+ yputc(0xfb);
+ yputc(7);
+ yputc(d);
+}
+
+"<UNKCMD "[[:digit:]]+">" {
+ int d = atoi(yytext + 8);
+ yputc(0xfb);
+ yputc(d);
+}
+
+"<AYA>" yputc(0xfa);
+"\n<TCLOSE>\n" yputc(0xf9);
+"<PAUSE>\n" yputc(0xf8);
+"\n" yputc(0xf7);
+
+"<ae>" yputc(0x5c);
+"<oe>" yputc(0x5d);
+
+. {
+ int i, trouve = 0;
+ for (i = 0; i <= MAXCHAR; i++) {
+ if (table[i] == *yytext) {
+ trouve = 1;
+ yputc(i);
+ }
+ }
+
+ if (!trouve) {
+ fprintf(stderr, "Caractère inconnu: %s\n", yytext);
+ }
+}
+
+%%
+
+int main(int argc, char ** argv) {
+ if ((argc < 2) || (argc > 3)) {
+ fprintf(stderr, "Usage: %s <output> [input]\n", argv[0]);
+ exit(-1);
+ }
+ if (!(yyout = fopen(argv[1], "wb"))) {
+ fprintf(stderr, "Error: can't open file %s\n", argv[1]);
+ exit(-1);
+ }
+ if (argc == 3) {
+ if (!(yyin = fopen(argv[2], "rb"))) {
+ fprintf(stderr, "Error: can't open file %s\n", argv[2]);
+ exit(-1);
+ }
+ }
+ fprintf(stderr, "Creating file %s\n", argv[1]);
+ yylex();
+ exit(0);
+}
diff --git a/PE/extract-rooms.cpp b/PE/extract-rooms.cpp
new file mode 100644
index 0000000..92bfb6f
--- /dev/null
+++ b/PE/extract-rooms.cpp
@@ -0,0 +1,173 @@
+#include <stdio.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 437
+
+struct entry tab[N];
+
+int main(void) {
+ int i, j, s, dcount = 1;
+ FILE * f, * t;
+ int alreadycounted = 0;
+ char fn[50], buff[2048];
+ unsigned char b, a1, a2;
+ struct tentry te;
+ unsigned long orig, pos, truesize, ptr, sig, size;
+ int found, empty;
+
+ f = fopen("slus_006.62", "r");
+ fseek(f, offset, SEEK_SET);
+
+ for (i = 0; i < N; i++) {
+ fread(&te, sizeof(struct tentry), 1, f);
+ tab[i].sector = te.sector;
+ tab[i].sizes[0] = te.u[0];
+ tab[i].sizes[1] = te.u[1] | (te.u[2] & 0xf);
+ tab[i].sizes[2] = (te.u[2] >> 4) | (te.u[3] << 4);
+ printf("entry %3i - offset: %9i, sizes = %4i %4i %4i\n", i, tab[i].sector * 2048,
+ tab[i].sizes[0], tab[i].sizes[1], tab[i].sizes[2]);
+ }
+
+ fclose(f);
+
+ f = fopen("pe.img", "r");
+
+ for (i = 0; i < N; i++) {
+ fprintf(stderr, "Dumping room %i\n", i);
+
+ if (!tab[i].sizes[0])
+ continue;
+
+ fseek(f, tab[i].sector * 2048, SEEK_SET);
+ for (j = 0; j < 3; j++) {
+ sprintf(fn, "rooms/room-%04i-%02i.out", i, j);
+
+ t = fopen(fn, "w");
+
+ for (s = 0; s < tab[i].sizes[j]; s++) {
+ fread(buff, 2048, 1, f);
+ fwrite(buff, 2048, 1, t);
+ }
+
+ fclose(t);
+ }
+ }
+
+ for (i = 0; i < N; i++) {
+ fprintf(stderr, "Dumping script %i\n", i);
+
+ found = empty = 0;
+
+ if (!tab[i].sizes[0])
+ continue;
+
+ fseek(f, (tab[i].sector + tab[i].sizes[0] + tab[i].sizes[1]) * 2048, SEEK_SET);
+ orig = ftell(f);
+
+ sprintf(fn, "scripts/room-%04i.txt", i);
+ t = fopen(fn, "w");
+
+ fread(&truesize, 4, 1, f);
+ fseek(f, truesize - 4, SEEK_CUR);
+
+ while (!found) {
+ fread(&ptr, 4, 1, f);
+ fseek(f, -8, SEEK_CUR);
+ pos = ftell(f);
+ if ((ptr >> 24) == 1) {
+ ptr &= 0x00ffffff;
+ fseek(f, orig + ptr, SEEK_SET);
+ fread(&sig, 4, 1, f);
+ if ((sig & 0xffff) == 0xfe) {
+ fseek(f, pos, SEEK_SET);
+ fread(&size, 4, 1, f);
+ pos = ptr + orig;
+ found = 1;
+ } else if (sig != 0x4f414b41) { /* AKAO */
+ fclose(t);
+ empty = 1;
+ break;
+ }
+ }
+ fseek(f, pos, SEEK_SET);
+ }
+
+ if (empty)
+ continue;
+
+ fprintf(stderr, "Found %i bytes of text at %i\n", size, pos);
+
+ for (j = 0; j < size; j++) {
+ b = fgetc(f);
+
+ if (b <= MAXCHAR) {
+ fputc(table[b], t);
+ } else {
+ switch(b) {
+ case 0xf7:
+ fputc('\n', t);
+ break;
+ case 0xf8:
+ fprintf(t, "<PAUSE>\n");
+ break;
+ case 0xf9:
+ fprintf(t, "\n<TCLOSE>\n");
+ break;
+ case 0xfa:
+ fprintf(t, "<AYA>");
+ break;
+ case 0xfb:
+ j++;
+ j++;
+ a1 = fgetc(f);
+ switch(a1) {
+ case 0:
+ fprintf(t, "<TAG0>");
+ break;
+ case 1:
+ fprintf(t, "<TAG1>");
+ break;
+ case 9:
+ a2 = fgetc(f);
+ fprintf(t, "<CHOICES %i>\n", a2);
+ break;
+ case 7:
+ a2 = fgetc(f);
+ fprintf(t, "<TIMER %i>", a2);
+ break;
+ default:
+ fprintf(t, "<UNKCMD %i>", a1);
+ break;
+ }
+ break;
+ case 0xfe:
+ j++;
+ b = fgetc(f);
+ fprintf(t, "<PT%i>\n", b);
+ break;
+ case 0xff:
+ fprintf(t, "\n<CLOSE>\n");
+ break;
+ default:
+ fprintf(t, "<UNK %02X>", b);
+ }
+ }
+ }
+
+ fclose(t);
+ }
+
+ return 0;
+}
diff --git a/PE/extract-various.cpp b/PE/extract-various.cpp
new file mode 100644
index 0000000..7bc01d7
--- /dev/null
+++ b/PE/extract-various.cpp
@@ -0,0 +1,126 @@
+#include <stdio.h>
+#include "table.h"
+
+int pos[50];
+
+int main(void) {
+ FILE * f = fopen("dump/0000.out", "r");
+ FILE * s = fopen("various/various.txt", "w");
+ unsigned int c, b, i, j, size, n, changed;
+ unsigned short p, t;
+ char fn[50];
+
+ for (c = 0; c < 6;) {
+ b = fgetc(f);
+ if (b <= MAXCHAR) {
+ fputc(table[b], s);
+ } else {
+ switch(b) {
+ case 0xfe:
+ b = fgetc(f);
+ fprintf(s, "<PT%i>\n", b);
+ break;
+ case 0xff:
+ fprintf(s, "\n<CLOSE>\n");
+ c++;
+ break;
+ default:
+ fprintf(s, "<UNK %02X>", b);
+ }
+ }
+ }
+
+ fclose(f);
+ fclose(s);
+
+
+ f = fopen("dump/0001.out", "r");
+
+ fread(&c, 4, 1, f);
+
+ for (i = 0; i < c; i++) {
+ fread(&(pos[i]), 4, 1, f);
+ }
+ fseek(f, 0, SEEK_END);
+ pos[c] = ftell(f);
+
+ for (i = 0; i < c; i++) {
+ fseek(f, pos[i], SEEK_SET);
+ size = pos[i + 1] - pos[i];
+ sprintf(fn, "various/0001/%02i.out", i);
+ s = fopen(fn, "w");
+ for (j = 0; j < size; j++) {
+ b = fgetc(f);
+ fputc(b, s);
+ }
+ fclose(s);
+ }
+
+ fclose(f);
+
+
+ f = fopen("various/0001/00.out", "r");
+
+ fread(&c, 4, 1, f);
+
+ for (i = 0; i < c; i++) {
+ fread(&(pos[i]), 4, 1, f);
+ }
+ fseek(f, 0, SEEK_END);
+ pos[c] = ftell(f);
+
+ for (i = 0; i < c; i++) {
+ fseek(f, pos[i], SEEK_SET);
+ size = pos[i + 1] - pos[i];
+ sprintf(fn, "various/0001/00/%01i.out", i);
+ s = fopen(fn, "w");
+ for (j = 0; j < size; j++) {
+ b = fgetc(f);
+ fputc(b, s);
+ }
+ fclose(s);
+ }
+
+ fclose(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");
+
+ fread(&p, 2, 1, f);
+ fseek(f, 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);
+ }
+ if (!(b = fgetc(f)) && changed)
+ break;
+
+ changed = 0;
+
+ if (b <= MAXCHAR) {
+ fputc(table[b], s);
+ } else {
+ switch(b) {
+ case 0xff:
+ fprintf(s, "\n<CLOSE>\n");
+ c++;
+ changed = 1;
+ break;
+ default:
+ fprintf(s, "<UNK %02X>", b);
+ }
+ }
+ }
+
+ fclose(f);
+ fclose(s);
+ }
+}
diff --git a/PE/extract.cpp b/PE/extract.cpp
new file mode 100644
index 0000000..001964a
--- /dev/null
+++ b/PE/extract.cpp
@@ -0,0 +1,72 @@
+#include <stdio.h>
+
+#define INDEX 0x838da
+
+#define N1 100
+#define N2 600
+
+int index1[N1];
+int index2[N2];
+
+int main(void) {
+ FILE * s, * f;
+ short int t, b;
+ int n1 = 0, n2 = 0, i, j, size;
+ char fn[50], buff[2048];
+
+ s = fopen("slus_006.62", "r");
+
+ fseek(s, INDEX, SEEK_SET);
+
+ while (1) {
+ fread(&t, 2, 1, s);
+ if (!t)
+ break;
+ index1[n1++] = t;
+ fprintf(stderr, "I1 - %3i - %4i\n", n1, t);
+ }
+
+ b = index1[n1 - 1];
+
+ fseek(s, 6, SEEK_CUR);
+
+ while (1) {
+ fread(&t, 2, 1, s);
+ if (!t)
+ break;
+ index2[n2++] = t + b;
+ fprintf(stderr, "I2 - %3i - %4i\n", n2, t);
+ }
+
+ fclose(s);
+
+ s = fopen("pe.img", "r");
+
+ for (i = 0; i < (n1 - 1); i++) {
+ sprintf(fn, "dump/%04i.out", i);
+ if (!(index1[i + 1] - index1[i]))
+ continue;
+ f = fopen(fn, "w");
+ fprintf(stderr, "Dumping %3i sectors at %4i (%8i) into %s\n", index1[i + 1] - index1[i], index1[i], index1[i] * 2048, fn);
+ fseek(s, index1[i] * 2048, SEEK_SET);
+ for (j = index1[i]; j < index1[i + 1]; j++) {
+ fread(buff, 2048, 1, s);
+ fwrite(buff, 2048, 1, f);
+ }
+ fclose(f);
+ }
+
+ for (i = 0; i < (n2 - 1); i++) {
+ sprintf(fn, "musics/song-%04i.out", i);
+ if (!(index2[i + 1] - index2[i]))
+ continue;
+ f = fopen(fn, "w");
+ fprintf(stderr, "Music - Dumping %3i sectors at %4i into %s\n", index2[i + 1] - index2[i], index2[i], fn);
+ fseek(s, index2[i] * 2048, SEEK_SET);
+ for (j = index2[i]; j < index2[i + 1]; j++) {
+ fread(buff, 2048, 1, s);
+ fwrite(buff, 2048, 1, f);
+ }
+ fclose(f);
+ }
+}
diff --git a/PE/groupe-01.txt b/PE/groupe-01.txt
new file mode 100644
index 0000000..4fdc124
--- /dev/null
+++ b/PE/groupe-01.txt
@@ -0,0 +1,31 @@
+0
+1
+2
+3
+4
+5
+8
+9
+10
+11
+12
+13
+15
+16
+17
+19
+20
+21
+22
+23
+24
+48
+49
+318
+358
+366
+371
+372
+376
+377
+430
diff --git a/PE/groupe-02.txt b/PE/groupe-02.txt
new file mode 100644
index 0000000..dd29cf3
--- /dev/null
+++ b/PE/groupe-02.txt
@@ -0,0 +1,11 @@
+25
+26
+27
+28
+29
+30
+31
+32
+33
+333
+347
diff --git a/PE/groupe-03.txt b/PE/groupe-03.txt
new file mode 100644
index 0000000..d02dd2c
--- /dev/null
+++ b/PE/groupe-03.txt
@@ -0,0 +1,10 @@
+34
+35
+36
+37
+38
+39
+258
+350
+351
+359
diff --git a/PE/groupe-04.txt b/PE/groupe-04.txt
new file mode 100644
index 0000000..8d6c934
--- /dev/null
+++ b/PE/groupe-04.txt
@@ -0,0 +1,12 @@
+40
+41
+42
+44
+45
+46
+50
+51
+52
+53
+54
+55
diff --git a/PE/groupe-05.txt b/PE/groupe-05.txt
new file mode 100644
index 0000000..9fd30cd
--- /dev/null
+++ b/PE/groupe-05.txt
@@ -0,0 +1,27 @@
+43
+47
+97
+98
+99
+101
+102
+103
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+119
+120
+121
+122
+123
+336
diff --git a/PE/groupe-06.txt b/PE/groupe-06.txt
new file mode 100644
index 0000000..109fb9a
--- /dev/null
+++ b/PE/groupe-06.txt
@@ -0,0 +1,34 @@
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
+79
+81
+82
+83
+84
+85
+86
+87
+88
+357
+373
diff --git a/PE/groupe-07.txt b/PE/groupe-07.txt
new file mode 100644
index 0000000..d15a2cc
--- /dev/null
+++ b/PE/groupe-07.txt
@@ -0,0 +1 @@
+80
diff --git a/PE/groupe-08.txt b/PE/groupe-08.txt
new file mode 100644
index 0000000..95d25e1
--- /dev/null
+++ b/PE/groupe-08.txt
@@ -0,0 +1,8 @@
+89
+90
+91
+92
+93
+94
+95
+96
diff --git a/PE/groupe-09.txt b/PE/groupe-09.txt
new file mode 100644
index 0000000..06b600f
--- /dev/null
+++ b/PE/groupe-09.txt
@@ -0,0 +1,52 @@
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+338
+379
+380
diff --git a/PE/groupe-10.txt b/PE/groupe-10.txt
new file mode 100644
index 0000000..ce9c994
--- /dev/null
+++ b/PE/groupe-10.txt
@@ -0,0 +1,5 @@
+160
+161
+162
+163
+164
diff --git a/PE/groupe-11.txt b/PE/groupe-11.txt
new file mode 100644
index 0000000..b45f6fb
--- /dev/null
+++ b/PE/groupe-11.txt
@@ -0,0 +1,25 @@
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+432
diff --git a/PE/groupe-12.txt b/PE/groupe-12.txt
new file mode 100644
index 0000000..048e4e7
--- /dev/null
+++ b/PE/groupe-12.txt
@@ -0,0 +1,5 @@
+190
+220
+232
+238
+255
diff --git a/PE/groupe-13.txt b/PE/groupe-13.txt
new file mode 100644
index 0000000..06bde55
--- /dev/null
+++ b/PE/groupe-13.txt
@@ -0,0 +1,69 @@
+191
+192
+193
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+221
+222
+223
+224
+225
+226
+227
+228
+230
+231
+233
+234
+235
+236
+237
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+256
+257
+339
+340
+341
+342
+343
+344
+345
+370
+378
diff --git a/PE/groupe-14.txt b/PE/groupe-14.txt
new file mode 100644
index 0000000..20187c2
--- /dev/null
+++ b/PE/groupe-14.txt
@@ -0,0 +1,9 @@
+259
+261
+262
+264
+265
+266
+267
+268
+332
diff --git a/PE/groupe-15.txt b/PE/groupe-15.txt
new file mode 100644
index 0000000..591da49
--- /dev/null
+++ b/PE/groupe-15.txt
@@ -0,0 +1,2 @@
+270
+271
diff --git a/PE/groupe-16.txt b/PE/groupe-16.txt
new file mode 100644
index 0000000..f3fa8d2
--- /dev/null
+++ b/PE/groupe-16.txt
@@ -0,0 +1,2 @@
+272
+431
diff --git a/PE/groupe-17.txt b/PE/groupe-17.txt
new file mode 100644
index 0000000..bcd1100
--- /dev/null
+++ b/PE/groupe-17.txt
@@ -0,0 +1,19 @@
+274
+275
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+349
+424
+425
+426
+427
+428
+429
diff --git a/PE/groupe-18.txt b/PE/groupe-18.txt
new file mode 100644
index 0000000..209ac45
--- /dev/null
+++ b/PE/groupe-18.txt
@@ -0,0 +1 @@
+287
diff --git a/PE/groupe-19.txt b/PE/groupe-19.txt
new file mode 100644
index 0000000..067126b
--- /dev/null
+++ b/PE/groupe-19.txt
@@ -0,0 +1,74 @@
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+334
+382
+383
+384
+385
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+415
+416
+417
+418
+419
+420
+421
+422
+423
+433
+434
+435
+436
diff --git a/PE/groupe-20.txt b/PE/groupe-20.txt
new file mode 100644
index 0000000..7dd0c6f
--- /dev/null
+++ b/PE/groupe-20.txt
@@ -0,0 +1,2 @@
+346
+381
diff --git a/PE/nmakefile b/PE/nmakefile
new file mode 100644
index 0000000..f508ab3
--- /dev/null
+++ b/PE/nmakefile
@@ -0,0 +1,13 @@
+_CCFLAGS = /I ..\includes /I ..\generic\include /I ..\..\zlib
+_LIBS = "..\MSVC\Baltisot - generic\Debug\Baltisot - generic.lib" "..\MSVC\PSX-Bundle - library\Debug\PSX-Bundle - library.lib" ..\..\zlib\dll32\zlib.lib ..\..\zlib\static32\zlibstat.lib
+
+!include $(COMMONTOOLSPATH)\master.mak
+
+#------------------------------------------------------------------
+
+TARGETS = extract.exe extract-rooms.exe extract-various.exe reinsert.exe
+
+all : $(TARGETS)
+
+clean :
+ -del /Q $(TARGETS) *.ilk *.pdb *.obj
diff --git a/PE/reinsert.cpp b/PE/reinsert.cpp
new file mode 100644
index 0000000..660e81e
--- /dev/null
+++ b/PE/reinsert.cpp
@@ -0,0 +1,151 @@
+#include <Exceptions.h>
+#include <Input.h>
+#include <Output.h>
+#include <Main.h>
+#include "cdutils.h"
+
+#define index 0x838da
+
+#define offset 0x83b78
+
+CODE_BEGINS
+virtual int startup() throw (GeneralException) {
+ Handle * ir;
+ Handle * iw;
+ cdutils * cd;
+
+ 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;
+
+ 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;
+
+ return 0;
+}
+
+int patch_img(cdutils * cd) {
+ struct cdutils::DirEntry d_slus, d_pe1;
+ unsigned char * slus;
+ int i, j, c, fontei;
+ String s;
+ int groupes[100][20];
+ int counts[20];
+
+ verbosity = M_INFO;
+
+ 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);
+
+ fontei = *((short *)(slus + index + 18));
+ 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;
+
+ Handle * menu = new Input("69/0069.out");
+ printm(M_INFO, "Ecriture du menu...\n");
+ cd->write_file(menu, GUESS, d_pe1.Sector + 978);
+ delete menu;
+
+ 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++) {
+ int sector, s1, s2, s3, r, size, size2, ptr, tptr, sig, jptr, sizes[2];
+ r = groupes[c][i];
+ 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);
+
+ ptr = size - 4;
+ while (1) {
+ tptr = *((int *) (room + ptr));
+ if ((tptr >> 24) == 1) {
+ tptr &= 0xffffff;
+ sig = *((int *) (room + tptr));
+ if ((sig & 0xffff) == 0xfe) {
+ break;
+ }
+ }
+ ptr -= 4;
+ }
+
+ jptr = *((int *) (room + ptr - 8));
+
+ printm(M_INFO, " Room %i\n", r);
+
+ if (size2 < (jptr + f->GetSize())) {
+ printm(M_ERROR, "size2 = %i, jptr = %i, f = %i, + = %i - script trop gros.\n", size2, jptr, f->GetSize(), jptr + f->GetSize());
+ exit(-1);
+ }
+
+ memcpy(room + jptr, script, f->GetSize());
+
+ *((int *) (room + ptr)) = jptr | 0x01000000;
+
+ 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
new file mode 100644
index 0000000..1eb7cb9
--- /dev/null
+++ b/PE/table.h
@@ -0,0 +1,3 @@
+char table[256] = "0123456789+-=*% ABCDEFGHIJKLMNOPQRSTUVWXYZ&!?\"'.abcdefghijklmnopqrstuvwxyz:,/éèêëàâäîïôöùûüç";
+
+#define MAXCHAR 0x5b