aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2016-01-02 21:50:35 +0100
committerMartin Kiewitz2016-01-02 21:50:35 +0100
commit9d5ee9cba0d1881296a14eb4385029afb3258c1f (patch)
tree5636037b2ddb7e7f3e65ea5fcb1da1cc75036dc9 /engines
parent85fa44c32d3021d538b132b47771efe01d5cb354 (diff)
downloadscummvm-rg350-9d5ee9cba0d1881296a14eb4385029afb3258c1f.tar.gz
scummvm-rg350-9d5ee9cba0d1881296a14eb4385029afb3258c1f.tar.bz2
scummvm-rg350-9d5ee9cba0d1881296a14eb4385029afb3258c1f.zip
SCI: fix sciAudio support on some platforms
The old code expected sciAudio FOpen calls to fail, because they contained a directory name. On AmigaOS those calls succeeded. Because of that at least on AmigaOS, sciAudio support didn't work at all. We now detect sciAudio FOpen calls and return a proper virtual file handle. This should fix it on all platforms. Also moved the SCI32 virtual save file handle from 200 to 32100.
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/file.cpp2
-rw-r--r--engines/sci/engine/file.h4
-rw-r--r--engines/sci/engine/kfile.cpp30
3 files changed, 24 insertions, 12 deletions
diff --git a/engines/sci/engine/file.cpp b/engines/sci/engine/file.cpp
index 623caec856..49e6e1716d 100644
--- a/engines/sci/engine/file.cpp
+++ b/engines/sci/engine/file.cpp
@@ -129,7 +129,7 @@ reg_t file_open(EngineState *s, const Common::String &filename, int mode, bool u
}
FileHandle *getFileFromHandle(EngineState *s, uint handle) {
- if (handle == 0 || handle == VIRTUALFILE_HANDLE) {
+ if (handle == 0 || handle >= VIRTUALFILE_HANDLE_START) {
error("Attempt to use invalid file handle (%d)", handle);
return 0;
}
diff --git a/engines/sci/engine/file.h b/engines/sci/engine/file.h
index 052eb735e9..f43958c5ab 100644
--- a/engines/sci/engine/file.h
+++ b/engines/sci/engine/file.h
@@ -41,8 +41,10 @@ enum {
MAX_SAVEGAME_NR = 20 /**< Maximum number of savegames */
};
-#define VIRTUALFILE_HANDLE 200
+#define VIRTUALFILE_HANDLE_START 32000
+#define VIRTUALFILE_HANDLE_SCI32SAVE 32100
#define PHANTASMAGORIA_SAVEGAME_INDEX "phantsg.dir"
+#define VIRTUALFILE_HANDLE_SCIAUDIO 32300
struct SavegameDesc {
int16 id;
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 61ac76d0a7..80bd683dcd 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -258,16 +258,21 @@ reg_t kFileIOOpen(EngineState *s, int argc, reg_t *argv) {
}
debugC(kDebugLevelFile, "kFileIO(open): %s, 0x%x", name.c_str(), mode);
+ if (name.hasPrefix("sciAudio\\")) {
+ // fan-made sciAudio extension, don't create those files and instead return a virtual handle
+ return make_reg(0, VIRTUALFILE_HANDLE_SCIAUDIO);
+ }
+
#ifdef ENABLE_SCI32
if (name == PHANTASMAGORIA_SAVEGAME_INDEX) {
if (s->_virtualIndexFile) {
- return make_reg(0, VIRTUALFILE_HANDLE);
+ return make_reg(0, VIRTUALFILE_HANDLE_SCI32SAVE);
} else {
Common::String englishName = g_sci->getSciLanguageString(name, K_LANG_ENGLISH);
Common::String wrappedName = g_sci->wrapFilename(englishName);
if (!g_sci->getSaveFileManager()->listSavefiles(wrappedName).empty()) {
s->_virtualIndexFile = new VirtualIndexFile(wrappedName);
- return make_reg(0, VIRTUALFILE_HANDLE);
+ return make_reg(0, VIRTUALFILE_HANDLE_SCI32SAVE);
}
}
}
@@ -320,7 +325,7 @@ reg_t kFileIOOpen(EngineState *s, int argc, reg_t *argv) {
s->_virtualIndexFile->write("\0", 1);
s->_virtualIndexFile->write("\0", 1); // Spot description (empty)
s->_virtualIndexFile->seek(0, SEEK_SET);
- return make_reg(0, VIRTUALFILE_HANDLE);
+ return make_reg(0, VIRTUALFILE_HANDLE_SCI32SAVE);
}
}
#endif
@@ -346,12 +351,17 @@ reg_t kFileIOClose(EngineState *s, int argc, reg_t *argv) {
uint16 handle = argv[0].toUint16();
#ifdef ENABLE_SCI32
- if (handle == VIRTUALFILE_HANDLE) {
+ if (handle == VIRTUALFILE_HANDLE_SCI32SAVE) {
s->_virtualIndexFile->close();
return SIGNAL_REG;
}
#endif
+ if (handle >= VIRTUALFILE_HANDLE_START) {
+ // it's a virtual handle? ignore it
+ return SIGNAL_REG;
+ }
+
FileHandle *f = getFileFromHandle(s, handle);
if (f) {
f->close();
@@ -373,7 +383,7 @@ reg_t kFileIOReadRaw(EngineState *s, int argc, reg_t *argv) {
debugC(kDebugLevelFile, "kFileIO(readRaw): %d, %d", handle, size);
#ifdef ENABLE_SCI32
- if (handle == VIRTUALFILE_HANDLE) {
+ if (handle == VIRTUALFILE_HANDLE_SCI32SAVE) {
bytesRead = s->_virtualIndexFile->read(buf, size);
} else {
#endif
@@ -403,7 +413,7 @@ reg_t kFileIOWriteRaw(EngineState *s, int argc, reg_t *argv) {
debugC(kDebugLevelFile, "kFileIO(writeRaw): %d, %d", handle, size);
#ifdef ENABLE_SCI32
- if (handle == VIRTUALFILE_HANDLE) {
+ if (handle == VIRTUALFILE_HANDLE_SCI32SAVE) {
s->_virtualIndexFile->write(buf, size);
success = true;
} else {
@@ -480,7 +490,7 @@ reg_t kFileIOReadString(EngineState *s, int argc, reg_t *argv) {
uint32 bytesRead;
#ifdef ENABLE_SCI32
- if (handle == VIRTUALFILE_HANDLE)
+ if (handle == VIRTUALFILE_HANDLE_SCI32SAVE)
bytesRead = s->_virtualIndexFile->readLine(buf, maxsize);
else
#endif
@@ -503,7 +513,7 @@ reg_t kFileIOWriteString(EngineState *s, int argc, reg_t *argv) {
// We skip creating these files, and instead handle the calls
// directly. Since the sciAudio calls are only creating text files,
// this is probably the most straightforward place to handle them.
- if (handle == 0xFFFF && str.hasPrefix("(sciAudio")) {
+ if (handle == VIRTUALFILE_HANDLE_SCIAUDIO) {
Common::List<ExecStack>::const_iterator iter = s->_executionStack.reverse_begin();
iter--; // sciAudio
iter--; // sciAudio child
@@ -512,7 +522,7 @@ reg_t kFileIOWriteString(EngineState *s, int argc, reg_t *argv) {
}
#ifdef ENABLE_SCI32
- if (handle == VIRTUALFILE_HANDLE) {
+ if (handle == VIRTUALFILE_HANDLE_SCI32SAVE) {
s->_virtualIndexFile->write(str.c_str(), str.size());
return NULL_REG;
}
@@ -539,7 +549,7 @@ reg_t kFileIOSeek(EngineState *s, int argc, reg_t *argv) {
debugC(kDebugLevelFile, "kFileIO(seek): %d, %d, %d", handle, offset, whence);
#ifdef ENABLE_SCI32
- if (handle == VIRTUALFILE_HANDLE)
+ if (handle == VIRTUALFILE_HANDLE_SCI32SAVE)
return make_reg(0, s->_virtualIndexFile->seek(offset, whence));
#endif