diff options
-rw-r--r-- | engines/sci/engine/kernel.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/kernel_tables.h | 14 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 42 | ||||
-rw-r--r-- | engines/sci/graphics/text32.cpp | 7 |
4 files changed, 45 insertions, 20 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index e549c1f8ae..42651ec4a5 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -458,6 +458,8 @@ reg_t kListAllTrue(EngineState *s, int argc, reg_t *argv); reg_t kInPolygon(EngineState *s, int argc, reg_t *argv); reg_t kObjectIntersect(EngineState *s, int argc, reg_t *argv); reg_t kEditText(EngineState *s, int argc, reg_t *argv); +reg_t kMakeSaveCatName(EngineState *s, int argc, reg_t *argv); +reg_t kMakeSaveFileName(EngineState *s, int argc, reg_t *argv); // SCI2.1 Kernel Functions reg_t kText(EngineState *s, int argc, reg_t *argv); diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h index 622511c906..ff06b79d72 100644 --- a/engines/sci/engine/kernel_tables.h +++ b/engines/sci/engine/kernel_tables.h @@ -500,6 +500,8 @@ static SciKernelMapEntry s_kernelMap[] = { { MAP_CALL(UpdateScreenItem), SIG_EVERYWHERE, "o", NULL, NULL }, { MAP_CALL(ObjectIntersect), SIG_EVERYWHERE, "oo", NULL, NULL }, { MAP_CALL(EditText), SIG_EVERYWHERE, "o", NULL, NULL }, + { MAP_CALL(MakeSaveCatName), SIG_EVERYWHERE, "rr", NULL, NULL }, + { MAP_CALL(MakeSaveFileName), SIG_EVERYWHERE, "rri", NULL, NULL }, // SCI2 unmapped functions - TODO! @@ -512,18 +514,6 @@ static SciKernelMapEntry s_kernelMap[] = { // Debug function used to track resources { MAP_EMPTY(ResourceTrack), SIG_EVERYWHERE, "(.*)", NULL, NULL }, - // SCI2 functions that are used in the original save/load menus. Marked as dummy, so - // that the engine errors out on purpose. TODO: Implement once the original save/load - // menus are implemented. - - // Creates the name of the save catalogue/directory to save into. - // TODO: Implement once the original save/load menus are implemented. - { MAP_DUMMY(MakeSaveCatName), SIG_EVERYWHERE, "(.*)", NULL, NULL }, - - // Creates the name of the save file to save into - // TODO: Implement once the original save/load menus are implemented. - { MAP_DUMMY(MakeSaveFileName), SIG_EVERYWHERE, "(.*)", NULL, NULL }, - // Unused / debug SCI2 unused functions, always mapped to kDummy // AddMagnify/DeleteMagnify are both called by script 64979 (the Magnifier diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 312497720a..24ef500d80 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -863,6 +863,10 @@ reg_t kFileIOUnlink(EngineState *s, int argc, reg_t *argv) { int savedir_nr = saves[slotNum].id; name = g_sci->getSavegameName(savedir_nr); result = saveFileMan->removeSavefile(name); + } else if (getSciVersion() >= SCI_VERSION_2) { + // We don't need to wrap the filename in SCI32 games, as it's already + // constructed here + result = saveFileMan->removeSavefile(name); } else { const Common::String wrappedName = g_sci->wrapFilename(name); result = saveFileMan->removeSavefile(wrappedName); @@ -1168,6 +1172,35 @@ reg_t kCD(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } +reg_t kMakeSaveCatName(EngineState *s, int argc, reg_t *argv) { + // Normally, this creates the name of the save catalogue/directory to save into. + // First parameter is the string to save the result into. Second is a string + // with game parameters. We don't have a use for this at all, as we have our own + // savegame directory management, thus we always return an empty string. + return argv[0]; +} + +reg_t kMakeSaveFileName(EngineState *s, int argc, reg_t *argv) { + // Creates a savegame name from a slot number. Used when deleting saved games. + // Param 0: the output buffer (same as in kMakeSaveCatName) + // Param 1: a string with game parameters, ignored + // Param 2: the selected slot + + SciString *resultString = s->_segMan->lookupString(argv[0]); + uint16 saveSlot = argv[2].toUint16(); + // For some reason, the save slot is incremented by 100... fix it here + if (saveSlot > 100) + saveSlot -= 100; + + Common::Array<SavegameDesc> saves; + listSavegames(saves); + + Common::String filename = g_sci->getSavegameName(saveSlot); + resultString->fromString(filename); + + return argv[0]; +} + reg_t kSave(EngineState *s, int argc, reg_t *argv) { switch (argv[0].toUint16()) { case 0: @@ -1181,12 +1214,9 @@ reg_t kSave(EngineState *s, int argc, reg_t *argv) { case 5: return kGetSaveFiles(s, argc - 1, argv + 1); case 6: - // This is used in Shivers to delete saved games, however it - // always passes the same file name (SHIVER), so it doesn't - // actually delete anything... - // TODO: Check why this happens - // argv[1] is a string (most likely the save game directory) - return kFileIOUnlink(s, argc - 2, argv + 2); + return kMakeSaveCatName(s, argc - 1, argv + 1); + case 7: + return kMakeSaveFileName(s, argc - 1, argv + 1); case 8: // TODO // This is a timer callback, with 1 parameter: the timer object diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp index 7894c7109c..cd24ca5a99 100644 --- a/engines/sci/graphics/text32.cpp +++ b/engines/sci/graphics/text32.cpp @@ -187,8 +187,11 @@ void GfxText32::drawTextBitmap(int16 x, int16 y, Common::Rect planeRect, reg_t t byte *memoryPtr = _segMan->getHunkPointer(hunkId); - if (!memoryPtr) - error("Attempt to draw an invalid text bitmap"); + if (!memoryPtr) { + // Happens when restoring in some SCI32 games + warning("Attempt to draw an invalid text bitmap"); + return; + } byte *surface = memoryPtr + BITMAP_HEADER_SIZE; |