From d870127ddb766be5d599b054ab1e4102aa9632ff Mon Sep 17 00:00:00 2001 From: Matthew Hoops Date: Wed, 14 Nov 2012 21:57:39 -0500 Subject: [PATCH] DIRECTOR: Mac v3 games just use the resource fork of the executable to start --- engines/director/director.cpp | 50 ++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 22 deletions(-) diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 5cb5f2089cd..0b6b626cfed 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -148,31 +148,37 @@ void DirectorEngine::loadEXERIFX(Common::SeekableReadStream *stream, uint32 offs } void DirectorEngine::loadMac() { - if (getVersion() < 4) - error("Unhandled pre-v4 Mac version"); + if (getVersion() < 4) { + // The data is part of the resource fork of the executable + _mainArchive = new MacArchive(); - _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->readUint32LE(); - - if (tag == MKTAG('P', 'J', '9', '3')) { - // PPC: The RIFX shares the data fork with the binary - dataFork->seek(dataFork->readUint32BE()); + if (!_mainArchive->openFile(getEXEName())) + error("Failed to open Mac binary '%s'", getEXEName().c_str()); } else { - // 68k: The RIFX is the only thing in the data fork - dataFork->seek(0); - } + // The RIFX is located in the data fork of the executable + _macBinary = new Common::MacResManager(); - if (!_mainArchive->openStream(dataFork)) - error("Failed to load RIFX from Mac binary"); + 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->readUint32LE(); + + if (tag == MKTAG('P', 'J', '9', '3')) { + // PPC: The RIFX shares the data fork with the binary + dataFork->seek(dataFork->readUint32BE()); + } else { + // 68k: The RIFX is the only thing in the data fork + dataFork->seek(0); + } + + if (!_mainArchive->openStream(dataFork)) + error("Failed to load RIFX from Mac binary"); + } } Common::String DirectorEngine::readPascalString(Common::SeekableReadStream &stream) {