aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2009-07-11 23:45:54 +0000
committerFilippos Karapetis2009-07-11 23:45:54 +0000
commit31a0c8090513023596351174aa48f787ca6384b3 (patch)
tree56a0bf0b62d543f533fe86e479a7edb080ea548d /engines/sci
parent116d2254119476f58b6b135b7a06a207f38fb5d0 (diff)
downloadscummvm-rg350-31a0c8090513023596351174aa48f787ca6384b3.tar.gz
scummvm-rg350-31a0c8090513023596351174aa48f787ca6384b3.tar.bz2
scummvm-rg350-31a0c8090513023596351174aa48f787ca6384b3.zip
Moved the kernel and the vocabulary outside of the engine state (they're static data, which never changes during a game)
svn-id: r42398
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/console.cpp64
-rw-r--r--engines/sci/engine/game.cpp14
-rw-r--r--engines/sci/engine/kernel.h8
-rw-r--r--engines/sci/engine/kgraphics.cpp34
-rw-r--r--engines/sci/engine/kmisc.cpp4
-rw-r--r--engines/sci/engine/kmovement.cpp4
-rw-r--r--engines/sci/engine/kscripts.cpp6
-rw-r--r--engines/sci/engine/ksound.cpp4
-rw-r--r--engines/sci/engine/kstring.cpp7
-rw-r--r--engines/sci/engine/said.cpp2
-rw-r--r--engines/sci/engine/said.y2
-rw-r--r--engines/sci/engine/savegame.cpp14
-rw-r--r--engines/sci/engine/scriptdebug.cpp10
-rw-r--r--engines/sci/engine/seg_manager.cpp2
-rw-r--r--engines/sci/engine/state.cpp3
-rw-r--r--engines/sci/engine/state.h5
-rw-r--r--engines/sci/engine/vm.cpp34
-rw-r--r--engines/sci/engine/vm.h2
-rw-r--r--engines/sci/sci.cpp7
-rw-r--r--engines/sci/sci.h8
20 files changed, 109 insertions, 125 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp
index ebf9656739..7c1a165ec1 100644
--- a/engines/sci/console.cpp
+++ b/engines/sci/console.cpp
@@ -366,8 +366,8 @@ ResourceType parseResourceType(const char *resid) {
}
const char *selector_name(EngineState *s, int selector) {
- if (selector >= 0 && selector < (int)s->_kernel->getSelectorNamesSize())
- return s->_kernel->getSelectorName(selector).c_str();
+ if (selector >= 0 && selector < (int)((SciEngine*)g_engine)->getKernel()->getSelectorNamesSize())
+ return ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector).c_str();
else
return "--INVALID--";
}
@@ -381,8 +381,8 @@ bool Console::cmdGetVersion(int argc, const char **argv) {
bool Console::cmdOpcodes(int argc, const char **argv) {
DebugPrintf("Opcode names in numeric order [index: type name]:\n");
- for (uint seeker = 0; seeker < _vm->_gamestate->_kernel->getOpcodesSize(); seeker++) {
- opcode op = _vm->_gamestate->_kernel->getOpcode(seeker);
+ for (uint seeker = 0; seeker < _vm->getKernel()->getOpcodesSize(); seeker++) {
+ opcode op = _vm->getKernel()->getOpcode(seeker);
DebugPrintf("%03x: %03x %20s | ", seeker, op.type, op.name.c_str());
if ((seeker % 3) == 2)
DebugPrintf("\n");
@@ -400,9 +400,9 @@ bool Console::cmdSelector(int argc, const char **argv) {
return true;
}
- for (uint seeker = 0; seeker < _vm->_gamestate->_kernel->getSelectorNamesSize(); seeker++) {
- if (!scumm_stricmp(_vm->_gamestate->_kernel->getSelectorName(seeker).c_str(), argv[1])) {
- DebugPrintf("Selector %s found at %03x\n", _vm->_gamestate->_kernel->getSelectorName(seeker).c_str(), seeker);
+ for (uint seeker = 0; seeker < _vm->getKernel()->getSelectorNamesSize(); seeker++) {
+ if (!scumm_stricmp(_vm->getKernel()->getSelectorName(seeker).c_str(), argv[1])) {
+ DebugPrintf("Selector %s found at %03x\n", _vm->getKernel()->getSelectorName(seeker).c_str(), seeker);
return true;
}
}
@@ -414,8 +414,8 @@ bool Console::cmdSelector(int argc, const char **argv) {
bool Console::cmdSelectors(int argc, const char **argv) {
DebugPrintf("Selector names in numeric order:\n");
- for (uint seeker = 0; seeker < _vm->_gamestate->_kernel->getSelectorNamesSize(); seeker++) {
- DebugPrintf("%03x: %20s | ", seeker, _vm->_gamestate->_kernel->getSelectorName(seeker).c_str());
+ for (uint seeker = 0; seeker < _vm->getKernel()->getSelectorNamesSize(); seeker++) {
+ DebugPrintf("%03x: %20s | ", seeker, _vm->getKernel()->getSelectorName(seeker).c_str());
if ((seeker % 3) == 2)
DebugPrintf("\n");
}
@@ -427,8 +427,8 @@ bool Console::cmdSelectors(int argc, const char **argv) {
bool Console::cmdKernelFunctions(int argc, const char **argv) {
DebugPrintf("Kernel function names in numeric order:\n");
- for (uint seeker = 0; seeker < _vm->_gamestate->_kernel->getKernelNamesSize(); seeker++) {
- DebugPrintf("%03x: %20s | ", seeker, _vm->_gamestate->_kernel->getKernelName(seeker).c_str());
+ for (uint seeker = 0; seeker < _vm->getKernel()->getKernelNamesSize(); seeker++) {
+ DebugPrintf("%03x: %20s | ", seeker, _vm->getKernel()->getKernelName(seeker).c_str());
if ((seeker % 3) == 2)
DebugPrintf("\n");
}
@@ -439,13 +439,13 @@ bool Console::cmdKernelFunctions(int argc, const char **argv) {
}
bool Console::cmdSuffixes(int argc, const char **argv) {
- _vm->_gamestate->_vocabulary->printSuffixes();
+ _vm->getVocabulary()->printSuffixes();
return true;
}
bool Console::cmdParserWords(int argc, const char **argv) {
- _vm->_gamestate->_vocabulary->printParserWords();
+ _vm->getVocabulary()->printParserWords();
return true;
}
@@ -604,7 +604,7 @@ bool Console::cmdDissectScript(int argc, const char **argv) {
return true;
}
- _vm->_gamestate->_kernel->dissectScript(atoi(argv[1]), _vm->_gamestate->_vocabulary);
+ _vm->getKernel()->dissectScript(atoi(argv[1]), _vm->getVocabulary());
return true;
}
@@ -894,10 +894,10 @@ bool Console::cmdClassTable(int argc, const char **argv) {
bool Console::cmdSentenceFragments(int argc, const char **argv) {
DebugPrintf("Sentence fragments (used to build Parse trees)\n");
- for (uint i = 0; i < _vm->_gamestate->_vocabulary->getParserBranchesSize(); i++) {
+ for (uint i = 0; i < _vm->getVocabulary()->getParserBranchesSize(); i++) {
int j = 0;
- const parse_tree_branch_t &branch = _vm->_gamestate->_vocabulary->getParseTreeBranch(i);
+ const parse_tree_branch_t &branch = _vm->getVocabulary()->getParseTreeBranch(i);
DebugPrintf("R%02d: [%x] ->", i, branch.id);
while ((j < 10) && branch.data[j]) {
int dat = branch.data[j++];
@@ -929,7 +929,7 @@ bool Console::cmdSentenceFragments(int argc, const char **argv) {
DebugPrintf("\n");
}
- DebugPrintf("%d rules.\n", _vm->_gamestate->_vocabulary->getParserBranchesSize());
+ DebugPrintf("%d rules.\n", _vm->getVocabulary()->getParserBranchesSize());
return true;
}
@@ -952,7 +952,7 @@ bool Console::cmdParse(int argc, const char **argv) {
}
DebugPrintf("Parsing '%s'\n", string);
- bool res = _vm->_gamestate->_vocabulary->tokenizeString(words, string, &error);
+ bool res = _vm->getVocabulary()->tokenizeString(words, string, &error);
if (res && !words.empty()) {
int syntax_fail = 0;
@@ -963,7 +963,7 @@ bool Console::cmdParse(int argc, const char **argv) {
for (ResultWordList::const_iterator i = words.begin(); i != words.end(); ++i)
DebugPrintf(" Type[%04x] Group[%04x]\n", i->_class, i->_group);
- if (_vm->_gamestate->_vocabulary->parseGNF(_vm->_gamestate->parser_nodes, words, true))
+ if (_vm->getVocabulary()->parseGNF(_vm->_gamestate->parser_nodes, words, true))
syntax_fail = 1; // Building a tree failed
if (syntax_fail)
@@ -1214,7 +1214,7 @@ bool Console::cmdPrintPort(int argc, const char **argv) {
bool Console::cmdParseGrammar(int argc, const char **argv) {
DebugPrintf("Parse grammar, in strict GNF:\n");
- _vm->_gamestate->_vocabulary->buildGNF(true);
+ _vm->getVocabulary()->buildGNF(true);
return true;
}
@@ -2049,12 +2049,12 @@ bool Console::cmdBacktrace(int argc, const char **argv) {
break;
case EXEC_STACK_TYPE_KERNEL: // Kernel function
- printf(" %x:[%x] k%s(", i, call.origin, _vm->_gamestate->_kernel->getKernelName(-(call.selector) - 42).c_str());
+ printf(" %x:[%x] k%s(", i, call.origin, _vm->getKernel()->getKernelName(-(call.selector) - 42).c_str());
break;
case EXEC_STACK_TYPE_VARSELECTOR:
printf(" %x:[%x] vs%s %s::%s (", i, call.origin, (call.argc) ? "write" : "read",
- objname, _vm->_gamestate->_kernel->getSelectorName(call.selector).c_str());
+ objname, _vm->getKernel()->getSelectorName(call.selector).c_str());
break;
}
@@ -2139,8 +2139,8 @@ bool Console::cmdStepCallk(int argc, const char **argv) {
callk_index = strtoul(argv[1], &endptr, 0);
if (*endptr != '\0') {
callk_index = -1;
- for (uint i = 0; i < _vm->_gamestate->_kernel->getKernelNamesSize(); i++)
- if (argv[1] == _vm->_gamestate->_kernel->getKernelName(i)) {
+ for (uint i = 0; i < _vm->getKernel()->getKernelNamesSize(); i++)
+ if (argv[1] == _vm->getKernel()->getKernelName(i)) {
callk_index = i;
break;
}
@@ -2176,7 +2176,7 @@ bool Console::cmdDissassemble(int argc, const char **argv) {
}
Object *obj = obj_get(_vm->_gamestate, objAddr);
- int selector_id = _vm->_gamestate->_kernel->findSelector(argv[2]);
+ int selector_id = _vm->getKernel()->findSelector(argv[2]);
reg_t addr;
if (!obj) {
@@ -2276,7 +2276,7 @@ bool Console::cmdSend(int argc, const char **argv) {
Object *o;
reg_t fptr;
- selector_id = _vm->_gamestate->_kernel->findSelector(selector_name);
+ selector_id = _vm->getKernel()->findSelector(selector_name);
if (selector_id < 0) {
DebugPrintf("Unknown selector: \"%s\"\n", selector_name);
@@ -3108,7 +3108,7 @@ static void viewobjinfo(EngineState *s, HeapPtr pos) {
int have_rects = 0;
Common::Rect nsrect, nsrect_clipped, brrect;
- if (lookup_selector(s, pos, s->_kernel->_selectorMap.nsBottom, NULL) == kSelectorVariable) {
+ if (lookup_selector(s, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL) == kSelectorVariable) {
GETRECT(nsLeft, nsRight, nsBottom, nsTop);
GETRECT(lsLeft, lsRight, lsBottom, lsTop);
GETRECT(brLeft, brRight, brBottom, brTop);
@@ -3122,7 +3122,7 @@ static void viewobjinfo(EngineState *s, HeapPtr pos) {
x = GET_SELECTOR(pos, x);
y = GET_SELECTOR(pos, y);
priority = GET_SELECTOR(pos, priority);
- if (s->_kernel->_selectorMap.z > 0) {
+ if (((SciEngine*)g_engine)->getKernel()->_selectorMap.z > 0) {
z = GET_SELECTOR(pos, z);
printf("(%d,%d,%d)\n", x, y, z);
} else
@@ -3186,10 +3186,10 @@ static int c_gfx_draw_viewobj(EngineState *s, const Common::Array<cmd_param_t> &
}
- is_view = (lookup_selector(s, pos, s->_kernel->_selectorMap.x, NULL) == kSelectorVariable) &&
- (lookup_selector(s, pos, s->_kernel->_selectorMap.brLeft, NULL) == kSelectorVariable) &&
- (lookup_selector(s, pos, s->_kernel->_selectorMap.signal, NULL) == kSelectorVariable) &&
- (lookup_selector(s, pos, s->_kernel->_selectorMap.nsTop, NULL) == kSelectorVariable);
+ is_view = (lookup_selector(s, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.x, NULL) == kSelectorVariable) &&
+ (lookup_selector(s, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.brLeft, NULL) == kSelectorVariable) &&
+ (lookup_selector(s, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.signal, NULL) == kSelectorVariable) &&
+ (lookup_selector(s, pos, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsTop, NULL) == kSelectorVariable);
if (!is_view) {
printf("Not a dynamic View object.\n");
diff --git a/engines/sci/engine/game.cpp b/engines/sci/engine/game.cpp
index 5b4c30f6b3..0a74ac32e4 100644
--- a/engines/sci/engine/game.cpp
+++ b/engines/sci/engine/game.cpp
@@ -87,7 +87,7 @@ int _reset_graphics_input(EngineState *s) {
s->priority_first = 42; // Priority zone 0 ends here
- if (s->_kernel->usesOldGfxFunctions())
+ if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions())
s->priority_last = 200;
else
s->priority_last = 190;
@@ -257,7 +257,7 @@ static int create_class_table_sci0(EngineState *s) {
Resource *script = s->resmgr->findResource(ResourceId(kResourceTypeScript, scriptnr), 0);
if (script) {
- if (s->_kernel->hasOldScriptHeader())
+ if (((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader())
magic_offset = seeker = 2;
else
magic_offset = seeker = 0;
@@ -327,9 +327,6 @@ int script_init_engine(EngineState *s) {
s->kernel_opt_flags = 0;
- s->_kernel = new Kernel(s->resmgr);
- s->_vocabulary = new Vocabulary(s->resmgr);
-
if (s->_version >= SCI_VERSION_1_1)
result = create_class_table_sci11(s);
else
@@ -375,7 +372,7 @@ int script_init_engine(EngineState *s) {
s->bp_list = NULL; // No breakpoints defined
s->have_bp = 0;
- if (s->_kernel->hasLofsAbsolute())
+ if (((SciEngine*)g_engine)->getKernel()->hasLofsAbsolute())
s->seg_manager->setExportWidth(1);
else
s->seg_manager->setExportWidth(0);
@@ -412,11 +409,6 @@ void script_free_engine(EngineState *s) {
script_free_vm_memory(s);
debug(2, "Freeing state-dependant data");
-
- delete s->_vocabulary;
- s->_vocabulary = 0;
- delete s->_kernel;
- s->_kernel = 0;
}
void script_free_breakpoints(EngineState *s) {
diff --git a/engines/sci/engine/kernel.h b/engines/sci/engine/kernel.h
index 17997e4a20..15f7c9fcf3 100644
--- a/engines/sci/engine/kernel.h
+++ b/engines/sci/engine/kernel.h
@@ -205,7 +205,7 @@ enum SelectorInvocation {
kContinueOnInvalidSelector = 1
};
-#define GET_SEL32(_o_, _slc_) read_selector(s, _o_, s->_kernel->_selectorMap._slc_, __FILE__, __LINE__)
+#define GET_SEL32(_o_, _slc_) read_selector(s, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._slc_, __FILE__, __LINE__)
#define GET_SEL32V(_o_, _slc_) (GET_SEL32(_o_, _slc_).offset)
#define GET_SEL32SV(_o_, _slc_) ((int16)(GET_SEL32(_o_, _slc_).offset))
/* Retrieves a selector from an object
@@ -216,8 +216,8 @@ enum SelectorInvocation {
** selector_map_t and mapped in script.c.
*/
-#define PUT_SEL32(_o_, _slc_, _val_) write_selector(s, _o_, s->_kernel->_selectorMap._slc_, _val_, __FILE__, __LINE__)
-#define PUT_SEL32V(_o_, _slc_, _val_) write_selector(s, _o_, s->_kernel->_selectorMap._slc_, make_reg(0, _val_), __FILE__, __LINE__)
+#define PUT_SEL32(_o_, _slc_, _val_) write_selector(s, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._slc_, _val_, __FILE__, __LINE__)
+#define PUT_SEL32V(_o_, _slc_, _val_) write_selector(s, _o_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._slc_, make_reg(0, _val_), __FILE__, __LINE__)
/* Writes a selector value to an object
** Parameters: (reg_t) object: The address of the object which the selector should be written to
** (selector_name) selector: The selector to read
@@ -229,7 +229,7 @@ enum SelectorInvocation {
#define INV_SEL(_object_, _selector_, _noinvalid_) \
- s, _object_, s->_kernel->_selectorMap._selector_, _noinvalid_, funct_nr, argv, argc, __FILE__, __LINE__
+ s, _object_, ((SciEngine*)g_engine)->getKernel()->_selectorMap._selector_, _noinvalid_, funct_nr, argv, argc, __FILE__, __LINE__
/* Kludge for use with invoke_selector(). Used for compatibility with compilers that can't
** handle vararg macros.
*/
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp
index d46ce3b938..c7086ddef7 100644
--- a/engines/sci/engine/kgraphics.cpp
+++ b/engines/sci/engine/kgraphics.cpp
@@ -164,7 +164,7 @@ int _find_view_priority(EngineState *s, int y) {
return j;
return 14; // Maximum
} else {
- if (!s->_kernel->usesOldGfxFunctions())
+ if (!((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions())
return SCI0_VIEW_PRIORITY_14_ZONES(y);
else
return SCI0_VIEW_PRIORITY(y) == 15 ? 14 : SCI0_VIEW_PRIORITY(y);
@@ -172,7 +172,7 @@ int _find_view_priority(EngineState *s, int y) {
}
int _find_priority_band(EngineState *s, int nr) {
- if (!s->_kernel->usesOldGfxFunctions() && (nr < 0 || nr > 14)) {
+ if (!((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions() && (nr < 0 || nr > 14)) {
if (nr == 15)
return 0xffff;
else {
@@ -181,7 +181,7 @@ int _find_priority_band(EngineState *s, int nr) {
return 0;
}
- if (s->_kernel->usesOldGfxFunctions() && (nr < 0 || nr > 15)) {
+ if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions() && (nr < 0 || nr > 15)) {
warning("Attempt to get priority band %d", nr);
return 0;
}
@@ -191,7 +191,7 @@ int _find_priority_band(EngineState *s, int nr) {
else {
int retval;
- if (!s->_kernel->usesOldGfxFunctions())
+ if (!((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions())
retval = SCI0_PRIORITY_BAND_FIRST_14_ZONES(nr);
else
retval = SCI0_PRIORITY_BAND_FIRST(nr);
@@ -696,7 +696,7 @@ void _k_dirloop(reg_t obj, uint16 angle, EngineState *s, int funct_nr, int argc,
angle %= 360;
- if (!s->_kernel->hasOldScriptHeader()) {
+ if (!((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader()) {
if (angle < 45)
loop = 3;
else if (angle < 136)
@@ -1002,7 +1002,7 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
gfx_color_t transparent = s->wm_port->_bgcolor;
int picFlags = DRAWPIC01_FLAG_FILL_NORMALLY;
- if (s->_kernel->usesOldGfxFunctions())
+ if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions())
add_to_pic = (argc > 2) ? argv[2].toSint16() : false;
dp.nr = argv[0].toSint16();
@@ -1056,7 +1056,7 @@ reg_t kDrawPic(EngineState *s, int funct_nr, int argc, reg_t *argv) {
s->priority_first = 42;
- if (s->_kernel->usesOldGfxFunctions())
+ if (((SciEngine*)g_engine)->getKernel()->usesOldGfxFunctions())
s->priority_last = 200;
else
s->priority_last = 190;
@@ -1079,7 +1079,7 @@ Common::Rect set_base(EngineState *s, reg_t object) {
x = GET_SEL32SV(object, x);
original_y = y = GET_SEL32SV(object, y);
- if (s->_kernel->_selectorMap.z > -1)
+ if (((SciEngine*)g_engine)->getKernel()->_selectorMap.z > -1)
z = GET_SEL32SV(object, z);
else
z = 0;
@@ -1133,7 +1133,7 @@ Common::Rect set_base(EngineState *s, reg_t object) {
void _k_base_setter(EngineState *s, reg_t object) {
Common::Rect absrect = set_base(s, object);
- if (lookup_selector(s, object, s->_kernel->_selectorMap.brLeft, NULL, NULL) != kSelectorVariable)
+ if (lookup_selector(s, object, ((SciEngine*)g_engine)->getKernel()->_selectorMap.brLeft, NULL, NULL) != kSelectorVariable)
return; // non-fatal
// Note: there was a check here for a very old version of SCI, which supposedly needed
@@ -1214,7 +1214,7 @@ Common::Rect get_nsrect(EngineState *s, reg_t object, byte clip) {
x = GET_SEL32SV(object, x);
y = GET_SEL32SV(object, y);
- if (s->_kernel->_selectorMap.z > -1)
+ if (((SciEngine*)g_engine)->getKernel()->_selectorMap.z > -1)
z = GET_SEL32SV(object, z);
else
z = 0;
@@ -1238,7 +1238,7 @@ Common::Rect get_nsrect(EngineState *s, reg_t object, byte clip) {
static void _k_set_now_seen(EngineState *s, reg_t object) {
Common::Rect absrect = get_nsrect(s, object, 0);
- if (lookup_selector(s, object, s->_kernel->_selectorMap.nsTop, NULL, NULL) != kSelectorVariable) {
+ if (lookup_selector(s, object, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsTop, NULL, NULL) != kSelectorVariable) {
return;
} // This isn't fatal
@@ -1724,7 +1724,7 @@ static void _k_view_list_do_postdraw(EngineState *s, GfxList *list) {
* if ((widget->signal & (_K_VIEW_SIG_FLAG_PRIVATE | _K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE)) == _K_VIEW_SIG_FLAG_PRIVATE) {
*/
if ((widget->signal & (_K_VIEW_SIG_FLAG_REMOVE | _K_VIEW_SIG_FLAG_NO_UPDATE)) == 0) {
- int has_nsrect = lookup_selector(s, obj, s->_kernel->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
+ int has_nsrect = lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
if (has_nsrect) {
int temp;
@@ -1746,7 +1746,7 @@ static void _k_view_list_do_postdraw(EngineState *s, GfxList *list) {
}
#ifdef DEBUG_LSRECT
else
- fprintf(stderr, "Not lsRecting %04x:%04x because %d\n", PRINT_REG(obj), lookup_selector(s, obj, s->_kernel->_selectorMap.nsBottom, NULL, NULL));
+ fprintf(stderr, "Not lsRecting %04x:%04x because %d\n", PRINT_REG(obj), lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL));
#endif
if (widget->signal & _K_VIEW_SIG_FLAG_HIDDEN)
@@ -1900,7 +1900,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i
loop = oldloop = sign_extend_byte(GET_SEL32V(obj, loop));
cel = oldcel = sign_extend_byte(GET_SEL32V(obj, cel));
- if (s->_kernel->_selectorMap.palette)
+ if (((SciEngine*)g_engine)->getKernel()->_selectorMap.palette)
palette = GET_SEL32V(obj, palette);
else
palette = 0;
@@ -1923,7 +1923,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i
}
ObjVarRef under_bitsp;
- if (lookup_selector(s, obj, s->_kernel->_selectorMap.underBits, &(under_bitsp), NULL) != kSelectorVariable) {
+ if (lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.underBits, &(under_bitsp), NULL) != kSelectorVariable) {
under_bitsp.obj = NULL_REG;
under_bits = NULL_REG;
debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no underBits\n", PRINT_REG(obj));
@@ -1931,7 +1931,7 @@ static GfxDynView *_k_make_dynview_obj(EngineState *s, reg_t obj, int options, i
under_bits = *under_bitsp.getPointer(s);
ObjVarRef signalp;
- if (lookup_selector(s, obj, s->_kernel->_selectorMap.signal, &(signalp), NULL) != kSelectorVariable) {
+ if (lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.signal, &(signalp), NULL) != kSelectorVariable) {
signalp.obj = NULL_REG;
signal = 0;
debugC(2, kDebugLevelGraphics, "Object at %04x:%04x has no signal selector\n", PRINT_REG(obj));
@@ -2024,7 +2024,7 @@ static void _k_prepare_view_list(EngineState *s, GfxList *list, int options) {
while (view) {
reg_t obj = make_reg(view->_ID, view->_subID);
int priority, _priority;
- int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s, obj, s->_kernel->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
+ int has_nsrect = (view->_ID <= 0) ? 0 : lookup_selector(s, obj, ((SciEngine*)g_engine)->getKernel()->_selectorMap.nsBottom, NULL, NULL) == kSelectorVariable;
int oldsignal = view->signal;
_k_set_now_seen(s, obj);
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index 7e0aca5b7a..c693009b35 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -240,7 +240,7 @@ reg_t kMemory(EngineState *s, int funct_nr, int argc, reg_t *argv) {
reg_t kStub(EngineState *s, int funct_nr, int argc, reg_t *argv) {
char tmpbuf[200];
sprintf(tmpbuf, "Unimplemented syscall: %s[%x] (",
- s->_kernel->getKernelName(funct_nr).c_str(), funct_nr);
+ ((SciEngine*)g_engine)->getKernel()->getKernelName(funct_nr).c_str(), funct_nr);
for (int i = 0; i < argc; i++) {
char tmpbuf2[20];
@@ -257,7 +257,7 @@ reg_t kStub(EngineState *s, int funct_nr, int argc, reg_t *argv) {
}
reg_t kNOP(EngineState *s, int funct_nr, int argc, reg_t *argv) {
- warning("Kernel function 0x%02x (%s) invoked: unmapped", funct_nr, s->_kernel->_kernelFuncs[funct_nr].orig_name.c_str());
+ warning("Kernel function 0x%02x (%s) invoked: unmapped", funct_nr, ((SciEngine*)g_engine)->getKernel()->_kernelFuncs[funct_nr].orig_name.c_str());
return NULL_REG;
}
diff --git a/engines/sci/engine/kmovement.cpp b/engines/sci/engine/kmovement.cpp
index 90db630bfa..8774224f60 100644
--- a/engines/sci/engine/kmovement.cpp
+++ b/engines/sci/engine/kmovement.cpp
@@ -267,7 +267,7 @@ static void bresenham_autodetect(EngineState *s) {
return;
}
- if (lookup_selector(s, motion_class, s->_kernel->_selectorMap.doit, NULL, &fptr) != kSelectorMethod) {
+ if (lookup_selector(s, motion_class, ((SciEngine*)g_engine)->getKernel()->_selectorMap.doit, NULL, &fptr) != kSelectorMethod) {
warning("bresenham_autodetect failed");
handle_movecnt = INCREMENT_MOVECNT; // Most games do this, so best guess
return;
@@ -362,7 +362,7 @@ reg_t kDoBresen(EngineState *s, int funct_nr, int argc, reg_t *argv) {
debugC(2, kDebugLevelBresen, "New data: (x,y)=(%d,%d), di=%d\n", x, y, bdi);
- if (s->_kernel->_selectorMap.cantBeHere != -1)
+ if (((SciEngine*)g_engine)->getKernel()->_selectorMap.cantBeHere != -1)
invoke_selector(INV_SEL(client, cantBeHere, kStopOnInvalidSelector), 0);
else
invoke_selector(INV_SEL(client, canBeHere, kStopOnInvalidSelector), 0);
diff --git a/engines/sci/engine/kscripts.cpp b/engines/sci/engine/kscripts.cpp
index d82f8ff132..df25e11729 100644
--- a/engines/sci/engine/kscripts.cpp
+++ b/engines/sci/engine/kscripts.cpp
@@ -43,7 +43,7 @@ reg_t read_selector(EngineState *s, reg_t object, Selector selector_id, const ch
void write_selector(EngineState *s, reg_t object, Selector selector_id, reg_t value, const char *fname, int line) {
ObjVarRef address;
- if ((selector_id < 0) || (selector_id > (int)s->_kernel->getSelectorNamesSize())) {
+ if ((selector_id < 0) || (selector_id > (int)((SciEngine*)g_engine)->getKernel()->getSelectorNamesSize())) {
warning("Attempt to write to invalid selector %d of"
" object at %04x:%04x (%s L%d).", selector_id, PRINT_REG(object), fname, line);
return;
@@ -51,7 +51,7 @@ void write_selector(EngineState *s, reg_t object, Selector selector_id, reg_t va
if (lookup_selector(s, object, selector_id, &address, NULL) != kSelectorVariable)
warning("Selector '%s' of object at %04x:%04x could not be"
- " written to (%s L%d)", s->_kernel->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line);
+ " written to (%s L%d)", ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line);
else
*address.getPointer(s) = value;
}
@@ -72,7 +72,7 @@ int invoke_selector(EngineState *s, reg_t object, int selector_id, SelectorInvoc
if (slc_type == kSelectorNone) {
warning("Selector '%s' of object at %04x:%04x could not be invoked (%s L%d)",
- s->_kernel->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line);
+ ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object), fname, line);
if (noinvalid == kStopOnInvalidSelector)
error("[Kernel] Not recoverable: VM was halted\n");
return 1;
diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp
index 95c2eaab1d..8c113d35a3 100644
--- a/engines/sci/engine/ksound.cpp
+++ b/engines/sci/engine/ksound.cpp
@@ -988,9 +988,9 @@ reg_t kDoSound_SCI1(EngineState *s, int funct_nr, int argc, reg_t *argv) {
* Used for synthesized music playback
*/
reg_t kDoSound(EngineState *s, int funct_nr, int argc, reg_t *argv) {
- if (s->_kernel->usesSci1SoundFunctions())
+ if (((SciEngine*)g_engine)->getKernel()->usesSci1SoundFunctions())
return kDoSound_SCI1(s, funct_nr, argc, argv);
- else if (s->_kernel->usesSci01SoundFunctions())
+ else if (((SciEngine*)g_engine)->getKernel()->usesSci01SoundFunctions())
return kDoSound_SCI01(s, funct_nr, argc, argv);
else
return kDoSound_SCI0(s, funct_nr, argc, argv);
diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index c572906285..b6bb404d5b 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -95,7 +95,7 @@ reg_t kSaid(EngineState *s, int funct_nr, int argc, reg_t *argv) {
#ifdef DEBUG_PARSER
debugC(2, kDebugLevelParser, "Said block:", 0);
- s->_vocabulary->decipherSaidBlock(said_block);
+ ((SciEngine*)g_engine)->getVocabulary()->decipherSaidBlock(said_block);
#endif
if (s->parser_event.isNull() || (GET_SEL32V(s->parser_event, claimed))) {
@@ -190,10 +190,11 @@ reg_t kParse(EngineState *s, int funct_nr, int argc, reg_t *argv) {
char *error;
ResultWordList words;
reg_t event = argv[1];
+ Vocabulary *voc = ((SciEngine*)g_engine)->getVocabulary();
s->parser_event = event;
- bool res = s->_vocabulary->tokenizeString(words, string, &error);
+ bool res = voc->tokenizeString(words, string, &error);
s->parser_valid = 0; /* not valid */
if (res && !words.empty()) {
@@ -211,7 +212,7 @@ reg_t kParse(EngineState *s, int funct_nr, int argc, reg_t *argv) {
debugC(2, kDebugLevelParser, " Type[%04x] Group[%04x]\n", i->_class, i->_group);
#endif
- if (s->_vocabulary->parseGNF(s->parser_nodes, words))
+ if (voc->parseGNF(s->parser_nodes, words))
syntax_fail = 1; /* Building a tree failed */
if (syntax_fail) {
diff --git a/engines/sci/engine/said.cpp b/engines/sci/engine/said.cpp
index 921fa4e599..b1d174b30f 100644
--- a/engines/sci/engine/said.cpp
+++ b/engines/sci/engine/said.cpp
@@ -2449,7 +2449,7 @@ int said(EngineState *s, byte *spec, int verbose) {
if (s->parser_valid) {
if (said_parse_spec(s, spec)) {
printf("Offending spec was: ");
- s->_vocabulary->decipherSaidBlock(spec);
+ ((SciEngine*)g_engine)->getVocabulary()->decipherSaidBlock(spec);
return SAID_NO_MATCH;
}
diff --git a/engines/sci/engine/said.y b/engines/sci/engine/said.y
index c1c8424cb5..e7c225b3e6 100644
--- a/engines/sci/engine/said.y
+++ b/engines/sci/engine/said.y
@@ -805,7 +805,7 @@ int said(EngineState *s, byte *spec, int verbose) {
if (s->parser_valid) {
if (said_parse_spec(s, spec)) {
warning("Offending spec was: ");
- s->_vocabulary->decypherSaidBlock(spec);
+ ((SciEngine*)g_engine)->getVocabulary()->decypherSaidBlock(spec);
return SAID_NO_MATCH;
}
diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index e167e7eca8..d5f094b540 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -497,7 +497,7 @@ static SegmentId find_unique_seg_by_type(SegManager *self, int type) {
}
static byte *find_unique_script_block(EngineState *s, byte *buf, int type) {
- if (s->_kernel->hasOldScriptHeader())
+ if (((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader())
buf += 2;
do {
@@ -756,13 +756,6 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
// FIXME: Do in-place loading at some point, instead of creating a new EngineState instance from scratch.
retval = new EngineState(s->resmgr, s->_version, s->_flags);
- // static VM/Kernel information:
- assert(0 == retval->_kernel);
- retval->_kernel = s->_kernel; // needs to be initialized before _reset_graphics_input is called
-// s->_kernel = 0; // FIXME: We should set s->_kernel to 0 here,
-// else it could be freed when the old EngineState is freed. Luckily, this freeing currently
-// never happens, so we don't need to.
-
// Copy some old data
retval->gfx_state = s->gfx_state;
retval->sound_mute = s->sound_mute;
@@ -821,11 +814,6 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
retval->game_start_time = g_system->getMillis() - retval->game_time * 1000;
// static parser information:
- assert(0 == retval->_vocabulary);
- retval->_vocabulary = s->_vocabulary;
-// s->_vocabulary = 0; // FIXME: We should set s->_vocabulary to 0 here,
-// else it could be freed when the old EngineState is freed. Luckily, this freeing currently
-// never happens, so we don't need to.
retval->parser_base = make_reg(s->sys_strings_segment, SYS_STRING_PARSER_BASE);
diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp
index 7f5f201079..92cfe9daf3 100644
--- a/engines/sci/engine/scriptdebug.cpp
+++ b/engines/sci/engine/scriptdebug.cpp
@@ -148,7 +148,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
if (print_bw_tag)
printf("[%c] ", opsize ? 'B' : 'W');
- printf("%s", s->_kernel->getOpcode(opcode).name.c_str());
+ printf("%s", ((SciEngine*)g_engine)->getKernel()->getOpcode(opcode).name.c_str());
i = 0;
while (g_opcode_formats[opcode][i]) {
@@ -183,8 +183,8 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
}
if (opcode == op_callk)
- printf(" %s[%x]", (param_value < s->_kernel->_kernelFuncs.size()) ?
- ((param_value < s->_kernel->getKernelNamesSize()) ? s->_kernel->getKernelName(param_value).c_str() : "[Unknown(postulated)]")
+ printf(" %s[%x]", (param_value < ((SciEngine*)g_engine)->getKernel()->_kernelFuncs.size()) ?
+ ((param_value < ((SciEngine*)g_engine)->getKernel()->getKernelNamesSize()) ? ((SciEngine*)g_engine)->getKernel()->getKernelName(param_value).c_str() : "[Unknown(postulated)]")
: "<invalid>", param_value);
else
printf(opsize ? " %02x" : " %04x", param_value);
@@ -238,7 +238,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
int stackframe = (scr[pos.offset + 2] >> 1) + (scriptState.restAdjust);
int argc = ((scriptState.xs->sp)[- stackframe - 1]).offset;
- if (!s->_kernel->hasOldScriptHeader())
+ if (!((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader())
argc += (scriptState.restAdjust);
printf(" Kernel params: (");
@@ -273,7 +273,7 @@ reg_t disassemble(EngineState *s, reg_t pos, int print_bw_tag, int print_bytecod
if (!name)
name = "<invalid>";
- printf(" %s::%s[", name, (selector > s->_kernel->getSelectorNamesSize()) ? "<invalid>" : selector_name(s, selector));
+ printf(" %s::%s[", name, (selector > ((SciEngine*)g_engine)->getKernel()->getSelectorNamesSize()) ? "<invalid>" : selector_name(s, selector));
switch (lookup_selector(s, called_obj_addr, selector, 0, &fun_ref)) {
case kSelectorMethod:
diff --git a/engines/sci/engine/seg_manager.cpp b/engines/sci/engine/seg_manager.cpp
index 74486ef015..6752ba3e56 100644
--- a/engines/sci/engine/seg_manager.cpp
+++ b/engines/sci/engine/seg_manager.cpp
@@ -138,7 +138,7 @@ void SegManager::setScriptSize(Script &scr, EngineState *s, int script_nr) {
if (!script || (s->_version >= SCI_VERSION_1_1 && !heap)) {
error("SegManager::setScriptSize: failed to load %s", !script ? "script" : "heap");
}
- if (s->_kernel->hasOldScriptHeader()) {
+ if (((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader()) {
scr.buf_size = script->size + READ_LE_UINT16(script->data) * 2;
//locals_size = READ_LE_UINT16(script->data) * 2;
} else if (s->_version < SCI_VERSION_1_1) {
diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp
index c43fe9b6de..38320c29cc 100644
--- a/engines/sci/engine/state.cpp
+++ b/engines/sci/engine/state.cpp
@@ -113,9 +113,6 @@ EngineState::EngineState(ResourceManager *res, sci_version_t version, uint32 fla
seg_manager = 0;
gc_countdown = 0;
- _vocabulary = 0;
- _kernel = 0;
-
successor = 0;
}
diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h
index 1759b26dcb..b41e9e383a 100644
--- a/engines/sci/engine/state.h
+++ b/engines/sci/engine/state.h
@@ -257,9 +257,6 @@ public:
MessageState _msgState;
- Vocabulary *_vocabulary;
- Kernel *_kernel;
-
EngineState *successor; /**< Successor of this state: Used for restoring */
private:
@@ -283,7 +280,7 @@ PaletteEntry get_pic_color(EngineState *s, int color);
// misleading. A different name (and a different place for declaring this)
// would be highly welcome.
static inline reg_t not_register(EngineState *s, reg_t r) {
- if (s->_kernel->_selectorMap.cantBeHere != -1)
+ if (((SciEngine*)g_engine)->getKernel()->_selectorMap.cantBeHere != -1)
return make_reg(0, !r.offset);
else
return r;
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index d220547c92..99b5a86e53 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -312,7 +312,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
Breakpoint *bp;
char method_name [256];
- sprintf(method_name, "%s::%s", obj_get_name(s, send_obj), s->_kernel->getSelectorName(selector).c_str());
+ sprintf(method_name, "%s::%s", obj_get_name(s, send_obj), ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector).c_str());
bp = s->bp_list;
while (bp) {
@@ -952,26 +952,26 @@ void run_vm(EngineState *s, int restoring) {
gc_countdown(s);
scriptState.xs->sp -= (opparams[1] >> 1) + 1;
- if (!s->_kernel->hasOldScriptHeader()) {
+ if (!((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader()) {
scriptState.xs->sp -= scriptState.restAdjust;
s->restAdjust = 0; // We just used up the scriptState.restAdjust, remember?
}
- if (opparams[0] >= (int)s->_kernel->_kernelFuncs.size()) {
+ if (opparams[0] >= (int)((SciEngine*)g_engine)->getKernel()->_kernelFuncs.size()) {
error("Invalid kernel function 0x%x requested\n", opparams[0]);
} else {
int argc = ASSERT_ARITHMETIC(scriptState.xs->sp[0]);
- if (!s->_kernel->hasOldScriptHeader())
+ if (!((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader())
argc += scriptState.restAdjust;
- if (s->_kernel->_kernelFuncs[opparams[0]].signature
+ if (((SciEngine*)g_engine)->getKernel()->_kernelFuncs[opparams[0]].signature
&& !kernel_matches_signature(s,
- s->_kernel->_kernelFuncs[opparams[0]].signature, argc,
+ ((SciEngine*)g_engine)->getKernel()->_kernelFuncs[opparams[0]].signature, argc,
scriptState.xs->sp + 1)) {
error("[VM] Invalid arguments to kernel call %x\n", opparams[0]);
} else {
- s->r_acc = s->_kernel->_kernelFuncs[opparams[0]].fun(s, opparams[0],
+ s->r_acc = ((SciEngine*)g_engine)->getKernel()->_kernelFuncs[opparams[0]].fun(s, opparams[0],
argc, scriptState.xs->sp + 1);
}
// Call kernel function
@@ -982,7 +982,7 @@ void run_vm(EngineState *s, int restoring) {
xs_new = &(s->_executionStack.back());
s->_executionStackPosChanged = true;
- if (!s->_kernel->hasOldScriptHeader())
+ if (!((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader())
scriptState.restAdjust = s->restAdjust;
}
@@ -1194,7 +1194,7 @@ void run_vm(EngineState *s, int restoring) {
if (s->_version >= SCI_VERSION_1_1) {
s->r_acc.offset = opparams[0] + local_script->script_size;
} else {
- if (s->_kernel->hasLofsAbsolute())
+ if (((SciEngine*)g_engine)->getKernel()->hasLofsAbsolute())
s->r_acc.offset = opparams[0];
else
s->r_acc.offset = scriptState.xs->addr.pc.offset + opparams[0];
@@ -1214,7 +1214,7 @@ void run_vm(EngineState *s, int restoring) {
if (s->_version >= SCI_VERSION_1_1) {
r_temp.offset = opparams[0] + local_script->script_size;
} else {
- if (s->_kernel->hasLofsAbsolute())
+ if (((SciEngine*)g_engine)->getKernel()->hasLofsAbsolute())
r_temp.offset = opparams[0];
else
r_temp.offset = scriptState.xs->addr.pc.offset + opparams[0];
@@ -1500,7 +1500,7 @@ SelectorType lookup_selector(EngineState *s, reg_t obj_location, Selector select
// Early SCI versions used the LSB in the selector ID as a read/write
// toggle, meaning that we must remove it for selector lookup.
- if (s->_kernel->hasOldScriptHeader())
+ if (((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader())
selector_id &= ~1;
if (!obj) {
@@ -1659,7 +1659,7 @@ int script_instantiate_sci0(EngineState *s, int script_nr) {
Script *scr = s->seg_manager->getScript(seg_id);
- if (s->_kernel->hasOldScriptHeader()) {
+ if (((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader()) {
//
int locals_nr = READ_LE_UINT16(script->data);
@@ -1835,7 +1835,7 @@ int script_instantiate(EngineState *s, int script_nr) {
}
void script_uninstantiate_sci0(EngineState *s, int script_nr, SegmentId seg) {
- reg_t reg = make_reg(seg, s->_kernel->hasOldScriptHeader() ? 2 : 0);
+ reg_t reg = make_reg(seg, ((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader() ? 2 : 0);
int objtype, objlength;
Script *scr = s->seg_manager->getScript(seg);
@@ -1879,7 +1879,7 @@ void script_uninstantiate_sci0(EngineState *s, int script_nr, SegmentId seg) {
}
void script_uninstantiate(EngineState *s, int script_nr) {
- reg_t reg = make_reg(0, s->_kernel->hasOldScriptHeader() ? 2 : 0);
+ reg_t reg = make_reg(0, ((SciEngine*)g_engine)->getKernel()->hasOldScriptHeader() ? 2 : 0);
reg.segment = s->seg_manager->segGet(script_nr);
Script *scr = script_locate_by_segment(s, reg.segment);
@@ -1938,7 +1938,7 @@ static EngineState *_game_run(EngineState *&s, int restoring) {
script_init_engine(s);
game_init(s);
sfx_reset_player();
- _init_stack_base_with_selector(s, s->_kernel->_selectorMap.play);
+ _init_stack_base_with_selector(s, ((SciEngine*)g_engine)->getKernel()->_selectorMap.play);
send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base);
@@ -1957,7 +1957,7 @@ static EngineState *_game_run(EngineState *&s, int restoring) {
debugC(2, kDebugLevelVM, "Restarting with replay()\n");
s->_executionStack.clear(); // Restart with replay
- _init_stack_base_with_selector(s, s->_kernel->_selectorMap.replay);
+ _init_stack_base_with_selector(s, ((SciEngine*)g_engine)->getKernel()->_selectorMap.replay);
send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base);
}
@@ -1976,7 +1976,7 @@ int game_run(EngineState **_s) {
EngineState *s = *_s;
debugC(2, kDebugLevelVM, "Calling %s::play()\n", s->_gameName.c_str());
- _init_stack_base_with_selector(s, s->_kernel->_selectorMap.play); // Call the play selector
+ _init_stack_base_with_selector(s, ((SciEngine*)g_engine)->getKernel()->_selectorMap.play); // Call the play selector
// Now: Register the first element on the execution stack-
if (!send_selector(s, s->game_obj, s->game_obj, s->stack_base, 2, s->stack_base)) {
diff --git a/engines/sci/engine/vm.h b/engines/sci/engine/vm.h
index 1472fae97c..f711570d11 100644
--- a/engines/sci/engine/vm.h
+++ b/engines/sci/engine/vm.h
@@ -419,7 +419,7 @@ void script_debug(EngineState *s, bool bp);
* @return 0 on success, 1 if vocab.996 (the class table) is missing
* or corrupted
*/
-int script_init_engine(EngineState *s);
+int script_init_engine(EngineState *);
/**
* Sets the gamestate's save_dir to the parameter path
diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp
index 9c94e2edde..504e38c7c1 100644
--- a/engines/sci/sci.cpp
+++ b/engines/sci/sci.cpp
@@ -100,7 +100,10 @@ SciEngine::~SciEngine() {
// Remove all of our debug levels here
Common::clearAllDebugChannels();
+ delete _kernel;
+ delete _vocabulary;
delete _console;
+ delete _resmgr;
}
Common::Error SciEngine::run() {
@@ -137,6 +140,8 @@ Common::Error SciEngine::run() {
return Common::kNoGameDataFoundError;
}
+ _kernel = new Kernel(_resmgr);
+ _vocabulary = new Vocabulary(_resmgr);
script_adjust_opcode_formats(_resmgr->_sciVersion);
#if 0
@@ -229,8 +234,6 @@ Common::Error SciEngine::run() {
delete _gamestate;
- delete _resmgr;
-
gfxop_exit(&gfx_state);
return Common::kNoError;
diff --git a/engines/sci/sci.h b/engines/sci/sci.h
index a2de5c3136..886a579799 100644
--- a/engines/sci/sci.h
+++ b/engines/sci/sci.h
@@ -35,6 +35,8 @@ namespace Sci {
class Console;
struct EngineState;
+class Kernel;
+class Vocabulary;
// our engine debug levels
enum kDebugLevels {
@@ -107,7 +109,9 @@ public:
Common::Language getLanguage() const;
Common::Platform getPlatform() const;
uint32 getFlags() const;
- ResourceManager *getResMgr() { return _resmgr; }
+ ResourceManager *getResMgr() const { return _resmgr; }
+ Kernel *getKernel() const { return _kernel; }
+ Vocabulary *getVocabulary() const { return _vocabulary; }
Common::String getSavegameName(int nr) const;
Common::String getSavegamePattern() const;
@@ -122,6 +126,8 @@ private:
const SciGameDescription *_gameDescription;
ResourceManager *_resmgr;
EngineState *_gamestate;
+ Kernel *_kernel;
+ Vocabulary *_vocabulary;
Console *_console;
};