From 44adf768555ecd211f90cbf4d87b44ba42044d86 Mon Sep 17 00:00:00 2001 From: pixel Date: Fri, 5 Sep 2003 23:50:16 +0000 Subject: Continuing toying --- PE/Makefile | 27 ++++++++ PE/compil.lex | 93 ++++++++++++++++++++++++++ PE/extract-rooms.cpp | 173 +++++++++++++++++++++++++++++++++++++++++++++++++ PE/extract-various.cpp | 126 +++++++++++++++++++++++++++++++++++ PE/extract.cpp | 72 ++++++++++++++++++++ PE/groupe-01.txt | 31 +++++++++ PE/groupe-02.txt | 11 ++++ PE/groupe-03.txt | 10 +++ PE/groupe-04.txt | 12 ++++ PE/groupe-05.txt | 27 ++++++++ PE/groupe-06.txt | 34 ++++++++++ PE/groupe-07.txt | 1 + PE/groupe-08.txt | 8 +++ PE/groupe-09.txt | 52 +++++++++++++++ PE/groupe-10.txt | 5 ++ PE/groupe-11.txt | 25 +++++++ PE/groupe-12.txt | 5 ++ PE/groupe-13.txt | 69 ++++++++++++++++++++ PE/groupe-14.txt | 9 +++ PE/groupe-15.txt | 2 + PE/groupe-16.txt | 2 + PE/groupe-17.txt | 19 ++++++ PE/groupe-18.txt | 1 + PE/groupe-19.txt | 74 +++++++++++++++++++++ PE/groupe-20.txt | 2 + PE/nmakefile | 13 ++++ PE/reinsert.cpp | 151 ++++++++++++++++++++++++++++++++++++++++++ PE/table.h | 3 + 28 files changed, 1057 insertions(+) create mode 100644 PE/Makefile create mode 100644 PE/compil.lex create mode 100644 PE/extract-rooms.cpp create mode 100644 PE/extract-various.cpp create mode 100644 PE/extract.cpp create mode 100644 PE/groupe-01.txt create mode 100644 PE/groupe-02.txt create mode 100644 PE/groupe-03.txt create mode 100644 PE/groupe-04.txt create mode 100644 PE/groupe-05.txt create mode 100644 PE/groupe-06.txt create mode 100644 PE/groupe-07.txt create mode 100644 PE/groupe-08.txt create mode 100644 PE/groupe-09.txt create mode 100644 PE/groupe-10.txt create mode 100644 PE/groupe-11.txt create mode 100644 PE/groupe-12.txt create mode 100644 PE/groupe-13.txt create mode 100644 PE/groupe-14.txt create mode 100644 PE/groupe-15.txt create mode 100644 PE/groupe-16.txt create mode 100644 PE/groupe-17.txt create mode 100644 PE/groupe-18.txt create mode 100644 PE/groupe-19.txt create mode 100644 PE/groupe-20.txt create mode 100644 PE/nmakefile create mode 100644 PE/reinsert.cpp create mode 100644 PE/table.h (limited to 'PE') 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" + +%% + +"\n" { + int d = atoi(yytext + 3); + yputc(0xfe); + yputc(d); +} + +"\n\n" { + yputc(0xff); +} + +"" { + int d = strtoul(yytext + 5, NULL, 16); + yputc(d); +} + +"" { + yputc(0xfb); + yputc(0); +} + +"" { + yputc(0xfb); + yputc(1); +} + +"\n" { + int d = atoi(yytext + 9); + yputc(0xfb); + yputc(9); + yputc(d); +} + +"" { + int d = atoi(yytext + 7); + yputc(0xfb); + yputc(7); + yputc(d); +} + +"" { + int d = atoi(yytext + 8); + yputc(0xfb); + yputc(d); +} + +"" yputc(0xfa); +"\n\n" yputc(0xf9); +"\n" yputc(0xf8); +"\n" yputc(0xf7); + +"" yputc(0x5c); +"" 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 [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 +#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, "\n"); + break; + case 0xf9: + fprintf(t, "\n\n"); + break; + case 0xfa: + fprintf(t, ""); + break; + case 0xfb: + j++; + j++; + a1 = fgetc(f); + switch(a1) { + case 0: + fprintf(t, ""); + break; + case 1: + fprintf(t, ""); + break; + case 9: + a2 = fgetc(f); + fprintf(t, "\n", a2); + break; + case 7: + a2 = fgetc(f); + fprintf(t, "", a2); + break; + default: + fprintf(t, "", a1); + break; + } + break; + case 0xfe: + j++; + b = fgetc(f); + fprintf(t, "\n", b); + break; + case 0xff: + fprintf(t, "\n\n"); + break; + default: + fprintf(t, "", 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 +#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, "\n", b); + break; + case 0xff: + fprintf(s, "\n\n"); + c++; + break; + default: + fprintf(s, "", 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\n"); + c++; + changed = 1; + break; + default: + fprintf(s, "", 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 + +#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 +#include +#include +#include +#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 -- cgit v1.2.3