diff options
author | Matthew Hoops | 2012-11-14 14:27:42 -0500 |
---|---|---|
committer | Eugene Sandulenko | 2016-08-03 23:40:36 +0200 |
commit | 9a9df86fded26b253e8d1c02a5a048839084f0e7 (patch) | |
tree | 290819a5f9ab573a7933b997f0fd18fdf4851422 /engines/director | |
parent | 09f6949cbc7e5943b7b6920cd39ac24bfd87bad5 (diff) | |
download | scummvm-rg350-9a9df86fded26b253e8d1c02a5a048839084f0e7.tar.gz scummvm-rg350-9a9df86fded26b253e8d1c02a5a048839084f0e7.tar.bz2 scummvm-rg350-9a9df86fded26b253e8d1c02a5a048839084f0e7.zip |
DIRECTOR: Parse the RIFX from v4 Mac versions
Diffstat (limited to 'engines/director')
-rw-r--r-- | engines/director/director.cpp | 33 | ||||
-rw-r--r-- | engines/director/director.h | 7 |
2 files changed, 40 insertions, 0 deletions
diff --git a/engines/director/director.cpp b/engines/director/director.cpp index 4df959d05d..5cb5f2089c 100644 --- a/engines/director/director.cpp +++ b/engines/director/director.cpp @@ -25,6 +25,7 @@ #include "common/debug.h" #include "common/scummsys.h" #include "common/error.h" +#include "common/macresman.h" #include "common/stream.h" #include "common/system.h" #include "common/textconsole.h" @@ -42,10 +43,12 @@ DirectorEngine::DirectorEngine(OSystem *syst, const DirectorGameDescription *gam syncSoundSettings(); _mainArchive = 0; + _macBinary = 0; } DirectorEngine::~DirectorEngine() { delete _mainArchive; + delete _macBinary; } Common::Error DirectorEngine::run() { @@ -53,6 +56,8 @@ Common::Error DirectorEngine::run() { if (getPlatform() == Common::kPlatformWindows) loadEXE(); + else + loadMac(); return Common::kNoError; } @@ -142,6 +147,34 @@ void DirectorEngine::loadEXERIFX(Common::SeekableReadStream *stream, uint32 offs error("Failed to load RIFX from EXE"); } +void DirectorEngine::loadMac() { + if (getVersion() < 4) + error("Unhandled pre-v4 Mac version"); + + _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()); + } 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) { byte length = stream.readByte(); Common::String x; diff --git a/engines/director/director.h b/engines/director/director.h index f1186f3b20..00198014e5 100644 --- a/engines/director/director.h +++ b/engines/director/director.h @@ -29,6 +29,10 @@ class OSystem; +namespace Common { +class MacResManager; +} + namespace Director { enum DirectorGameID { @@ -65,9 +69,12 @@ private: void loadEXEv5(Common::SeekableReadStream *stream); void loadEXERIFX(Common::SeekableReadStream *stream, uint32 offset); + void loadMac(); + Common::String readPascalString(Common::SeekableReadStream &stream); Archive *_mainArchive; + Common::MacResManager *_macBinary; }; } // End of namespace Director |