diff options
author | Gregory Montoir | 2003-12-29 13:18:24 +0000 |
---|---|---|
committer | Gregory Montoir | 2003-12-29 13:18:24 +0000 |
commit | 14cfaf88520e45205689d35ce14aaa40d2a4368a (patch) | |
tree | c4fd27b609c0686c329c8ce51031257b35ebf532 | |
parent | 7e388f2237a9ad22214374bac3ffbb2a9d14f21a (diff) | |
download | scummvm-rg350-14cfaf88520e45205689d35ce14aaa40d2a4368a.tar.gz scummvm-rg350-14cfaf88520e45205689d35ce14aaa40d2a4368a.tar.bz2 scummvm-rg350-14cfaf88520e45205689d35ce14aaa40d2a4368a.zip |
- hack to read patched .dog files (french & italian versions) from game data path instead of data file
- cleanup Resource a bit (add an accessor for ResourceEntry in order to avoid multiple calls to resourceIndex)
svn-id: r12006
-rw-r--r-- | queen/display.cpp | 4 | ||||
-rw-r--r-- | queen/resource.cpp | 23 | ||||
-rw-r--r-- | queen/resource.h | 6 | ||||
-rw-r--r-- | queen/sound.cpp | 6 | ||||
-rw-r--r-- | queen/talk.cpp | 31 | ||||
-rw-r--r-- | queen/talk.h | 5 |
6 files changed, 58 insertions, 17 deletions
diff --git a/queen/display.cpp b/queen/display.cpp index 1635ff97b3..9aed6c6957 100644 --- a/queen/display.cpp +++ b/queen/display.cpp @@ -155,12 +155,12 @@ void Display::dynalumInit(const char *roomName, uint16 roomNum) { char filename[20]; sprintf(filename, "%s.msk", roomName); - _dynalum.valid = _vm->resource()->exists(filename); + _dynalum.valid = _vm->resource()->fileExists(filename); if (_dynalum.valid) _vm->resource()->loadFile(filename, 0, (uint8*)_dynalum.msk); sprintf(filename, "%s.lum", roomName); - _dynalum.valid = _vm->resource()->exists(filename); + _dynalum.valid = _vm->resource()->fileExists(filename); if (_dynalum.valid) _vm->resource()->loadFile(filename, 0, (uint8*)_dynalum.lum); } diff --git a/queen/resource.cpp b/queen/resource.cpp index e2d6811627..5dbd488ef0 100644 --- a/queen/resource.cpp +++ b/queen/resource.cpp @@ -103,6 +103,14 @@ int32 Resource::resourceIndex(const char *filename) const { return -1; } +ResourceEntry *Resource::resourceEntry(const char *filename) const { + int32 index = resourceIndex(filename); + if (index >= 0) + return &_resourceTable[index]; + else + return NULL; +} + char *Resource::getJAS2Line() { char *startOfLine = _JAS2Ptr + _JAS2Pos; char *curPos = startOfLine; @@ -114,11 +122,12 @@ char *Resource::getJAS2Line() { } uint8 *Resource::loadFile(const char *filename, uint32 skipBytes, byte *dstBuf) { - uint32 size = fileSize(filename) - skipBytes; - if (dstBuf == NULL) + ResourceEntry *re = resourceEntry(filename); + assert(re != NULL); + uint32 size = re->size - skipBytes; + if (dstBuf == NULL) dstBuf = new byte[size]; - // skip 'skipBytes' bytes (useful for headers) - _resourceFile->seek(fileOffset(filename) + skipBytes, SEEK_SET); + _resourceFile->seek(re->offset + skipBytes); _resourceFile->read(dstBuf, size); return dstBuf; } @@ -164,14 +173,14 @@ bool Resource::findCompressedVersion() { } void Resource::checkJASVersion() { - int32 offset = fileOffset("QUEEN.JAS"); + int32 offset = resourceEntry("QUEEN.JAS")->offset; if (isDemo()) offset += JAS_VERSION_OFFSET_DEMO; else if (isInterview()) offset += JAS_VERSION_OFFSET_INTV; else offset += JAS_VERSION_OFFSET; - _resourceFile->seek(offset, SEEK_SET); + _resourceFile->seek(offset); char versionStr[6]; _resourceFile->read(versionStr, 6); @@ -246,7 +255,7 @@ const GameVersion *Resource::detectGameVersion(uint32 size) const { File *Resource::giveCompressedSound(const char *filename) { assert(strstr(filename, ".SB")); - _resourceFile->seek(fileOffset(filename), SEEK_SET); + _resourceFile->seek(resourceEntry(filename)->offset); return _resourceFile; } diff --git a/queen/resource.h b/queen/resource.h index dae72aff0c..c79d6f25cd 100644 --- a/queen/resource.h +++ b/queen/resource.h @@ -70,9 +70,8 @@ public: uint8 *loadFile(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL); uint8 *loadFileMalloc(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL); - bool exists(const char *filename) const { return resourceIndex(filename) >= 0; } - uint32 fileSize(const char *filename) const { return _resourceTable[resourceIndex(filename)].size; } - uint32 fileOffset(const char *filename) const { return _resourceTable[resourceIndex(filename)].offset; } + bool fileExists(const char *filename) const { return resourceEntry(filename) != NULL; } + uint32 fileSize(const char *filename) const { return resourceEntry(filename)->size; } File *giveCompressedSound(const char *filename); @@ -109,6 +108,7 @@ protected: bool findCompressedVersion(); void checkJASVersion(); int32 resourceIndex(const char *filename) const; + ResourceEntry *resourceEntry(const char *filename) const; bool readTableFile(const GameVersion *gameVersion); void readTableCompResource(); void readTableEntries(File *file); diff --git a/queen/sound.cpp b/queen/sound.cpp index ceeb5cc9e7..67edeafa14 100644 --- a/queen/sound.cpp +++ b/queen/sound.cpp @@ -147,14 +147,14 @@ void SBSound::playSound(byte *sound, uint32 size) { void SBSound::sfxPlay(const char *name) { waitSfxFinished(); - if (_vm->resource()->exists(name)) + if (_vm->resource()->fileExists(name)) playSound(_vm->resource()->loadFileMalloc(name, SB_HEADER_SIZE), _vm->resource()->fileSize(name) - SB_HEADER_SIZE); } #ifdef USE_MAD void MP3Sound::sfxPlay(const char *name) { waitSfxFinished(); - if (_vm->resource()->exists(name)) + if (_vm->resource()->fileExists(name)) _mixer->playMP3(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name)); } #endif @@ -162,7 +162,7 @@ void MP3Sound::sfxPlay(const char *name) { #ifdef USE_VORBIS void OGGSound::sfxPlay(const char *name) { waitSfxFinished(); - if (_vm->resource()->exists(name)) + if (_vm->resource()->fileExists(name)) _mixer->playVorbis(&_sfxHandle, _vm->resource()->giveCompressedSound(name), _vm->resource()->fileSize(name)); } #endif diff --git a/queen/talk.cpp b/queen/talk.cpp index e531c31e09..4830343b9f 100644 --- a/queen/talk.cpp +++ b/queen/talk.cpp @@ -31,6 +31,8 @@ #include "queen/sound.h" #include "queen/state.h" +#include "common/file.h" + namespace Queen { /* @@ -378,10 +380,37 @@ void Talk::findDialogueString(byte *ptr, int16 id, int16 max, char *str) { warning("Failed to find string with ID %i", id); } +byte *Talk::loadDialogFile(const char *filename) { + static const struct { + const char *filename; + Language lang; + } dogFiles[] = { + { "chief1.dog", FRENCH }, + { "chief2.dog", FRENCH }, + { "bud1.dog", ITALIAN } + }; + for (int i = 0; i < ARRAYSIZE(dogFiles); ++i) { + if (!scumm_stricmp(filename, dogFiles[i].filename) && + _vm->resource()->getLanguage() == dogFiles[i].lang) { + File fdog; + fdog.open(filename, _vm->getGameDataPath()); + if (fdog.isOpen()) { + debug(0, "Loading dog file '%s' from game data path", filename); + uint32 size = fdog.size() - DOG_HEADER_SIZE; + byte *buf = new byte[size]; + fdog.seek(DOG_HEADER_SIZE); + fdog.read(buf, size); + return buf; + } + } + } + return _vm->resource()->loadFile(filename, DOG_HEADER_SIZE); +} + void Talk::load(const char *filename) { int i; - byte *ptr = _fileData = _vm->resource()->loadFile(filename, 20); + byte *ptr = _fileData = loadDialogFile(filename); if (!_fileData) { error("Failed to load resource data file '%s'", filename); } diff --git a/queen/talk.h b/queen/talk.h index 6e3fc4c600..e94315f670 100644 --- a/queen/talk.h +++ b/queen/talk.h @@ -60,7 +60,8 @@ private: ARROW_BOB_UP = 62, ARROW_BOB_DOWN = 63, ARROW_ZONE_UP = 5, - ARROW_ZONE_DOWN = 6 + ARROW_ZONE_DOWN = 6, + DOG_HEADER_SIZE = 20 }; //! Special commands for speech @@ -153,6 +154,8 @@ private: //! Perform talk in file and return a cutaway filename void talk(const char *filename, int personInRoom, char *cutawayFilename); + byte *loadDialogFile(const char *filename); + //! Load talk data from .dog file void load(const char *filename); |