aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/sci/engine/klists.cpp22
-rw-r--r--engines/sci/engine/vm.cpp4
2 files changed, 8 insertions, 18 deletions
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp
index f49c6a06c9..d655472ba4 100644
--- a/engines/sci/engine/klists.cpp
+++ b/engines/sci/engine/klists.cpp
@@ -56,16 +56,8 @@ Node *lookup_node(EngineState *s, reg_t addr, const char *file, int line) {
return &(nt->table[addr.offset].entry);
}
-#define LOOKUP_NULL_LIST(addr) _lookup_list(s, addr, __FILE__, __LINE__, 1)
-
-List *_lookup_list(EngineState *s, reg_t addr, const char *file, int line, int may_be_null) {
- MemObject *mobj;
- ListTable *lt;
-
- if (may_be_null && !addr.segment && !addr.offset)
- return NULL;
-
- mobj = GET_SEGMENT(*s->seg_manager, addr.segment, MEM_OBJ_LISTS);
+List *lookup_list(EngineState *s, reg_t addr, const char *file, int line) {
+ MemObject *mobj = GET_SEGMENT(*s->seg_manager, addr.segment, MEM_OBJ_LISTS);
if (!mobj) {
sciprintf("%s, L%d: Attempt to use non-list "PREG" as list\n", __FILE__, __LINE__, PRINT_REG(addr));
@@ -73,7 +65,7 @@ List *_lookup_list(EngineState *s, reg_t addr, const char *file, int line, int m
return NULL;
}
- lt = &(mobj->data.lists);
+ ListTable *lt = &(mobj->data.lists);
if (!ENTRY_IS_VALID(lt, addr.offset)) {
sciprintf("%s, L%d: Attempt to use non-list "PREG" as list\n", __FILE__, __LINE__, PRINT_REG(addr));
@@ -84,10 +76,6 @@ List *_lookup_list(EngineState *s, reg_t addr, const char *file, int line, int m
return &(lt->table[addr.offset].entry);
}
-List *lookup_list(EngineState *s, reg_t addr, const char *file, int line) {
- return _lookup_list(s, addr, file, line, 0);
-}
-
#ifdef DISABLE_VALIDATIONS
#define sane_nodep(a, b) 1
@@ -212,7 +200,9 @@ reg_t kNewNode(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
reg_t kFirstNode(EngineState *s, int funct_nr, int argc, reg_t *argv) {
- List *l = LOOKUP_NULL_LIST(argv[0]);
+ if (IS_NULL_REG(argv[0]))
+ return NULL_REG;
+ List *l = LOOKUP_LIST(argv[0]);
if (l && !sane_listp(s, argv[0]))
SCIkwarn(SCIkERROR, "List at "PREG" is not sane anymore!\n", PRINT_REG(argv[0]));
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 515f3e46d4..424c7a8180 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -578,7 +578,7 @@ static void gc_countdown(EngineState *s) {
}
}
-static byte _fake_return_buffer[2] = {op_ret << 1, op_ret << 1};
+static const byte _fake_return_buffer[2] = {op_ret << 1, op_ret << 1};
void run_vm(EngineState *s, int restoring) {
reg_t *variables[4]; // global, local, temp, param, as immediate pointers
@@ -603,7 +603,7 @@ void run_vm(EngineState *s, int restoring) {
Script *local_script = script_locate_by_segment(s, xs->local_segment);
int old_execution_stack_base = s->execution_stack_base;
// Used to detect the stack bottom, for "physical" returns
- byte *code_buf = NULL; // (Avoid spurious warning)
+ const byte *code_buf = NULL; // (Avoid spurious warning)
if (!local_script) {
script_error(s, __FILE__, __LINE__, "Program Counter gone astray");