* removed kNOP
* renamed k_Unknown to kUnknown
* added FIXME to kfunct_mappers table
* more cleanup

svn-id: r43906
This commit is contained in:
Max Horn 2009-09-02 11:35:00 +00:00
parent 6c44eafa97
commit 0c7093e05c
3 changed files with 36 additions and 40 deletions

View File

@ -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) {

View File

@ -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

View File

@ -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