diff options
author | pixel <pixel> | 2003-12-14 21:14:07 +0000 |
---|---|---|
committer | pixel <pixel> | 2003-12-14 21:14:07 +0000 |
commit | 83473b5e976c94eb1692e8d35d77b61cf57c97f9 (patch) | |
tree | 2b2703f65ee75beeb25ca5316b23d05fab042140 /PE | |
parent | d6214b0f60cb6c8386723717159b9212b1d55174 (diff) |
Fixing things...
Diffstat (limited to 'PE')
-rw-r--r-- | PE/Makefile | 2 | ||||
-rw-r--r-- | PE/extract-rooms.cpp | 6 | ||||
-rw-r--r-- | PE/pe-hack.lua | 268 |
3 files changed, 272 insertions, 4 deletions
diff --git a/PE/Makefile b/PE/Makefile index 2d404ab..1444f44 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 = reinsert compil extract extract-various extract-rooms +TARGET = compil extract extract-various extract-rooms all: ${TARGET} diff --git a/PE/extract-rooms.cpp b/PE/extract-rooms.cpp index 738411d..a23026f 100644 --- a/PE/extract-rooms.cpp +++ b/PE/extract-rooms.cpp @@ -15,7 +15,7 @@ struct entry { #define fullsize 206213120 #define offset 0x83b78 -#define N 437 +#define N 438 CODE_BEGINS struct entry tab[N]; @@ -43,8 +43,8 @@ virtual int startup() throw (GeneralException) { tab[i].sizes[0] = te.u[0]; tab[i].sizes[1] = te.u[1] | ((te.u[2] & 0xf) << 8); tab[i].sizes[2] = (te.u[2] >> 4) | (te.u[3] << 4); - printm(M_INFO, "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]); + printm(M_INFO, "entry %3i - offset: %9i, sizes = %4i %4i %4i (%02x %02x %02x %02x)\n", i, tab[i].sector * 2048, + tab[i].sizes[0], tab[i].sizes[1], tab[i].sizes[2], te.u[0], te.u[1], te.u[2], te.u[3]); } delete f; diff --git a/PE/pe-hack.lua b/PE/pe-hack.lua new file mode 100644 index 0000000..97f1ec2 --- /dev/null +++ b/PE/pe-hack.lua @@ -0,0 +1,268 @@ +slus_hacks = { + +-- ASM Ptr hack + [0x1603c] = { 0xbc }, + +-- ASM Font hack + [0x284e4] = { 0x21 }, + [0x28540] = { 0x21, 0x18, 0x00, 0x00 }, + [0x28fb8] = { 0x21, 0x18, 0x00, 0x00 }, + [0x29074] = { 0x00, 0x00, 0x00 }, + + +-- Text "Susceptible to poison" + [0x81c96] = { 0x25, 0x34, 0x3d, 0x38, 0x3c, 0x34, 0x44, 0x47, + 0xff }, + +-- Text "Susceptible to acid" + [0x81cc0] = { 0x14, 0x3c, 0x3f, 0x3e, 0x38, 0x42, 0x3e, 0x3d, + 0x3d, 0x34, 0x0f, 0x3f, 0x30, 0x41, 0x0f, 0x30, + 0x32, 0x38, 0x33, 0x34, 0xff }, + +-- Text "Easily tranquilized" + [0x81ce8] = { 0x22, 0x34, 0x3d, 0x42, 0x38, 0x31, 0x3b, 0x34, + 0x0f, 0x30, 0x44, 0x47, 0x0f, 0x43, 0x41, 0x30, + 0x3d, 0x40, 0x44, 0x38, 0x3b, 0x38, 0x42, 0x30, + 0x3d, 0x43, 0x42, 0xff }, + +-- Text "Sensitive to heat" + [0x81d0e] = { 0x22, 0x34, 0x3d, 0x42, 0x38, 0x31, 0x3b, 0x34, + 0x0f, 0x51, 0x0f, 0x3b, 0x30, 0x0f, 0x32, 0x37, + 0x30, 0x3b, 0x34, 0x44, 0x41, 0xff }, + +-- Text "Sensitive to cold" + [0x81d32] = { 0x22, 0x34, 0x3d, 0x42, 0x38, 0x31, 0x3b, 0x34, + 0x0f, 0x30, 0x44, 0x0f, 0x35, 0x41, 0x3e, 0x38, + 0x33, 0xff }, + +-- Text "Objects easily stolen" + [0x81d5a] = { 0x1f, 0x3e, 0x42, 0x42, 0x4e, 0x33, 0x34, 0x0f, + 0x33, 0x34, 0x42, 0x0f, 0x3e, 0x31, 0x39, 0x34, + 0x43, 0x42, 0x0f, 0x51, 0x0f, 0x45, 0x3e, 0x3b, + 0x34, 0x41, 0xff }, + +-- Text "Gets confused easily" + [0x81d85] = { 0x12, 0x3e, 0x3d, 0x35, 0x44, 0x42, 0x38, 0x3e, + 0x3d, 0x0f, 0x3f, 0x3e, 0x42, 0x42, 0x38, 0x31, + 0x3b, 0x34, 0x0f, 0x34, 0x43, 0x0f, 0x34, 0x35, + 0x35, 0x38, 0x32, 0x30, 0x32, 0x34, 0xff }, + +-- Text "Failed to escape" + [0x81dad] = { 0x15, 0x44, 0x38, 0x43, 0x34, 0x0f, 0x4d, 0x32, + 0x37, 0x44, 0x4d, 0x34, 0xff }, + +-- Text "Can't escape!" + [0x81dca] = { 0x15, 0x44, 0x38, 0x43, 0x34, 0x0f, 0x38, 0x3c, + 0x3f, 0x3e, 0x42, 0x42, 0x38, 0x31, 0x3b, 0x34, + 0x2b, 0xff }, + + +-- Font width table + [0x81ea1] = { 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 6, 6, 8, 11, 14, + 9, 8, 7, 8, 7, 7, 8, 9, 6, 7, 9, 8, 11, 9, 7, 8, + 7, 9, 7, 7, 9, 9, 11, 7, 9, 7, 9, 4, 7, 6, 4, 4, + 8, 8, 7, 7, 7, 7, 8, 9, 5, 4, 8, 5, 11, 9, 7, 8, + 8, 7, 6, 5, 9, 9, 11, 7, 9, 6, 4, 4, 7, 7, 7, 7, + 7, 7, 7, 7, 5, 5, 7, 7, 9, 9, 9, 7, 11, 11, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }, + +-- PE.BIN filename extension + [0x01b4c] = { 0x54, 0x49, 0x4d }, +} + +function apply_hacks(hacks, file) + local k, v, i, h + for k, v in pairs(slus_hacks) do + for i, h in ipairs(v) do + file[k + i - 1] = h + end + end +end + +function mainpatch() + local dirent, pvd, root, is_cd1, is_cd2, slusname, fmvdir, systemcnfstring, inslus, slus, peimg, pesect, tim, startsect, fmvdirtree + + dirent = cdutil:findpath "/SLUS_006.62;1" or cdutil:findpath "/SLUS_006.68;1" or error "Not a Parasite Eve CD" + + iso:foreword(cdutil) + pvd = createpvd(cdutil) + + print "Identifying CD..." + if (dirent.id == "SLUS_006.62;1") then + print "CD is Parasite Eve CD1" + pvd.volid = "PARASITE_EVE_FRANCAIS_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" + slusname = "PE-FR.CD2" + fmvdir = "FMV2" + is_cd1 = false + is_cd2 = true + end + root = iso:setbasics(pvd) + + systemcnfstring = "BOOT=cdrom:\\" .. slusname .. [[;1 +TCB=4 +EVENT=16 +STACK=801fff00 +]] + + systemcnf = Buffer() + systemcnf:write(systemcnfstring) + iso:createfile(root, "SYSTEM.CNF", systemcnf, dirent) + + print "Reading CD's slus file" + inslus = cdfile(cdutil, dirent) + slus = Buffer(true) + slus:copyfrom(inslus) + apply_hacks(slus_hacks, slus) + + dirent = cdutil:findpath "/" + root:setbasicsxa() + root:fromdir(dirent) + + dirent = cdutil:findpath "/PE.IMG;1" + pesect = dirent.Sector + peimg = cdfile(cdutil, dirent) + tim = Buffer() + peimg:copyto(tim, 0x23800) + startsect = iso:createfile(root, "PE.TIM", tim, dirent).sector + print "Compiling IMG file" + do_img_file(slus, startsect, pesect) + + print "Writing final main file" + slus:seek(0) + iso:createfile(root, slusname, slus):setbasicsxa() + + print "Copying FMV directory" + dirent = cdutil:findpath("/" .. fmvdir) + fmvdirtree = iso:createdir(root, fmvdir, 1, dirent) +-- fmvdirtree.hardhide = true + iso:copydir(fmvdirtree, cdutil, dirent) + + print "Finalizing CD" + iso:createfile(root, "README.TXT", Input("readme.txt")):setbasicsxa() + + iso:close() +end + +function do_img_file(slus, startsect, pesect) + local i, j, sect1, tab1, sect2, tab2, sect3, tab3, sizes1, sizes2, sizes3, sect, file, file1, file2, file3, songsect, b1, b2, b3, b4, lastsect, s1, s2, s3 + + sect1 = {} + tab1 = {} + sect2 = {} + tab2 = {} + sect3 = {} + tab3 = {} + sizes1 = {} + sizes2 = {} + sizes3 = {} + + + print "Putting various files" + slus:seek(0x838da) + for i = 1, 80, 1 do + sect1[i] = slus:readU16() + pesect + end + for i = 1, 79, 1 do +-- print(i) + file = cdfile(cdutil, sect1[i], (sect1[i + 1] - sect1[i]) * 2048) + s1 = iso:putfile(file) + tab1[i] = s1 - startsect + print("Putting file " .. i .. " from sector " .. sect1[i] .. " to sector " .. s1) + end + tab1[80] = iso:getdispsect() - startsect + songsect = tab1[80] + + print "Putting musics" + slus:seek(0x83980) + for i = 1, 251, 1 do + sect2[i] = slus:readU16() + sect1[80] + end + for i = 1, 250, 1 do +-- print(i) + file = nil + if ((sect2[i + 1] - sect2[i]) ~= 0) then + file = cdfile(cdutil, sect2[i], (sect2[i + 1] - sect2[i]) * 2048) + end + if (file) then + s1 = iso:putfile(file) + end + tab2[i] = s1 - startsect - songsect + print("Putting music " .. i .. " from sector " .. sect2[i] .. " to sector " .. s1) + end + tab2[251] = iso:getdispsect() - startsect - songsect + + + print "Putting rooms" + slus:seek(0x83b78) + for i = 1, 438, 1 do + sect3[i] = slus:readU32() + pesect + b1 = slus:readU8() + b2 = slus:readU8() + b3 = slus:readU8() + b4 = slus:readU8() + sizes1[i] = b1 + sizes2[i] = orB(b2, (shl(andB(b3, 0x0f), 8))) + sizes3[i] = orB(shr(b3, 4), shl(b4, 4)) + end + for i = 1, 438, 1 do +-- print(i) + file1 = nil + file2 = nil + file3 = nil + if (sizes1[i] ~= 0) then + print("File " .. i .. " from sector " .. sect3[i]) + file1 = cdfile(cdutil, sect3[i], sizes1[i] * 2048) + end + if (sizes2[i] ~= 0) then + print("File " .. i .. " from sector " .. sect3[i] + sizes1[i]) + file2 = cdfile(cdutil, sect3[i] + sizes1[i], sizes2[i] * 2048) + end + if (sizes3[i] ~= 0) then + print("File " .. i .. " from sector " .. sect3[i] + sizes1[i] + sizes2[i]) + file3 = cdfile(cdutil, sect3[i] + sizes1[i] + sizes2[i], sizes3[i] * 2048) + end + + s1 = iso:getdispsect() - startsect + if (file1) then + print("Put file " .. i .. " at " .. s1) + iso:putfile(file1) + end + s2 = iso:getdispsect() - startsect + if (file2) then + iso:putfile(file2) + end + s3 = iso:getdispsect() - startsect + if (file3) then + iso:putfile(file3) + end + tab3[i] = s1 + sizes1[i] = s2 - s1 + sizes2[i] = s3 - s2 + sizes3[i] = iso:getdispsect() - s3 + end + + slus:wseek(0x838da) + for i = 1, 80, 1 do + slus:writeU16(tab1[i]) + end + slus:writeU16(0) + slus:writeU16(songsect) + slus:writeU16(0) + for i = 1, 251, 1 do + slus:writeU16(tab2[i]) + end + + slus:wseek(0x83b78) +end + +mainpatch() |