diff options
author | Paweł Kołodziejski | 2003-09-13 13:41:44 +0000 |
---|---|---|
committer | Paweł Kołodziejski | 2003-09-13 13:41:44 +0000 |
commit | c334c1103fbb927d4826bcafd89a71fa7391a093 (patch) | |
tree | a37507e83fe2d17fefffe9a6d8396377e534fc46 /scumm | |
parent | 059781c80a3fe3e120914650cad0dd94f353246d (diff) | |
download | scummvm-rg350-c334c1103fbb927d4826bcafd89a71fa7391a093.tar.gz scummvm-rg350-c334c1103fbb927d4826bcafd89a71fa7391a093.tar.bz2 scummvm-rg350-c334c1103fbb927d4826bcafd89a71fa7391a093.zip |
implemented opcodes: openfile and closefile
svn-id: r10226
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/script_v6.cpp | 31 | ||||
-rw-r--r-- | scumm/scumm.h | 1 |
2 files changed, 25 insertions, 7 deletions
diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index e7a6f23958..4241b27ae0 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -2827,7 +2827,7 @@ void Scumm_v6::o6_stopTalking() { } void Scumm_v6::o6_openFile() { - int a, len; + int mode, len, slot; byte filename[100]; _msgPtrToAdd = filename; @@ -2837,15 +2837,32 @@ void Scumm_v6::o6_openFile() { len = resStrLen(_scriptPointer); _scriptPointer += len + 1; - a = pop(); - warning("stub o6_openFile(\"%s\", %d)", filename, a); - // -1 open failed, otherwise file slot - push(0); + mode = pop(); + slot = -1; + for (int l = 0; l < 17; l++) { + if (_hFileTable[l].isOpen() == false) { + slot = l; + break; + } + } + + if (slot != -1) { + if (mode == 1) + _hFileTable[slot].open((char*)filename, this->getGameDataPath(), File::kFileReadMode); + else if (mode == 2) + _hFileTable[slot].open((char*)filename, this->getGameDataPath(), File::kFileWriteMode); + else + error("o6_openFile(): wrong open file mode"); + + warning("%d = o6_openFile(\"%s\", %d)", slot, filename, mode); + } + push(slot); } void Scumm_v6::o6_closeFile() { - // pop'd variable should be that pushed in o6_openFile() - warning("stub o6_closeFile(%d)", pop()); + int slot = pop(); + _hFileTable[slot].close(); + warning("o6_closeFile(%d)", slot); } void Scumm_v6::o6_deleteFile() { diff --git a/scumm/scumm.h b/scumm/scumm.h index c5869f4835..0b8f760f78 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -559,6 +559,7 @@ protected: /* Should be in Resource class */ File _fileHandle; uint32 _fileOffset; + File _hFileTable[17]; int _resourceHeaderSize; char *_exe_name; // This is the name we use for opening resource files char *_game_name; // This is the game the user calls it, so use for saving |