mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-15 14:18:37 +00:00
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.
This commit is contained in:
parent
568a5bcd7c
commit
649c801839
@ -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);
|
||||
|
@ -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 },
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user