mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-20 08:53:51 +00:00
some fixes with resource files handling for Amiga versions
svn-id: r25785
This commit is contained in:
parent
2c1445056d
commit
eec3543c7d
@ -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) {
|
||||
|
@ -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(
|
||||
|
@ -211,6 +211,7 @@ void QueenEngine::update(bool checkPlayerInput) {
|
||||
_display->blankScreen();
|
||||
}
|
||||
}
|
||||
_sound->updateMusic();
|
||||
}
|
||||
|
||||
bool QueenEngine::canLoadOrSave() const {
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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:
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user