aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/engine
diff options
context:
space:
mode:
authorMax Horn2010-02-13 17:42:49 +0000
committerMax Horn2010-02-13 17:42:49 +0000
commitac4d325e0d61b649026a5f5414f749697b285ccc (patch)
treec58f62596d050be62e98180c0255e7998a9a62e4 /engines/sci/engine
parent24fd77eb242c4d90e8c3a3b0bcc5f0c48a4dc77f (diff)
downloadscummvm-rg350-ac4d325e0d61b649026a5f5414f749697b285ccc.tar.gz
scummvm-rg350-ac4d325e0d61b649026a5f5414f749697b285ccc.tar.bz2
scummvm-rg350-ac4d325e0d61b649026a5f5414f749697b285ccc.zip
SCI: Add global g_sci pointer to the active SciEngine instance
svn-id: r48046
Diffstat (limited to 'engines/sci/engine')
-rw-r--r--engines/sci/engine/kevent.cpp4
-rw-r--r--engines/sci/engine/kfile.cpp26
-rw-r--r--engines/sci/engine/kmisc.cpp2
-rw-r--r--engines/sci/engine/message.cpp2
-rw-r--r--engines/sci/engine/selector.cpp4
-rw-r--r--engines/sci/engine/selector.h2
-rw-r--r--engines/sci/engine/vm.cpp12
7 files changed, 26 insertions, 26 deletions
diff --git a/engines/sci/engine/kevent.cpp b/engines/sci/engine/kevent.cpp
index 3099c87ff4..7762417625 100644
--- a/engines/sci/engine/kevent.cpp
+++ b/engines/sci/engine/kevent.cpp
@@ -93,7 +93,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
// track left buttton clicks, if requested
if (curEvent.type == SCI_EVENT_MOUSE_PRESS && curEvent.data == 1 && g_debug_track_mouse_clicks) {
- ((SciEngine *)g_engine)->getSciDebugger()->DebugPrintf("Mouse clicked at %d, %d\n",
+ g_sci->getSciDebugger()->DebugPrintf("Mouse clicked at %d, %d\n",
mousePos.x, mousePos.y);
}
@@ -125,7 +125,7 @@ reg_t kGetEvent(EngineState *s, int argc, reg_t *argv) {
g_debugState.stopOnEvent = false;
// A SCI event occured, and we have been asked to stop, so open the debug console
- Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
+ Console *con = g_sci->getSciDebugger();
con->DebugPrintf("SCI event occured: ");
switch (curEvent.type) {
case SCI_EVENT_QUIT:
diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp
index 09b03f538f..d6c95bda87 100644
--- a/engines/sci/engine/kfile.cpp
+++ b/engines/sci/engine/kfile.cpp
@@ -105,7 +105,7 @@ void file_open(EngineState *s, const char *filename, int mode) {
filename += 2;
Common::String englishName = s->getLanguageString(filename, K_LANG_ENGLISH);
- const Common::String wrappedName = ((Sci::SciEngine*)g_engine)->wrapFilename(englishName);
+ const Common::String wrappedName = g_sci->wrapFilename(englishName);
Common::SeekableReadStream *inFile = 0;
Common::WriteStream *outFile = 0;
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
@@ -257,7 +257,7 @@ void listSavegames(Common::Array<SavegameDesc> &saves) {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
// Load all saves
- Common::StringList saveNames = saveFileMan->listSavefiles(((SciEngine *)g_engine)->getSavegamePattern());
+ Common::StringList saveNames = saveFileMan->listSavefiles(g_sci->getSavegamePattern());
for (Common::StringList::const_iterator iter = saveNames.begin(); iter != saveNames.end(); ++iter) {
Common::String filename = *iter;
@@ -294,7 +294,7 @@ bool Console::cmdListSaves(int argc, const char **argv) {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
for (uint i = 0; i < saves.size(); i++) {
- Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(saves[i].id);
+ Common::String filename = g_sci->getSavegameName(saves[i].id);
Common::SeekableReadStream *in;
if ((in = saveFileMan->openForLoading(filename))) {
SavegameMetadata meta;
@@ -405,7 +405,7 @@ reg_t kDeviceInfo(EngineState *s, int argc, reg_t *argv) {
Common::Array<SavegameDesc> saves;
listSavegames(saves);
int savedir_nr = saves[savegame_id].id;
- Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_nr);
+ Common::String filename = g_sci->getSavegameName(savedir_nr);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
saveFileMan->removeSavefile(filename);
}
@@ -462,7 +462,7 @@ reg_t kCheckSaveGame(EngineState *s, int argc, reg_t *argv) {
}
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
- Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_nr);
+ Common::String filename = g_sci->getSavegameName(savedir_nr);
Common::SeekableReadStream *in;
if ((in = saveFileMan->openForLoading(filename))) {
// found a savegame file
@@ -496,7 +496,7 @@ reg_t kGetSaveFiles(EngineState *s, int argc, reg_t *argv) {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
for (uint i = 0; i < saves.size(); i++) {
- Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(saves[i].id);
+ Common::String filename = g_sci->getSavegameName(saves[i].id);
Common::SeekableReadStream *in;
if ((in = saveFileMan->openForLoading(filename))) {
// found a savegame file
@@ -575,7 +575,7 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) {
return NULL_REG;
}
- Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_id);
+ Common::String filename = g_sci->getSavegameName(savedir_id);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
Common::OutSaveFile *out;
if (!(out = saveFileMan->openForSaving(filename))) {
@@ -619,7 +619,7 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) {
if (savedir_nr > -1) {
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
- Common::String filename = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_nr);
+ Common::String filename = g_sci->getSavegameName(savedir_nr);
Common::SeekableReadStream *in;
if ((in = saveFileMan->openForLoading(filename))) {
// found a savegame file
@@ -677,7 +677,7 @@ reg_t DirSeeker::firstFile(const Common::String &mask, reg_t buffer, SegManager
_outbuffer = buffer;
// Prefix the mask
- const Common::String wrappedMask = ((Sci::SciEngine*)g_engine)->wrapFilename(mask);
+ const Common::String wrappedMask = g_sci->wrapFilename(mask);
// Obtain a list of all savefiles matching the given mask
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
@@ -696,7 +696,7 @@ reg_t DirSeeker::nextFile(SegManager *segMan) {
const Common::String wrappedString = *_iter;
// Strip the prefix
- Common::String string = ((Sci::SciEngine*)g_engine)->unwrapFilename(wrappedString);
+ Common::String string = g_sci->unwrapFilename(wrappedString);
if (string.size() > 12)
string = Common::String(string.c_str(), 12);
segMan->strcpy(_outbuffer, string.c_str());
@@ -795,10 +795,10 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) {
Common::Array<SavegameDesc> saves;
listSavegames(saves);
int savedir_nr = saves[slotNum].id;
- name = ((Sci::SciEngine*)g_engine)->getSavegameName(savedir_nr);
+ name = g_sci->getSavegameName(savedir_nr);
saveFileMan->removeSavefile(name);
} else {
- const Common::String wrappedName = ((Sci::SciEngine*)g_engine)->wrapFilename(name);
+ const Common::String wrappedName = g_sci->wrapFilename(name);
saveFileMan->removeSavefile(wrappedName);
}
@@ -878,7 +878,7 @@ reg_t kFileIO(EngineState *s, int argc, reg_t *argv) {
// Check for regular file
bool exists = Common::File::exists(name);
Common::SaveFileManager *saveFileMan = g_engine->getSaveFileManager();
- const Common::String wrappedName = ((Sci::SciEngine*)g_engine)->wrapFilename(name);
+ const Common::String wrappedName = g_sci->wrapFilename(name);
if (!exists)
exists = !saveFileMan->listSavefiles(name).empty();
diff --git a/engines/sci/engine/kmisc.cpp b/engines/sci/engine/kmisc.cpp
index bd1cf587ea..01aa1fe6f8 100644
--- a/engines/sci/engine/kmisc.cpp
+++ b/engines/sci/engine/kmisc.cpp
@@ -306,7 +306,7 @@ enum kPlatformOps {
};
reg_t kPlatform(EngineState *s, int argc, reg_t *argv) {
- bool isWindows = ((SciEngine*)g_engine)->getPlatform() == Common::kPlatformWindows;
+ bool isWindows = g_sci->getPlatform() == Common::kPlatformWindows;
if (argc == 0 && getSciVersion() < SCI_VERSION_2) {
// This is called in KQ5CD with no parameters, where it seems to do some graphics
diff --git a/engines/sci/engine/message.cpp b/engines/sci/engine/message.cpp
index c55ac0b84f..5d72248939 100644
--- a/engines/sci/engine/message.cpp
+++ b/engines/sci/engine/message.cpp
@@ -135,7 +135,7 @@ public:
};
bool MessageState::getRecord(CursorStack &stack, bool recurse, MessageRecord &record) {
- Resource *res = ((SciEngine *)g_engine)->getResourceManager()->findResource(ResourceId(kResourceTypeMessage, stack.getModule()), 0);
+ Resource *res = g_sci->getResourceManager()->findResource(ResourceId(kResourceTypeMessage, stack.getModule()), 0);
if (!res) {
warning("Failed to open message resource %d", stack.getModule());
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 41e0c435af..8a859b1431 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -187,7 +187,7 @@ reg_t read_selector(SegManager *segMan, reg_t object, Selector selector_id) {
void write_selector(SegManager *segMan, reg_t object, Selector selector_id, reg_t value) {
ObjVarRef address;
- if ((selector_id < 0) || (selector_id > (int)((SciEngine*)g_engine)->getKernel()->getSelectorNamesSize())) {
+ if ((selector_id < 0) || (selector_id > (int)g_sci->getKernel()->getSelectorNamesSize())) {
warning("Attempt to write to invalid selector %d of"
" object at %04x:%04x.", selector_id, PRINT_REG(object));
return;
@@ -195,7 +195,7 @@ void write_selector(SegManager *segMan, reg_t object, Selector selector_id, reg_
if (lookup_selector(segMan, object, selector_id, &address, NULL) != kSelectorVariable)
warning("Selector '%s' of object at %04x:%04x could not be"
- " written to", ((SciEngine*)g_engine)->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object));
+ " written to", g_sci->getKernel()->getSelectorName(selector_id).c_str(), PRINT_REG(object));
else
*address.getPointer(segMan) = value;
}
diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h
index f74ec45213..427af7430a 100644
--- a/engines/sci/engine/selector.h
+++ b/engines/sci/engine/selector.h
@@ -46,7 +46,7 @@ enum SelectorInvocation {
/**
* Map a selector name to a selector id. Shortcut for accessing the selector cache.
*/
-#define SELECTOR(_slc_) (((SciEngine *)g_engine)->getKernel()->_selectorCache._slc_)
+#define SELECTOR(_slc_) (g_sci->getKernel()->_selectorCache._slc_)
//#define SELECTOR(_slc_) _slc_
/**
diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp
index 262773a0ed..aa7163929b 100644
--- a/engines/sci/engine/vm.cpp
+++ b/engines/sci/engine/vm.cpp
@@ -285,7 +285,7 @@ ExecStack *execute_method(EngineState *s, uint16 script, uint16 pubfunct, StackP
Common::List<Breakpoint>::const_iterator bp;
for (bp = s->_breakpoints.begin(); bp != s->_breakpoints.end(); ++bp) {
if (bp->type == BREAK_EXPORT && bp->address == bpaddress) {
- Console *con = ((SciEngine *)g_engine)->getSciDebugger();
+ Console *con = g_sci->getSciDebugger();
con->DebugPrintf("Break on script %d, export %d\n", script, pubfunct);
g_debugState.debugging = true;
breakpointWasHit = true;
@@ -368,7 +368,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
cmplen = 256;
if (bp->type == BREAK_SELECTOR && !strncmp(bp->name.c_str(), method_name, cmplen)) {
- Console *con = ((SciEngine *)g_engine)->getSciDebugger();
+ Console *con = g_sci->getSciDebugger();
con->DebugPrintf("Break on %s (in [%04x:%04x])\n", method_name, PRINT_REG(send_obj));
print_send_action = 1;
breakpointWasHit = true;
@@ -379,7 +379,7 @@ ExecStack *send_selector(EngineState *s, reg_t send_obj, reg_t work_obj, StackPt
}
#ifdef VM_DEBUG_SEND
- printf("Send to %04x:%04x, selector %04x (%s):", PRINT_REG(send_obj), selector, ((SciEngine *)g_engine)->getKernel()->getSelectorName(selector).c_str());
+ printf("Send to %04x:%04x, selector %04x (%s):", PRINT_REG(send_obj), selector, g_sci->getKernel()->getSelectorName(selector).c_str());
#endif // VM_DEBUG_SEND
ObjVarRef varp;
@@ -816,7 +816,7 @@ void run_vm(EngineState *s, bool restoring) {
script_debug(s, breakpointWasHit);
breakpointWasHit = false;
}
- Console *con = ((Sci::SciEngine*)g_engine)->getSciDebugger();
+ Console *con = g_sci->getSciDebugger();
if (con->isAttached()) {
con->onFrame();
}
@@ -1681,7 +1681,7 @@ static EngineState *_game_run(EngineState *&s) {
int game_is_finished = 0;
if (Common::isDebugChannelEnabled(kDebugLevelOnStartup))
- ((Sci::SciEngine*)g_engine)->getSciDebugger()->attach();
+ g_sci->getSciDebugger()->attach();
do {
s->_executionStackPosChanged = false;
@@ -1738,7 +1738,7 @@ int game_run(EngineState **_s) {
// Now: Register the first element on the execution stack-
if (!send_selector(s, s->_gameObj, s->_gameObj, s->stack_base, 2, s->stack_base)) {
- Console *con = ((SciEngine *)g_engine)->getSciDebugger();
+ Console *con = g_sci->getSciDebugger();
con->printObject(s->_gameObj);
warning("Failed to run the game! Aborting...");
return 1;