LastExpressEngine::LastExpressEngine(OSystem *syst, const ADGameDescription *gd) : Engine(syst), _gameDescription(gd), _debugger(NULL), _cursor(NULL), _font(NULL), _logic(NULL), _menu(NULL), _frameCounter(0), _lastFrameCount(0), _graphicsMan(NULL), _resMan(NULL), _sceneMan(NULL), _soundMan(NULL), _eventMouse(NULL), _eventTick(NULL), _eventMouseBackup(NULL), _eventTickBackup(NULL) { // Setup mixer syncSoundSettings(); // Adding the default directories const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "data"); // Initialize the custom debug levels DebugMan.addDebugChannel(kLastExpressDebugAll, "All", "Debug everything"); DebugMan.addDebugChannel(kLastExpressDebugGraphics, "Graphics", "Debug graphics & animation/sequence playback"); DebugMan.addDebugChannel(kLastExpressDebugResource, "Resource", "Debug resource management"); DebugMan.addDebugChannel(kLastExpressDebugCursor, "Cursor", "Debug cursor handling"); DebugMan.addDebugChannel(kLastExpressDebugSound, "Sound", "Debug sound playback"); DebugMan.addDebugChannel(kLastExpressDebugSubtitle, "Subtitle", "Debug subtitles"); DebugMan.addDebugChannel(kLastExpressDebugSavegame, "Savegame", "Debug savegames"); DebugMan.addDebugChannel(kLastExpressDebugLogic, "Logic", "Debug logic"); DebugMan.addDebugChannel(kLastExpressDebugScenes, "Scenes", "Debug scenes & hotspots"); DebugMan.addDebugChannel(kLastExpressDebugUnknown, "Unknown", "Debug unknown data"); g_eventRec.registerRandomSource(_random, "lastexpress"); }
MadeEngine::MadeEngine(OSystem *syst, const MadeGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { const GameSettings *g; const char *gameid = ConfMan.get("gameid").c_str(); for (g = madeSettings; g->gameid; ++g) if (!scumm_stricmp(g->gameid, gameid)) _gameId = g->id; _rnd = new Common::RandomSource(); syst->getEventManager()->registerRandomSource(*_rnd, "made"); int cd_num = ConfMan.getInt("cdrom"); if (cd_num >= 0) _system->openCD(cd_num); _pmvPlayer = new PmvPlayer(this, _mixer); _res = new ResourceReader(); _screen = new Screen(this); if (getGameID() == GID_LGOP2 || getGameID() == GID_MANHOLE || getGameID() == GID_RODNEY) { _dat = new GameDatabaseV2(this); } else if (getGameID() == GID_RTZ) { _dat = new GameDatabaseV3(this); } else { error("Unknown GameID"); } _script = new ScriptInterpreter(this); int midiDriver = MidiDriver::detectMusicDriver(MDT_MIDI | MDT_ADLIB | MDT_PREFER_MIDI); bool native_mt32 = ((midiDriver == MD_MT32) || ConfMan.getBool("native_mt32")); //bool adlib = (midiDriver == MD_ADLIB); MidiDriver *driver = MidiDriver::createMidi(midiDriver); if (native_mt32) driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); _music = new MusicPlayer(driver); _music->setNativeMT32(native_mt32); //_music->setAdlib(adlib); // Set default sound frequency switch (getGameID()) { case GID_RODNEY: _soundRate = 11025; break; case GID_MANHOLE: _soundRate = 11025; break; case GID_LGOP2: _soundRate = 8000; break; case GID_RTZ: // Return to Zork sets it itself via a script funtion break; } syncSoundSettings(); }
void Engine::openMainMenuDialog() { if (!_mainMenuDialog) _mainMenuDialog = new MainMenuDialog(this); setGameToLoadSlot(-1); runDialog(*_mainMenuDialog); // Load savegame after main menu execution // (not from inside the menu loop to avoid // mouse cursor glitches and simliar bugs, // e.g. #2822778). if (_saveSlotToLoad >= 0) { Common::Error status = loadGameState(_saveSlotToLoad); if (status.getCode() != Common::kNoError) { Common::String failMessage = Common::String::format(_("Failed to load saved game (%s)! " "Please consult the README for basic information, and for " "instructions on how to obtain further assistance."), status.getDesc().c_str()); GUI::MessageDialog dialog(failMessage); dialog.runModal(); } } syncSoundSettings(); }
bool XeenEngine::initialize() { // Create sub-objects of the engine _files = new FileManager(this); if (!_files->setup()) return false; _resources = new Resources(); _combat = new Combat(this); _debugger = new Debugger(this); _events = new EventsManager(this); _interface = new Interface(this); _locations = new LocationManager(); _map = new Map(this); _party = new Party(this); _patcher = new Patcher(); _saves = new SavesManager(_targetName); _screen = new Screen(this); _scripts = new Scripts(this); _sound = new Sound(_mixer); _spells = new Spells(this); _windows = new Windows(); // Set graphics mode initGraphics(SCREEN_WIDTH, SCREEN_HEIGHT); // Setup mixer syncSoundSettings(); // Load settings loadSettings(); return true; }
void TSageEngine::initialize() { _saver = new Saver(); // Set up the resource manager _resourceManager = new ResourceManager(); if (_vm->getFeatures() & GF_DEMO) { // Add the single library file associated with the demo _resourceManager->addLib(getPrimaryFilename()); } else if (_vm->getGameID() == GType_Ringworld) { _resourceManager->addLib("RING.RLB"); _resourceManager->addLib("TSAGE.RLB"); } else if (_vm->getGameID() == GType_BlueForce) { _resourceManager->addLib("BLUE.RLB"); if (_vm->getFeatures() & GF_FLOPPY) { _resourceManager->addLib("FILES.RLB"); _resourceManager->addLib("TSAGE.RLB"); } } _globals = new Globals(); _globals->gfxManager().setDefaults(); // Setup sound settings syncSoundSettings(); }
Common::Error QueenEngine::run() { initGraphics(GAME_SCREEN_WIDTH, GAME_SCREEN_HEIGHT, false); _resource = new Resource(); _bam = new BamScene(this); _bankMan = new BankManager(_resource); _command = new Command(this); _debugger = new Debugger(this); _display = new Display(this, _system); _graphics = new Graphics(this); _grid = new Grid(this); _input = new Input(_resource->getLanguage(), _system, this); if (_resource->isDemo()) { _logic = new LogicDemo(this); } else if (_resource->isInterview()) { _logic = new LogicInterview(this); } else { _logic = new LogicGame(this); } _sound = Sound::makeSoundInstance(_mixer, this, _resource->getCompression()); _walk = new Walk(this); //_talkspeedScale = (MAX_TEXT_SPEED - MIN_TEXT_SPEED) / 255.0; registerDefaultSettings(); // Setup mixer syncSoundSettings(); _logic->start(); if (ConfMan.hasKey("save_slot") && canLoadOrSave()) { loadGameState(ConfMan.getInt("save_slot")); } _lastSaveTime = _lastUpdateTime = _system->getMillis(); while (!shouldQuit()) { if (_logic->newRoom() > 0) { _logic->update(); _logic->oldRoom(_logic->currentRoom()); _logic->currentRoom(_logic->newRoom()); _logic->changeRoom(); _display->fullscreen(false); if (_logic->currentRoom() == _logic->newRoom()) { _logic->newRoom(0); } } else if (_logic->joeWalk() == JWM_EXECUTE) { _logic->joeWalk(JWM_NORMAL); _command->executeCurrentAction(); } else { _logic->joeWalk(JWM_NORMAL); update(true); } } return Common::kNoError; }
Common::Error MadeEngine::run() { _music = new MusicPlayer(getGameID() == GID_RTZ); syncSoundSettings(); // Initialize backend initGraphics(320, 200, false); resetAllTimers(); if (getGameID() == GID_RTZ) { if (getFeatures() & GF_DEMO) { _dat->open("demo.dat"); _res->open("demo.prj"); } else if (getFeatures() & GF_CD) { _dat->open("rtzcd.dat"); _res->open("rtzcd.prj"); } else if (getFeatures() & GF_CD_COMPRESSED) { _dat->openFromRed("rtzcd.red", "rtzcd.dat"); _res->open("rtzcd.prj"); } else if (getFeatures() & GF_FLOPPY) { _dat->open("rtz.dat"); _res->open("rtz.prj"); } else { error("Unknown RTZ game features"); } } else if (getGameID() == GID_MANHOLE) { _dat->open("manhole.dat"); if (getVersion() == 2) { _res->open("manhole.prj"); } else { _res->openResourceBlocks(); } } else if (getGameID() == GID_LGOP2) { _dat->open("lgop2.dat"); _res->open("lgop2.prj"); } else if (getGameID() == GID_RODNEY) { _dat->open("rodneys.dat"); _res->open("rodneys.prj"); } else { error ("Unknown MADE game"); } if ((getFeatures() & GF_CD) || (getFeatures() & GF_CD_COMPRESSED)) checkCD(); _autoStopSound = false; _eventNum = _eventKey = _eventMouseX = _eventMouseY = 0; #ifdef DUMP_SCRIPTS _script->dumpAllScripts(); #else _screen->setDefaultMouseCursor(); _script->runScript(_dat->getMainCodeObjectIndex()); #endif return Common::kNoError; }
AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) { // Setup mixer syncSoundSettings(); parseFeatures(); DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level"); DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging"); DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging"); DebugMan.addDebugChannel(kDebugLevelInventory, "Inventory", "Inventory debugging"); DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging"); DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging"); DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging"); DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging"); DebugMan.addDebugChannel(kDebugLevelText, "Text", "Text output debugging"); DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging"); memset(&_game, 0, sizeof(struct AgiGame)); memset(&_debug, 0, sizeof(struct AgiDebug)); memset(&_mouse, 0, sizeof(struct Mouse)); _game._vm = this; _game.clockEnabled = false; _game.state = STATE_INIT; _keyQueueStart = 0; _keyQueueEnd = 0; _allowSynthetic = false; _intobj = NULL; _menu = NULL; _menuSelected = false; _lastSentence[0] = 0; memset(&_stringdata, 0, sizeof(struct StringData)); _objects = NULL; _restartGame = false; _oldMode = INPUT_NONE; _firstSlot = 0; resetControllers(); setupOpcodes(); _game._curLogic = NULL; _timerHack = 0; }
void TSageEngine::initialize() { // Set up the correct graphics mode init(); g_saver = new Saver(); // Set up the resource manager g_resourceManager = new ResourceManager(); if (g_vm->getGameID() == GType_Ringworld) { if (g_vm->getFeatures() & GF_DEMO) { // Add the single library file associated with the demo g_resourceManager->addLib(getPrimaryFilename()); g_globals = new Globals(); } else { g_resourceManager->addLib("RING.RLB"); g_resourceManager->addLib("TSAGE.RLB"); g_globals = new Globals(); } } else if (g_vm->getGameID() == GType_BlueForce) { g_resourceManager->addLib("BLUE.RLB"); if (g_vm->getFeatures() & GF_FLOPPY) { g_resourceManager->addLib("FILES.RLB"); g_resourceManager->addLib("TSAGE.RLB"); } g_globals = new BlueForce::BlueForceGlobals(); // Setup the user interface T2_GLOBALS._uiElements.setup(Common::Point(0, UI_INTERFACE_Y - 2)); // Reset all global variables BF_GLOBALS.reset(); } else if (g_vm->getGameID() == GType_Ringworld2) { g_resourceManager->addLib("R2RW.RLB"); g_globals = new Ringworld2::Ringworld2Globals(); // Setup the user interface T2_GLOBALS._uiElements.setup(Common::Point(0, UI_INTERFACE_Y)); // Reset all global variables R2_GLOBALS.reset(); } else if (g_vm->getGameID() == GType_Sherlock1) { #ifdef TSAGE_SHERLOCK_ENABLED g_resourceManager->addLib("SF3.RLB"); g_globals = new Globals(); return; #endif } g_globals->gfxManager().setDefaults(); // Setup sound settings syncSoundSettings(); }
MohawkEngine::MohawkEngine(OSystem *syst, const MohawkGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc) { if (!_mixer->isReady()) error ("Sound initialization failed"); // Setup mixer syncSoundSettings(); _video = 0; _pauseDialog = 0; _cursor = 0; }
Sword25Engine::Sword25Engine(OSystem *syst, const ADGameDescription *gameDesc): Engine(syst), _gameDescription(gameDesc) { // Setup mixer syncSoundSettings(); DebugMan.addDebugChannel(kDebugScript, "Script", "Script debug level"); DebugMan.addDebugChannel(kDebugScript, "Scripts", "Script debug level"); DebugMan.addDebugChannel(kDebugSound, "Sound", "Sound debug level"); _console = new Sword25Console(this); }
CruiseEngine::CruiseEngine(OSystem * syst, const CRUISEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _rnd("cruise") { DebugMan.addDebugChannel(kCruiseDebugScript, "scripts", "Scripts debug level"); DebugMan.addDebugChannel(kCruiseDebugSound, "sound", "Sound debug level"); _vm = this; _debugger = new Debugger(); _sound = new PCSound(_mixer, this); // Setup mixer syncSoundSettings(); }
CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { // Setup mixer syncSoundSettings(); DebugMan.addDebugChannel(kCineDebugScript, "Script", "Script debug level"); DebugMan.addDebugChannel(kCineDebugPart, "Part", "Part debug level"); DebugMan.addDebugChannel(kCineDebugSound, "Sound", "Sound debug level"); DebugMan.addDebugChannel(kCineDebugCollision, "Collision", "Collision debug level"); _console = new CineConsole(this); g_cine = this; g_eventRec.registerRandomSource(_rnd, "cine"); }
void SherlockEngine::loadConfig() { // Load sound settings syncSoundSettings(); ConfMan.registerDefault("font", getGameID() == GType_SerratedScalpel ? 1 : 4); _screen->setFont(ConfMan.getInt("font")); if (getGameID() == GType_SerratedScalpel) _screen->_fadeStyle = ConfMan.getBool("fade_style"); _ui->_helpStyle = ConfMan.getBool("help_style"); _ui->_slideWindows = ConfMan.getBool("window_style"); _people->_portraitsOn = ConfMan.getBool("portraits_on"); }
void Engine::flipMute() { // Mute will be set to true by default here. This has two reasons: // - if the game already has an "mute" config entry, it will be overwritten anyway. // - if it does not have a "mute" config entry, the sound is unmuted currently and should be muted now. bool mute = true; if (ConfMan.hasKey("mute")) { mute = !ConfMan.getBool("mute"); } ConfMan.setBool("mute", mute); syncSoundSettings(); }
Common::Error LureEngine::init() { int_engine = this; _initialized = false; _saveLoadAllowed = false; initGraphics(FULL_SCREEN_WIDTH, FULL_SCREEN_HEIGHT, false); // Check the version of the lure.dat file Common::File f; VersionStructure version; if (!f.open(SUPPORT_FILENAME)) { GUIError("Could not locate Lure support file"); return Common::kUnknownError; } f.seek(0xbf * 8); f.read(&version, sizeof(VersionStructure)); f.close(); if (READ_LE_UINT16(&version.id) != 0xffff) { GUIError("Error validating %s - file is invalid or out of date", SUPPORT_FILENAME); return Common::kUnknownError; } else if ((version.vMajor != LURE_DAT_MAJOR) || (version.vMinor != LURE_DAT_MINOR)) { GUIError("Incorrect version of %s file - expected %d.%d but got %d.%d", SUPPORT_FILENAME, LURE_DAT_MAJOR, LURE_DAT_MINOR, version.vMajor, version.vMinor); return Common::kUnknownError; } _disk = new Disk(); _resources = new Resources(); _strings = new StringData(); _screen = new Screen(*_system); _mouse = new Mouse(); _events = new Events(); _menu = new Menu(); Surface::initialize(); _room = new Room(); _fights = new FightsManager(); _gameToLoad = -1; _initialized = true; // Setup mixer syncSoundSettings(); return Common::kNoError; }
Common::Error DreamWebEngine::run() { syncSoundSettings(); _console = new DreamWebConsole(this); ConfMan.registerDefault("dreamweb_originalsaveload", "false"); _hasSpeech = Common::File::exists("speech/r01c0000.raw") && !ConfMan.getBool("speech_mute"); _timer->installTimerProc(vSyncInterrupt, 1000000 / 70, this, "dreamwebVSync"); dreamweb(); dreamwebFinalize(); _quitRequested = false; _timer->removeTimerProc(vSyncInterrupt); return Common::kNoError; }
TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _randomSource("tony") { g_vm = this; _loadSlotNumber = -1; // Set the up the debugger _debugger = new Debugger(); DebugMan.addDebugChannel(kTonyDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging"); DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging"); DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging"); // Add folders to the search directory list const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "Voices"); SearchMan.addSubDirectoryMatching(gameDataDir, "Roasted"); SearchMan.addSubDirectoryMatching(gameDataDir, "Music"); SearchMan.addSubDirectoryMatching(gameDataDir, "Music/utilsfx"); SearchMan.addSubDirectoryMatching(gameDataDir, "Music/Layer"); // Set up load slot number _initialLoadSlotNumber = -1; if (ConfMan.hasKey("save_slot")) { int slotNumber = ConfMan.getInt("save_slot"); if (slotNumber >= 0 && slotNumber <= 99) _initialLoadSlotNumber = slotNumber; } // Load the ScummVM sound settings syncSoundSettings(); _hEndOfFrame = 0; for (int i = 0; i < 6; i++) _stream[i] = NULL; for (int i = 0; i < MAX_SFX_CHANNELS; i++) { _sfx[i] = NULL; _utilSfx[i] = NULL; } _bPaused = false; _bDrawLocation = false; _startTime = 0; _curThumbnail = NULL; _bQuitNow = false; _bTimeFreezed = false; _nTimeFreezed = 0; _vdbCodec = FPCODEC_UNKNOWN; }
void SciEngine::runGame() { setTotalPlayTime(0); initStackBaseWithSelector(SELECTOR(play)); // Call the play selector // Attach the debug console on game startup, if requested if (DebugMan.isDebugChannelEnabled(kDebugLevelOnStartup)) _console->attach(); _gamestate->_syncedAudioOptions = false; do { _gamestate->_executionStackPosChanged = false; run_vm(_gamestate); exitGame(); _gamestate->_syncedAudioOptions = true; if (_gamestate->abortScriptProcessing == kAbortRestartGame) { _gamestate->_segMan->resetSegMan(); initGame(); initStackBaseWithSelector(SELECTOR(play)); patchGameSaveRestore(); setLauncherLanguage(); _gamestate->gameIsRestarting = GAMEISRESTARTING_RESTART; _gamestate->_throttleLastTime = 0; if (_gfxMenu) _gfxMenu->reset(); _gamestate->abortScriptProcessing = kAbortNone; _gamestate->_syncedAudioOptions = false; } else if (_gamestate->abortScriptProcessing == kAbortLoadGame) { _gamestate->abortScriptProcessing = kAbortNone; _gamestate->_executionStack.clear(); initStackBaseWithSelector(SELECTOR(replay)); patchGameSaveRestore(); setLauncherLanguage(); _gamestate->shrinkStackToBase(); _gamestate->abortScriptProcessing = kAbortNone; syncSoundSettings(); syncIngameAudioOptions(); // Games do not set their audio settings when loading } else { break; // exit loop } } while (true); }
TinselEngine::TinselEngine(OSystem *syst, const TinselGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _random("tinsel") { _vm = this; _config = new Config(this); // Register debug flags DebugMan.addDebugChannel(kTinselDebugAnimations, "animations", "Animations debugging"); DebugMan.addDebugChannel(kTinselDebugActions, "actions", "Actions debugging"); DebugMan.addDebugChannel(kTinselDebugSound, "sound", "Sound debugging"); DebugMan.addDebugChannel(kTinselDebugMusic, "music", "Music debugging"); // Setup mixer syncSoundSettings(); // Add DW2 subfolder to search path in case user is running directly from the CDs const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "dw2"); // Add subfolders needed for psx versions of Discworld 1 if (TinselV1PSX) SearchMan.addDirectory(gameDataDir.getPath(), gameDataDir, 0, 3, true); const GameSettings *g; const char *gameid = ConfMan.get("gameid").c_str(); for (g = tinselSettings; g->gameid; ++g) if (!scumm_stricmp(g->gameid, gameid)) _gameId = g->id; int cd_num = ConfMan.getInt("cdrom"); if (cd_num >= 0) _system->getAudioCDManager()->openCD(cd_num); _midiMusic = new MidiMusicPlayer(); _pcmMusic = new PCMMusicPlayer(); _sound = new SoundManager(this); _bmv = new BMVPlayer(); _mousePos.x = 0; _mousePos.y = 0; _keyHandler = NULL; _dosPlayerDir = 0; }
Common::Error PinkEngine::init() { debugC(10, kPinkDebugGeneral, "PinkEngine init"); initGraphics(640, 480); Common::PEResources exeResources; Common::String fileName = isPeril() ? "pptp.exe" : "hpp.exe"; if (!exeResources.loadFromEXE(fileName)) { return Common::kNoGameDataFoundError; } _console = new Console(this); _director = new Director(); initMenu(exeResources); Common::String orbName; Common::String broName; if (isPeril()) { orbName = "PPTP.ORB"; broName = "PPTP.BRO"; _bro = new BroFile; } else { orbName = "HPP.ORB"; } if (!_orb.open(orbName) || (_bro && !_bro->open(broName) && _orb.getTimestamp() == _bro->getTimestamp())) return Common::kNoGameDataFoundError; if (!loadCursors(exeResources)) return Common::kNoGameDataFoundError; setCursor(kLoadingCursor); _orb.loadGame(this); debugC(6, kPinkDebugGeneral, "Modules are loaded"); syncSoundSettings(); if (ConfMan.hasKey("save_slot")) loadGameState(ConfMan.getInt("save_slot")); else initModule(_modules[0]->getName(), "", nullptr); return Common::kNoError; }
DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _rnd("director") { DebugMan.addDebugChannel(kDebugLingoExec, "lingoexec", "Lingo Execution"); DebugMan.addDebugChannel(kDebugLingoCompile, "lingocompile", "Lingo Compilation"); DebugMan.addDebugChannel(kDebugLoading, "loading", "Loading"); DebugMan.addDebugChannel(kDebugImages, "images", "Image drawing"); DebugMan.addDebugChannel(kDebugText, "text", "Text rendering"); if (!_mixer->isReady()) error("Sound initialization failed"); // Setup mixer syncSoundSettings(); _sharedCasts = nullptr; _currentScore = nullptr; _soundManager = nullptr; _currentPalette = nullptr; _currentPaletteLength = 0; _lingo = nullptr; _sharedCasts = nullptr; _sharedSound = nullptr; _sharedBMP = nullptr; _sharedSTXT = nullptr; _sharedDIB = nullptr; _mainArchive = nullptr; _macBinary = nullptr; _movies = nullptr; _wm = nullptr; const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "data"); SearchMan.addSubDirectoryMatching(gameDataDir, "install"); _colorDepth = 8; // 256-color _key = 0; _keyCode = 0; _machineType = 9; // Macintosh IIci }
PreAgiEngine::PreAgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBase(syst, gameDesc) { // Setup mixer syncSoundSettings(); DebugMan.addDebugChannel(kDebugLevelMain, "Main", "Generic debug level"); DebugMan.addDebugChannel(kDebugLevelResources, "Resources", "Resources debugging"); DebugMan.addDebugChannel(kDebugLevelSprites, "Sprites", "Sprites debugging"); DebugMan.addDebugChannel(kDebugLevelInventory, "Inventory", "Inventory debugging"); DebugMan.addDebugChannel(kDebugLevelInput, "Input", "Input events debugging"); DebugMan.addDebugChannel(kDebugLevelMenu, "Menu", "Menu debugging"); DebugMan.addDebugChannel(kDebugLevelScripts, "Scripts", "Scripts debugging"); DebugMan.addDebugChannel(kDebugLevelSound, "Sound", "Sound debugging"); DebugMan.addDebugChannel(kDebugLevelText, "Text", "Text output debugging"); DebugMan.addDebugChannel(kDebugLevelSavegame, "Savegame", "Saving & restoring game debugging"); memset(&_game, 0, sizeof(struct AgiGame)); memset(&_debug, 0, sizeof(struct AgiDebug)); memset(&_mouse, 0, sizeof(struct Mouse)); }
void Engine::openMainMenuDialog() { if (!_mainMenuDialog) _mainMenuDialog = new MainMenuDialog(this); setGameToLoadSlot(-1); runDialog(*_mainMenuDialog); // Load savegame after main menu execution // (not from inside the menu loop to avoid // mouse cursor glitches and simliar bugs, // e.g. #2822778). // FIXME: For now we just ignore the return // value, which is quite bad since it could // be a fatal loading error, which renders // the engine unusable. if (_saveSlotToLoad >= 0) loadGameState(_saveSlotToLoad); syncSoundSettings(); }
DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _rnd("director") { if (!_mixer->isReady()) error("Sound initialization failed"); // Setup mixer syncSoundSettings(); _sharedCasts = new Common::HashMap<int, Cast *>; _sharedDIB = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; _sharedBMP = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; _sharedSTXT = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; _sharedSound = new Common::HashMap<int, Common::SeekableSubReadStreamEndian *>; _mainArchive = 0; _macBinary = 0; //FIXME _sharedMMM = "SHARDCST.MMM"; _movies = new Common::HashMap<Common::String, Score *>; const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "data"); SearchMan.addSubDirectoryMatching(gameDataDir, "install"); }
MadsM4Engine::MadsM4Engine(OSystem *syst, const M4GameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) { // Setup mixer syncSoundSettings(); // FIXME _vm = this; _madsVm = NULL; const Common::FSNode gameDataDir(ConfMan.get("path")); SearchMan.addSubDirectoryMatching(gameDataDir, "goodstuf"); SearchMan.addSubDirectoryMatching(gameDataDir, "resource"); DebugMan.addDebugChannel(kDebugScript, "script", "Script debug level"); DebugMan.addDebugChannel(kDebugGraphics, "graphics", "Graphics debug level"); DebugMan.addDebugChannel(kDebugConversations, "conversations", "Conversations debugging"); DebugMan.addDebugChannel(kDebugSound, "sound", "Sounds debug level"); DebugMan.addDebugChannel(kDebugCore, "core", "Core debug level"); _resourceManager = NULL; _globals = NULL; }
CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc), _rnd("cine") { // Setup mixer syncSoundSettings(); DebugMan.addDebugChannel(kCineDebugScript, "Script", "Script debug level"); DebugMan.addDebugChannel(kCineDebugPart, "Part", "Part debug level"); DebugMan.addDebugChannel(kCineDebugSound, "Sound", "Sound debug level"); DebugMan.addDebugChannel(kCineDebugCollision, "Collision", "Collision debug level"); _console = new CineConsole(this); g_cine = this; for (int i = 0; i < NUM_FONT_CHARS; i++) { _textHandler.fontParamTable[i].characterIdx = 0; _textHandler.fontParamTable[i].characterWidth = 0; } _restartRequested = false; _preLoad = false; _timerDelayMultiplier = 12; }
Common::Error HugoEngine::run() { s_Engine = this; initGraphics(320, 200, false); _mouse = new MouseHandler(this); _inventory = new InventoryHandler(this); _route = new Route(this); _sound = new SoundHandler(this); // Setup mixer syncSoundSettings(); _text = new TextHandler(this); _topMenu = new TopMenu(this); switch (_gameVariant) { case kGameVariantH1Win: // H1 Win _file = new FileManager_v1w(this); _scheduler = new Scheduler_v1w(this); _intro = new intro_v1w(this); _screen = new Screen_v1w(this); _parser = new Parser_v1w(this); _object = new ObjectHandler_v1w(this); _normalTPS = 9; break; case kGameVariantH2Win: _file = new FileManager_v2w(this); _scheduler = new Scheduler_v1w(this); _intro = new intro_v2w(this); _screen = new Screen_v1w(this); _parser = new Parser_v1w(this); _object = new ObjectHandler_v1w(this); _normalTPS = 9; break; case kGameVariantH3Win: _file = new FileManager_v2w(this); _scheduler = new Scheduler_v1w(this); _intro = new intro_v3w(this); _screen = new Screen_v1w(this); _parser = new Parser_v1w(this); _object = new ObjectHandler_v1w(this); _normalTPS = 9; break; case kGameVariantH1Dos: // H1 DOS _file = new FileManager_v1d(this); _scheduler = new Scheduler_v1d(this); _intro = new intro_v1d(this); _screen = new Screen_v1d(this); _parser = new Parser_v1d(this); _object = new ObjectHandler_v1d(this); _normalTPS = 8; break; case kGameVariantH2Dos: _file = new FileManager_v2d(this); _scheduler = new Scheduler_v2d(this); _intro = new intro_v2d(this); _screen = new Screen_v1d(this); _parser = new Parser_v2d(this); _object = new ObjectHandler_v2d(this); _normalTPS = 8; break; case kGameVariantH3Dos: _file = new FileManager_v3d(this); _scheduler = new Scheduler_v3d(this); _intro = new intro_v3d(this); _screen = new Screen_v1d(this); _parser = new Parser_v3d(this); _object = new ObjectHandler_v3d(this); _normalTPS = 9; break; } if (!loadHugoDat()) return Common::kUnknownError; // Use Windows-looking mouse cursor _screen->setCursorPal(); _screen->resetInventoryObjId(); _scheduler->initCypher(); initStatus(); // Initialize game status initConfig(); // Initialize user's config if (!_status._doQuitFl) { initialize(); resetConfig(); // Reset user's config initMachine(); // Start the state machine _status._viewState = kViewIntroInit; int16 loadSlot = Common::ConfigManager::instance().getInt("save_slot"); if (loadSlot >= 0) { _status._skipIntroFl = true; _file->restoreGame(loadSlot); } else { _file->saveGame(0, "New Game"); } } while (!_status._doQuitFl) { _screen->drawBoundaries(); g_system->updateScreen(); runMachine(); // Handle input Common::Event event; while (_eventMan->pollEvent(event)) { switch (event.type) { case Common::EVENT_KEYDOWN: _parser->keyHandler(event); break; case Common::EVENT_MOUSEMOVE: _mouse->setMouseX(event.mouse.x); _mouse->setMouseY(event.mouse.y); break; case Common::EVENT_LBUTTONUP: _mouse->setLeftButton(); break; case Common::EVENT_RBUTTONUP: _mouse->setRightButton(); break; case Common::EVENT_QUIT: _status._doQuitFl = true; break; default: break; } } if (_status._helpFl) { _status._helpFl = false; _file->instructions(); } _mouse->mouseHandler(); // Mouse activity - adds to display list _screen->displayList(kDisplayDisplay); // Blit the display list to screen _status._doQuitFl |= shouldQuit(); // update game quit flag } return Common::kNoError; }
void Sword2Engine::readSettings() { syncSoundSettings(); _mouse->setObjectLabels(ConfMan.getBool("object_labels")); _screen->setRenderLevel(ConfMan.getInt("gfx_details")); }
Common::Error SciEngine::run() { _resMan = new ResourceManager(); assert(_resMan); _resMan->addAppropriateSources(); _resMan->init(); // TODO: Add error handling. Check return values of addAppropriateSources // and init. We first have to *add* sensible return values, though ;). /* if (!_resMan) { warning("No resources found, aborting"); return Common::kNoGameDataFoundError; } */ // Reset, so that error()s before SoundCommandParser is initialized wont cause a crash _soundCmd = NULL; // Add the after market GM patches for the specified game, if they exist _resMan->addNewGMPatch(_gameId); _gameObjectAddress = _resMan->findGameObject(); _scriptPatcher = new ScriptPatcher(); SegManager *segMan = new SegManager(_resMan, _scriptPatcher); // Read user option for forcing hires graphics // Only show/selectable for: // - King's Quest 6 CD // - King's Quest 6 CD demo // - Gabriel Knight 1 CD // - Police Quest 4 CD // TODO: Check, if Gabriel Knight 1 floppy supports high resolution // // Gabriel Knight 1 on Mac is hi-res only, so it should NOT get this option. // Confirmed by [md5] and originally by clone2727. if (Common::checkGameGUIOption(GAMEOPTION_HIGH_RESOLUTION_GRAPHICS, ConfMan.get("guioptions"))) { // GAMEOPTION_HIGH_RESOLUTION_GRAPHICS is available for the currently detected game, // so read the user option now. // We need to do this, because the option's default is "true", but we don't want "true" // for any game that does not have this option. _forceHiresGraphics = ConfMan.getBool("enable_high_resolution_graphics"); } if (getSciVersion() < SCI_VERSION_2) { // Initialize the game screen _gfxScreen = new GfxScreen(_resMan); _gfxScreen->enableUndithering(ConfMan.getBool("disable_dithering")); } else { _gfxScreen = nullptr; } _kernel = new Kernel(_resMan, segMan); _kernel->init(); _features = new GameFeatures(segMan, _kernel); // Only SCI0, SCI01 and SCI1 EGA games used a parser _vocabulary = (getSciVersion() <= SCI_VERSION_1_EGA_ONLY) ? new Vocabulary(_resMan, false) : NULL; // Also, XMAS1990 apparently had a parser too. Refer to http://forums.scummvm.org/viewtopic.php?t=9135 if (getGameId() == GID_CHRISTMAS1990) _vocabulary = new Vocabulary(_resMan, false); _gamestate = new EngineState(segMan); _eventMan = new EventManager(_resMan->detectFontExtended()); #ifdef ENABLE_SCI32 if (getSciVersion() >= SCI_VERSION_2_1_EARLY) { _audio32 = new Audio32(_resMan); } else #endif _audio = new AudioPlayer(_resMan); #ifdef ENABLE_SCI32 if (getSciVersion() >= SCI_VERSION_2) { _video32 = new Video32(segMan, _eventMan); } #endif _sync = new Sync(_resMan, segMan); // Create debugger console. It requires GFX and _gamestate to be initialized _console = new Console(this); // 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; } script_adjust_opcode_formats(); // Must be called after game_init(), as they use _features _kernel->loadKernelNames(_features); // Load our Mac executable here for icon bar palettes and high-res fonts loadMacExecutable(); // Initialize all graphics related subsystems initGraphics(); // Sound must be initialized after graphics because SysEx transfers at the // start of the game must pump the event loop to avoid making the OS think // that ScummVM is hanged, and pumping the event loop requires GfxCursor to // be initialized _soundCmd = new SoundCommandParser(_resMan, segMan, _kernel, _audio, _features->detectDoSoundType()); syncSoundSettings(); syncIngameAudioOptions(); // Patch in our save/restore code, so that dialogs are replaced patchGameSaveRestore(); setLauncherLanguage(); // Check whether loading a savestate was requested int directSaveSlotLoading = ConfMan.getInt("save_slot"); if (directSaveSlotLoading >= 0) { _gamestate->_delayedRestoreGame = true; _gamestate->_delayedRestoreGameId = directSaveSlotLoading; _gamestate->_delayedRestoreFromLauncher = true; // Jones only initializes its menus when restarting/restoring, thus set // the gameIsRestarting flag here before initializing. Fixes bug #6536. if (g_sci->getGameId() == GID_JONES) _gamestate->gameIsRestarting = GAMEISRESTARTING_RESTORE; } // Show any special warnings for buggy scripts with severe game bugs, // which have been patched by Sierra if (getGameId() == GID_LONGBOW) { // Longbow 1.0 has a buggy script which prevents the game // from progressing during the Green Man riddle sequence. // A patch for this buggy script has been released by Sierra, // and is necessary to complete the game without issues. // The patched script is included in Longbow 1.1. // Refer to bug #3036609. Resource *buggyScript = _resMan->findResource(ResourceId(kResourceTypeScript, 180), 0); if (buggyScript && (buggyScript->size == 12354 || buggyScript->size == 12362)) { showScummVMDialog("A known buggy game script has been detected, which could " "prevent you from progressing later on in the game, during " "the sequence with the Green Man's riddles. Please, apply " "the latest patch for this game by Sierra to avoid possible " "problems"); } } if (getGameId() == GID_KQ7 && ConfMan.getBool("subtitles")) { showScummVMDialog("Subtitles are enabled, but subtitling in King's" " Quest 7 was unfinished and disabled in the release" " version of the game. ScummVM allows the subtitles" " to be re-enabled, but because they were removed from" " the original game, they do not always render" " properly or reflect the actual game speech." " This is not a ScummVM bug -- it is a problem with" " the game's assets."); } // Show a warning if the user has selected a General MIDI device, no GM patch exists // (i.e. patch 4) and the game is one of the known 8 SCI1 games that Sierra has provided // after market patches for in their "General MIDI Utility". if (_soundCmd->getMusicType() == MT_GM && !ConfMan.getBool("native_mt32")) { if (!_resMan->findResource(ResourceId(kResourceTypePatch, 4), 0)) { switch (getGameId()) { case GID_ECOQUEST: case GID_HOYLE3: case GID_LSL1: case GID_LSL5: case GID_LONGBOW: case GID_SQ1: case GID_SQ4: case GID_FAIRYTALES: showScummVMDialog("You have selected General MIDI as a sound device. Sierra " "has provided after-market support for General MIDI for this " "game in their \"General MIDI Utility\". Please, apply this " "patch in order to enjoy MIDI music with this game. Once you " "have obtained it, you can unpack all of the included *.PAT " "files in your ScummVM extras folder and ScummVM will add the " "appropriate patch automatically. Alternatively, you can follow " "the instructions in the READ.ME file included in the patch and " "rename the associated *.PAT file to 4.PAT and place it in the " "game folder. Without this patch, General MIDI music for this " "game will sound badly distorted."); break; default: break; } } } if (gameHasFanMadePatch()) { showScummVMDialog("Your game is patched with a fan made script patch. Such patches have " "been reported to cause issues, as they modify game scripts extensively. " "The issues that these patches fix do not occur in ScummVM, so you are " "advised to remove this patch from your game folder in order to avoid " "having unexpected errors and/or issues later on."); } runGame(); ConfMan.flushToDisk(); return Common::kNoError; }