summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpixel <pixel>2004-01-26 15:31:54 +0000
committerpixel <pixel>2004-01-26 15:31:54 +0000
commitdd1a70b70cc5a4ab3a7dbeef2862d4a817fd91a7 (patch)
treec231980c6568c1a87412d6a7740025d7fce34742
parent3830a1a01fac86fea249fafc81f42b2f1e8ed1ae (diff)
Blah
-rwxr-xr-xMakefile2
-rw-r--r--PE/pe-hack.lua58
-rw-r--r--includes/mipsobj.h74
-rwxr-xr-xlib/Makefile2
-rw-r--r--lib/mipsdis.cpp7
-rw-r--r--lib/mipsobj.cpp269
-rw-r--r--luapatch.cpp2
7 files changed, 388 insertions, 26 deletions
diff --git a/Makefile b/Makefile
index 257e8b2..37b6399 100755
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ CDTOOL_LDFLAGS=`baltisot-config --libs`
CXX=g++
#SUBDIRS = psxdev lib Xenogears VP MegamanX5
-SUBDIRS = psxdev lib PE
+SUBDIRS = psxdev lib PE Xenogears
TARGET = lzss dlzss cd-tool str-player crypto-search bgrep tile-convert mipspoke
all: subdirs ${TARGET}
diff --git a/PE/pe-hack.lua b/PE/pe-hack.lua
index 0937a70..80bb494 100644
--- a/PE/pe-hack.lua
+++ b/PE/pe-hack.lua
@@ -1,24 +1,28 @@
-- Parasite Eve's french patch
--- $Id: pe-hack.lua,v 1.9 2004-01-03 15:04:47 pixel Exp $
+-- $Id: pe-hack.lua,v 1.10 2004-01-26 15:31:55 pixel Exp $
function mainpatch()
local dirent, slusdirent, pvd, root, is_cd1, is_cd2, slusname, fmvdir, systemcnfstring, inslus, slus, peimg, pesect, tim, startsect, slussect, fmvdirtree, xadirtree, falsesect, i, picts, pict
- slusdirent = cdutil:findpath "/SLUS_006.62;1" or cdutil:findpath "/SLUS_006.68;1" or error "Not a Parasite Eve CD"
+-- slusdirent = cdutil:findpath "/SLUS_006.62;1" or cdutil:findpath "/SLUS_006.68;1" or error "Not a US Parasite Eve CD"
+ slusdirent = cdutil:findpath "/SLUS_006.62;1" or cdutil:findpath "/SLUS_006.68;1" or error "Ce n'est pas un CD de Parasite Eve US"
iso:foreword(cdutil)
pvd = createpvd(cdutil)
- print "Identifying CD..."
+-- print "Identifying CD..."
+ print "Identification du CD..."
if (slusdirent.id == "SLUS_006.62;1") then
- print "CD is Parasite Eve CD1"
+-- print "CD is Parasite Eve CD1"
+ print "CD1 de Parasite Eve"
pvd.volid = "PE-FR-CD1"
slusname = "PE-FR.CD1"
fmvdir = "FMV1"
is_cd1 = true
is_cd2 = false
else
- print "CD is Parasite Eve CD2"
+-- print "CD is Parasite Eve CD2"
+ print "CD2 de Parasite Eve"
pvd.volid = "PE-FR-CD2"
slusname = "PE-FR.CD2"
fmvdir = "FMV2"
@@ -34,15 +38,17 @@ function mainpatch()
dirent = cdutil:findpath("/SYSTEM.CNF;1")
iso:createfile(root, "SYSTEM.CNF", systemcnf, slusdirent)
- print "Reading CD's slus file"
- inslus = cdfile(cdutil, slusdirent)
--- inslus = Input("PE-SLUS00662-patched-debug-room.exe")
+-- print "Reading CD's slus file"
+ print "Lecture du fichier slus"
+-- inslus = cdfile(cdutil, slusdirent)
+ inslus = Input("PE-SLUS00662-patched-debug-room.exe")
slus = Buffer(true)
slus:copyfrom(inslus)
apply_hacks(slus_hacks, slus)
slussect = iso:getdispsect()
- print("Reserving space for SLUS file at sector " .. slussect)
+-- print("Reserving space for SLUS file at sector " .. slussect)
+ print("Reservation d'espace pour le SLUS au sector " .. slussect)
slus:seek(0)
iso:createfile(root, slusname, slus, slusdirent):setbasicsxa()
slus:seek(0)
@@ -57,14 +63,17 @@ function mainpatch()
tim = Buffer()
peimg:copyto(tim, 0x23800)
startsect = iso:createfile(root, "PE.TIM", tim, dirent).sector
- print "Compiling IMG file"
+-- print "Compiling IMG file"
+ print "Compilation du fichier IMG"
do_img_file(slus, startsect, pesect)
- print "Writing final main file"
+-- print "Writing final main file"
+ print "Ecriture du fichier SLUS final"
slus:seek(0)
iso:putfile(slus, -1, slussect)
- print "Copying FMV directory"
+-- print "Copying FMV directory"
+ print "Copie du répertoire FMV..."
dirent = cdutil:findpath("/" .. fmvdir)
fmvdirtree = iso:createdir(root, fmvdir, 1, dirent)
fmvdirtree:setbasicsxa()
@@ -72,7 +81,8 @@ function mainpatch()
iso:copydir(fmvdirtree, cdutil, dirent)
if (is_cd2) then
- print "Copying xastream directory"
+-- print "Copying xastream directory"
+ print "Copie du répertoire xastream..."
dirent = cdutil:findpath("/XASTREAM")
xadirtree = iso:createdir(root, "XASTREAM", 1, dirent)
xadirtree:setbasicsxa()
@@ -80,7 +90,8 @@ function mainpatch()
iso:copydir(xadirtree, cdutil, dirent)
end
- print "Finalizing CD"
+-- print "Finalizing CD"
+ print "Finalisation du CD"
iso:createfile(root, "README.TXT", Input("readme.txt")):setbasicsxa()
iso:createfile(root, "DIVERS.HTM", Input("divers.htm")):setbasicsxa()
picts = iso:createdir(root, "PICTS")
@@ -100,7 +111,8 @@ 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, str = 0, 0, {}, {}, {}, {}, {}, {}, {}, {}, {}
- print "Putting various files"
+-- print "Putting various files"
+ print "Fichiers divers..."
slus:seek(0x838da)
for i = 1, 80, 1 do
sect1[i] = slus:readU16() + pesect
@@ -108,7 +120,6 @@ 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)
@@ -118,12 +129,14 @@ function do_img_file(slus, startsect, pesect)
end
s1 = iso:putfile(file)
tab1[i] = s1 - startsect
- print("Putting file " .. i .. " from sector " .. sect1[i] .. " to sector " .. s1)
+-- print("Putting file " .. i .. " from sector " .. sect1[i] .. " to sector " .. s1)
+ print("Ecriture du fichier " .. i .. "...")
end
tab1[80] = iso:getdispsect() - startsect
songsect = tab1[80]
- print "Putting musics"
+-- print "Putting musics"
+ print "Les musiques"
slus:seek(0x83980)
for i = 1, 251, 1 do
sect2[i] = slus:readU16() + sect1[80]
@@ -137,12 +150,14 @@ function do_img_file(slus, startsect, pesect)
s1 = iso:putfile(file)
end
tab2[i] = s1 - startsect - songsect
- print("Putting music " .. i .. " from sector " .. sect2[i] .. " to sector " .. s1)
+-- print("Putting music " .. i .. " from sector " .. sect2[i] .. " to sector " .. s1)
+ print("Ecriture de la musique " .. i .. "...")
end
tab2[251] = iso:getdispsect() - startsect - songsect
- print "Putting rooms"
+-- print "Putting rooms"
+ print "Les rooms"
slus:seek(0x83b78)
for i = 1, 438, 1 do
sect3[i] = slus:readU32() + pesect
@@ -184,7 +199,8 @@ function do_img_file(slus, startsect, pesect)
end
iso:putfile(file3)
end
- print("Putting room " .. i .. " from sector " .. sect3[i] .. " to sector " .. s1 + startsect)
+-- print("Putting room " .. i .. " from sector " .. sect3[i] .. " to sector " .. s1 + startsect)
+ print("Ecriture de la room " .. i .. "...")
tab3[i] = s1
sizes1[i] = s2 - s1
sizes2[i] = s3 - s2
diff --git a/includes/mipsobj.h b/includes/mipsobj.h
new file mode 100644
index 0000000..18ac504
--- /dev/null
+++ b/includes/mipsobj.h
@@ -0,0 +1,74 @@
+#ifndef __MIPSOBJ_H__
+#define __MIPSOBJ_H__
+
+#include <map>
+#include <Exceptions.h>
+#include <Handle.h>
+
+enum mips_reloc_t {
+ R_MIPS_26,
+ R_MIPS_32,
+ R_MIPS_HI16,
+ R_MIPS_LO16,
+};
+
+enum symbol_type_t {
+ LOCAL,
+ GLOBAL,
+ EXTERN,
+};
+
+enum section_type_t {
+ TEXT,
+ DATA,
+ BSS,
+};
+
+struct reloc_t {
+ String symbol;
+ int type;
+ Uint32 offset;
+};
+
+struct symbol_t {
+ String name;
+ String section;
+ int type;
+ Uint32 offset;
+};
+
+class section : public Base {
+ public:
+ section(const String &, int);
+ section();
+ virtual ~section();
+ void setname(const String &);
+ void settype(int);
+ void putdatas(const Uint8 *, int);
+ int gettype();
+ int getsize();
+ const Uint8 * getdatas();
+ void putreloc(const String &, int, Uint32);
+ void putreloc(const struct reloc_t &);
+ std::vector<struct reloc_t> relocs;
+ private:
+ String name;
+ int type;
+ Uint8 * datas;
+ int length;
+};
+
+class mipsobj : public Base {
+ public:
+ mipsobj();
+ virtual ~mipsobj();
+ std::map<String, section> sections;
+ std::map<String, symbol_t> symbols;
+ void loadELF(Handle *) throw (GeneralException);
+ void loadOBJ(Handle *) throw (GeneralException);
+ void loadLIB(Handle *, const String &) throw (GeneralException);
+ private:
+ bool loaded;
+};
+
+#endif
diff --git a/lib/Makefile b/lib/Makefile
index b3d7399..3adf730 100755
--- a/lib/Makefile
+++ b/lib/Makefile
@@ -3,7 +3,7 @@
CPPFLAGS=-Wall -g -O3 -mcpu=i686 -I../includes -DHAVE_ZLIB -DUSE_CDREADER -DDEBUG `baltisot-config --cflags` `lua-config --include`
CXX=g++
-OBJECTS = cdutils.o lzss.o yazedc.o cdreader.o cdabstract.o isobuilder.o luacd.o mips.o mipsmem.o mipsdis.o mipsdump.o
+OBJECTS = cdutils.o lzss.o yazedc.o cdreader.o cdabstract.o isobuilder.o luacd.o mips.o mipsmem.o mipsdis.o mipsdump.o mipsobj.o
TARGET = lib.a
all: ${TARGET}
diff --git a/lib/mipsdis.cpp b/lib/mipsdis.cpp
index a1b2a68..cbaf9e3 100644
--- a/lib/mipsdis.cpp
+++ b/lib/mipsdis.cpp
@@ -17,7 +17,7 @@
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
-/* $Id: mipsdis.cpp,v 1.1 2004-01-03 15:04:47 pixel Exp $ */
+/* $Id: mipsdis.cpp,v 1.2 2004-01-26 15:31:55 pixel Exp $ */
#include "mipsdis.h"
#include "mips.h"
@@ -110,6 +110,7 @@ void Disassembler::crawl_code(Uint32 pc) {
while (dis->bheap.size()) {
branched = pc = dis->bheap.top();
dis->bheap.pop();
+ printm(M_STATUS, "Crawling to branch %8.8lX\n", pc);
do {
if (pc >= (0x80000000 + PSXMEM)) {
dis->invalid = true;
@@ -121,7 +122,7 @@ void Disassembler::crawl_code(Uint32 pc) {
}
mm->SetTag(pc, CODE, true);
- printm(M_STATUS, "%8.8lX\r", pc);
+ printm(M_STATUS, "Working at %8.8lX\n", pc);
decode(dis, pc);
pc += 4;
@@ -146,6 +147,7 @@ void Disassembler::mainloop(void) {
infunction = false;
// Crawl the start part.
+ printm(M_STATUS, "Starting crawl at %8.8lX\n", mm->GetPC());
if (!started)
crawl_code();
@@ -157,6 +159,7 @@ void Disassembler::mainloop(void) {
while (dis->fheap.size()) {
pc = dis->fheap.top();
dis->fheap.pop();
+ printm(M_STATUS, "Crawling function %8.8lX\n", pc);
if (mm->GetTag(pc, CODE))
continue;
crawl_code(pc);
diff --git a/lib/mipsobj.cpp b/lib/mipsobj.cpp
new file mode 100644
index 0000000..97663e6
--- /dev/null
+++ b/lib/mipsobj.cpp
@@ -0,0 +1,269 @@
+#include "mipsobj.h"
+
+section::section(const String & _name, int _type) : name(_name), type(_type), datas(0), length(0) { }
+section::section() : name(""), type(-1), datas(0), length(0) { }
+
+section::~section() {
+ if (datas)
+ free(datas);
+}
+
+void section::setname(const String & _name) {
+ name = _name;
+}
+
+void section::settype(int _type) {
+ type = _type;
+}
+
+void section::putdatas(const Uint8 * _datas, int _length) {
+ if (type != BSS) {
+ datas = (Uint8 *) realloc(datas, length + _length);
+ memcpy(datas + length, _datas, _length);
+ }
+ length += _length;
+}
+
+int section::gettype() {
+ return type;
+}
+
+int section::getsize() {
+ return length;
+}
+
+const Uint8 * section::getdatas() {
+ return datas;
+}
+
+void section::putreloc(const String & _symbol, int _type, Uint32 _offset) {
+ struct reloc_t r;
+
+ r.symbol = _symbol;
+ r.type = _type;
+ r.offset = _offset;
+
+ putreloc(r);
+}
+
+void section::putreloc(const struct reloc_t & r) {
+ relocs.push_back(r);
+}
+
+mipsobj::mipsobj() : loaded(false) { }
+
+mipsobj::~mipsobj() { }
+
+void loadELF(Handle * elf) throw (GeneralException) {
+}
+
+#define OBJSIG 0x024b4e4c
+
+#define READNAME(_str, _file) { \
+ char _name[256]; \
+ int _len; \
+ \
+ _len = _file->readU8(); \
+ _file->read(_name, _len); \
+ _name[_len] = 0; \
+ _str = _name; \
+}
+
+void mipsobj::loadOBJ(Handle * obj) throw (GeneralException) {
+ int cursec, len, reloctype, relocexpr, id;
+ bool eof = false;
+ std::map<int, String> secnames;
+ std::map<int, String> symbolnames;
+ Uint8 * datas;
+ struct reloc_t reloc;
+ struct symbol_t symbol;
+ String name;
+
+ while (!eof) {
+ int entryid = obj->readU8();
+
+ switch (entryid) {
+ case 0x00:
+ eof = true;
+ break;
+
+ case 0x02:
+ len = obj->readU16();
+ datas = (Uint8 *) malloc(len);
+
+ obj->read(datas, len);
+ sections[secnames[cursec]].putdatas(datas, len);
+
+ free(datas);
+ break;
+
+ case 0x06:
+ cursec = obj->readU16();
+ break;
+
+ case 0x08:
+ len = obj->readU32();
+
+ sections[secnames[cursec]].putdatas(0, len);
+ break;
+
+ case 0x0a:
+ reloctype = obj->readU8();
+ reloc.offset = obj->readU16();
+
+ switch (reloctype) {
+ case 0x10:
+ reloc.type = R_MIPS_32;
+ break;
+ case 0x4a:
+ reloc.type = R_MIPS_26;
+ break;
+ case 0x52:
+ reloc.type = R_MIPS_HI16;
+ break;
+ case 0x54:
+ reloc.type = R_MIPS_LO16;
+ break;
+ case 0x0a:
+ case 0x26:
+ case 0x28:
+ case 0x64:
+ printm(M_ERROR, "Relocation type %02x not supported.\n", reloctype);
+ exit(-1);
+ break;
+ default:
+ printm(M_ERROR, "Relocation type %02x UNKNOWN! Please send the object to the author.\n", reloctype);
+ exit(-1);
+ }
+
+ relocexpr = obj->readU8();
+
+ switch (relocexpr) {
+ case 0x02:
+ reloc.symbol = symbolnames[obj->readU16()];
+ break;
+ case 0x04:
+ reloc.symbol = secnames[obj->readU16()];
+ break;
+ case 0x00:
+ case 0x0c:
+ case 0x16:
+ case 0x2c:
+ case 0x2e:
+ case 0x30:
+ case 0x32:
+ case 0x36:
+ printm(M_ERROR, "Relocation expression %02x not supported.\n", relocexpr);
+ exit(-1);
+ break;
+ default:
+ printm(M_ERROR, "Relocation expression %02x UNKNOWN! Please mail the author.\n", relocexpr);
+ exit(-1);
+ break;
+ }
+
+ sections[secnames[cursec]].relocs.push_back(reloc);
+
+ break;
+
+ case 0x0c:
+ id = obj->readU16();
+ symbol.section = obj->readU16();
+ symbol.offset = obj->readU32();
+ READNAME(symbol.name, obj);
+ symbol.type = GLOBAL;
+
+ symbolnames[id] = symbol.name;
+
+ break;
+
+ case 0x0e:
+ id = obj->readU16();
+ READNAME(symbol.name, obj);
+ symbol.type = EXTERN;
+
+ symbolnames[id] = symbol.name;
+
+ break;
+
+ case 0x10:
+ id = obj->readU16();
+ obj->readU8();
+ obj->readU16();
+ READNAME(name, obj);
+
+ secnames[id] = name;
+
+ break;
+
+ case 0x12:
+ printm(M_WARNING, "Local symbol not supported.\n");
+ obj->readU16();
+ obj->readU32();
+ READNAME(name, obj);
+ break;
+
+ case 0x1c:
+ printm(M_WARNING, "File number and name not supported.\n");
+ obj->readU16();
+ READNAME(name, obj);
+ break;
+
+ case 0x2e:
+ if ((id = obj->readU8()) != 7) {
+ printm(M_ERROR, "CPU type %i not supported.\n", id);
+ exit(-1);
+ }
+ break;
+
+ case 0x30:
+ printm(M_ERROR, "Constant not supported.\n");
+ exit(-1);
+ break;
+
+ default:
+ printm(M_ERROR, "Object entry type %i UNKNOWN! Please send the object to the author.\n", entryid);
+ exit(-1);
+ break;
+ }
+ }
+}
+
+#define LIBSIG 0x0142494c
+
+void mipsobj::loadLIB(Handle * lib, const String & objname) throw (GeneralException) {
+ char _name[9];
+ String name;
+ int hsize, size, ptr;
+ bool found = false;
+
+ lib->seek(0);
+
+ if (lib->readU32() != LIBSIG) {
+ throw GeneralException("Not a Psy-Q lib file");
+ }
+
+ while (lib->tell() != lib->GetSize()) {
+ ptr = lib->tell();
+
+ lib->read(_name, 8);
+ name = _name;
+ lib->seek(4, SEEK_CUR);
+ hsize = lib->readU32();
+ size = lib->readU32();
+
+ if (objname == name.trim()) {
+ lib->seek(ptr + hsize);
+ found = true;
+ break;
+ }
+
+ lib->seek(ptr + size);
+ }
+
+ if (!found) {
+ throw GeneralException("Object `" + objname + "' not found in archive " + lib->GetName());
+ }
+
+ loadOBJ(lib);
+}
diff --git a/luapatch.cpp b/luapatch.cpp
index 0bee6c2..f878bd7 100644
--- a/luapatch.cpp
+++ b/luapatch.cpp
@@ -74,7 +74,7 @@ struct texts_t t_french[] = {
{IDC_ST_SOURCETYPE, IDD_FILESELECT, "Type de source:"},
{IDC_ST_DEST, IDD_FILESELECT, "Fichier de destination:"},
{IDC_ST_PATCH, IDD_FILESELECT, "Fichier de patch:"},
- {ISOFILE, 0, "FIchier ISO"},
+ {ISOFILE, 0, "Fichier ISO"},
{CDDRIVE, 0, "Lecteur CD"},
{ISODEST, 0, "Image ISO 2352-raw (*.bin)\0*.BIN\0\0\0"},
{ISOSOURCE, 0, "Image ISO 2352-raw (*.bin, *.iso, *.img)\0*.BIN;*.ISO;*.IMG\0\0\0"},