void DirectorEngine::loadMac() { if (getVersion() < 4) { // The data is part of the resource fork of the executable _mainArchive = new MacArchive(); if (!_mainArchive->openFile(getEXEName())) error("Failed to open Mac binary '%s'", getEXEName().c_str()); } else { // The RIFX is located in the data fork of the executable _macBinary = new Common::MacResManager(); if (!_macBinary->open(getEXEName()) || !_macBinary->hasDataFork()) error("Failed to open Mac binary '%s'", getEXEName().c_str()); Common::SeekableReadStream *dataFork = _macBinary->getDataFork(); _mainArchive = new RIFXArchive(); // First we need to detect PPC vs. 68k uint32 tag = dataFork->readUint32BE(); uint32 startOffset; if (SWAP_BYTES_32(tag) == MKTAG('P', 'J', '9', '3') || tag == MKTAG('P', 'J', '9', '5') || tag == MKTAG('P', 'J', '0', '0')) { // PPC: The RIFX shares the data fork with the binary startOffset = dataFork->readUint32BE(); } else { // 68k: The RIFX is the only thing in the data fork startOffset = 0; } if (!_mainArchive->openStream(dataFork, startOffset)) error("Failed to load RIFX from Mac binary"); } }
void DirectorEngine::loadEXE() { Common::SeekableReadStream *exeStream = SearchMan.createReadStreamForMember(getEXEName()); if (!exeStream) error("Failed to open EXE '%s'", getEXEName().c_str()); _lingo->processEvent(kEventStart, 0); exeStream->seek(-4, SEEK_END); exeStream->seek(exeStream->readUint32LE()); switch (getVersion()) { case 3: loadEXEv3(exeStream); break; case 4: loadEXEv4(exeStream); break; case 5: loadEXEv5(exeStream); break; case 7: loadEXEv7(exeStream); break; default: error("Unhandled Windows EXE version %d", getVersion()); } }
Common::Error BuriedEngine::run() { _console = new BuriedConsole(this); #ifndef USE_ICONV // The Japanese version needs iconv support if (getLanguage() == Common::JA_JPN) return Common::Error(Common::kUnknownError, "No iconv support available"); #endif if (isTrueColor()) { initGraphics(640, 480, true, 0); if (_system->getScreenFormat().bytesPerPixel == 1) return Common::kUnsupportedColorMode; } else { initGraphics(640, 480, true); } if (isWin95()) { _mainEXE = new DatabasePE(); _library = new DatabasePE(); } else if (isCompressed()) { _mainEXE = new DatabaseNECompressed(); _library = new DatabaseNECompressed(); } else { _mainEXE = new DatabaseNE(); // Demo only uses the main EXE if (!isDemo()) _library = new DatabaseNE(); } if (!_mainEXE->load(getEXEName())) error("Failed to load main EXE '%s'", getEXEName().c_str()); if (_library && !_library->load(getLibraryName())) error("Failed to load library DLL '%s'", getLibraryName().c_str()); syncSoundSettings(); _gfx = new GraphicsManager(this); _sound = new SoundManager(this); _mainWindow = new FrameWindow(this); _mainWindow->showWindow(Window::kWindowShow); if (isDemo()) { ((FrameWindow *)_mainWindow)->showTitleSequence(); ((FrameWindow *)_mainWindow)->showMainMenu(); } else { bool doIntro = true; if (ConfMan.hasKey("save_slot")) { uint32 gameToLoad = ConfMan.getInt("save_slot"); doIntro = (loadGameState(gameToLoad).getCode() != Common::kNoError); // If the trial version tries to load a game without a time // zone that's part of the trial version, force the intro. if (isTrial() && !((FrameWindow *)_mainWindow)->getMainChildWindow()) doIntro = true; } // Play the intro only if we're starting from scratch if (doIntro) ((FrameWindow *)_mainWindow)->showClosingScreen(); } while (!shouldQuit()) { updateVideos(); pollForEvents(); sendAllMessages(); _gfx->updateScreen(); _system->delayMillis(10); } return Common::kNoError; }