From 0177d50e3ae979872e5d8c60a7b4ca97b2ba9f5b Mon Sep 17 00:00:00 2001 From: pixel Date: Thu, 25 Dec 2003 15:14:02 +0000 Subject: Final push :-P --- PE/Makefile | 2 +- PE/compil.lex | 52 ++++++++++++++++++++++++++++++++++++--- PE/extract-various.cpp | 1 + PE/pe-hack.lua | 7 ++++-- PE/rebuildmenus.cpp | 67 ++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 122 insertions(+), 7 deletions(-) create mode 100644 PE/rebuildmenus.cpp (limited to 'PE') diff --git a/PE/Makefile b/PE/Makefile index 1444f44..54f9b39 100644 --- a/PE/Makefile +++ b/PE/Makefile @@ -9,7 +9,7 @@ LIBS=-lz -lefence LDFLAGS=${LIBS} `baltisot-config --libs` #`pkg-config --libs glib-2.0` -TARGET = compil extract extract-various extract-rooms +TARGET = compil extract extract-various extract-rooms rebuildmenus all: ${TARGET} diff --git a/PE/compil.lex b/PE/compil.lex index cda7fa0..bc6614d 100644 --- a/PE/compil.lex +++ b/PE/compil.lex @@ -2,10 +2,31 @@ #define yputc(a) putc(a, yyout) #include "table.h" - int oldpt = -1; + int oldpt = -1, nbpts = -1; + int curptr = 0, p, full = 0; + void putptr(void); %% +"\n" { + int i; + nbpts = atoi(yytext + 7); + fprintf(stderr, "nbpts = %i\n", nbpts); + unsigned short int z = 0; + + fwrite(&nbpts, 2, 1, yyout); + + for (i = 0; i < nbpts; i++) { + fwrite(&z, 2, 1, yyout); + } + + curptr = 1; + p = ftell(yyout); + fseek(yyout, 2, SEEK_SET); + fwrite(&p, 2, 1, yyout); + fseek(yyout, p, SEEK_SET); +} + "\n" { int d = atoi(yytext + 3); if (d != (oldpt + 1)) { @@ -47,10 +68,11 @@ yputc(d); } -"\n\n" yputc(0xff); -"\n" { yputc(0xf7); yputc(0xff); } +"\n" { yputc(0xff); putptr(); } +"\n\n" { yputc(0xff); putptr(); } "" yputc(0xfa); -"\n\n" yputc(0xf9); +"\n\n" { yputc(0xf9); putptr(); } +"\n" { putptr(); } "\n" yputc(0xf8); "\n" yputc(0xf7); @@ -78,9 +100,31 @@ %% int yywrap(void) { + if ((nbpts != -1) && (!full)) { + fprintf(stderr, "Pas assez de pointeurs\n"); + } exit(0); } +void putptr(void) { + if (nbpts == -1) + return; + if (curptr == nbpts) { + full = 1; + curptr++; + return; + } + if (curptr > nbpts) { + fprintf(stderr, "Trop de pointeurs ligne %i\n", yylineno); + return; + } + p = ftell(yyout); + fseek(yyout, 2 * curptr + 2, SEEK_SET); + fwrite(&p, 2, 1, yyout); + fseek(yyout, 0, SEEK_END); + curptr++; +} + int main(int argc, char ** argv) { if ((argc < 2) || (argc > 3)) { fprintf(stderr, "Usage: %s [input]\n", argv[0]); diff --git a/PE/extract-various.cpp b/PE/extract-various.cpp index a4261b9..6f02fba 100644 --- a/PE/extract-various.cpp +++ b/PE/extract-various.cpp @@ -93,6 +93,7 @@ virtual int startup() throw (GeneralException) { p = f->readU16(); f->seek(p * 2, SEEK_CUR); + (*s) << "\n"; changed = 1; diff --git a/PE/pe-hack.lua b/PE/pe-hack.lua index f7a943a..0d67bdc 100644 --- a/PE/pe-hack.lua +++ b/PE/pe-hack.lua @@ -9,14 +9,14 @@ function mainpatch() print "Identifying CD..." if (dirent.id == "SLUS_006.62;1") then print "CD is Parasite Eve CD1" - pvd.volid = "PARASITE_EVE_FRANCAIS_CD1" + pvd.volid = "PE-FR-CD1" slusname = "PE-FR.CD1" fmvdir = "FMV1" is_cd1 = true is_cd2 = false else print "CD is Parasite Eve CD2" - pvd.volid = "PARASITE_EVE_FRANCAIS_CD2" + pvd.volid = "PE-FR-CD2" slusname = "PE-FR.CD2" fmvdir = "FMV2" is_cd1 = false @@ -94,6 +94,7 @@ function do_img_file(slus, startsect, pesect) for i = 1, 79, 1 do if (files[i] ~= nil) then if (type(files[i]) == "string") then + print("Putting file " .. files[i] .. " instead"); file = Input(files[i]) else file = files[i](sect1[i], (sect1[i + 1] - sect1[i]) * 2048) @@ -355,6 +356,8 @@ function buffer_pad(buffer) end files = { + [1] = "various.bin", + [2] = "menus.bin", [10] = "font.tim", [70] = "mainmenu.bin", [72] = patch_map, diff --git a/PE/rebuildmenus.cpp b/PE/rebuildmenus.cpp new file mode 100644 index 0000000..76b3e97 --- /dev/null +++ b/PE/rebuildmenus.cpp @@ -0,0 +1,67 @@ +#include +#include +#include + +CODE_BEGINS +virtual int startup(void) throw (GeneralException) { + int i, p; + 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); + + p = inter->tell(); + + inter->seek(i * 4 + 4); + inter->writeU32(p); + inter->seek(0, SEEK_END); + + copy(f, inter); + + 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 -- cgit v1.2.3