diff options
author | Max Horn | 2009-09-02 11:35:00 +0000 |
---|---|---|
committer | Max Horn | 2009-09-02 11:35:00 +0000 |
commit | 0c7093e05c354d942ee1ed475e5c5cf9c688d384 (patch) | |
tree | 5155c3a22fc98ac3f12a0c478193a6842f2e72fe | |
parent | 6c44eafa9768d2b8104ab1b3898ac01527629077 (diff) | |
download | scummvm-rg350-0c7093e05c354d942ee1ed475e5c5cf9c688d384.tar.gz scummvm-rg350-0c7093e05c354d942ee1ed475e5c5cf9c688d384.tar.bz2 scummvm-rg350-0c7093e05c354d942ee1ed475e5c5cf9c688d384.zip |
SCI:
* removed kNOP
* renamed k_Unknown to kUnknown
* added FIXME to kfunct_mappers table
* more cleanup
svn-id: r43906
-rw-r--r-- | engines/sci/engine/kernel.cpp | 45 | ||||
-rw-r--r-- | engines/sci/engine/kernel.h | 9 | ||||
-rw-r--r-- | engines/sci/engine/kmisc.cpp | 22 |
3 files changed, 36 insertions, 40 deletions
diff --git a/engines/sci/engine/kernel.cpp b/engines/sci/engine/kernel.cpp index 1890c07479..f2e69029ce 100644 --- a/engines/sci/engine/kernel.cpp +++ b/engines/sci/engine/kernel.cpp @@ -273,8 +273,8 @@ SciKernelFunction kfunct_mappers[] = { /*4e*/ DEFUN("ReadNumber", kReadNumber, "r"), /*4f*/ DEFUN("BaseSetter", kBaseSetter, "o"), /*50*/ DEFUN("DirLoop", kDirLoop, "oi"), - // Opcode 51 is defined twice for a reason. Older SCI versions - // call CanBeHere, whereas newer ones its inverse, CantBeHere + // Opcode 51 is defined twice for a reason: In older SCI versions + // it is CanBeHere, whereas in newer version it is CantBeHere /*51*/ DEFUN("CanBeHere", kCanBeHere, "ol*"), /*51*/ DEFUN("CantBeHere", kCanBeHere, "ol*"), /*52*/ DEFUN("OnControl", kOnControl, "i*"), @@ -346,7 +346,13 @@ SciKernelFunction kfunct_mappers[] = { // Special and NOP stuff DEFUN("Dummy", kStub, ".*"), - {NULL, k_Unknown, NULL}, + {NULL, kUnknown, NULL}, + + // FIXME: The stub functions below are ignored since the entry + // above ( {NULL, kUnknown, NULL} ) terminates this array effectively. + // Seems like a bug to me; maybe the line above should just be removed? + // If this is on purpose, then whoever knows the reason should replace + // this FIXME by a comment explaining it. // Stub functions DEFUN("ShiftScreen", kStub, ".*"), @@ -572,29 +578,28 @@ void Kernel::mapFunctions() { if (functnr < getKernelNamesSize()) sought_name = getKernelName(functnr); - // If the name is known, look it up in kfunct_mappers. This table - // maps kernel func names to actual function (pointers). - if (!sought_name.empty()) { - for (uint seeker = 0; (found == -1) && kfunct_mappers[seeker].name; seeker++) - if (sought_name == kfunct_mappers[seeker].name) - found = seeker; // Found a kernel function with the correct name! - } - // Reset the table entry _kernelFuncs[functnr].fun = NULL; _kernelFuncs[functnr].signature = NULL; _kernelFuncs[functnr].orig_name = sought_name; + if (sought_name.empty()) { + // No name was given -> must be an unknown opcode + warning("Flagging kernel function %x as unknown", functnr); + _kernelFuncs[functnr].fun = kUnknown; + continue; + } + + // If the name is known, look it up in kfunct_mappers. This table + // maps kernel func names to actual function (pointers). + for (uint seeker = 0; (found == -1) && kfunct_mappers[seeker].name; seeker++) + if (sought_name == kfunct_mappers[seeker].name) + found = seeker; // Found a kernel function with the correct name! + if (found == -1) { - if (!sought_name.empty()) { - // No match but a name was given -> NOP - warning("Kernel function %s[%x] unmapped", sought_name.c_str(), functnr); - _kernelFuncs[functnr].fun = kNOP; - } else { - // No match and no name was given -> must be an unknown opcode - warning("Flagging kernel function %x as unknown", functnr); - _kernelFuncs[functnr].fun = k_Unknown; - } + // No match but a name was given -> stub + warning("Kernel function %s[%x] unmapped", sought_name.c_str(), functnr); + _kernelFuncs[functnr].fun = kStub; } else { // A match in kfunct_mappers was found if (kfunct_mappers[found].fun) { diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h index 87b235c8dc..4c430d3da2 100644 --- a/engines/sci/engine/kernel.h +++ b/engines/sci/engine/kernel.h @@ -503,15 +503,14 @@ reg_t kSetQuitStr(EngineState *s, int, int argc, reg_t *argv); reg_t kShowMovie(EngineState *s, int, int argc, reg_t *argv); reg_t kSetVideoMode(EngineState *s, int, int argc, reg_t *argv); reg_t kStrSplit(EngineState *s, int, int argc, reg_t *argv); -reg_t k_Unknown(EngineState *s, int, int argc, reg_t *argv); reg_t kPlatform(EngineState *s, int, int argc, reg_t *argv); reg_t kPalVary(EngineState *s, int, int argc, reg_t *argv); -// The Unknown/Unnamed kernel function +// for unknown/unnamed kernel function +reg_t kUnknown(EngineState *s, int, int argc, reg_t *argv); + +// for named but unimplemented kernel functions reg_t kStub(EngineState *s, int, int argc, reg_t *argv); -// for unimplemented kernel functions -reg_t kNOP(EngineState *s, int, int argc, reg_t *argv); -// for kernel functions that don't do anything } // End of namespace Sci diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp index 1377f3ae89..fc78f71c07 100644 --- a/engines/sci/engine/kmisc.cpp +++ b/engines/sci/engine/kmisc.cpp @@ -92,14 +92,6 @@ reg_t kMemoryInfo(EngineState *s, int, int argc, reg_t *argv) { return NULL_REG; } -#define SCI_MAPPED_UNKNOWN_KFUNCTIONS_NR 0x75 -// kfunct_mappers below doubles for unknown kfunctions - -reg_t k_Unknown(EngineState *s, int funct_nr, int argc, reg_t *argv) { - warning("Unhandled Unknown function %04x", funct_nr); - return NULL_REG; -} - reg_t kFlushResources(EngineState *s, int, int argc, reg_t *argv) { run_gc(s); debugC(2, kDebugLevelRoom, "Entering room number %d", argv[0].toUint16()); @@ -268,10 +260,15 @@ reg_t kPlatform(EngineState *s, int, int argc, reg_t *argv) { return NULL_REG; } +reg_t kUnknown(EngineState *s, int funct_nr, int argc, reg_t *argv) { + warning("Unknown kernel function 0x%02x", funct_nr); + return NULL_REG; +} + reg_t kStub(EngineState *s, int funct_nr, int argc, reg_t *argv) { char tmpbuf[256]; - snprintf(tmpbuf, sizeof(tmpbuf), "Unimplemented syscall: %s[%x] (", - ((SciEngine*)g_engine)->getKernel()->getKernelName(funct_nr).c_str(), funct_nr); + snprintf(tmpbuf, sizeof(tmpbuf), "Unimplemented kernel function: 0x%02x (%s) (", + funct_nr, ((SciEngine*)g_engine)->getKernel()->getKernelName(funct_nr).c_str()); for (int i = 0; i < argc; i++) { char tmpbuf2[20]; @@ -287,9 +284,4 @@ reg_t kStub(EngineState *s, int funct_nr, int argc, reg_t *argv) { return NULL_REG; } -reg_t kNOP(EngineState *s, int funct_nr, int argc, reg_t *argv) { - warning("Kernel function 0x%02x (%s) invoked: unmapped", funct_nr, ((SciEngine*)g_engine)->getKernel()->_kernelFuncs[funct_nr].orig_name.c_str()); - return NULL_REG; -} - } // End of namespace Sci |