aboutsummaryrefslogtreecommitdiff
path: root/tools/create_kyradat
diff options
context:
space:
mode:
authorJohannes Schickel2009-11-22 18:16:25 +0000
committerJohannes Schickel2009-11-22 18:16:25 +0000
commitd2d3a9a9eb821346632c46c26b0d750fea0d575e (patch)
treec361c54c3259c80dfe873618504e980edfb2b080 /tools/create_kyradat
parent45856206e6eea615da78a00ba086cb2a1291c6d7 (diff)
downloadscummvm-rg350-d2d3a9a9eb821346632c46c26b0d750fea0d575e.tar.gz
scummvm-rg350-d2d3a9a9eb821346632c46c26b0d750fea0d575e.tar.bz2
scummvm-rg350-d2d3a9a9eb821346632c46c26b0d750fea0d575e.zip
- Store ID map for static resources in kyra.dat instead of hardcoding it in the main KYRA source
- Changed how static resource types are specified - Rebuilt kyra.dat svn-id: r46091
Diffstat (limited to 'tools/create_kyradat')
-rw-r--r--tools/create_kyradat/create_kyradat.cpp91
-rw-r--r--tools/create_kyradat/create_kyradat.h4
2 files changed, 72 insertions, 23 deletions
diff --git a/tools/create_kyradat/create_kyradat.cpp b/tools/create_kyradat/create_kyradat.cpp
index f6b768ec43..ae498992c2 100644
--- a/tools/create_kyradat/create_kyradat.cpp
+++ b/tools/create_kyradat/create_kyradat.cpp
@@ -42,10 +42,13 @@
#include <map>
enum {
- kKyraDatVersion = 68
+ kKyraDatVersion = 69
};
const ExtractFilename extractFilenames[] = {
+ // GENERIC ID MAP
+ { kIdMap, -1, true },
+
// INTRO / OUTRO sequences
{ k1ForestSeq, kTypeRawData, false },
{ k1KallakWritingSeq, kTypeRawData, false },
@@ -327,12 +330,13 @@ byte getGameID(int game) {
}
const TypeTable languageTable[] = {
- { EN_ANY, 0 },
- { FR_FRA, 1 },
- { DE_DEU, 2 },
- { ES_ESP, 3 },
- { IT_ITA, 4 },
- { JA_JPN, 5 },
+ { UNK_LANG, 0 },
+ { EN_ANY, 1 },
+ { FR_FRA, 2 },
+ { DE_DEU, 3 },
+ { ES_ESP, 4 },
+ { IT_ITA, 5 },
+ { JA_JPN, 6 },
{ -1, -1 }
};
@@ -367,17 +371,23 @@ byte getSpecialID(int special) {
// filename processing
-bool getFilename(char *dstFilename, const ExtractInformation *info, const int id) {
- const ExtractFilename *i = getFilenameDesc(id);
+uint32 getFilename(const ExtractInformation *info, const int id) {
+ const ExtractFilename *fDesc = getFilenameDesc(id);
- if (!i)
- return false;
+ if (!fDesc)
+ return 0;
+
+ // GAME, PLATFORM, SPECIAL, ID, LANG
+ return ((getGameID(info->game) & 0xF) << 24) |
+ ((getPlatformID(info->platform) & 0xF) << 20) |
+ ((getSpecialID(info->special) & 0xF) << 16) |
+ ((id & 0xFFF) << 4) |
+ ((getLanguageID(fDesc->langSpecific ? info->lang : UNK_LANG) & 0xF) << 0);
+}
- // GAME, PLATFORM, SPECIAL, TYPE, ID[, LANG]
- if (i->langSpecific)
- sprintf(dstFilename, "%01X%01X%01X%02X%03X%01X", getGameID(info->game), getPlatformID(info->platform), getSpecialID(info->special), getTypeID(i->type), id, getLanguageID(info->lang));
- else
- sprintf(dstFilename, "%01X%01X%01X%02X%03X", getGameID(info->game), getPlatformID(info->platform), getSpecialID(info->special), getTypeID(i->type), id);
+// TODO: Get rid of this
+bool getFilename(char *dstFilename, const ExtractInformation *info, const int id) {
+ sprintf(dstFilename, "%08X", getFilename(info, id));
return true;
}
@@ -388,7 +398,8 @@ typedef uint16 GameDef;
GameDef createGameDef(const ExtractInformation *eI) {
return ((getGameID(eI->game) & 0xF) << 12) |
((getPlatformID(eI->platform) & 0xF) << 8) |
- ((getSpecialID(eI->special) & 0xF) << 4);
+ ((getSpecialID(eI->special) & 0xF) << 4) |
+ ((getLanguageID(eI->lang) & 0xF) << 0);
}
struct Index {
@@ -1127,6 +1138,8 @@ typedef std::multimap<int, ExtractData> ExtractMap;
bool getExtractionData(const Game *g, Search &search, ExtractMap &map);
+bool createIDMap(PAKFile &out, const ExtractInformation *eI, const int *needList);
+
bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
char filename[128];
@@ -1149,6 +1162,7 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
for (ExtractMap::const_iterator i = ids.begin(); i != ids.end(); ++i) {
const int id = i->first;
+ extractInfo.lang = i->second.desc.lang;
const ExtractFilename *fDesc = getFilenameDesc(id);
@@ -1157,11 +1171,6 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
return false;
}
- if (fDesc->langSpecific)
- extractInfo.lang = i->second.desc.lang;
- else
- extractInfo.lang = UNK_LANG;
-
filename[0] = 0;
if (!getFilename(filename, &extractInfo, id)) {
fprintf(stderr, "ERROR: couldn't get filename for id %d/%s\n", id, getIdString(id));
@@ -1190,6 +1199,9 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
continue;
extractInfo.lang = g->lang[i];
+ if (!createIDMap(out, &extractInfo, needList))
+ return false;
+
if (!updateIndex(out, &extractInfo)) {
error("couldn't update INDEX file, stop processing of all files");
return false;
@@ -1199,6 +1211,41 @@ bool process(PAKFile &out, const Game *g, const byte *data, const uint32 size) {
return true;
}
+bool createIDMap(PAKFile &out, const ExtractInformation *eI, const int *needList) {
+ int dataEntries = 0;
+ // Count entries in the need list
+ for (const int *n = needList; *n != -1; ++n)
+ ++dataEntries;
+
+ const int mapSize = 2 + dataEntries * (2 + 1 + 4);
+ uint8 *map = new uint8[mapSize];
+ uint8 *dst = map;
+
+ WRITE_BE_UINT16(dst, dataEntries); dst += 2;
+ for (const int *id = needList; *id != -1; ++id) {
+ WRITE_BE_UINT16(dst, *id); dst += 2;
+ const ExtractFilename *fDesc = getFilenameDesc(*id);
+ if (!fDesc)
+ return false;
+ *dst++ = getTypeID(fDesc->type);
+ WRITE_BE_UINT32(dst, getFilename(eI, *id)); dst += 4;
+ }
+
+ char filename[12];
+ if (!getFilename(filename, eI, 0)) {
+ fprintf(stderr, "ERROR: Could not create ID map for game\n");
+ return false;
+ }
+
+ out.removeFile(filename);
+ if (!out.addFile(filename, map, mapSize)) {
+ fprintf(stderr, "ERROR: Could not add ID map \"%s\" to kyra.dat\n", filename);
+ return false;
+ }
+
+ return true;
+}
+
// Uncomment this to get various debug information about the detection table entries.
//#define DEBUG_EXTRACTION_TABLES
diff --git a/tools/create_kyradat/create_kyradat.h b/tools/create_kyradat/create_kyradat.h
index 93e03d40b6..c247846b93 100644
--- a/tools/create_kyradat/create_kyradat.h
+++ b/tools/create_kyradat/create_kyradat.h
@@ -27,7 +27,9 @@
// This list has to match orderwise (and thus value wise) the static data list of "engines/kyra/resource.h"!
enum kExtractID {
- k1ForestSeq = 0,
+ kIdMap = 0,
+
+ k1ForestSeq = 1,
k1KallakWritingSeq,
k1KyrandiaLogoSeq,
k1KallakMalcolmSeq,