aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he
diff options
context:
space:
mode:
authorMax Horn2006-04-23 17:33:16 +0000
committerMax Horn2006-04-23 17:33:16 +0000
commit0d67640a58b044ade0605319e091df9b2f666e4a (patch)
treefcec3906ad2abb5ea28072663193a7cce9282e83 /engines/scumm/he
parentd11f5724f96107a07d462be2410d93f55bd1fba2 (diff)
downloadscummvm-rg350-0d67640a58b044ade0605319e091df9b2f666e4a.tar.gz
scummvm-rg350-0d67640a58b044ade0605319e091df9b2f666e4a.tar.bz2
scummvm-rg350-0d67640a58b044ade0605319e091df9b2f666e4a.zip
Behold, the new SCUMM detector finally has arrived. Unified detection & engine instantiation, reduced code duplication, more powerful detection in case MD5 is not known / can't be computed, and many other nifty improvements.
svn-id: r22110
Diffstat (limited to 'engines/scumm/he')
-rw-r--r--engines/scumm/he/intern_he.h16
-rw-r--r--engines/scumm/he/resource_he.cpp45
-rw-r--r--engines/scumm/he/resource_he.h2
-rw-r--r--engines/scumm/he/sound_he.cpp18
4 files changed, 30 insertions, 51 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h
index 5524b2a21e..dc906a654c 100644
--- a/engines/scumm/he/intern_he.h
+++ b/engines/scumm/he/intern_he.h
@@ -51,7 +51,7 @@ protected:
Common::File _hFileTable[17];
public:
- ScummEngine_v60he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst) : ScummEngine_v6(syst, gs, md5sum, subst) {}
+ ScummEngine_v60he(OSystem *syst, const DetectorResult &dr) : ScummEngine_v6(syst, dr) {}
virtual void scummInit();
@@ -116,7 +116,7 @@ protected:
bool _skipProcessActors;
public:
- ScummEngine_v70he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst);
+ ScummEngine_v70he(OSystem *syst, const DetectorResult &dr);
~ScummEngine_v70he();
Wiz *_wiz;
@@ -181,7 +181,7 @@ protected:
class ScummEngine_v71he : public ScummEngine_v70he {
public:
- ScummEngine_v71he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst);
+ ScummEngine_v71he(OSystem *syst, const DetectorResult &dr);
protected:
virtual void saveOrLoad(Serializer *s);
@@ -236,7 +236,7 @@ protected:
WizParameters _wizParams;
public:
- ScummEngine_v72he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst);
+ ScummEngine_v72he(OSystem *syst, const DetectorResult &dr);
virtual void scummInit();
@@ -347,7 +347,7 @@ protected:
int32 _heSndResId, _curSndId, _sndPtrOffs, _sndTmrOffs;
public:
- ScummEngine_v80he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst);
+ ScummEngine_v80he(OSystem *syst, const DetectorResult &dr);
protected:
virtual void setupOpcodes();
@@ -420,7 +420,7 @@ protected:
int32 _curSpriteGroupId;
public:
- ScummEngine_v90he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst);
+ ScummEngine_v90he(OSystem *syst, const DetectorResult &dr);
~ScummEngine_v90he();
virtual void scummInit();
@@ -517,7 +517,7 @@ protected:
class ScummEngine_v99he : public ScummEngine_v90he {
public:
- ScummEngine_v99he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst) : ScummEngine_v90he(syst, gs, md5sum, subst) {}
+ ScummEngine_v99he(OSystem *syst, const DetectorResult &dr) : ScummEngine_v90he(syst, dr) {}
virtual void scummInit();
@@ -548,7 +548,7 @@ protected:
const OpcodeEntryV100he *_opcodesV100he;
public:
- ScummEngine_v100he(OSystem *syst, const GameSettings &gs, uint8 md5sum[16], SubstResFileNames subst) : ScummEngine_v99he(syst, gs, md5sum, subst) {}
+ ScummEngine_v100he(OSystem *syst, const DetectorResult &dr) : ScummEngine_v99he(syst, dr) {}
protected:
virtual void setupOpcodes();
diff --git a/engines/scumm/he/resource_he.cpp b/engines/scumm/he/resource_he.cpp
index c4b81f8516..13d78c5517 100644
--- a/engines/scumm/he/resource_he.cpp
+++ b/engines/scumm/he/resource_he.cpp
@@ -42,7 +42,6 @@ namespace Scumm {
ResExtractor::ResExtractor(ScummEngine_v70he *scumm)
: _vm(scumm) {
- _fileName[0] = 0;
memset(_cursorCache, 0, sizeof(_cursorCache));
}
@@ -159,21 +158,15 @@ int Win32ResExtractor::extractResource_(const char *resType, char *resName, byte
fi.memory = NULL;
fi.file = new Common::File;
- if (!_fileName[0]) { // We are running for the first time
- snprintf(_fileName, 256, "%s.he3", _vm->getBaseName());
-
- if (_vm->_substResFileName.almostGameID != 0) {
- char buf1[128];
- _vm->generateSubstResFileName(_fileName, buf1, sizeof(buf1));
- strcpy(_fileName, buf1);
- }
+ if (_fileName.empty()) { // We are running for the first time
+ _fileName = _vm->generateFilename(3);
}
/* get file size */
fi.file->open(_fileName);
if (!fi.file->isOpen()) {
- error("Cannot open file %s", _fileName);
+ error("Cannot open file %s", _fileName.c_str());
}
fi.total_size = fi.file->size();
@@ -1288,38 +1281,36 @@ int MacResExtractor::extractResource(int id, byte **buf) {
Common::File in;
int size;
- if (!_fileName[0]) // We are running for the first time
- if (_vm->_substResFileName.almostGameID != 0) {
- char buf1[128];
+ if (_fileName.empty()) { // We are running for the first time
+ _fileName = _vm->generateFilename(3);
- snprintf(buf1, 128, "%s.he3", _vm->getBaseName());
- _vm->generateSubstResFileName(buf1, _fileName, sizeof(buf1));
+ // Some programs write it as .bin. Try that too
+ if (!in.exists(_fileName)) {
+ Common::String tmp(_fileName);
+
+ _fileName += ".bin";
- // Some programs write it as .bin. Try that too
if (!in.exists(_fileName)) {
- strcpy(buf1, _fileName);
- snprintf(_fileName, 128, "%s.bin", buf1);
-
+ // And finally check if we have dumped resource fork
+ _fileName = tmp;
+ _fileName += ".bin";
if (!in.exists(_fileName)) {
- // And finally check if we have dumped resource fork
- snprintf(_fileName, 128, "%s.rsrc", buf1);
- if (!in.exists(_fileName)) {
- error("Cannot open file any of files '%s', '%s.bin', '%s.rsrc",
- buf1, buf1, buf1);
- }
+ error("Cannot open file any of files '%s', '%s.bin', '%s.rsrc",
+ tmp.c_str(), tmp.c_str(), tmp.c_str());
}
}
}
+ }
in.open(_fileName);
if (!in.isOpen()) {
- error("Cannot open file %s", _fileName);
+ error("Cannot open file %s", _fileName.c_str());
}
// we haven't calculated it
if (_resOffset == -1) {
if (!init(in))
- error("Resource fork is missing in file '%s'", _fileName);
+ error("Resource fork is missing in file '%s'", _fileName.c_str());
in.close();
in.open(_fileName);
}
diff --git a/engines/scumm/he/resource_he.h b/engines/scumm/he/resource_he.h
index 20ad0a1110..976511a974 100644
--- a/engines/scumm/he/resource_he.h
+++ b/engines/scumm/he/resource_he.h
@@ -150,7 +150,7 @@ public:
ResExtractor::CachedCursor *getCachedCursorSlot();
bool _arg_raw;
- char _fileName[256];
+ Common::String _fileName;
CachedCursor _cursorCache[MAX_CACHED_CURSORS];
typedef Common::MemoryReadStream MemoryReadStream;
diff --git a/engines/scumm/he/sound_he.cpp b/engines/scumm/he/sound_he.cpp
index 57a03ed129..86221aea88 100644
--- a/engines/scumm/he/sound_he.cpp
+++ b/engines/scumm/he/sound_he.cpp
@@ -161,15 +161,9 @@ void Sound::setOverrideFreq(int freq) {
void Sound::setupHEMusicFile() {
int i, total_size;
- char buf[32], buf1[128];
Common::File musicFile;
+ Common::String buf(_vm->generateFilename(4));
- sprintf(buf, "%s.he4", _vm->getBaseName());
-
- if (_vm->_substResFileName.almostGameID != 0) {
- _vm->generateSubstResFileName(buf, buf1, sizeof(buf1));
- strcpy(buf, buf1);
- }
if (musicFile.open(buf) == true) {
musicFile.seek(4, SEEK_SET);
total_size = musicFile.readUint32BE();
@@ -360,17 +354,11 @@ void Sound::playHESound(int soundID, int heOffset, int heChannel, int heFlags) {
if (soundID > _vm->_numSounds) {
int music_offs;
- char buf[32], buf1[128];
Common::File musicFile;
+ Common::String buf(_vm->generateFilename(4));
- sprintf(buf, "%s.he4", _vm->getBaseName());
-
- if (_vm->_substResFileName.almostGameID != 0) {
- _vm->generateSubstResFileName(buf, buf1, sizeof(buf1));
- strcpy(buf, buf1);
- }
if (musicFile.open(buf) == false) {
- warning("playHESound: Can't open music file %s", buf);
+ warning("playHESound: Can't open music file %s", buf.c_str());
return;
}
if (!getHEMusicDetails(soundID, music_offs, size)) {