diff options
author | Matthew Hoops | 2010-02-07 04:25:05 +0000 |
---|---|---|
committer | Matthew Hoops | 2010-02-07 04:25:05 +0000 |
commit | 9183ab57a3c260fda721b4eb3103f707be0ea16a (patch) | |
tree | fdbe0b842fc6632b92a7069577e4a7db48676173 /engines/sci/engine | |
parent | 71c222e340a11c999c0fcfc7536bd43c60aa01be (diff) | |
download | scummvm-rg350-9183ab57a3c260fda721b4eb3103f707be0ea16a.tar.gz scummvm-rg350-9183ab57a3c260fda721b4eb3103f707be0ea16a.tar.bz2 scummvm-rg350-9183ab57a3c260fda721b4eb3103f707be0ea16a.zip |
SCI1 Mac games can call kGetFarText with a NULL destination, so we need to allocate the memory. King's Quest V Mac is now playable.
svn-id: r47950
Diffstat (limited to 'engines/sci/engine')
-rw-r--r-- | engines/sci/engine/kernel.cpp | 2 | ||||
-rw-r--r-- | engines/sci/engine/kstring.cpp | 17 |
2 files changed, 11 insertions, 8 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 0f4c64f703..9c47e8458f 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -265,7 +265,7 @@ SciKernelFunction kfunct_mappers[] = { /*4a*/ DEFUN("StrLen", kStrLen, "Zr"), /*4b*/ DEFUN("StrCpy", kStrCpy, "rZri*"), /*4c*/ DEFUN("Format", kFormat, "r.*"), - /*4d*/ DEFUN("GetFarText", kGetFarText, "iir"), + /*4d*/ DEFUN("GetFarText", kGetFarText, "iiZr"), /*4e*/ DEFUN("ReadNumber", kReadNumber, "r"), /*4f*/ DEFUN("BaseSetter", kBaseSetter, "o"), /*50*/ DEFUN("DirLoop", kDirLoop, "oi"), diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp index c11e7fc28b..f3662da6fe 100644 --- a/engines/sci/engine/kstring.cpp +++ b/engines/sci/engine/kstring.cpp @@ -424,23 +424,26 @@ reg_t kGetFarText(EngineState *s, int argc, reg_t *argv) { char *seeker; int counter = argv[1].toUint16(); - if (!textres) { error("text.%d does not exist", argv[0].toUint16()); return NULL_REG; } - seeker = (char *) textres->data; - + seeker = (char *)textres->data; + + // The second parameter (counter) determines the number of the string inside the text + // resource. while (counter--) { while (*seeker++) ; } - /* The second parameter (counter) determines the number of the string inside the text - ** resource. - */ - s->_segMan->strcpy(argv[2], seeker); /* Copy the string and get return value */ + // If the third argument is NULL, allocate memory for the destination. This occurs in + // SCI1 Mac games. The memory will later be freed by the game's scripts. + if (argv[2] == NULL_REG) + s->_segMan->allocDynmem(strlen(seeker) + 1, "Mac FarText", &argv[2]); + + s->_segMan->strcpy(argv[2], seeker); // Copy the string and get return value return argv[2]; } |