aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorMatthew Hoops2011-03-13 22:00:10 -0400
committerMatthew Hoops2011-03-13 22:01:41 -0400
commit0b9e6675ef7e7c2b11345ac2f556e5891222840c (patch)
tree0d31d04fb013f246b1a2724b721fc9475df07882 /engines/sci/engine
parent4b6e5e7b06c758d2c6738efaff5dceaaacfed214 (diff)
downloadscummvm-rg350-0b9e6675ef7e7c2b11345ac2f556e5891222840c.tar.gz
scummvm-rg350-0b9e6675ef7e7c2b11345ac2f556e5891222840c.tar.bz2
scummvm-rg350-0b9e6675ef7e7c2b11345ac2f556e5891222840c.zip
SCI: Add workaround for a QFG1 VGA Mac kFormat bug
Also, fix the kernel signature for kFormat to require two parameters
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kernel_tables.h2
-rw-r--r--engines/sci/engine/kstring.cpp10
2 files changed, 9 insertions, 3 deletions
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index b26290612c..16d56d10a8 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -348,7 +348,7 @@ static SciKernelMapEntry s_kernelMap[] = {
{ MAP_CALL(FindKey), SIG_EVERYWHERE, "l.", NULL, kFindKey_workarounds },
{ MAP_CALL(FirstNode), SIG_EVERYWHERE, "[l0]", NULL, NULL },
{ MAP_CALL(FlushResources), SIG_EVERYWHERE, "i", NULL, NULL },
- { MAP_CALL(Format), SIG_EVERYWHERE, "r(.*)", NULL, NULL },
+ { MAP_CALL(Format), SIG_EVERYWHERE, "r[ri](.*)", NULL, NULL },
{ MAP_CALL(GameIsRestarting), SIG_EVERYWHERE, "(i)", NULL, NULL },
{ MAP_CALL(GetAngle), SIG_EVERYWHERE, "iiii", NULL, kGetAngle_workarounds },
{ MAP_CALL(GetCWD), SIG_EVERYWHERE, "r", NULL, NULL },
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index 730f7af9b8..d9bb1c3531 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -190,7 +190,6 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) {
char targetbuf[4096];
char *target = targetbuf;
reg_t position = argv[1]; /* source */
- int index = argv[2].toUint16();
int mode = 0;
int paramindex = 0; /* Next parameter to evaluate */
char xfer;
@@ -201,9 +200,16 @@ reg_t kFormat(EngineState *s, int argc, reg_t *argv) {
if (position.segment)
startarg = 2;
- else
+ else {
+ // WORKAROUND: QFG1 VGA Mac calls this without the first parameter (dest). It then
+ // treats the source as the dest and overwrites the source string with an empty string.
+ if (argc < 3)
+ return NULL_REG;
+
startarg = 3; /* First parameter to use for formatting */
+ }
+ int index = (startarg == 3) ? argv[2].toUint16() : 0;
Common::String source_str = g_sci->getKernel()->lookupText(position, index);
const char* source = source_str.c_str();