Handle extraction of "k2IngameSfxFiles" via a special extraction routine, instead of a hacky patch level.
svn-id: r44124
This commit is contained in:
parent
d5fcfc8b7f
commit
c4e8c51110
2 changed files with 27 additions and 8 deletions
|
@ -44,6 +44,7 @@ enum {
|
|||
|
||||
bool extractRaw(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch);
|
||||
bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch);
|
||||
bool extractStrings10(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch);
|
||||
bool extractRooms(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch);
|
||||
bool extractShapes(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch);
|
||||
bool extractAmigaSfx(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch);
|
||||
|
@ -79,6 +80,7 @@ const ExtractType extractTypeTable[] = {
|
|||
{ k2TypeShpDataV2, extractHofShapeAnimDataV2, createFilename },
|
||||
{ k2TypeSoundList, extractStringsWoSuffix, createFilename },
|
||||
{ k2TypeLangSoundList, extractStringsWoSuffix, createLangFilename },
|
||||
{ k2TypeSize10StringList, extractStrings10, createFilename },
|
||||
{ k2TypeSfxList, extractPaddedStrings, createFilename },
|
||||
{ k3TypeRaw16to8, extractRaw16to8, createFilename },
|
||||
{ k3TypeShpData, extractMrShapeAnimData, createFilename },
|
||||
|
@ -226,7 +228,7 @@ const ExtractFilename extractFilenames[] = {
|
|||
|
||||
// Ingame
|
||||
{ k2IngamePakFiles, kTypeStringList, "I_PAKFILES.TXT" },
|
||||
{ k2IngameSfxFiles, kTypeStringList, "I_SFXFILES.TRA" },
|
||||
{ k2IngameSfxFiles, k2TypeSize10StringList, "I_SFXFILES.TRA" },
|
||||
{ k2IngameSfxFilesTns, k2TypeSoundList, "I_SFXFILES.TRA" },
|
||||
{ k2IngameSfxIndex, kTypeRawData, "I_SFXINDEX.MAP" },
|
||||
{ k2IngameTracks, kTypeStringList, "I_TRACKS.TRA" },
|
||||
|
@ -449,7 +451,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
|
|||
|
||||
if (g->special == kFMTownsVersionE || g->special == kFMTownsVersionJ ||
|
||||
g->special == k2TownsFile1E || g->special == k2TownsFile1J ||
|
||||
g->special == k2TownsFile2E || g->special == k2TownsFile2J || fmtPatch == 5) {
|
||||
g->special == k2TownsFile2E || g->special == k2TownsFile2J) {
|
||||
// prevents creation of empty entries (which we have mostly between all strings in the FM-TOWNS version)
|
||||
while (!data[++i]) {
|
||||
if (i == size)
|
||||
|
@ -506,7 +508,7 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
|
|||
WRITE_BE_UINT32(output, entries); output += 4;
|
||||
if (g->special == kFMTownsVersionE || g->special == kFMTownsVersionJ ||
|
||||
g->special == k2TownsFile1E || g->special == k2TownsFile1J ||
|
||||
g->special == k2TownsFile2E || g->special == k2TownsFile2J || fmtPatch == 5) {
|
||||
g->special == k2TownsFile2E || g->special == k2TownsFile2J) {
|
||||
const byte *c = data + size;
|
||||
do {
|
||||
if (fmtPatch == 2 && input - data == 0x3C0 && input[0x10] == 0x32) {
|
||||
|
@ -587,6 +589,27 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32
|
|||
return out.addFile(filename, buffer, targetsize);
|
||||
}
|
||||
|
||||
bool extractStrings10(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch) {
|
||||
const int strSize = 10;
|
||||
uint32 entries = (size + (strSize - 1)) / strSize;
|
||||
uint32 targetSize = 4;
|
||||
|
||||
uint8 *buffer = new uint8[size + 4];
|
||||
assert(buffer);
|
||||
uint8 *output = buffer;
|
||||
WRITE_BE_UINT32(output, entries); output += 4;
|
||||
|
||||
for (uint32 i = 0; i < entries; ++i) {
|
||||
const byte *src = data + i * strSize;
|
||||
|
||||
while (*src)
|
||||
*output++ = *src++;
|
||||
*output++ = '\0';
|
||||
}
|
||||
|
||||
return out.addFile(filename, buffer, output - buffer);
|
||||
}
|
||||
|
||||
bool extractRooms(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch) {
|
||||
// different entry size for the FM-TOWNS version
|
||||
const int roomEntrySize = (g->special == kFMTownsVersionE || g->special == kFMTownsVersionJ) ? (0x69) : ((g->special == kAmigaVersion) ? 0x52 : 0x51);
|
||||
|
@ -1985,11 +2008,6 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
|
|||
patch = 4;
|
||||
}
|
||||
|
||||
if (g->special == k2FloppyFile2 || g->special == k2CDFile2E) {
|
||||
if (id == k2IngameSfxFiles)
|
||||
patch = 5;
|
||||
}
|
||||
|
||||
if (!tDesc->extract(out, g, data + i->second.offset, i->second.data.size, filename, patch)) {
|
||||
fprintf(stderr, "ERROR: couldn't extract id %d\n", id);
|
||||
return false;
|
||||
|
|
|
@ -366,6 +366,7 @@ enum kExtractType {
|
|||
k2TypeShpDataV2,
|
||||
k2TypeSoundList,
|
||||
k2TypeLangSoundList,
|
||||
k2TypeSize10StringList,
|
||||
k2TypeSfxList,
|
||||
|
||||
k3TypeRaw16to8,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue