aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/create_kyradat/create_kyradat.cpp154
-rw-r--r--tools/create_kyradat/create_kyradat.h15
-rw-r--r--tools/create_kyradat/malcolm.h17
-rw-r--r--tools/create_kyradat/misc.h14
4 files changed, 178 insertions, 22 deletions
diff --git a/tools/create_kyradat/create_kyradat.cpp b/tools/create_kyradat/create_kyradat.cpp
index 8ca0f61edc..0ee3da4143 100644
--- a/tools/create_kyradat/create_kyradat.cpp
+++ b/tools/create_kyradat/create_kyradat.cpp
@@ -31,7 +31,7 @@
#include "md5.h"
enum {
- kKyraDatVersion = 24,
+ kKyraDatVersion = 25,
kIndexSize = 12
};
@@ -50,6 +50,8 @@ enum {
#include "hof_cd.h"
#include "hof_demo.h"
+#include "malcolm.h"
+
const Game kyra1FanTranslations[] = {
{ kKyra1, IT_ITA, kTalkieVersion, "d0f1752098236083d81b9497bd2b6989", kyra1FreCD },
GAME_DUMMY_ENTRY
@@ -63,6 +65,10 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
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);
+bool extractStringsWoSuffix(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch = 0);
+bool extractRaw16to8(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch = 0);
+bool extractMrShapeAnimData(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);
@@ -81,6 +87,10 @@ const ExtractType extractTypeTable[] = {
{ k2TypeShpDataV1, extractHofShapeAnimDataV1, createFilename },
{ k2TypeShpDataV2, extractHofShapeAnimDataV2, createFilename },
+ { k2TypeSoundList, extractStringsWoSuffix, createFilename },
+ { k3TypeRaw16to8, extractRaw16to8, createFilename },
+ { k3TypeShpData, extractMrShapeAnimData, createFilename },
+
{ -1, 0, 0}
};
@@ -224,8 +234,19 @@ const ExtractFilename extractFilenames[] = {
{ k2IngameTalkObjIndex, kTypeRawData, "I_TALKOBJECTS.MAP" },
{ k2IngameTimJpStrings, kTypeStringList, "I_TIMJPSTR.TXT" },
{ k2IngameItemAnimData, k2TypeShpDataV2, "I_INVANIM.SHP" },
- { k2IngameTlkDemoStrings, kTypeLanguageList, "I_TLKDEMO.TXT" },
-
+ { k2IngameTlkDemoStrings, kTypeLanguageList, "I_TLKDEMO.TXT" },
+
+
+ // MALCOLM'S REVENGE
+ { k3MainMenuStrings, kTypeStringList, "MAINMENU.TXT" },
+ { k3MusicFiles, k2TypeSoundList, "SCORE.TRA" },
+ { k3ScoreTable, kTypeRawData, "SCORE.MAP" },
+ { k3SfxFiles, kTypeStringList, "SFXFILES.TRA" },
+ { k3SfxMap, k3TypeRaw16to8, "SFXINDEX.MAP" },
+ { k3ItemAnimData, k3TypeShpData, "INVANIM.SHP" },
+ { k3ItemMagicTable, k3TypeRaw16to8, "ITEMMAGIC.MAP" },
+ { k3ItemStringMap, kTypeRawData, "ITEMSTRINGS.MAP" },
+
{ -1, 0, 0 }
};
@@ -637,6 +658,7 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
} else if (cycle == 1 && v != 1 && v != -2) {
uint16 controlOffs = 0;
+ uint16 ctrSize = 0;
if (v) {
const byte *ctrStart = ptr;
while (v && v != -2) {
@@ -647,7 +669,7 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
if (v == -2)
break;
- uint16 ctrSize = (uint16)(ptr - ctrStart);
+ ctrSize = (uint16)(ptr - ctrStart);
if (g->special != k2DemoVersion &&
extractHofSeqData_isControl(ctrStart, ctrSize)) {
@@ -673,11 +695,20 @@ bool extractHofSeqData(PAKFile &out, const Game *g, const byte *data, const uint
ptr += 14;
output += 14;
- for (int w = 0; w < 3; w++) { //startframe, endFrame, frameDelay
- WRITE_BE_UINT16(output, READ_LE_UINT16(ptr));
- ptr += 2;
- output += 2;
- }
+ // startframe
+ WRITE_BE_UINT16(output, READ_LE_UINT16(ptr));
+ ptr += 2;
+ output += 2;
+
+ // endFrame
+ WRITE_BE_UINT16(output, (ctrSize && ((ctrSize >> 2) < READ_LE_UINT16(ptr))) ? (ctrSize >> 2) : READ_LE_UINT16(ptr));
+ ptr += 2;
+ output += 2;
+
+ // frameDelay
+ WRITE_BE_UINT16(output, READ_LE_UINT16(ptr));
+ ptr += 2;
+ output += 2;
ptr += 4;
@@ -839,8 +870,8 @@ int extractHofSeqData_isControl(const void *ptr, uint32 size) {
}
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];
+ int outsize = 1;
+ uint8 *buffer = new uint8[size + 1];
const uint8 *src = data;
uint8 *dst = buffer + 1;
@@ -851,12 +882,13 @@ bool extractHofShapeAnimDataV1(PAKFile &out, const Game *g, const byte *data, co
WRITE_BE_UINT16(dst, READ_LE_UINT16(src));
src += 4;
dst += 2;
- outsize -= 2;
+ outsize += 4;
for (int j = 0; j < 20; j++) {
WRITE_BE_UINT16(dst, READ_LE_UINT16(src));
src += 2;
dst += 2;
+ outsize += 2;
}
};
@@ -867,11 +899,11 @@ bool extractHofShapeAnimDataV1(PAKFile &out, const Game *g, const byte *data, co
}
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];
+ int outsize = 1;
+ uint8 *buffer = new uint8[size + 1];
const uint8 *src = data;
uint8 *dst = buffer + 1;
- uint8 *fin = buffer + outsize;
+ const uint8 *fin = data + size;
int count = 0;
do {
@@ -887,17 +919,98 @@ bool extractHofShapeAnimDataV2(PAKFile &out, const Game *g, const byte *data, co
uint8 numFrames = *src;
*dst++ = numFrames;
src += 6;
- outsize -= 5;
+ outsize += 3;
for (int i = 0; i < (numFrames << 1); i++) {
WRITE_BE_UINT16(dst, READ_LE_UINT16(src));
src += 2;
dst += 2;
+ outsize += 2;
}
src += (48 - (numFrames << 2));
- } while (dst < fin);
+ } while (src < fin);
+
+ *buffer = count; // number of items
+
+ return out.addFile(filename, buffer, outsize);
+}
+
+bool extractStringsWoSuffix(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch) {
+ int outsize = size + 4;
+ uint8 *buffer = new uint8[outsize];
+ const uint8 *src = data;
+ uint8 *dst = buffer + 4;
+ const uint8 *fin = src + size;
+ int entries = 0;
+
+ while (src < fin) {
+ while (!*src && src < fin)
+ src++;
+ while (*src && *src != '.' && src < fin)
+ *dst++ = *src++;
+
+ *dst++ = '\0';
+ entries++;
+
+ if (*src == '.') {
+ while (*src && src < fin)
+ src++;
+ }
+ }
+
+ WRITE_BE_UINT32(buffer, entries);
+ outsize = dst - buffer;
+
+ return out.addFile(filename, buffer, outsize);
+}
+
+bool extractRaw16to8(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;
+
+ for (int i = 0; i < outsize; i++) {
+ *dst++ = *src++;
+ *src++;
+ }
+
+ return out.addFile(filename, buffer, outsize);
+}
+
+bool extractMrShapeAnimData(PAKFile &out, const Game *g, const byte *data, const uint32 size, const char *filename, int fmtPatch) {
+ int outsize = 1;
+ uint8 *buffer = new uint8[size + 1];
+ const uint8 *src2 = data;
+ const uint8 *src1 = data + 324;
+ uint8 *dst = buffer + 1;
+ const uint8 *fin = data + size;
+ int count = 0;
+
+ do {
+ if (READ_LE_UINT16(src1) == 0xffff)
+ break;
+
+ count++;
+
+ WRITE_BE_UINT16(dst, READ_LE_UINT16(src1));
+ src1 += 2;
+ dst += 2;
+
+ uint8 numFrames = *src1;
+ *dst++ = numFrames;
+ src1 += 10;
+ outsize += 3;
+
+ for (int i = 0; i < (numFrames << 1); i++) {
+ WRITE_BE_UINT16(dst, READ_LE_UINT16(src2));
+ src2 += 2;
+ dst += 2;
+ outsize += 2;
+ }
+ } while (src1 < fin);
*buffer = count; // number of items
@@ -925,7 +1038,7 @@ enum {
uint32 getFeatures(const Game *g) {
uint32 features = 0;
- if (g->special == kTalkieVersion || g->special == k2CDFile1E || g->special == k2CDFile1F || g->special == k2CDFile1G || g->special == k2CDFile2E || g->special == k2CDFile2F || g->special == k2CDFile2G)
+ if (g->special == kTalkieVersion || g->special == k2CDFile1E || g->special == k2CDFile1F || g->special == k2CDFile1G || g->special == k2CDFile2E || g->special == k2CDFile2F || g->special == k2CDFile2G || g->game == kKyra3)
features |= GF_TALKIE;
else if (g->special == kDemoVersion || g->special == k2DemoVersion)
features |= GF_DEMO;
@@ -1203,6 +1316,8 @@ const Game *gameDescs[] = {
kyra2TownsGames,
kyra2Demos,
+ kyra3Games,
+
0
};
@@ -1229,6 +1344,3 @@ const Game *findGame(const byte *buffer, const uint32 size) {
printf("file is not supported (unknown md5 \"%s\")\n", md5str);
return 0;
}
-
-
-
diff --git a/tools/create_kyradat/create_kyradat.h b/tools/create_kyradat/create_kyradat.h
index 5127f16b5d..79d7dd3001 100644
--- a/tools/create_kyradat/create_kyradat.h
+++ b/tools/create_kyradat/create_kyradat.h
@@ -164,6 +164,15 @@ enum kExtractID {
k2IngameItemAnimData,
k2IngameTlkDemoStrings,
+ k3MainMenuStrings,
+ k3MusicFiles,
+ k3ScoreTable,
+ k3SfxFiles,
+ k3SfxMap,
+ k3ItemAnimData,
+ k3ItemMagicTable,
+ k3ItemStringMap,
+
kMaxResIDs
};
@@ -246,7 +255,11 @@ enum kExtractType {
k2TypeSeqData,
k2TypeShpDataV1,
- k2TypeShpDataV2
+ k2TypeShpDataV2,
+ k2TypeSoundList,
+
+ k3TypeRaw16to8,
+ k3TypeShpData
};
struct ExtractType {
diff --git a/tools/create_kyradat/malcolm.h b/tools/create_kyradat/malcolm.h
new file mode 100644
index 0000000000..253d6e7b1c
--- /dev/null
+++ b/tools/create_kyradat/malcolm.h
@@ -0,0 +1,17 @@
+const ExtractEntry kyra3cd[] = {
+ { k3MainMenuStrings, 0x0002D932, 0x0002D9E2 },
+ { k3MusicFiles, 0x0003062C, 0x00030801 },
+ { k3ScoreTable, 0x0002E4D0, 0x0002E598 },
+ { k3SfxFiles, 0x0002E84E, 0x0002F10D },
+ { k3SfxMap, 0x0002A590, 0x0002AA50 },
+ { k3ItemAnimData, 0x00031614, 0x000317DC },
+ { k3ItemMagicTable, 0x0002FB2A, 0x0002FB72 },
+ { k3ItemStringMap, 0x0002D07A, 0x0002D0C2 },
+ { -1, 0, 0 }
+};
+
+const Game kyra3Games[] = {
+ { kKyra3, EN_ANY, -1, "bf68701eb591d0b72219f314c0d32688", kyra3cd },
+ GAME_DUMMY_ENTRY
+};
+
diff --git a/tools/create_kyradat/misc.h b/tools/create_kyradat/misc.h
index bd2421ebab..194624acba 100644
--- a/tools/create_kyradat/misc.h
+++ b/tools/create_kyradat/misc.h
@@ -460,6 +460,18 @@ const int kyra2TlkDemoNeed[] = {
-1
};
+const int kyra3Need[] = {
+ k3MainMenuStrings,
+ k3MusicFiles,
+ k3ScoreTable,
+ k3SfxFiles,
+ k3SfxMap,
+ k3ItemAnimData,
+ k3ItemMagicTable,
+ k3ItemStringMap,
+ -1
+};
+
const GameNeed gameNeedTable[] = {
{ kKyra1, -1, kyra1FloppyNeed },
{ kKyra1, kTalkieVersion, kyra1CDNeed },
@@ -485,6 +497,8 @@ const GameNeed gameNeedTable[] = {
{ kKyra2, k2DemoVersionTlkF, kyra2TlkDemoNeed},
{ kKyra2, k2DemoVersionTlkG, kyra2TlkDemoNeed},
+ { kKyra3, -1, kyra3Need },
+
{ -1, -1, 0 }
};