From 7dec2bd6a8f363b389b48364cdf8b286c6400b7e Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Wed, 10 Nov 2010 01:08:17 +0000 Subject: [PATCH] SCI: Some SCI3 changes - Extended the SCI2.1 kernel function signatures for SCI3, as they share the same kernel table - All the engine parts are now initialized in SCI3 games, apart from the VM svn-id: r54178 --- engines/sci/engine/kernel_tables.h | 4 +- engines/sci/sci.cpp | 111 +++++++++++++++-------------- 2 files changed, 60 insertions(+), 55 deletions(-) diff --git a/engines/sci/engine/kernel_tables.h b/engines/sci/engine/kernel_tables.h index c59307b7f9e..141e191e474 100644 --- a/engines/sci/engine/kernel_tables.h +++ b/engines/sci/engine/kernel_tables.h @@ -59,7 +59,7 @@ struct SciKernelMapSubEntry { #define SIG_SCI1 SCI_VERSION_1_EGA, SCI_VERSION_1_LATE #define SIG_SCI11 SCI_VERSION_1_1, SCI_VERSION_1_1 #define SIG_SINCE_SCI11 SCI_VERSION_1_1, SCI_VERSION_NONE -#define SIG_SCI21 SCI_VERSION_2_1, SCI_VERSION_2_1 +#define SIG_SCI21 SCI_VERSION_2_1, SCI_VERSION_3 #define SIG_SCI16 SCI_VERSION_NONE, SCI_VERSION_1_1 #define SIG_SCI32 SCI_VERSION_2, SCI_VERSION_NONE @@ -68,7 +68,7 @@ struct SciKernelMapSubEntry { #define SIG_SOUNDSCI0 SCI_VERSION_0_EARLY, SCI_VERSION_0_LATE #define SIG_SOUNDSCI1EARLY SCI_VERSION_1_EARLY, SCI_VERSION_1_EARLY #define SIG_SOUNDSCI1LATE SCI_VERSION_1_LATE, SCI_VERSION_1_LATE -#define SIG_SOUNDSCI21 SCI_VERSION_2_1, SCI_VERSION_2_1 +#define SIG_SOUNDSCI21 SCI_VERSION_2_1, SCI_VERSION_3 #define SIGFOR_ALL 0x3f #define SIGFOR_DOS 1 << 0 diff --git a/engines/sci/sci.cpp b/engines/sci/sci.cpp index 60b4ad40989..a3cf1ff0431 100644 --- a/engines/sci/sci.cpp +++ b/engines/sci/sci.cpp @@ -224,37 +224,30 @@ Common::Error SciEngine::run() { _audio = new AudioPlayer(_resMan); _gamestate = new EngineState(segMan); _eventMan = new EventManager(_resMan->detectFontExtended()); - - // TODO/FIXME: Remove once SCI3 support is improved + if (getSciVersion() == SCI_VERSION_3) { - initGraphics(); // invoked to init the graphics subsystem + // TODO: SCI3 equivalent + warning("SCI3 game - skipping VM initialization"); _gamestate->_msgState = NULL; // for proper engine destruction - // Attach the console to use resource manager functionality - _console->attach(); - _console->DebugPrintf("\nSCI3 game, stopping before actual game initialization.\n" - "Resource-related functionality should be usable at this point\n\n"); - _console->onFrame(); + } else { + // The game needs to be initialized before the graphics system is initialized, as + // the graphics code checks parts of the seg manager upon initialization (e.g. for + // the presence of the fastCast object) + if (!initGame()) { /* Initialize */ + warning("Game initialization failed: Aborting..."); + // TODO: Add an "init failed" error? + return Common::kUnknownError; + } - return Common::kNoError; + // we try to find the super class address of the game object, we can't do that earlier + const Object *gameObject = segMan->getObject(_gameObjectAddress); + if (!gameObject) { + warning("Could not get game object, aborting..."); + return Common::kUnknownError; + } + _gameSuperClassAddress = gameObject->getSuperClassSelector(); } - // The game needs to be initialized before the graphics system is initialized, as - // the graphics code checks parts of the seg manager upon initialization (e.g. for - // the presence of the fastCast object) - if (!initGame()) { /* Initialize */ - warning("Game initialization failed: Aborting..."); - // TODO: Add an "init failed" error? - return Common::kUnknownError; - } - - // we try to find the super class address of the game object, we can't do that earlier - const Object *gameObject = segMan->getObject(_gameObjectAddress); - if (!gameObject) { - warning("Could not get game object, aborting..."); - return Common::kUnknownError; - } - _gameSuperClassAddress = gameObject->getSuperClassSelector(); - script_adjust_opcode_formats(); // Must be called after game_init(), as they use _features @@ -268,38 +261,40 @@ Common::Error SciEngine::run() { debug("Emulating SCI version %s\n", getSciVersionDesc(getSciVersion())); - // Patch in our save/restore code, so that dialogs are replaced - patchGameSaveRestore(segMan); + if (getSciVersion() <= SCI_VERSION_2_1) { // TODO/FIXME: Enable for SCI3 once the VM is done + // Patch in our save/restore code, so that dialogs are replaced + patchGameSaveRestore(segMan); - if (_gameDescription->flags & ADGF_ADDENGLISH) { - // if game is multilingual - Common::Language selectedLanguage = Common::parseLanguage(ConfMan.get("language")); - if (selectedLanguage == Common::EN_ANY) { - // and english was selected as language - if (SELECTOR(printLang) != -1) // set text language to english - writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(printLang), 1); - if (SELECTOR(parseLang) != -1) // and set parser language to english as well - writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(parseLang), 1); + if (_gameDescription->flags & ADGF_ADDENGLISH) { + // if game is multilingual + Common::Language selectedLanguage = Common::parseLanguage(ConfMan.get("language")); + if (selectedLanguage == Common::EN_ANY) { + // and english was selected as language + if (SELECTOR(printLang) != -1) // set text language to english + writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(printLang), 1); + if (SELECTOR(parseLang) != -1) // and set parser language to english as well + writeSelectorValue(segMan, _gameObjectAddress, SELECTOR(parseLang), 1); + } } - } - // Check whether loading a savestate was requested - int directSaveSlotLoading = ConfMan.getInt("save_slot"); - if (directSaveSlotLoading >= 0) { - // call GameObject::play (like normally) - initStackBaseWithSelector(SELECTOR(play)); - // We set this, so that the game automatically quit right after init - _gamestate->variables[VAR_GLOBAL][4] = TRUE_REG; + // Check whether loading a savestate was requested + int directSaveSlotLoading = ConfMan.getInt("save_slot"); + if (directSaveSlotLoading >= 0) { + // call GameObject::play (like normally) + initStackBaseWithSelector(SELECTOR(play)); + // We set this, so that the game automatically quit right after init + _gamestate->variables[VAR_GLOBAL][4] = TRUE_REG; - _gamestate->_executionStackPosChanged = false; - run_vm(_gamestate); + _gamestate->_executionStackPosChanged = false; + run_vm(_gamestate); - // As soon as we get control again, actually restore the game - reg_t restoreArgv[2] = { NULL_REG, make_reg(0, directSaveSlotLoading) }; // special call (argv[0] is NULL) - kRestoreGame(_gamestate, 2, restoreArgv); + // As soon as we get control again, actually restore the game + reg_t restoreArgv[2] = { NULL_REG, make_reg(0, directSaveSlotLoading) }; // special call (argv[0] is NULL) + kRestoreGame(_gamestate, 2, restoreArgv); - // this indirectly calls GameObject::init, which will setup menu, text font/color codes etc. - // without this games would be pretty badly broken + // this indirectly calls GameObject::init, which will setup menu, text font/color codes etc. + // without this games would be pretty badly broken + } } // Show any special warnings for buggy scripts with severe game bugs, @@ -362,7 +357,17 @@ Common::Error SciEngine::run() { "having unexpected errors and/or issues later on."); } - runGame(); + + // TODO/FIXME: Remove once SCI3 support is improved + if (getSciVersion() == SCI_VERSION_3) { + // Attach the console to use resource manager functionality + _console->attach(); + _console->DebugPrintf("\nSCI3 game, stopping before actual game entry point.\n" + "Resource-related functionality should be usable at this point\n\n"); + _console->onFrame(); + } else { + runGame(); + } ConfMan.flushToDisk();