aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/queen/bankman.cpp6
-rw-r--r--engines/queen/cutaway.cpp8
-rw-r--r--engines/queen/queen.cpp1
-rw-r--r--engines/queen/resource.cpp43
-rw-r--r--engines/queen/resource.h5
-rw-r--r--engines/queen/sound.cpp2
-rw-r--r--engines/queen/sound.h6
7 files changed, 44 insertions, 27 deletions
diff --git a/engines/queen/bankman.cpp b/engines/queen/bankman.cpp
index d9eb020dfe..eb8c2793fa 100644
--- a/engines/queen/bankman.cpp
+++ b/engines/queen/bankman.cpp
@@ -52,6 +52,12 @@ void BankManager::load(const char *bankname, uint32 bankslot) {
}
close(bankslot);
+
+ if (_res->getPlatform() == Common::kPlatformAmiga && !_res->fileExists(bankname)) {
+ debug(9, "BankManager::load() bank '%s' doesn't exist", bankname);
+ return;
+ }
+
bank->data = _res->loadFile(bankname);
if (_res->getPlatform() == Common::kPlatformAmiga) {
diff --git a/engines/queen/cutaway.cpp b/engines/queen/cutaway.cpp
index f6220cf7dd..4acf25cf46 100644
--- a/engines/queen/cutaway.cpp
+++ b/engines/queen/cutaway.cpp
@@ -41,9 +41,11 @@ void Cutaway::run(
const char *filename,
char *nextFilename,
QueenEngine *vm) {
- Cutaway *cutaway = new Cutaway(filename, vm);
- cutaway->run(nextFilename);
- delete cutaway;
+ if (vm->resource()->fileExists(filename)) {
+ Cutaway *cutaway = new Cutaway(filename, vm);
+ cutaway->run(nextFilename);
+ delete cutaway;
+ }
}
Cutaway::Cutaway(
diff --git a/engines/queen/queen.cpp b/engines/queen/queen.cpp
index 2363d29429..87f7030b71 100644
--- a/engines/queen/queen.cpp
+++ b/engines/queen/queen.cpp
@@ -211,6 +211,7 @@ void QueenEngine::update(bool checkPlayerInput) {
_display->blankScreen();
}
}
+ _sound->updateMusic();
}
bool QueenEngine::canLoadOrSave() const {
diff --git a/engines/queen/resource.cpp b/engines/queen/resource.cpp
index cece71ae8b..9724963884 100644
--- a/engines/queen/resource.cpp
+++ b/engines/queen/resource.cpp
@@ -62,6 +62,7 @@ Resource::Resource()
: _resourceEntries(0), _resourceTable(NULL) {
memset(&_version, 0, sizeof(_version));
+ _currentResourceFileNum = 1;
if (!_resourceFile.open("queen.1c")) {
if (!_resourceFile.open("queen.1")) {
error("Could not open resource file 'queen.1[c]'");
@@ -110,33 +111,17 @@ ResourceEntry *Resource::resourceEntry(const char *filename) const {
return re;
}
-static uint8 emptyBank[] = { 0, 0 };
-
uint8 *Resource::loadFile(const char *filename, uint32 skipBytes, uint32 *size) {
debug(7, "Resource::loadFile('%s')", filename);
ResourceEntry *re = resourceEntry(filename);
- if (_version.platform == Common::kPlatformAmiga && re == NULL) {
- return emptyBank;
- }
assert(re != NULL);
uint32 sz = re->size - skipBytes;
if (size != NULL) {
*size = sz;
}
byte *dstBuf = new byte[sz];
- if (re->bundle == 1) {
- _resourceFile.seek(re->offset + skipBytes);
- _resourceFile.read(dstBuf, sz);
- } else {
- Common::File resourceFile;
- char name[20];
- sprintf(name, "queen.%d", re->bundle);
- if (!resourceFile.open(name)) {
- error("Could not open resource file '%s'", name);
- }
- resourceFile.seek(re->offset + skipBytes);
- resourceFile.read(dstBuf, sz);
- }
+ seekResourceFile(re->bundle, re->offset + skipBytes);
+ _resourceFile.read(dstBuf, sz);
return dstBuf;
}
@@ -234,7 +219,7 @@ void Resource::checkJASVersion() {
return;
}
ResourceEntry *re = resourceEntry("QUEEN.JAS");
- assert(re != NULL && re->bundle == 1);
+ assert(re != NULL);
uint32 offset = re->offset;
if (isDemo())
offset += JAS_VERSION_OFFSET_DEMO;
@@ -242,7 +227,7 @@ void Resource::checkJASVersion() {
offset += JAS_VERSION_OFFSET_INTV;
else
offset += JAS_VERSION_OFFSET_PC;
- _resourceFile.seek(offset);
+ seekResourceFile(re->bundle, offset);
char versionStr[6];
_resourceFile.read(versionStr, 6);
@@ -250,6 +235,20 @@ void Resource::checkJASVersion() {
error("Verifying game version failed! (expected: '%s', found: '%s')", _version.str, versionStr);
}
+void Resource::seekResourceFile(int num, uint32 offset) {
+ if (_currentResourceFileNum != num) {
+ debug(7, "Opening resource file %d, current %d", num, _currentResourceFileNum);
+ _resourceFile.close();
+ char name[20];
+ sprintf(name, "queen.%d", num);
+ if (!_resourceFile.open(name)) {
+ error("Could not open resource file '%s'", name);
+ }
+ _currentResourceFileNum = num;
+ }
+ _resourceFile.seek(offset);
+}
+
void Resource::readTableFile(uint32 offset) {
Common::File tableFile;
tableFile.open(_tableFilename);
@@ -295,9 +294,9 @@ const RetailGameVersion *Resource::detectGameVersionFromSize(uint32 size) {
Common::File *Resource::findSound(const char *filename, uint32 *size) {
assert(strstr(filename, ".SB") != NULL || strstr(filename, ".AMR") != NULL);
ResourceEntry *re = resourceEntry(filename);
- if (re && re->bundle == 1) {
+ if (re) {
*size = re->size;
- _resourceFile.seek(re->offset);
+ seekResourceFile(re->bundle, re->offset);
return &_resourceFile;
}
return NULL;
diff --git a/engines/queen/resource.h b/engines/queen/resource.h
index 2c16e51b82..609e8edc8f 100644
--- a/engines/queen/resource.h
+++ b/engines/queen/resource.h
@@ -128,6 +128,8 @@ protected:
Common::File _resourceFile;
+ int _currentResourceFileNum;
+
DetectedGameVersion _version;
//! number of entries in resource table
@@ -141,6 +143,9 @@ protected:
//! returns a reference to the ReseourceEntry for the specified filename
ResourceEntry *resourceEntry(const char *filename) const;
+ //! seeks resource file to specific bundle and file offset
+ void seekResourceFile(int num, uint32 offset);
+
//! extarct the resource table for the specified game version
void readTableFile(uint32 offset);
diff --git a/engines/queen/sound.cpp b/engines/queen/sound.cpp
index e228d6a1dd..af4e7ad894 100644
--- a/engines/queen/sound.cpp
+++ b/engines/queen/sound.cpp
@@ -547,6 +547,7 @@ void AmigaSound::updateMusic() {
}
void AmigaSound::playSound(const char *base) {
+ debug(7, "AmigaSound::playSound(%s)", base);
char soundName[20];
sprintf(soundName, "%s.AMR", base);
@@ -563,6 +564,7 @@ void AmigaSound::playSound(const char *base) {
}
void AmigaSound::playModule(const char *base, int song) {
+ debug(7, "AmigaSound::playModule(%s, %d)", base, song);
char name[20];
// load song/pattern data
diff --git a/engines/queen/sound.h b/engines/queen/sound.h
index c93714e0d9..b719bce7a8 100644
--- a/engines/queen/sound.h
+++ b/engines/queen/sound.h
@@ -74,6 +74,8 @@ public:
virtual bool isSpeechActive() const { return false; }
virtual bool isSfxActive() const { return false; }
+ virtual void updateMusic() {}
+
virtual void setVolume(int vol) { _masterVolume = vol; }
virtual int volume() { return _masterVolume; }
@@ -168,9 +170,9 @@ public:
void stopSfx();
void stopSong();
- void updateMusic();
+ bool isSfxActive() const { return _mixer->isSoundHandleActive(_sfxHandle); }
- bool isSfxActive() const { return false; }
+ void updateMusic();
protected: