diff options
author | Filippos Karapetis | 2010-06-10 11:18:10 +0000 |
---|---|---|
committer | Filippos Karapetis | 2010-06-10 11:18:10 +0000 |
commit | 93f33c7dab009e8ff82fac195e7b6d02e66ab755 (patch) | |
tree | 6e96c80da2d5167d781a50f5c4b81b57af3a99b0 /engines/sci | |
parent | a635b948239fbbd1ce302fb9d5eac943e90ca7ee (diff) | |
download | scummvm-rg350-93f33c7dab009e8ff82fac195e7b6d02e66ab755.tar.gz scummvm-rg350-93f33c7dab009e8ff82fac195e7b6d02e66ab755.tar.bz2 scummvm-rg350-93f33c7dab009e8ff82fac195e7b6d02e66ab755.zip |
Resolved a FIXME with getSciLanguage(), by creating a separate setter. Also, some camelCase changes
svn-id: r49568
Diffstat (limited to 'engines/sci')
-rw-r--r-- | engines/sci/console.cpp | 6 | ||||
-rw-r--r-- | engines/sci/detection.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/ksound.cpp | 5 | ||||
-rw-r--r-- | engines/sci/engine/savegame.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/scriptdebug.cpp | 4 | ||||
-rw-r--r-- | engines/sci/engine/state.cpp | 25 | ||||
-rw-r--r-- | engines/sci/engine/state.h | 10 | ||||
-rw-r--r-- | engines/sci/engine/vm.cpp | 12 | ||||
-rw-r--r-- | engines/sci/sci.cpp | 8 | ||||
-rw-r--r-- | engines/sci/sci.h | 2 |
10 files changed, 44 insertions, 36 deletions
diff --git a/engines/sci/console.cpp b/engines/sci/console.cpp index 7246bef586..098d83a2d3 100644 --- a/engines/sci/console.cpp +++ b/engines/sci/console.cpp @@ -75,7 +75,7 @@ Console::Console(SciEngine *engine) : GUI::Debugger() { // Variables DVar_Register("sleeptime_factor", &g_debug_sleeptime_factor, DVAR_INT, 0); - DVar_Register("gc_interval", &engine->_gamestate->script_gc_interval, DVAR_INT, 0); + DVar_Register("gc_interval", &engine->_gamestate->scriptGCInterval, DVAR_INT, 0); DVar_Register("simulated_key", &g_debug_simulated_key, DVAR_INT, 0); DVar_Register("track_mouse_clicks", &g_debug_track_mouse_clicks, DVAR_BOOL, 0); DVar_Register("script_abort_flag", &_engine->_gamestate->abortScriptProcessing, DVAR_INT, 0); @@ -2086,7 +2086,7 @@ bool Console::cmdViewAccumulatorObject(int argc, const char **argv) { } bool Console::cmdScriptSteps(int argc, const char **argv) { - DebugPrintf("Number of executed SCI operations: %d\n", _engine->_gamestate->script_step_counter); + DebugPrintf("Number of executed SCI operations: %d\n", _engine->_gamestate->scriptStepCounter); return true; } @@ -2114,7 +2114,7 @@ bool Console::cmdSetAccumulator(int argc, const char **argv) { bool Console::cmdBacktrace(int argc, const char **argv) { DebugPrintf("Dumping the send/self/super/call/calle/callb stack:\n"); - DebugPrintf("Call stack (current base: 0x%x):\n", _engine->_gamestate->execution_stack_base); + DebugPrintf("Call stack (current base: 0x%x):\n", _engine->_gamestate->executionStackBase); Common::List<ExecStack>::iterator iter; uint i = 0; diff --git a/engines/sci/detection.cpp b/engines/sci/detection.cpp index f36bae2d6d..579414b3ea 100644 --- a/engines/sci/detection.cpp +++ b/engines/sci/detection.cpp @@ -673,11 +673,11 @@ Common::Error SciEngine::saveGameState(int slot, const char *desc) { } bool SciEngine::canLoadGameStateCurrently() { - return !_gamestate->execution_stack_base; + return !_gamestate->executionStackBase; } bool SciEngine::canSaveGameStateCurrently() { - return !_gamestate->execution_stack_base; + return !_gamestate->executionStackBase; } } // End of namespace Sci diff --git a/engines/sci/engine/ksound.cpp b/engines/sci/engine/ksound.cpp index 367a89005c..29302181b1 100644 --- a/engines/sci/engine/ksound.cpp +++ b/engines/sci/engine/ksound.cpp @@ -151,7 +151,10 @@ reg_t kDoAudio(EngineState *s, int argc, reg_t *argv) { if (language != -1) g_sci->getResMan()->setAudioLanguage(language); - return make_reg(0, g_sci->getSciLanguage()); + kLanguage kLang = g_sci->getSciLanguage(); + g_sci->setSciLanguage(kLang); + + return make_reg(0, kLang); } break; case kSciAudioCD: diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp index 99191146e5..3cd444d4d7 100644 --- a/engines/sci/engine/savegame.cpp +++ b/engines/sci/engine/savegame.cpp @@ -722,7 +722,7 @@ int gamestate_save(EngineState *s, Common::WriteStream *fh, const char* savename meta.savegame_date = ((curTime.tm_mday & 0xFF) << 24) | (((curTime.tm_mon + 1) & 0xFF) << 16) | ((curTime.tm_year + 1900) & 0xFFFF); meta.savegame_time = ((curTime.tm_hour & 0xFF) << 16) | (((curTime.tm_min) & 0xFF) << 8) | ((curTime.tm_sec) & 0xFF); - if (s->execution_stack_base) { + if (s->executionStackBase) { warning("Cannot save from below kernel function"); return 1; } @@ -875,7 +875,7 @@ void gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) { s->gc_countdown = GC_INTERVAL - 1; // Time state: - s->last_wait_time = g_system->getMillis(); + s->lastWaitTime = g_system->getMillis(); s->game_start_time = g_system->getMillis(); #ifdef USE_OLD_MUSIC_FUNCTIONS diff --git a/engines/sci/engine/scriptdebug.cpp b/engines/sci/engine/scriptdebug.cpp index 159c278e8c..436eaafec5 100644 --- a/engines/sci/engine/scriptdebug.cpp +++ b/engines/sci/engine/scriptdebug.cpp @@ -284,7 +284,7 @@ void script_debug(EngineState *s) { #if 0 if (sci_debug_flags & _DEBUG_FLAG_LOGGING) { - printf("%d: acc=%04x:%04x ", script_step_counter, PRINT_REG(s->r_acc)); + printf("%d: acc=%04x:%04x ", scriptStepCounter, PRINT_REG(s->r_acc)); disassemble(s, s->xs->addr.pc, 0, 1); if (s->seeking == kDebugSeekGlobal) printf("Global %d (0x%x) = %04x:%04x\n", s->seekSpecial, @@ -351,7 +351,7 @@ void script_debug(EngineState *s) { } } - printf("Step #%d\n", s->script_step_counter); + printf("Step #%d\n", s->scriptStepCounter); disassemble(s, s->xs->addr.pc, 0, 1); if (g_debugState.runningStep) { diff --git a/engines/sci/engine/state.cpp b/engines/sci/engine/state.cpp index 367a9b78b9..8e4a5200c8 100644 --- a/engines/sci/engine/state.cpp +++ b/engines/sci/engine/state.cpp @@ -95,7 +95,7 @@ void EngineState::reset(bool isRestoring) { abortScriptProcessing = kAbortNone; } - execution_stack_base = 0; + executionStackBase = 0; _executionStackPosChanged = false; restAdjust = 0; @@ -103,7 +103,7 @@ void EngineState::reset(bool isRestoring) { r_acc = NULL_REG; r_prev = NULL_REG; - last_wait_time = 0; + lastWaitTime = 0; gc_countdown = 0; @@ -111,14 +111,14 @@ void EngineState::reset(bool isRestoring) { _throttleLastTime = 0; _throttleTrigger = false; - script_step_counter = 0; - script_gc_interval = GC_INTERVAL; + scriptStepCounter = 0; + scriptGCInterval = GC_INTERVAL; } void EngineState::wait(int16 ticks) { uint32 time = g_system->getMillis(); - r_acc = make_reg(0, ((long)time - (long)last_wait_time) * 60 / 1000); - last_wait_time = time; + r_acc = make_reg(0, ((long)time - (long)lastWaitTime) * 60 / 1000); + lastWaitTime = time; ticks *= g_debug_sleeptime_factor; g_sci->getEventManager()->sleep(ticks * 1000 / 60); @@ -144,7 +144,7 @@ void EngineState::setRoomNumber(uint16 roomNumber) { } void EngineState::shrinkStackToBase() { - uint size = execution_stack_base + 1; + uint size = executionStackBase + 1; assert(_executionStack.size() >= size); Common::List<ExecStack>::iterator iter = _executionStack.begin(); for (uint i = 0; i < size; ++i) @@ -268,15 +268,20 @@ kLanguage SciEngine::getSciLanguage() { default: lang = K_LANG_ENGLISH; } - - // Store language in printLang selector - writeSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(printLang), lang); } } return lang; } +void SciEngine::setSciLanguage(kLanguage lang) { + writeSelectorValue(_gamestate->_segMan, _gameObj, SELECTOR(printLang), lang); +} + +void SciEngine::setSciLanguage() { + setSciLanguage(getSciLanguage()); +} + Common::String SciEngine::strSplit(const char *str, const char *sep) { kLanguage lang = getSciLanguage(); kLanguage subLang = K_LANG_NONE; diff --git a/engines/sci/engine/state.h b/engines/sci/engine/state.h index 32da83b162..fd2380667b 100644 --- a/engines/sci/engine/state.h +++ b/engines/sci/engine/state.h @@ -112,7 +112,7 @@ public: SoundCommandParser *_soundCmd; uint32 game_start_time; /**< The time at which the interpreter was started */ - uint32 last_wait_time; /**< The last time the game invoked Wait() */ + uint32 lastWaitTime; /**< The last time the game invoked Wait() */ void wait(int16 ticks); @@ -134,7 +134,7 @@ public: * When called from kernel functions, the vm is re-started recursively on * the same stack. This variable contains the stack base for the current vm. */ - int execution_stack_base; + int executionStackBase; bool _executionStackPosChanged; /**< Set to true if the execution stack position should be re-evaluated by the vm */ reg_t r_acc; /**< Accumulator */ @@ -156,8 +156,8 @@ public: AbortGameState abortScriptProcessing; bool gameWasRestarted; - int script_step_counter; // Counts the number of steps executed - int script_gc_interval; // Number of steps in between gcs + int scriptStepCounter; // Counts the number of steps executed + int scriptGCInterval; // Number of steps in between gcs uint16 currentRoomNumber() const; void setRoomNumber(uint16 roomNumber); @@ -169,7 +169,7 @@ public: /** * Shrink execution stack to size. - * Contains an assert it is not already smaller. + * Contains an assert if it is not already smaller. */ void shrinkStackToBase(); diff --git a/engines/sci/engine/vm.cpp b/engines/sci/engine/vm.cpp index f99ae817bf..a203352dcd 100644 --- a/engines/sci/engine/vm.cpp +++ b/engines/sci/engine/vm.cpp @@ -631,7 +631,7 @@ static void callKernelFunc(EngineState *s, int kernelFuncNum, int argc) { static void gc_countdown(EngineState *s) { if (s->gc_countdown-- <= 0) { - s->gc_countdown = s->script_gc_interval; + s->gc_countdown = s->scriptGCInterval; run_gc(s); } } @@ -726,7 +726,7 @@ void run_vm(EngineState *s, bool restoring) { ExecStack *xs_new = NULL; Object *obj = s->_segMan->getObject(s->xs->objp); Script *local_script = s->_segMan->getScriptIfLoaded(s->xs->local_segment); - int old_execution_stack_base = s->execution_stack_base; + int old_executionStackBase = s->executionStackBase; // Used to detect the stack bottom, for "physical" returns const byte *code_buf = NULL; // (Avoid spurious warning) @@ -735,7 +735,7 @@ void run_vm(EngineState *s, bool restoring) { } if (!restoring) - s->execution_stack_base = s->_executionStack.size() - 1; + s->executionStackBase = s->_executionStack.size() - 1; s->variables_seg[VAR_TEMP] = s->variables_seg[VAR_PARAM] = s->_segMan->findSegmentByType(SEG_TYPE_STACK); s->variables_base[VAR_TEMP] = s->variables_base[VAR_PARAM] = s->stack_base; @@ -1179,8 +1179,8 @@ void run_vm(EngineState *s, bool restoring) { StackPtr old_fp = s->xs->fp; ExecStack *old_xs = &(s->_executionStack.back()); - if ((int)s->_executionStack.size() - 1 == s->execution_stack_base) { // Have we reached the base? - s->execution_stack_base = old_execution_stack_base; // Restore stack base + if ((int)s->_executionStack.size() - 1 == s->executionStackBase) { // Have we reached the base? + s->executionStackBase = old_executionStackBase; // Restore stack base s->_executionStack.pop_back(); @@ -1661,7 +1661,7 @@ void run_vm(EngineState *s, bool restoring) { opcode); } //#endif - ++s->script_step_counter; + ++s->scriptStepCounter; } } diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 3a3c147cb6..2b3194830d 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -304,7 +304,7 @@ bool SciEngine::initGame() { _gamestate->r_acc = _gamestate->r_prev = NULL_REG; _gamestate->_executionStack.clear(); // Start without any execution stack - _gamestate->execution_stack_base = -1; // No vm is running yet + _gamestate->executionStackBase = -1; // No vm is running yet _gamestate->_executionStackPosChanged = false; _gamestate->abortScriptProcessing = kAbortNone; @@ -325,7 +325,7 @@ bool SciEngine::initGame() { _vocabulary->parser_base = make_reg(_gamestate->_segMan->getSysStringsSegment(), SYS_STRING_PARSER_BASE); } - _gamestate->game_start_time = _gamestate->last_wait_time = g_system->getMillis(); + _gamestate->game_start_time = _gamestate->lastWaitTime = g_system->getMillis(); srand(g_system->getMillis()); // Initialize random number generator @@ -335,9 +335,7 @@ bool SciEngine::initGame() { #endif // Load game language into printLang property of game object - // FIXME: It's evil to achieve this as a side effect of a getter. - // Much better to have an explicit init method for this. - getSciLanguage(); + setSciLanguage(); return true; } diff --git a/engines/sci/sci.h b/engines/sci/sci.h index 4096019a86..eb2b82fdce 100644 --- a/engines/sci/sci.h +++ b/engines/sci/sci.h @@ -187,6 +187,8 @@ public: Common::String strSplit(const char *str, const char *sep = "\r----------\r"); kLanguage getSciLanguage(); + void setSciLanguage(kLanguage lang); + void setSciLanguage(); Common::String getSciLanguageString(const char *str, kLanguage lang, kLanguage *lang2 = NULL) const; |