diff options
author | Matthew Hoops | 2009-12-24 02:43:07 +0000 |
---|---|---|
committer | Matthew Hoops | 2009-12-24 02:43:07 +0000 |
commit | 65dcc0b2a366cdcf84601263b942448654e92c30 (patch) | |
tree | 1a7ca4dff2432e9f47ec79cd162019f05963fa28 | |
parent | 963dc5f142160bc223cccfe699a9e4f4d8c1a84a (diff) | |
download | scummvm-rg350-65dcc0b2a366cdcf84601263b942448654e92c30.tar.gz scummvm-rg350-65dcc0b2a366cdcf84601263b942448654e92c30.tar.bz2 scummvm-rg350-65dcc0b2a366cdcf84601263b942448654e92c30.zip |
SCI32:
- Fix dup for kArray/kString
- Implement kFileIO::rename (SCI1.1)
- Implement part of the SCI32 additions to kFileIO
- Implement the GetSaveDir part of kSave (SCI2.1)
- Torin (SCI2.1!) now shows signs of life -- it will create the torin.prf file with correct data!
svn-id: r46521
-rw-r--r-- | engines/sci/engine/kernel.cpp | 5 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 3 | ||||
-rw-r--r-- | engines/sci/engine/kernel32.cpp | 33 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 35 | ||||
-rw-r--r-- | engines/sci/engine/segment.h | 2 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 9 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 2 |
7 files changed, 78 insertions, 11 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 717e850c3f..cc15268a59 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -338,10 +338,13 @@ SciKernelFunction kfunct_mappers[] = { DEFUN("Portrait", kPortrait, ".*"), #ifdef ENABLE_SCI32 - // SCI32 Kernel Functions + // SCI2 Kernel Functions DEFUN("IsHiRes", kIsHiRes, ""), DEFUN("Array", kArray, ".*"), DEFUN("String", kString, ".*"), + + // SCI2.1 Kernel Functions + DEFUN("Save", kSave, ".*"), #endif // its a stub, but its needed for Pharkas to work diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 0e94fa5bc8..5c78bc7b00 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -395,6 +395,9 @@ reg_t kTextFonts(EngineState *s, int argc, reg_t *argv); reg_t kIsHiRes(EngineState *s, int argc, reg_t *argv); reg_t kArray(EngineState *s, int argc, reg_t *argv); reg_t kString(EngineState *s, int argc, reg_t *argv); + +// SCI2.1 Kernel Functions +reg_t kSave(EngineState *s, int argc, reg_t *argv); #endif } // End of namespace Sci diff --git a/engines/sci/engine/kernel32.cpp b/engines/sci/engine/kernel32.cpp index cde3c26154..5b4f9ccc2d 100644 --- a/engines/sci/engine/kernel32.cpp +++ b/engines/sci/engine/kernel32.cpp @@ -433,7 +433,13 @@ reg_t kArray(EngineState *s, int argc, reg_t *argv) { SciArray<reg_t> *array = s->_segMan->lookupArray(argv[1]); reg_t arrayHandle; SciArray<reg_t> *dupArray = s->_segMan->allocateArray(&arrayHandle); - *dupArray = SciArray<reg_t>(*array); + + dupArray->setType(array->getType()); + dupArray->setSize(array->getSize()); + + for (uint32 i = 0; i < array->getSize(); i++) + dupArray->setValue(i, array->getValue(i)); + return arrayHandle; } case 9: // Getdata @@ -453,7 +459,6 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { case 0: { // New reg_t stringHandle; SciString *string = s->_segMan->allocateString(&stringHandle); - string->setType(3); string->setSize(argv[1].toUint16()); // Make sure the first character is a null character @@ -512,7 +517,7 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { break; // A count of -1 means fill the rest of the array - uint32 count = argv[5].toSint16() == -1 ? string2.size() - index2 : argv[5].toUint16(); + uint32 count = argv[5].toSint16() == -1 ? string2.size() - index2 + 1 : argv[5].toUint16(); if (string1->getSize() < index1 + count) string1->setSize(index1 + count); @@ -534,10 +539,16 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { return make_reg(0, strcmp(string1.c_str(), string2.c_str())); } case 8: { // Dup - SciString *string = s->_segMan->lookupString(argv[1]); + Common::String string = s->_segMan->getString(argv[1]); reg_t stringHandle; SciString *dupString = s->_segMan->allocateString(&stringHandle); - *dupString = SciString(*string); + dupString->setSize(string.size() + 1); + + for (uint32 i = 0; i < string.size(); i++) + dupString->setValue(i, string.c_str()[i]); + + dupString->setValue(dupString->getSize() - 1, 0); + return stringHandle; } case 9: // Getdata @@ -566,6 +577,18 @@ reg_t kString(EngineState *s, int argc, reg_t *argv) { return NULL_REG; } +reg_t kSave(EngineState *s, int argc, reg_t *argv) { + switch (argv[0].toUint16()) { + case 2: // GetSaveDir + // Yay! Reusing the old kernel function! + return kGetSaveDir(s, argc - 1, argv + 1); + default: + warning("Unknown/unhandled kSave subop %d", argv[0].toUint16()); + } + + return NULL_REG; +} + } // End of namespace Sci #endif // ENABLE_SCI32 diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index a7a39042dc..257abaeaa7 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -615,12 +615,19 @@ enum { K_FILEIO_SEEK = 7, K_FILEIO_FIND_FIRST = 8, K_FILEIO_FIND_NEXT = 9, - K_FILEIO_FILE_EXISTS = 10 + K_FILEIO_FILE_EXISTS = 10, + // SCI1.1 + K_FILEIO_RENAME = 11, + // SCI32 + // 12? + K_FILEIO_READ_BYTE = 13, + K_FILEIO_WRITE_BYTE = 14, + K_FILEIO_READ_WORD = 15, + K_FILEIO_WRITE_WORD = 16 }; reg_t DirSeeker::firstFile(const Common::String &mask, reg_t buffer) { - // Verify that we are given a valid buffer if (!buffer.segment) { error("DirSeeker::firstFile('%s') invoked with invalid buffer", mask.c_str()); @@ -842,6 +849,30 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) { debug(3, "K_FILEIO_FILE_EXISTS(%s) -> %d", name.c_str(), exists); return make_reg(0, exists); } + case K_FILEIO_RENAME: { + Common::String oldName = s->_segMan->getString(argv[1]); + Common::String newName = s->_segMan->getString(argv[2]); + + // 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_engine->getSaveFileManager()->renameSavefile(oldName, newName)) + return NULL_REG; + else + return SIGNAL_REG; + } +#ifdef ENABLE_SCI32 + case K_FILEIO_READ_BYTE: + // Read the byte into the low byte of the accumulator + return make_reg(0, s->r_acc.toUint16() & 0xff00 | getFileFromHandle(s, argv[1].toUint16())->_in->readByte()); + case K_FILEIO_WRITE_BYTE: + getFileFromHandle(s, argv[1].toUint16())->_out->writeByte(argv[2].toUint16() & 0xff); + break; + case K_FILEIO_READ_WORD: + return make_reg(0, getFileFromHandle(s, argv[1].toUint16())->_in->readUint16LE()); + case K_FILEIO_WRITE_WORD: + getFileFromHandle(s, argv[1].toUint16())->_out->writeUint16LE(argv[2].toUint16()); + break; +#endif default : error("Unknown FileIO() sub-command: %d", func_nr); } diff --git a/engines/sci/engine/segment.h b/engines/sci/engine/segment.h index 44aff9d41c..eb34043c01 100644 --- a/engines/sci/engine/segment.h +++ b/engines/sci/engine/segment.h @@ -747,7 +747,7 @@ protected: class SciString : public SciArray<char> { public: - SciString() : SciArray<char>() {} + SciString() : SciArray<char>() { setType(3); } Common::String toString(); void fromString(Common::String string); diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index 4011cbcb54..2d335a3904 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -343,7 +343,14 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt ObjVarRef varp; switch (lookup_selector(s->_segMan, send_obj, selector, &varp, &funcp)) { case kSelectorNone: - error("Send to invalid selector 0x%x of object at %04x:%04x", 0xffff & selector, PRINT_REG(send_obj)); +#ifdef ENABLE_SCI32 + // HACK: Temporarily switch to a warning in SCI32 games until we can figure out why Torin has + // an invalid selector. + if (getSciVersion() >= SCI_VERSION_2) + warning("Send to invalid selector 0x%x of object at %04x:%04x", 0xffff & selector, PRINT_REG(send_obj)); + else +#endif + error("Send to invalid selector 0x%x of object at %04x:%04x", 0xffff & selector, PRINT_REG(send_obj)); break; diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index c9e33ac85f..5299ff0d91 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -177,7 +177,7 @@ Common::Error SciEngine::run() { // Set the savegame dir (actually, we set it to a fake value, // since we cannot let the game control where saves are stored) - strcpy(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value, "/"); + strcpy(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value, ""); _gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _audio, _gamestate->detectDoSoundType()); |