aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorsluicebox2019-12-20 21:39:46 -0700
committersluicebox2019-12-21 18:26:07 -0700
commit649c801839b833c120a0581936b9200c65a8701e (patch)
treea78d53472c8096bcb78d246a1f110ce445c17227 /engines/sci
parent568a5bcd7cb31ae840be38c5269319708bf77367 (diff)
downloadscummvm-rg350-649c801839b833c120a0581936b9200c65a8701e.tar.gz
scummvm-rg350-649c801839b833c120a0581936b9200c65a8701e.tar.bz2
scummvm-rg350-649c801839b833c120a0581936b9200c65a8701e.zip
SCI: Implement kFileIOCopy
Allows patching a Phantasmagoria 1 script to copy instead of rename. Although most games can call this through their File:copy script, none have been discovered yet that do.
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/kernel.h1
-rw-r--r--engines/sci/engine/kernel_tables.h1
-rw-r--r--engines/sci/engine/kfile.cpp19
3 files changed, 21 insertions, 0 deletions
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 7583e2479b..f784e7ee70 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -725,6 +725,7 @@ reg_t kFileIOFindFirst(EngineState *s, int argc, reg_t *argv);
reg_t kFileIOFindNext(EngineState *s, int argc, reg_t *argv);
reg_t kFileIOExists(EngineState *s, int argc, reg_t *argv);
reg_t kFileIORename(EngineState *s, int argc, reg_t *argv);
+reg_t kFileIOCopy(EngineState *s, int argc, reg_t *argv);
#ifdef ENABLE_SCI32
reg_t kFileIOReadByte(EngineState *s, int argc, reg_t *argv);
reg_t kFileIOWriteByte(EngineState *s, int argc, reg_t *argv);
diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h
index 8dab326361..8275a36f9a 100644
--- a/engines/sci/engine/kernel_tables.h
+++ b/engines/sci/engine/kernel_tables.h
@@ -322,6 +322,7 @@ static const SciKernelMapSubEntry kFileIO_subops[] = {
{ SIG_SCIALL, 9, MAP_CALL(FileIOFindNext), "r", NULL },
{ SIG_SCIALL, 10, MAP_CALL(FileIOExists), "r", NULL },
{ SIG_SINCE_SCI11, 11, MAP_CALL(FileIORename), "rr", NULL },
+ { SIG_SINCE_SCI11, 12, MAP_CALL(FileIOCopy), "rr", NULL },
#ifdef ENABLE_SCI32
{ SIG_SINCE_SCI21MID, 13, MAP_CALL(FileIOReadByte), "i", NULL },
{ SIG_SINCE_SCI21MID, 14, MAP_CALL(FileIOWriteByte), "ii", NULL },
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 1e3f8bfd4c..3256e20fff 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -912,6 +912,25 @@ reg_t kFileIORename(EngineState *s, int argc, reg_t *argv) {
return SIGNAL_REG;
}
+reg_t kFileIOCopy(EngineState *s, int argc, reg_t *argv) {
+ Common::String oldName = s->_segMan->getString(argv[0]);
+ Common::String newName = s->_segMan->getString(argv[1]);
+
+ oldName = g_sci->wrapFilename(oldName);
+ newName = g_sci->wrapFilename(newName);
+
+ // Phantasmagoria 1 files are small and interoperable with the
+ // original interpreter so they aren't compressed, see file_open().
+ bool isCompressed = (g_sci->getGameId() != GID_PHANTASMAGORIA);
+
+ // SCI1.1 returns 0 on success and a DOS error code on fail. SCI32
+ // returns -1 on fail. We just return -1 for all versions.
+ if (g_sci->getSaveFileManager()->copySavefile(oldName, newName, isCompressed))
+ return NULL_REG;
+ else
+ return SIGNAL_REG;
+}
+
#ifdef ENABLE_SCI32
reg_t kFileIOReadByte(EngineState *s, int argc, reg_t *argv) {
// Read the byte into the low byte of the accumulator