From 0b9e6675ef7e7c2b11345ac2f556e5891222840c Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Sun, 13 Mar 2011 22:00:10 -0400 Subject: SCI: Add workaround for a QFG1 VGA Mac kFormat bug Also, fix the kernel signature for kFormat to require two parameters --- engines/sci/engine/kstring.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'engines/sci/engine/kstring.cpp') 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(); -- cgit v1.2.3