aboutsummaryrefslogtreecommitdiff
path: root/devtools/create_kyradat/extract.cpp
diff options
context:
space:
mode:
authorathrxx2011-07-25 17:55:19 +0200
committerathrxx2011-07-25 17:57:33 +0200
commitf2f6ddced9a1b4ab28f4ff6a8d6dc4b3be39a5ee (patch)
tree30a16e5fcec5d9389a4496bef8223421d3982e63 /devtools/create_kyradat/extract.cpp
parent77908a9357c30d2ff6325d552a26903499c718f1 (diff)
downloadscummvm-rg350-f2f6ddced9a1b4ab28f4ff6a8d6dc4b3be39a5ee.tar.gz
scummvm-rg350-f2f6ddced9a1b4ab28f4ff6a8d6dc4b3be39a5ee.tar.bz2
scummvm-rg350-f2f6ddced9a1b4ab28f4ff6a8d6dc4b3be39a5ee.zip
KYRA: add support for Kyra 2 Russian floppy
Diffstat (limited to 'devtools/create_kyradat/extract.cpp')
-rw-r--r--devtools/create_kyradat/extract.cpp92
1 files changed, 78 insertions, 14 deletions
diff --git a/devtools/create_kyradat/extract.cpp b/devtools/create_kyradat/extract.cpp
index 5581dacec0..6e39e3da78 100644
--- a/devtools/create_kyradat/extract.cpp
+++ b/devtools/create_kyradat/extract.cpp
@@ -142,25 +142,32 @@ bool extractRaw(PAKFile &out, const ExtractInformation *info, const byte *data,
}
bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *data, const uint32 size, const char *filename, int id) {
- int fmtPatch = 0;
+ int patch = 0;
// FM Towns files that need addional patches
if (info->platform == kPlatformFMTowns) {
if (id == k1TakenStrings || id == k1NoDropStrings || id == k1PoisonGoneString ||
id == k1ThePoisonStrings || id == k1FluteStrings || id == k1WispJewelStrings)
- fmtPatch = 1;
+ patch = 1;
else if (id == k1IntroStrings)
- fmtPatch = 2;
+ patch = 2;
else if (id == k2SeqplayStrings)
- fmtPatch = 3;
+ patch = 3;
} else if (info->platform == kPlatformPC) {
if (id == k2IngamePakFiles)
- fmtPatch = 4;
+ patch = 4;
+
+ if (id == k2SeqplayStrings && info->lang == Common::RU_RUS)
+ patch = 5;
// HACK
if (id == k2SeqplayIntroTracks && info->game == kLol)
return extractStringsWoSuffix(out, info, data, size, filename, id);
}
+ // Skip English string left-overs in the hacky Russian fan translation
+ static const uint8 rusFanSkipId[] = { 1, 3, 5, 8, 10, 11, 13, 15, 17, 20, 22, 25, 26, 30, 33, 38, 40, 41, 44, 49, 51, 55, 104, 119, 121, 123 };
+ uint32 skipCount = 0;
+
uint32 entries = 0;
uint32 targetsize = size + 4;
for (uint32 i = 0; i < size; ++i) {
@@ -183,7 +190,7 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
break;
targetsize--;
}
- if (fmtPatch == 1) {
+ if (patch == 1) {
// Here is the first step of the extra treatment for all FM-TOWNS string arrays that
// contain more than one string and which the original code
// addresses via stringname[boolJapanese].
@@ -201,11 +208,38 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
targetsize--;
}
}
+ } else if (patch == 5) {
+ ++skipCount;
+ while (!data[++i]) {
+ if (skipCount == 81) {
+ ++skipCount;
+ ++entries;
+ break;
+ }
+ if (i == size)
+ break;
+ targetsize--;
+ }
+
+ for (uint32 ii = 0; ii < ARRAYSIZE(rusFanSkipId); ++ii) {
+ // Skip English string left-overs in the hacky Russian fan translation
+ if (skipCount == rusFanSkipId[ii]) {
+ ++skipCount;
+ uint32 len = strlen((const char*) data + i);
+ i += len;
+ targetsize = targetsize - 1 - len;
+ while (!data[++i]) {
+ if (i == len)
+ break;
+ targetsize--;
+ }
+ }
+ }
}
}
}
- if (fmtPatch == 2) {
+ if (patch == 2) {
if (info->lang == EN_ANY) {
targetsize--;
entries += 1;
@@ -215,12 +249,12 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
}
}
- if (fmtPatch == 3) {
+ if (patch == 3) {
entries++;
targetsize++;
}
- if (fmtPatch == 4) {
+ if (patch == 4) {
targetsize -= 9;
}
@@ -229,12 +263,13 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
memset(buffer, 0, targetsize);
uint8 *output = buffer;
const uint8 *input = (const uint8*) data;
+ skipCount = 0;
WRITE_BE_UINT32(output, entries); output += 4;
if (info->platform == kPlatformFMTowns) {
const byte *c = data + size;
do {
- if (fmtPatch == 2 && input - data == 0x3C0 && input[0x10] == 0x32) {
+ if (patch == 2 && input - data == 0x3C0 && input[0x10] == 0x32) {
memcpy(output, input, 0x0F);
input += 0x11; output += 0x0F;
}
@@ -245,14 +280,14 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
// skip empty entries
while (!*input) {
// Write one empty string into intro strings file
- if (fmtPatch == 2) {
+ if (patch == 2) {
if ((info->lang == EN_ANY && input - data == 0x260) ||
(info->lang == JA_JPN && (input - data == 0x2BD || input - data == 0x2BE)))
*output++ = *input;
}
// insert one dummy string at hof sequence strings position 59
- if (fmtPatch == 3) {
+ if (patch == 3) {
if ((info->lang == EN_ANY && input - data == 0x695) ||
(info->lang == JA_JPN && input - data == 0x598))
*output++ = *input;
@@ -262,7 +297,7 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
break;
}
- if (fmtPatch == 1) {
+ if (patch == 1) {
// Here is the extra treatment for all FM-TOWNS string arrays that
// contain more than one string and which the original code
// addresses via stringname[boolJapanese].
@@ -292,9 +327,38 @@ bool extractStrings(PAKFile &out, const ExtractInformation *info, const byte *da
++dstPos;
}
targetsize = dstPos + 4;
+ } else if (patch == 5) {
+ const byte *c = data + size;
+ do {
+ strcpy((char*) output, (const char*) input);
+ uint32 stringsize = strlen((const char*)output) + 1;
+ input += stringsize; output += stringsize;
+
+ ++skipCount;
+ while (!*input) {
+ if (skipCount == 81) {
+ *output++ = *input;
+ ++skipCount;
+ }
+ if (++input == c)
+ break;
+ }
+ // Skip English string left-overs in the hacky Russian fan translation
+ for (uint32 ii = 0; ii < ARRAYSIZE(rusFanSkipId); ++ii) {
+ if (skipCount == rusFanSkipId[ii]) {
+ ++skipCount;
+ input += strlen((const char*)input);
+ while (!*input) {
+ if (++input == c)
+ break;
+ }
+ }
+ }
+
+ } while (input < c);
} else {
uint32 copySize = size;
- if (fmtPatch == 4) {
+ if (patch == 4) {
memcpy(output, data, 44);
output += 44;
data += 44;