aboutsummaryrefslogtreecommitdiff
path: root/engines/director/director.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2012-11-14 14:27:42 -0500
committerEugene Sandulenko2016-08-03 23:40:36 +0200
commit9a9df86fded26b253e8d1c02a5a048839084f0e7 (patch)
tree290819a5f9ab573a7933b997f0fd18fdf4851422 /engines/director/director.cpp
parent09f6949cbc7e5943b7b6920cd39ac24bfd87bad5 (diff)
downloadscummvm-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/director.cpp')
-rw-r--r--engines/director/director.cpp33
1 files changed, 33 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;