Common::Error KyraEngine_HoF::go() { if (_gameToLoad == -1) { if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) seq_showStarcraftLogo(); if (_flags.isDemo && !_flags.isTalkie) { #ifdef ENABLE_LOL if (_flags.gameID == GI_LOL) seq_playSequences(kSequenceLolDemoScene1, kSequenceLolDemoScene6); else #endif // ENABLE_LOL seq_playSequences(kSequenceDemoVirgin, kSequenceDemoFisher); _menuChoice = 4; } else { seq_playSequences(kSequenceVirgin, kSequenceZanfaun); } } else { _menuChoice = 1; } _res->unloadAllPakFiles(); if (_menuChoice != 4) { // load just the pak files needed for ingame _staticres->loadStaticResourceFile(); if (_flags.platform == Common::kPlatformPC && _flags.isTalkie) { if (!_res->loadFileList("FILEDATA.FDT")) error("couldn't load 'FILEDATA.FDT'"); } else { _res->loadFileList(_ingamePakList, _ingamePakListSize); } if (_flags.platform == Common::kPlatformPC98) { _res->loadPakFile("AUDIO.PAK"); _sound->loadSoundFile("SOUND.DAT"); } } _menuDirectlyToLoad = (_menuChoice == 3) ? true : false; _menuDirectlyToLoad &= saveFileLoadable(0); if (_menuChoice & 1) { startup(); if (!shouldQuit()) runLoop(); cleanup(); if (_showOutro) seq_playSequences(kSequenceFunters, kSequenceFrash); } return Common::kNoError; }
Common::Error KyraEngine_HoF::go() { int menuChoice = 0; if (_gameToLoad == -1) { if (_flags.platform == Common::kPlatformFMTowns || _flags.platform == Common::kPlatformPC98) seq_showStarcraftLogo(); if (_flags.isDemo && !_flags.isTalkie) { menuChoice = seq_playDemo(); } else { menuChoice = seq_playIntro(); } } else { menuChoice = 1; } _res->unloadAllPakFiles(); if (menuChoice != 4) { // load just the pak files needed for ingame _staticres->loadStaticResourceFile(); if (_flags.platform == Common::kPlatformDOS && _flags.isTalkie) { if (!_res->loadFileList("FILEDATA.FDT")) error("couldn't load 'FILEDATA.FDT'"); } else { _res->loadFileList(_ingamePakList, _ingamePakListSize); } if (_flags.platform == Common::kPlatformPC98) { _res->loadPakFile("AUDIO.PAK"); _sound->loadSoundFile("SOUND.DAT"); } } _menuDirectlyToLoad = (menuChoice == 3) ? true : false; _menuDirectlyToLoad &= saveFileLoadable(0); if (menuChoice & 1) { startup(); if (!shouldQuit()) runLoop(); cleanup(); if (_showOutro) seq_playOutro(); } return Common::kNoError; }
Common::Error KyraEngine_LoK::go() { if (_res->getFileSize("6.FNT")) _screen->loadFont(Screen::FID_6_FNT, "6.FNT"); _screen->loadFont(Screen::FID_8_FNT, "8FAT.FNT"); _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT); _screen->setScreenDim(0); _abortIntroFlag = false; if (_flags.isDemo && !_flags.isTalkie) { _seqPlayerFlag = true; seq_demo(); _seqPlayerFlag = false; } else { setGameFlag(0xF3); setGameFlag(0xFD); if (_gameToLoad == -1) { setGameFlag(0xEF); _seqPlayerFlag = true; seq_intro(); _seqPlayerFlag = false; if (_flags.isDemo) { _screen->fadeToBlack(); return Common::kNoError; } if (shouldQuit()) return Common::kNoError; if (_skipIntroFlag && _abortIntroFlag && saveFileLoadable(0)) resetGameFlag(0xEF); } _eventList.clear(); startup(); resetGameFlag(0xEF); mainLoop(); } return Common::kNoError; }
Common::Error KyraEngine_v1::init() { // Setup mixer syncSoundSettings(); if (!_flags.useDigSound) { if (_flags.platform == Common::kPlatformFMTowns) { if (_flags.gameID == GI_KYRA1) _sound = new SoundTowns(this, _mixer); else _sound = new SoundTownsPC98_v2(this, _mixer); } else if (_flags.platform == Common::kPlatformPC98) { if (_flags.gameID == GI_KYRA1) _sound = new SoundPC98(this, _mixer); else _sound = new SoundTownsPC98_v2(this, _mixer); } else if (_flags.platform == Common::kPlatformAmiga) { _sound = new SoundAmiga(this, _mixer); } else { // In Kyra 1 users who have specified a default MT-32 device in the launcher settings // will get MT-32 music, otherwise AdLib. In Kyra 2 and LoL users who have specified a // default GM device in the launcher will get GM music, otherwise AdLib. Users who want // MT-32 music in Kyra2 or LoL have to select this individually (since we assume that // most users rather have a GM device than a MT-32 device). // Users who want PC speaker sound always have to select this individually for all // Kyra games. MidiDriver::DeviceHandle dev = MidiDriver::detectDevice(MDT_PCSPK | MDT_MIDI | MDT_ADLIB | ((_flags.gameID == GI_KYRA2 || _flags.gameID == GI_LOL) ? MDT_PREFER_GM : MDT_PREFER_MT32)); if (MidiDriver::getMusicType(dev) == MT_ADLIB) { _sound = new SoundAdLibPC(this, _mixer); } else { Sound::kType type; const MusicType midiType = MidiDriver::getMusicType(dev); if (midiType == MT_PCSPK || midiType == MT_NULL) type = Sound::kPCSpkr; else if (midiType == MT_MT32 || ConfMan.getBool("native_mt32")) type = Sound::kMidiMT32; else type = Sound::kMidiGM; MidiDriver *driver = 0; if (MidiDriver::getMusicType(dev) == MT_PCSPK) { driver = new MidiDriver_PCSpeaker(_mixer); } else { driver = MidiDriver::createMidi(dev); if (type == Sound::kMidiMT32) driver->property(MidiDriver::PROP_CHANNEL_MASK, 0x03FE); } assert(driver); SoundMidiPC *soundMidiPc = new SoundMidiPC(this, _mixer, driver, type); _sound = soundMidiPc; assert(_sound); // Unlike some SCUMM games, it's not that the MIDI sounds are // missing. It's just that at least at the time of writing they // are decidedly inferior to the AdLib ones. if (ConfMan.getBool("multi_midi")) { SoundAdLibPC *adlib = new SoundAdLibPC(this, _mixer); assert(adlib); _sound = new MixedSoundDriver(this, _mixer, soundMidiPc, adlib); } } } assert(_sound); } if (_sound) _sound->updateVolumeSettings(); _res = new Resource(this); assert(_res); _res->reset(); if (_flags.isDemo) { // HACK: check whether this is the HOF demo or the LOL demo. // The LOL demo needs to be detected and run as KyraEngine_HoF, // but the static resource loader and the sequence player will // need correct IDs. if (_res->exists("scene1.cps")) #ifdef ENABLE_LOL _flags.gameID = GI_LOL; #else error("Lands of Lore demo is not supported in this build"); #endif // !ENABLE_LOL } _staticres = new StaticResource(this); assert(_staticres); if (!_staticres->init()) error("_staticres->init() failed"); if (!screen()->init()) error("screen()->init() failed"); _timer = new TimerManager(this, _system); assert(_timer); setupTimers(); _emc = new EMCInterpreter(this); assert(_emc); setupOpcodeTable(); readSettings(); if (ConfMan.hasKey("save_slot")) { _gameToLoad = ConfMan.getInt("save_slot"); if (!saveFileLoadable(_gameToLoad)) _gameToLoad = -1; } setupKeyMap(); // Prevent autosave on game startup _lastAutosave = _system->getMillis(); return Common::kNoError; }
void KyraEngine_LoK::startup() { static const uint8 colorMap[] = { 0, 0, 0, 0, 12, 12, 12, 0, 0, 0, 0, 0 }; _screen->setTextColorMap(colorMap); _sound->selectAudioResourceSet(kMusicIngame); if (_flags.platform == Common::kPlatformPC98) _sound->loadSoundFile("SE.DAT"); else _sound->loadSoundFile(0); // _screen->setFont(Screen::FID_6_FNT); _screen->setAnimBlockPtr(3750); memset(_sceneAnimTable, 0, sizeof(_sceneAnimTable)); loadMouseShapes(); _currentCharacter = &_characterList[0]; for (int i = 1; i < 5; ++i) _animator->setCharacterDefaultFrame(i); for (int i = 5; i <= 10; ++i) setCharactersPositions(i); _animator->setCharactersHeight(); resetBrandonPoisonFlags(); _screen->_curPage = 0; // XXX for (int i = 0; i < 12; ++i) { int size = _screen->getRectSize(3, 24); _shapes[361 + i] = new byte[size]; } _itemBkgBackUp[0] = new uint8[_screen->getRectSize(3, 24)]; memset(_itemBkgBackUp[0], 0, _screen->getRectSize(3, 24)); _itemBkgBackUp[1] = new uint8[_screen->getRectSize(4, 32)]; memset(_itemBkgBackUp[1], 0, _screen->getRectSize(4, 32)); for (int i = 0; i < _roomTableSize; ++i) { for (int item = 0; item < 12; ++item) { _roomTable[i].itemsTable[item] = kItemNone; _roomTable[i].itemsXPos[item] = 0xFFFF; _roomTable[i].itemsYPos[item] = 0xFF; _roomTable[i].needInit[item] = 0; } } loadCharacterShapes(); loadSpecialEffectShapes(); loadItems(); loadButtonShapes(); initMainButtonList(); loadMainScreen(); _screen->loadPalette("PALETTE.COL", _screen->getPalette(0)); if (_flags.platform == Common::kPlatformAmiga) _screen->loadPaletteTable("PALETTE.DAT", 6); // XXX _animator->initAnimStateList(); setCharactersInDefaultScene(); if (!_emc->load("_STARTUP.EMC", &_npcScriptData, &_opcodes)) error("Could not load \"_STARTUP.EMC\" script"); _emc->init(&_scriptMain, &_npcScriptData); if (!_emc->start(&_scriptMain, 0)) error("Could not start script function 0 of script \"_STARTUP.EMC\""); while (_emc->isValid(&_scriptMain)) _emc->run(&_scriptMain); _emc->unload(&_npcScriptData); if (!_emc->load("_NPC.EMC", &_npcScriptData, &_opcodes)) error("Could not load \"_NPC.EMC\" script"); snd_playTheme(1, -1); if (_gameToLoad == -1) { enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1); if (_abortIntroFlag && _skipIntroFlag && saveFileLoadable(0)) { _menuDirectlyToLoad = true; _screen->setMouseCursor(1, 1, _shapes[0]); _screen->showMouse(); _gui->buttonMenuCallback(0); _menuDirectlyToLoad = false; } else if (!shouldQuit()) { saveGameStateIntern(0, "New game", 0); } } else { _screen->setFont(_flags.lang == Common::JA_JPN ? Screen::FID_SJIS_FNT : Screen::FID_8_FNT); loadGameStateCheck(_gameToLoad); _gameToLoad = -1; } }
Common::Error KyraEngine_MR::go() { bool running = true; preinit(); _screen->hideMouse(); initMainMenu(); _screen->clearPage(0); _screen->clearPage(2); const bool firstTimeGame = !saveFileLoadable(0); if (firstTimeGame) { playVQA("K3INTRO"); _wasPlayingVQA = false; } if (_gameToLoad != -1 || firstTimeGame) { while (!_screen->isMouseVisible()) _screen->showMouse(); uninitMainMenu(); _musicSoundChannel = -1; startup(); runLoop(); running = false; } while (running && !shouldQuit()) { _screen->_curPage = 0; _screen->clearPage(0); _screen->setScreenPalette(_screen->getPalette(0)); playMenuAudioFile(); for (int i = 0; i < 64 && !shouldQuit(); ++i) { uint32 nextRun = _system->getMillis() + 3 * _tickLength; _menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0); _screen->updateScreen(); delayUntil(nextRun); } for (int i = 64; i > 29 && !shouldQuit(); --i) { uint32 nextRun = _system->getMillis() + 3 * _tickLength; _menuAnim->displayFrame(i, 0, 0, 0, 0, 0, 0); _screen->updateScreen(); delayUntil(nextRun); } _eventList.clear(); switch (_menu->handle(3)) { case 2: _menuDirectlyToLoad = true; // fall through case 0: uninitMainMenu(); fadeOutMusic(60); _screen->fadeToBlack(60); _musicSoundChannel = -1; startup(); runLoop(); running = false; break; case 1: playVQA("K3INTRO"); _wasPlayingVQA = false; _screen->hideMouse(); break; case 3: fadeOutMusic(60); _screen->fadeToBlack(60); uninitMainMenu(); quitGame(); running = false; break; default: break; } } if (_showOutro && !shouldQuit()) playVQA("CREDITS"); return Common::kNoError; }