svn-id: r45987
This commit is contained in:
Johannes Schickel 2009-11-19 17:42:51 +00:00
parent f9a1a5751e
commit 113c720ee1
3 changed files with 87 additions and 74 deletions

View file

@ -1069,6 +1069,12 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
if (breakProcess) if (breakProcess)
return false; return false;
ExtractInformation extractInfo;
extractInfo.game = g->game;
extractInfo.lang = g->lang;
extractInfo.platform = g->platform;
extractInfo.special = g->special;
for (IdMap::const_iterator i = ids.begin(); i != ids.end(); ++i) { for (IdMap::const_iterator i = ids.begin(); i != ids.end(); ++i) {
const int id = i->first; const int id = i->first;
@ -1096,7 +1102,7 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
if (list && list->findEntry(filename) != 0) if (list && list->findEntry(filename) != 0)
continue; continue;
if (!tDesc->extract(out, g, data + i->second.offset, i->second.data.size, filename, id, UNK_LANG)) { if (!tDesc->extract(out, &extractInfo, data + i->second.offset, i->second.data.size, filename, id, UNK_LANG)) {
fprintf(stderr, "ERROR: couldn't extract id %d\n", id); fprintf(stderr, "ERROR: couldn't extract id %d\n", id);
return false; return false;
} }

View file

@ -25,33 +25,33 @@
// Filename creation // Filename creation
void createFilename(char *dstFilename, const int gid, const int lang, const int platform, const int special, const char *filename); void createFilename(char *dstFilename, const ExtractInformation *info, const char *filename);
namespace { namespace {
void createLangFilename(char *dstFilename, const int gid, const int lang, const int platform, const int special, const char *filename); void createLangFilename(char *dstFilename, const ExtractInformation *info, const char *filename);
// Extraction function prototypes // Extraction function prototypes
bool extractRaw(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractRaw(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractStrings10(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractStrings10(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractRooms(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractRooms(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractShapes(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractShapes(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractAmigaSfx(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractAmigaSfx(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractWdSfx(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractWdSfx(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractHofSeqData(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractHofShapeAnimDataV1(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractHofShapeAnimDataV1(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractHofShapeAnimDataV2(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractHofShapeAnimDataV2(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractStringsWoSuffix(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractStringsWoSuffix(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractPaddedStrings(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractPaddedStrings(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractRaw16to8(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractRaw16to8(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractMrShapeAnimData(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractMrShapeAnimData(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractRaw16(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractRaw16(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractRaw32(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractRaw32(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
bool extractLolButtonDefs(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool extractLolButtonDefs(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
// Extraction type table // Extraction type table
@ -83,14 +83,14 @@ const ExtractType extractTypeTable[] = {
} // end of anonymous namespace } // end of anonymous namespace
void createFilename(char *dstFilename, const int gid, const int lang, const int platform, const int special, const char *filename) { void createFilename(char *dstFilename, const ExtractInformation *info, const char *filename) {
strcpy(dstFilename, filename); strcpy(dstFilename, filename);
static const char *gidExtensions[] = { "", ".K2", ".K3", 0, ".LOL" }; static const char *gidExtensions[] = { "", ".K2", ".K3", 0, ".LOL" };
strcat(dstFilename, gidExtensions[gid]); strcat(dstFilename, gidExtensions[info->gid]);
for (const SpecialExtension *specialE = specialTable; specialE->special != -1; ++specialE) { for (const SpecialExtension *specialE = specialTable; specialE->special != -1; ++specialE) {
if (specialE->special == special) { if (specialE->special == info->special) {
strcat(dstFilename, "."); strcat(dstFilename, ".");
strcat(dstFilename, specialE->ext); strcat(dstFilename, specialE->ext);
break; break;
@ -98,7 +98,7 @@ void createFilename(char *dstFilename, const int gid, const int lang, const int
} }
for (const PlatformExtension *platformE = platformTable; platformE->platform != -1; ++platformE) { for (const PlatformExtension *platformE = platformTable; platformE->platform != -1; ++platformE) {
if (platformE->platform == platform) { if (platformE->platform == info->platform) {
strcat(dstFilename, "."); strcat(dstFilename, ".");
strcat(dstFilename, platformE->ext); strcat(dstFilename, platformE->ext);
} }
@ -107,11 +107,11 @@ void createFilename(char *dstFilename, const int gid, const int lang, const int
namespace { namespace {
void createLangFilename(char *dstFilename, const int gid, const int lang, const int platform, const int special, const char *filename) { void createLangFilename(char *dstFilename, const ExtractInformation *info, const char *filename) {
strcpy(dstFilename, filename); strcpy(dstFilename, filename);
for (const Language *langE = languageTable; langE->lang != -1; ++langE) { for (const Language *langE = languageTable; langE->lang != -1; ++langE) {
if (langE->lang == lang) { if (langE->lang == info->lang) {
strcat(dstFilename, "."); strcat(dstFilename, ".");
strcat(dstFilename, langE->ext); strcat(dstFilename, langE->ext);
break; break;
@ -122,7 +122,7 @@ void createLangFilename(char *dstFilename, const int gid, const int lang, const
strcat(dstFilename, gidExtensions[gid]); strcat(dstFilename, gidExtensions[gid]);
for (const SpecialExtension *specialE = specialTable; specialE->special != -1; ++specialE) { for (const SpecialExtension *specialE = specialTable; specialE->special != -1; ++specialE) {
if (specialE->special == special) { if (specialE->special == info->special) {
strcat(dstFilename, "."); strcat(dstFilename, ".");
strcat(dstFilename, specialE->ext); strcat(dstFilename, specialE->ext);
break; break;
@ -130,7 +130,7 @@ void createLangFilename(char *dstFilename, const int gid, const int lang, const
} }
for (const PlatformExtension *platformE = platformTable; platformE->platform != -1; ++platformE) { for (const PlatformExtension *platformE = platformTable; platformE->platform != -1; ++platformE) {
if (platformE->platform == platform) { if (platformE->platform == info->platform) {
strcat(dstFilename, "."); strcat(dstFilename, ".");
strcat(dstFilename, platformE->ext); strcat(dstFilename, platformE->ext);
} }
@ -153,7 +153,7 @@ const ExtractType *findExtractType(const int type) {
namespace { namespace {
bool extractRaw(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractRaw(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
uint8 *buffer = new uint8[size]; uint8 *buffer = new uint8[size];
assert(buffer); assert(buffer);
memcpy(buffer, data, size); memcpy(buffer, data, size);
@ -161,10 +161,10 @@ bool extractRaw(PAKFile &out, const Game *g, const byte *data, const uint32 size
return out.addFile(filename, buffer, size); return out.addFile(filename, buffer, size);
} }
bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int fmtPatch = 0; int fmtPatch = 0;
// FM Towns files that need addional patches // FM Towns files that need addional patches
if (g->platform == kPlatformFMTowns) { if (info->platform == kPlatformFMTowns) {
if (id == kTakenStrings || id == kNoDropStrings || id == kPoisonGoneString || if (id == kTakenStrings || id == kNoDropStrings || id == kPoisonGoneString ||
id == kThePoisonStrings || id == kFluteStrings || id == kWispJewelStrings) id == kThePoisonStrings || id == kFluteStrings || id == kWispJewelStrings)
fmtPatch = 1; fmtPatch = 1;
@ -172,7 +172,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
fmtPatch = 2; fmtPatch = 2;
else if (id == k2SeqplayStrings) else if (id == k2SeqplayStrings)
fmtPatch = 3; fmtPatch = 3;
} else if (g->platform == kPlatformPC && g->special == kFile2) { } else if (info->platform == kPlatformPC && info->special == kFile2) {
if (id == k2IngamePakFiles) if (id == k2IngamePakFiles)
fmtPatch = 4; fmtPatch = 4;
} }
@ -181,7 +181,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
uint32 targetsize = size + 4; uint32 targetsize = size + 4;
for (uint32 i = 0; i < size; ++i) { for (uint32 i = 0; i < size; ++i) {
if (!data[i]) { if (!data[i]) {
if (g->platform == kPlatformAmiga) { if (info->platform == kPlatformAmiga) {
if (i + 1 >= size) if (i + 1 >= size)
++entries; ++entries;
else if (!data[i+1] && !(i & 1)) else if (!data[i+1] && !(i & 1))
@ -192,7 +192,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
++entries; ++entries;
} }
if (g->platform == kPlatformFMTowns) { if (info->platform == kPlatformFMTowns) {
// prevents creation of empty entries (which we have mostly between all strings in the FM-TOWNS version) // prevents creation of empty entries (which we have mostly between all strings in the FM-TOWNS version)
while (!data[++i]) { while (!data[++i]) {
if (i == size) if (i == size)
@ -222,10 +222,10 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
} }
if (fmtPatch == 2) { if (fmtPatch == 2) {
if (g->lang == EN_ANY) { if (info->lang == EN_ANY) {
targetsize--; targetsize--;
entries += 1; entries += 1;
} else if (g->lang == JA_JPN) { } else if (info->lang == JA_JPN) {
targetsize += 2; targetsize += 2;
entries += 2; entries += 2;
} }
@ -247,7 +247,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
const uint8 *input = (const uint8*) data; const uint8 *input = (const uint8*) data;
WRITE_BE_UINT32(output, entries); output += 4; WRITE_BE_UINT32(output, entries); output += 4;
if (g->platform == kPlatformFMTowns) { if (info->platform == kPlatformFMTowns) {
const byte *c = data + size; const byte *c = data + size;
do { do {
if (fmtPatch == 2 && input - data == 0x3C0 && input[0x10] == 0x32) { if (fmtPatch == 2 && input - data == 0x3C0 && input[0x10] == 0x32) {
@ -262,15 +262,15 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
while (!*input) { while (!*input) {
// Write one empty string into intro strings file // Write one empty string into intro strings file
if (fmtPatch == 2) { if (fmtPatch == 2) {
if ((g->lang == EN_ANY && input - data == 0x260) || if ((info->lang == EN_ANY && input - data == 0x260) ||
(g->lang == JA_JPN && (input - data == 0x2BD || input - data == 0x2BE))) (info->lang == JA_JPN && (input - data == 0x2BD || input - data == 0x2BE)))
*output++ = *input; *output++ = *input;
} }
// insert one dummy string at hof sequence strings position 59 // insert one dummy string at hof sequence strings position 59
if (fmtPatch == 3) { if (fmtPatch == 3) {
if ((g->lang == EN_ANY && input - data == 0x695) || if ((info->lang == EN_ANY && input - data == 0x695) ||
(g->lang == JA_JPN && input - data == 0x598)) (info->lang == JA_JPN && input - data == 0x598))
*output++ = *input; *output++ = *input;
} }
@ -293,7 +293,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
} }
} while (input < c); } while (input < c);
} else if (g->platform == kPlatformAmiga) { } else if (info->platform == kPlatformAmiga) {
// we need to strip some aligment zeros out here // we need to strip some aligment zeros out here
int dstPos = 0; int dstPos = 0;
for (uint32 i = 0; i < size; ++i) { for (uint32 i = 0; i < size; ++i) {
@ -327,7 +327,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
return out.addFile(filename, buffer, targetsize); return out.addFile(filename, buffer, targetsize);
} }
bool extractStrings10(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractStrings10(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
const int strSize = 10; const int strSize = 10;
uint32 entries = (size + (strSize - 1)) / strSize; uint32 entries = (size + (strSize - 1)) / strSize;
@ -347,9 +347,9 @@ bool extractStrings10(PAKFile &out, const Game *g, const byte *data, const uint3
return out.addFile(filename, buffer, output - buffer); return out.addFile(filename, buffer, output - buffer);
} }
bool extractRooms(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractRooms(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
// different entry size for the FM-TOWNS version // different entry size for the FM-TOWNS version
const int roomEntrySize = (g->platform == kPlatformFMTowns) ? (0x69) : ((g->platform == kPlatformAmiga) ? 0x52 : 0x51); const int roomEntrySize = (info->platform == kPlatformFMTowns) ? (0x69) : ((info->platform == kPlatformAmiga) ? 0x52 : 0x51);
const int countRooms = size / roomEntrySize; const int countRooms = size / roomEntrySize;
uint8 *buffer = new uint8[countRooms * 9 + 4]; uint8 *buffer = new uint8[countRooms * 9 + 4];
@ -359,7 +359,7 @@ bool extractRooms(PAKFile &out, const Game *g, const byte *data, const uint32 si
WRITE_BE_UINT32(output, countRooms); output += 4; WRITE_BE_UINT32(output, countRooms); output += 4;
const byte *src = data; const byte *src = data;
if (g->platform == kPlatformAmiga) { if (info->platform == kPlatformAmiga) {
for (int i = 0; i < countRooms; ++i) { for (int i = 0; i < countRooms; ++i) {
*output++ = *src++; assert(*src == 0); ++src; *output++ = *src++; assert(*src == 0); ++src;
memcpy(output, src, 8); output += 0x8; memcpy(output, src, 8); output += 0x8;
@ -379,7 +379,7 @@ bool extractRooms(PAKFile &out, const Game *g, const byte *data, const uint32 si
return out.addFile(filename, buffer, countRooms * 9 + 4); return out.addFile(filename, buffer, countRooms * 9 + 4);
} }
bool extractShapes(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractShapes(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
byte *buffer = new byte[size + 1 * 4]; byte *buffer = new byte[size + 1 * 4];
assert(buffer); assert(buffer);
byte *output = buffer; byte *output = buffer;
@ -391,7 +391,7 @@ bool extractShapes(PAKFile &out, const Game *g, const byte *data, const uint32 s
return out.addFile(filename, buffer, size + 1 * 4); return out.addFile(filename, buffer, size + 1 * 4);
} }
bool extractAmigaSfx(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractAmigaSfx(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
const uint32 entries = size / 8; const uint32 entries = size / 8;
byte *buffer = new byte[entries * 6 + 1 * 4]; byte *buffer = new byte[entries * 6 + 1 * 4];
@ -410,7 +410,7 @@ bool extractAmigaSfx(PAKFile &out, const Game *g, const byte *data, const uint32
return out.addFile(filename, buffer, entries * 6 + 1 * 4); return out.addFile(filename, buffer, entries * 6 + 1 * 4);
} }
bool extractWdSfx(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractWdSfx(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
const int bufferSize = 0x12602; const int bufferSize = 0x12602;
uint8 *buffer = new uint8[0x12602]; uint8 *buffer = new uint8[0x12602];
@ -423,10 +423,10 @@ bool extractWdSfx(PAKFile &out, const Game *g, const byte *data, const uint32 si
} }
int extractHofSeqData_checkString(const void *ptr, uint8 checkSize); int extractHofSeqData_checkString(const void *ptr, uint8 checkSize);
int extractHofSeqData_isSequence(const void *ptr, const Game *g, uint32 maxCheckSize); int extractHofSeqData_isSequence(const void *ptr, const ExtractInformation *info, uint32 maxCheckSize);
int extractHofSeqData_isControl(const void *ptr, uint32 size); int extractHofSeqData_isControl(const void *ptr, uint32 size);
bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractHofSeqData(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int numSequences = 0; int numSequences = 0;
int numNestedSequences = 0; int numNestedSequences = 0;
@ -454,10 +454,10 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
return false; return false;
} }
int v = extractHofSeqData_isSequence(ptr, g, endOffs - ptr); int v = extractHofSeqData_isSequence(ptr, info, endOffs - ptr);
if (cycle == 0 && v == 1) { if (cycle == 0 && v == 1) {
if ((g->platform == kPlatformPC && g->special == kFile1 && *ptr == 5) || (g->special == kDemoVersion && (ptr - data == 312))) { if ((info->platform == kPlatformPC && info->special == kFile1 && *ptr == 5) || (info->special == kDemoVersion && (ptr - data == 312))) {
// patch for floppy version: skips invalid ferb sequence // patch for floppy version: skips invalid ferb sequence
// patch for demo: skips invalid title sequence // patch for demo: skips invalid title sequence
ptr += 54; ptr += 54;
@ -477,7 +477,7 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
ptr += 28; ptr += 28;
output += 28; output += 28;
if (g->platform == kPlatformFMTowns) { // startupCommand + finalCommand if (info->platform == kPlatformFMTowns) { // startupCommand + finalCommand
memcpy(output , ptr, 2); memcpy(output , ptr, 2);
ptr += 2; ptr += 2;
output += 2; output += 2;
@ -506,7 +506,7 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
const byte *ctrStart = ptr; const byte *ctrStart = ptr;
while (v && v != -2) { while (v && v != -2) {
ptr++; ptr++;
v = extractHofSeqData_isSequence(ptr, g, endOffs - ptr); v = extractHofSeqData_isSequence(ptr, info, endOffs - ptr);
} }
if (v == -2) if (v == -2)
@ -514,7 +514,7 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
ctrSize = (uint16)(ptr - ctrStart); ctrSize = (uint16)(ptr - ctrStart);
if (g->special != kDemoVersion && if (info->special != kDemoVersion &&
extractHofSeqData_isControl(ctrStart, ctrSize)) { extractHofSeqData_isControl(ctrStart, ctrSize)) {
controlOffs = (uint16) (output - buffer); controlOffs = (uint16) (output - buffer);
*output++ = ctrSize >> 2; *output++ = ctrSize >> 2;
@ -565,11 +565,11 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
controlOffs = 0; controlOffs = 0;
WRITE_BE_UINT16(output, controlOffs); WRITE_BE_UINT16(output, controlOffs);
if (g->special != kDemoVersion) if (info->special != kDemoVersion)
ptr += 4; ptr += 4;
output += 2; output += 2;
if (g->special != kDemoVersion) { if (info->special != kDemoVersion) {
for (int w = 0; w < 2; w++) { //startupCommand, finalCommand for (int w = 0; w < 2; w++) { //startupCommand, finalCommand
WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); WRITE_BE_UINT16(output, READ_LE_UINT16(ptr));
ptr += 2; ptr += 2;
@ -580,13 +580,13 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
output += 4; output += 4;
} }
if (g->platform == kPlatformFMTowns) if (info->platform == kPlatformFMTowns)
ptr += 2; ptr += 2;
} else if (cycle == 0) { } else if (cycle == 0) {
while (v != 1 && v != -2) { while (v != 1 && v != -2) {
ptr++; ptr++;
v = extractHofSeqData_isSequence(ptr, g, endOffs - ptr); v = extractHofSeqData_isSequence(ptr, info, endOffs - ptr);
} }
if (v == -2) if (v == -2)
@ -596,7 +596,7 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
} else if (cycle == 1) { } else if (cycle == 1) {
while (v == 1 && v != -2) { while (v == 1 && v != -2) {
ptr++; ptr++;
v = extractHofSeqData_isSequence(ptr, g, endOffs - ptr); v = extractHofSeqData_isSequence(ptr, info, endOffs - ptr);
} }
if (v == -2) if (v == -2)
@ -658,7 +658,7 @@ int extractHofSeqData_checkString(const void *ptr, uint8 checkSize) {
return (sum) ? -1 : 0; return (sum) ? -1 : 0;
} }
int extractHofSeqData_isSequence(const void *ptr, const Game *g, uint32 maxCheckSize) { int extractHofSeqData_isSequence(const void *ptr, const ExtractInformation *info, uint32 maxCheckSize) {
// return values: 1 = Sequence; 0 = Nested Sequence; -1 = other; -2 = overflow // return values: 1 = Sequence; 0 = Nested Sequence; -1 = other; -2 = overflow
if (maxCheckSize < 30) if (maxCheckSize < 30)
@ -676,7 +676,7 @@ int extractHofSeqData_isSequence(const void *ptr, const Game *g, uint32 maxCheck
if (maxCheckSize < 41) if (maxCheckSize < 41)
return -2; return -2;
if (g->platform == kPlatformFMTowns) { if (info->platform == kPlatformFMTowns) {
if (!(s[37] | s[39]) && s[38] > s[36]) if (!(s[37] | s[39]) && s[38] > s[36])
return 1; return 1;
} else { } else {
@ -712,7 +712,7 @@ int extractHofSeqData_isControl(const void *ptr, uint32 size) {
return 1; return 1;
} }
bool extractHofShapeAnimDataV1(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractHofShapeAnimDataV1(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int outsize = 1; int outsize = 1;
uint8 *buffer = new uint8[size + 1]; uint8 *buffer = new uint8[size + 1];
const uint8 *src = data; const uint8 *src = data;
@ -741,7 +741,7 @@ bool extractHofShapeAnimDataV1(PAKFile &out, const Game *g, const byte *data, co
return out.addFile(filename, buffer, outsize); return out.addFile(filename, buffer, outsize);
} }
bool extractHofShapeAnimDataV2(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractHofShapeAnimDataV2(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int outsize = 1; int outsize = 1;
uint8 *buffer = new uint8[size + 1]; uint8 *buffer = new uint8[size + 1];
const uint8 *src = data; const uint8 *src = data;
@ -780,7 +780,7 @@ bool extractHofShapeAnimDataV2(PAKFile &out, const Game *g, const byte *data, co
return out.addFile(filename, buffer, outsize); return out.addFile(filename, buffer, outsize);
} }
bool extractStringsWoSuffix(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractStringsWoSuffix(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int outsize = size + 4; int outsize = size + 4;
uint8 *buffer = new uint8[outsize]; uint8 *buffer = new uint8[outsize];
const uint8 *src = data; const uint8 *src = data;
@ -809,7 +809,7 @@ bool extractStringsWoSuffix(PAKFile &out, const Game *g, const byte *data, const
return out.addFile(filename, buffer, outsize); return out.addFile(filename, buffer, outsize);
} }
bool extractPaddedStrings(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractPaddedStrings(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int outsize = size + 4; int outsize = size + 4;
uint8 *buffer = new uint8[outsize]; uint8 *buffer = new uint8[outsize];
const uint8 *src = data; const uint8 *src = data;
@ -833,7 +833,7 @@ bool extractPaddedStrings(PAKFile &out, const Game *g, const byte *data, const u
return out.addFile(filename, buffer, outsize); return out.addFile(filename, buffer, outsize);
} }
bool extractRaw16to8(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractRaw16to8(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int outsize = size >> 1; int outsize = size >> 1;
uint8 *buffer = new uint8[outsize]; uint8 *buffer = new uint8[outsize];
const uint8 *src = data; const uint8 *src = data;
@ -847,7 +847,7 @@ bool extractRaw16to8(PAKFile &out, const Game *g, const byte *data, const uint32
return out.addFile(filename, buffer, outsize); return out.addFile(filename, buffer, outsize);
} }
bool extractRaw16(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractRaw16(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
uint8 *buffer = new uint8[size]; uint8 *buffer = new uint8[size];
const uint8 *src = data; const uint8 *src = data;
uint8 *dst = buffer; uint8 *dst = buffer;
@ -861,7 +861,7 @@ bool extractRaw16(PAKFile &out, const Game *g, const byte *data, const uint32 si
return out.addFile(filename, buffer, size); return out.addFile(filename, buffer, size);
} }
bool extractRaw32(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractRaw32(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
uint8 *buffer = new uint8[size]; uint8 *buffer = new uint8[size];
const uint8 *src = data; const uint8 *src = data;
uint8 *dst = buffer; uint8 *dst = buffer;
@ -875,7 +875,7 @@ bool extractRaw32(PAKFile &out, const Game *g, const byte *data, const uint32 si
return out.addFile(filename, buffer, size); return out.addFile(filename, buffer, size);
} }
bool extractLolButtonDefs(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractLolButtonDefs(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int num = size / 22; int num = size / 22;
uint8 *buffer = new uint8[size]; uint8 *buffer = new uint8[size];
uint32 outsize = num * 18; uint32 outsize = num * 18;
@ -906,7 +906,7 @@ bool extractLolButtonDefs(PAKFile &out, const Game *g, const byte *data, const u
return out.addFile(filename, buffer, outsize); return out.addFile(filename, buffer, outsize);
} }
bool extractMrShapeAnimData(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang) { bool extractMrShapeAnimData(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang) {
int outsize = 1; int outsize = 1;
uint8 *buffer = new uint8[size + 1]; uint8 *buffer = new uint8[size + 1];
const uint8 *src2 = data; const uint8 *src2 = data;

View file

@ -52,10 +52,17 @@ enum kExtractType {
kLolTypeButtonDef kLolTypeButtonDef
}; };
struct ExtractInformation {
int game;
int platform;
int lang;
int special;
};
struct ExtractType { struct ExtractType {
int type; int type;
bool (*extract)(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int id, int lang); bool (*extract)(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id, int lang);
void (*createFilename)(char *dstFilename, const int gid, const int lang, const int platform, const int special, const char *filename); void (*createFilename)(char *dstFilename, const ExtractInformation *info, const char *filename);
}; };
const ExtractType *findExtractType(const int type); const ExtractType *findExtractType(const int type);