diff options
Diffstat (limited to 'tools/create_kyradat')
-rw-r--r-- | tools/create_kyradat/create_kyradat.cpp | 193 | ||||
-rw-r--r-- | tools/create_kyradat/create_kyradat.h | 8 | ||||
-rw-r--r-- | tools/create_kyradat/hof_cd.h | 2 | ||||
-rw-r--r-- | tools/create_kyradat/hof_demo.h | 2 | ||||
-rw-r--r-- | tools/create_kyradat/hof_floppy.h | 6 | ||||
-rw-r--r-- | tools/create_kyradat/hof_towns.h | 2 | ||||
-rw-r--r-- | tools/create_kyradat/misc.h | 8 |
7 files changed, 146 insertions, 75 deletions
diff --git a/tools/create_kyradat/create_kyradat.cpp b/tools/create_kyradat/create_kyradat.cpp index 69f7984b89..ec8238abc7 100644 --- a/tools/create_kyradat/create_kyradat.cpp +++ b/tools/create_kyradat/create_kyradat.cpp @@ -31,7 +31,7 @@ #include "md5.h" enum { - kKyraDatVersion = 22, + kKyraDatVersion = 23, kIndexSize = 12 }; @@ -60,6 +60,9 @@ bool extractStrings(PAKFile &out, const Game *g, const byte *data, const uint32 bool extractRooms(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch = 0); bool extractShapes(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch = 0); bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch = 0); +bool extractHofShapeAnimDataV1(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch = 0); +bool extractHofShapeAnimDataV2(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch = 0); + int extractHofSeqData_checkString(const void *ptr, uint8 checkSize); int extractHofSeqData_isSequence(const void *ptr, const Game *g, uint32 maxCheckSize); int extractHofSeqData_isControl(const void *ptr, uint32 size); @@ -75,6 +78,8 @@ const ExtractType extractTypeTable[] = { { kTypeRawData, extractRaw, createFilename }, { k2TypeSeqData, extractHofSeqData, createFilename }, + { k2TypeShpDataV1, extractHofShapeAnimDataV1, createFilename }, + { k2TypeShpDataV2, extractHofShapeAnimDataV2, createFilename }, { -1, 0, 0} }; @@ -208,7 +213,7 @@ const ExtractFilename extractFilenames[] = { { k2SeqplayFinaleTracks, kTypeStringList, "S_FINALE.TRA" }, { k2SeqplayIntroCDA, kTypeRawData, "S_INTRO.CDA" }, { k2SeqplayFinaleCDA, kTypeRawData, "S_FINALE.CDA" }, - { k2SeqplayShapeDefs, kTypeRawData, "S_DEMO.SHP" }, + { k2SeqplayShapeAnimData, k2TypeShpDataV1, "S_DEMO.SHP" }, // Ingame { k2IngamePakFiles, kTypeStringList, "I_PAKFILES.TXT" }, @@ -218,7 +223,7 @@ const ExtractFilename extractFilenames[] = { { k2IngameCDA, kTypeRawData, "I_TRACKS.CDA" }, { k2IngameTalkObjIndex, kTypeRawData, "I_TALKOBJECTS.MAP" }, { k2IngameTimJpStrings, kTypeStringList, "I_TIMJPSTR.TXT" }, - { k2IngameItemAnimTable, kTypeRawData, "I_INVANIM.SHP" }, + { k2IngameItemAnimData, k2TypeShpDataV2, "I_INVANIM.SHP" }, { -1, 0, 0 } }; @@ -596,26 +601,18 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint numSequences++; uint16 relOffs = (uint16) (output - buffer); - WRITE_LE_UINT16(hdout, relOffs); + WRITE_BE_UINT16(hdout, relOffs); hdout++; + + WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); // flags + ptr += 2; + output += 2; - /*char cc[15]; - cc[14] = 0; - if (ptr[2]) { - memcpy(cc, ptr + 2, 14); - debug(1, "adding sequence with file: %s, output file offset: 0x%x", cc, relOffs); - } else if (ptr[16]) { - memcpy(cc, ptr + 16, 14); - debug(1, "adding sequence with file: %s, output file offset: 0x%x", cc, relOffs); - } else if (ptr[0] == 4) { - debug(1, "adding sequence (text only), output file offset: 0x%x", relOffs); - //}*/ - - memcpy(output , ptr, 30); - ptr += 30; - output += 30; - - if (g->special == k2TownsFile1E) { + memcpy(output, ptr, 28); // wsa and cps file names + ptr += 28; + output += 28; + + if (g->special == k2TownsFile1E) { // startupCommand + finalCommand memcpy(output , ptr, 2); ptr += 2; output += 2; @@ -626,10 +623,14 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint ptr += 2; } - memcpy(output, ptr, 14); - ptr += 18; - output += 14; - memcpy(output, ptr, 2); + for (int w = 0; w < 7; w++) { //stringIndex1 to yPos + WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); + ptr += 2; + output += 2; + } + + ptr += 4; + WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); // duration ptr += 2; output+= 2; @@ -649,49 +650,61 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint if (g->special != k2DemoVersion && extractHofSeqData_isControl(ctrStart, ctrSize)) { - controlOffs = (uint16) (output - buffer); - //debug(1, "frame control encountered, size: %d, output file offset: 0x%x", ctrSize, controlOffs); - memcpy(output, ctrStart, ctrSize); + *output++ = ctrSize >> 2; + + for (int cc = 0; cc < ctrSize; cc += 2) + WRITE_BE_UINT16(output + cc, READ_LE_UINT16(ctrStart + cc)); // frame control output += ctrSize; } } numNestedSequences++; uint16 relOffs = (uint16) (output - buffer); - WRITE_LE_UINT16(hdout, relOffs); + WRITE_BE_UINT16(hdout, relOffs); hdout++; - /*char cc[15]; - cc[14] = 0; - memcpy(cc, ptr + 2, 14); - debug(1, "adding nested sequence with file: %s, output file offset: 0x%x", cc, relOffs);*/ + WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); // flags + ptr += 2; + output += 2; + + memcpy(output, ptr, 14); // wsa file name + ptr += 14; + output += 14; - memcpy(output , ptr, 22); - ptr += 26; - output += 22; - memcpy(output, ptr, 4); + for (int w = 0; w < 3; w++) { //startframe, endFrame, frameDelay + WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); + ptr += 2; + output += 2; + } + ptr += 4; - output += 4; + + for (int w = 0; w < 2; w++) { //x, y + WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); + ptr += 2; + output += 2; + } if (!READ_LE_UINT32(ptr)) controlOffs = 0; - //else if (controlOffs) - // debug(1, "assigning frame control with output file offset 0x%x to item %s (output file offset: 0x%x)", controlOffs, cc, relOffs); - WRITE_LE_UINT16(output, controlOffs); + WRITE_BE_UINT16(output, controlOffs); if (g->special != k2DemoVersion) ptr += 4; output += 2; if (g->special != k2DemoVersion) { - memcpy(output, ptr, 4); - ptr += 4; + for (int w = 0; w < 2; w++) { //startupCommand, finalCommand + WRITE_BE_UINT16(output, READ_LE_UINT16(ptr)); + ptr += 2; + output += 2; + } } else { - WRITE_LE_UINT32(output, 0); + memset(output, 0, 4); + output += 4; } - - output+= 4; + if (g->special == k2TownsFile1E) ptr += 2; @@ -704,13 +717,6 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint if (v == -2) break; - /*char cc[15]; - cc[14] = 0; - if (ptr[2]) - memcpy(cc, ptr + 2, 14); - else - memcpy(cc, ptr + 16, 14); - debug(1, "next item: sequence with file %s", cc);*/ } else if (cycle == 1) { while (v == 1 && v != -2) { @@ -732,24 +738,21 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint uint16 *finHeader = (uint16*) finBuffer; for (int i = 1; i < finHeaderSize; i++) - WRITE_LE_UINT16(&finHeader[i], (READ_LE_UINT16(&header[i]) - diff)); - WRITE_LE_UINT16(finHeader, numSequences); - WRITE_LE_UINT16(&finHeader[numSequences + 1], numNestedSequences); + WRITE_BE_UINT16(&finHeader[i], (READ_BE_UINT16(&header[i]) - diff)); + WRITE_BE_UINT16(finHeader, numSequences); + WRITE_BE_UINT16(&finHeader[numSequences + 1], numNestedSequences); memcpy (finBuffer + finHeaderSize, buffer + headerSize, finBufferSize - finHeaderSize); delete [] buffer; finHeader = (uint16*) (finBuffer + ((numSequences + 2) * sizeof(uint16))); for (int i = 0; i < numNestedSequences; i++) { - uint8 * offs = finBuffer + READ_LE_UINT16(finHeader++) + 26; - uint16 ctrl = READ_LE_UINT16(offs); + uint8 * offs = finBuffer + READ_BE_UINT16(finHeader++) + 26; + uint16 ctrl = READ_BE_UINT16(offs); if (ctrl) ctrl -= diff; - WRITE_LE_UINT16(offs, ctrl); + WRITE_BE_UINT16(offs, ctrl); } - - //debug(1, "\n\nFinished.\n"); - return out.addFile(filename, finBuffer, finBufferSize); } @@ -834,6 +837,72 @@ int extractHofSeqData_isControl(const void *ptr, uint32 size) { return 1; } +bool extractHofShapeAnimDataV1(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch) { + int outsize = size + 1; + uint8 *buffer = new uint8[outsize]; + const uint8 *src = data; + uint8 *dst = buffer + 1; + + for (int i = 0; i < 4; i++) { + WRITE_BE_UINT16(dst, READ_LE_UINT16(src)); + src += 2; + dst += 2; + WRITE_BE_UINT16(dst, READ_LE_UINT16(src)); + src += 4; + dst += 2; + outsize -= 2; + + for (int i = 0; i < 20; i ++) { + WRITE_BE_UINT16(dst, READ_LE_UINT16(src)); + src += 2; + dst += 2; + } + + }; + + *buffer = 4; // number of items + + return out.addFile(filename, buffer, outsize); +} + +bool extractHofShapeAnimDataV2(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch) { + int outsize = size + 1; + uint8 *buffer = new uint8[outsize]; + const uint8 *src = data; + uint8 *dst = buffer + 1; + uint8 *fin = buffer + outsize; + int count = 0; + + do { + if (READ_LE_UINT16(src) == 0xffff) + break; + + count++; + + WRITE_BE_UINT16(dst, READ_LE_UINT16(src)); + src += 2; + dst += 2; + + uint8 numFrames = *src; + *dst++ = numFrames; + src += 6; + outsize -= 5; + + for (int i = 0; i < (numFrames << 1); i++) { + WRITE_BE_UINT16(dst, READ_LE_UINT16(src)); + src += 2; + dst += 2; + } + + src += (48 - (numFrames << 2)); + + } while (dst < fin); + + *buffer = count; // number of items + + return out.addFile(filename, buffer, outsize); +} + // index generation enum { diff --git a/tools/create_kyradat/create_kyradat.h b/tools/create_kyradat/create_kyradat.h index c60ec32854..7cc78244e2 100644 --- a/tools/create_kyradat/create_kyradat.h +++ b/tools/create_kyradat/create_kyradat.h @@ -152,7 +152,7 @@ enum kExtractID { k2SeqplayFinaleTracks, k2SeqplayIntroCDA, k2SeqplayFinaleCDA, - k2SeqplayShapeDefs, + k2SeqplayShapeAnimData, k2IngamePakFiles, k2IngameSfxFiles, @@ -161,7 +161,7 @@ enum kExtractID { k2IngameCDA, k2IngameTalkObjIndex, k2IngameTimJpStrings, - k2IngameItemAnimTable, + k2IngameItemAnimData, kMaxResIDs }; @@ -239,7 +239,9 @@ enum kExtractType { kTypeShapeList, kTypeRawData, - k2TypeSeqData + k2TypeSeqData, + k2TypeShpDataV1, + k2TypeShpDataV2 }; struct ExtractType { diff --git a/tools/create_kyradat/hof_cd.h b/tools/create_kyradat/hof_cd.h index b7973e4acd..1393f74890 100644 --- a/tools/create_kyradat/hof_cd.h +++ b/tools/create_kyradat/hof_cd.h @@ -28,7 +28,7 @@ const ExtractEntry kyra2File2CDE[] = { { k2IngameSfxIndex, 0x000294F0, 0x00029848 }, { k2IngameTracks, 0x0002F2FE, 0x0002F37E }, { k2IngameTalkObjIndex, 0x0002BAC2, 0x0002BB46 }, - { k2IngameItemAnimTable, 0x0002FE68, 0x000301B0 }, + { k2IngameItemAnimData, 0x0002FE68, 0x000301B0 }, { -1, 0, 0 } }; diff --git a/tools/create_kyradat/hof_demo.h b/tools/create_kyradat/hof_demo.h index ee1f433f66..b4bb1b9845 100644 --- a/tools/create_kyradat/hof_demo.h +++ b/tools/create_kyradat/hof_demo.h @@ -3,7 +3,7 @@ const ExtractEntry kyra2Demo[] = { { k2SeqplaySfxFiles, 0x0001CDDE, 0x0001CEBC }, { k2SeqplaySeqData, 0x0001C920, 0x0001CB9C }, { k2SeqplayIntroTracks, 0x0001CEBC, 0x0001CECC }, - { k2SeqplayShapeDefs, 0x0001CC14, 0x0001CCCC }, + { k2SeqplayShapeAnimData, 0x0001CC14, 0x0001CCCC }, { -1, 0, 0 } }; diff --git a/tools/create_kyradat/hof_floppy.h b/tools/create_kyradat/hof_floppy.h index 70f7dfc1f9..e2709eb3fd 100644 --- a/tools/create_kyradat/hof_floppy.h +++ b/tools/create_kyradat/hof_floppy.h @@ -34,7 +34,7 @@ const ExtractEntry kyra2File2E[] = { { k2IngameSfxIndex, 0x0002A710, 0x0002AA68 }, { k2IngameTracks, 0x0003B2F2, 0x0003B370 }, { k2IngameTalkObjIndex, 0x00033EB2, 0x00033F2A }, - { k2IngameItemAnimTable, 0x0003B94A, 0x0003BC92 }, + { k2IngameItemAnimData, 0x0003B94A, 0x0003BC92 }, { -1, 0, 0 } }; @@ -44,7 +44,7 @@ const ExtractEntry kyra2File2F[] = { { k2IngameSfxIndex, 0x000288B0, 0x00028C08 }, { k2IngameTracks, 0x0003B2F2, 0x0003B370 }, { k2IngameTalkObjIndex, 0x0003328E, 0x00033306 }, - { k2IngameItemAnimTable, 0x0003AFF6, 0x0003B33E }, + { k2IngameItemAnimData, 0x0003AFF6, 0x0003B33E }, { -1, 0, 0 } }; @@ -54,7 +54,7 @@ const ExtractEntry kyra2File2G[] = { { k2IngameSfxIndex, 0x000288E0, 0x00028C38 }, { k2IngameTracks, 0x0003AA8C, 0x0003AB0A }, { k2IngameTalkObjIndex, 0x000332BE, 0x00033336 }, - { k2IngameItemAnimTable, 0x0003B00A, 0x0003B352 }, + { k2IngameItemAnimData, 0x0003B00A, 0x0003B352 }, { -1, 0, 0 } }; diff --git a/tools/create_kyradat/hof_towns.h b/tools/create_kyradat/hof_towns.h index 40143b041a..bff2b35673 100644 --- a/tools/create_kyradat/hof_towns.h +++ b/tools/create_kyradat/hof_towns.h @@ -20,7 +20,7 @@ const ExtractEntry kyra2File2FMTownsE[] = { { k2IngameCDA, 0x0001808C, 0x000181BC }, { k2IngameTalkObjIndex, 0x000199B6, 0x00019A30 }, { k2IngameTimJpStrings, 0x0000677C, 0x000067A9 }, - { k2IngameItemAnimTable, 0x00012F28, 0x00013270 }, + { k2IngameItemAnimData, 0x00012F28, 0x00013270 }, { -1, 0, 0 } }; diff --git a/tools/create_kyradat/misc.h b/tools/create_kyradat/misc.h index 452fdbfc31..72150d94be 100644 --- a/tools/create_kyradat/misc.h +++ b/tools/create_kyradat/misc.h @@ -383,7 +383,7 @@ const int kyra2CDFile2EngNeed[] = { k2IngameSfxIndex, k2IngameTracks, k2IngameTalkObjIndex, - k2IngameItemAnimTable, + k2IngameItemAnimData, -1 }; @@ -411,7 +411,7 @@ const int kyra2FloppyFile2Need[] = { k2IngameSfxIndex, k2IngameTracks, k2IngameTalkObjIndex, - k2IngameItemAnimTable, + k2IngameItemAnimData, -1 }; @@ -437,7 +437,7 @@ const int kyra2TownsFile2EngNeed[] = { k2IngameCDA, k2IngameTalkObjIndex, k2IngameTimJpStrings, - k2IngameItemAnimTable, + k2IngameItemAnimData, -1 }; @@ -450,7 +450,7 @@ const int kyra2DemoNeed[] = { k2SeqplaySeqData, k2SeqplaySfxFiles, k2SeqplayIntroTracks, - k2SeqplayShapeDefs, + k2SeqplayShapeAnimData, -1 }; |