diff options
-rw-r--r-- | queen/defs.h | 6 | ||||
-rw-r--r-- | queen/queen.cpp | 20 | ||||
-rw-r--r-- | queen/resource.cpp | 58 | ||||
-rw-r--r-- | queen/resource.h | 6 |
4 files changed, 66 insertions, 24 deletions
diff --git a/queen/defs.h b/queen/defs.h index c8f4667192..9d4dda98a7 100644 --- a/queen/defs.h +++ b/queen/defs.h @@ -28,6 +28,12 @@ namespace Queen { #define InRange(x,l,h) ((x)<=(h) && (x)>=(l)) /* X in [l..h] */ enum { + COMPRESSION_NONE = 0, + COMPRESSION_MP3 = 1, + COMPRESSION_OGG = 2 +}; + +enum { GAME_SCREEN_WIDTH = 320, GAME_SCREEN_HEIGHT = 200, ROOM_ZONE_HEIGHT = 150, diff --git a/queen/queen.cpp b/queen/queen.cpp index 4f84d22cec..cb8d43ac92 100644 --- a/queen/queen.cpp +++ b/queen/queen.cpp @@ -44,6 +44,7 @@ extern bool draw_keyboard; static const GameSettings queen_settings[] = { /* Flight of the Amazon Queen */ { "queen", "Flight of the Amazon Queen", GID_QUEEN_FIRST, 99, MDT_ADLIB | MDT_NATIVE | MDT_PREFER_NATIVE, 0, "queen.1" }, + { "queencomp", "Flight of the Amazon Queen", GID_QUEEN_FIRST, 99, MDT_ADLIB | MDT_NATIVE | MDT_PREFER_NATIVE, 0, "queen.1c" }, { NULL, NULL, 0, 0, MDT_NONE, 0, NULL} }; @@ -59,15 +60,18 @@ GameList Engine_QUEEN_detectGames(const FSList &fslist) { GameList detectedGames; const GameSettings *g = &queen_settings[0]; - // Iterate over all files in the given directory - for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) { - const char *gameName = file->displayName().c_str(); + while(g->detectname) { + // Iterate over all files in the given directory + for (FSList::ConstIterator file = fslist.begin(); file != fslist.end(); ++file) { + const char *gameName = file->displayName().c_str(); - if (0 == scumm_stricmp(g->detectname, gameName)) { - // Match found, add to list of candidates, then abort inner loop. - detectedGames.push_back(*g); - break; + if (0 == scumm_stricmp(g->detectname, gameName)) { + // Match found, add to list of candidates, then abort inner loop. + detectedGames.push_back(*g); + break; + } } + g++; } return detectedGames; } @@ -213,7 +217,7 @@ void QueenEngine::go() { } void QueenEngine::initialise(void) { - _resource = new Resource(_gameDataPath); + _resource = new Resource(_gameDataPath, _detector->_game.detectname); _display = new Display(_system); _graphics = new Graphics(_display, _resource); _logic = new Logic(_resource, _graphics, _display); diff --git a/queen/resource.cpp b/queen/resource.cpp index e6cc1b64d3..c7994b4be0 100644 --- a/queen/resource.cpp +++ b/queen/resource.cpp @@ -27,7 +27,6 @@ namespace Queen { #define DEMO_JAS_VERSION_OFFSET 0x119A8 #define JAS_VERSION_OFFSET 0x12484 -static const char *dataFilename = "queen.1"; static const char *tableFilename = "queen.tbl"; const GameVersion Resource::_gameVersions[] = { @@ -43,28 +42,30 @@ const GameVersion Resource::_gameVersions[] = { { "PE100", true, true, 0x000B40F5 } }; -Resource::Resource(const Common::String &datafilePath) +Resource::Resource(const Common::String &datafilePath, const char *datafileName) : _JAS2Pos(0), _datafilePath(datafilePath), _resourceEntries(0), _resourceTable(NULL) { _resourceFile = new File(); - _resourceFile->open(dataFilename, _datafilePath); + _resourceFile->open(datafileName, _datafilePath); if (_resourceFile->isOpen() == false) - error("Could not open resource file '%s%s'", _datafilePath.c_str(), dataFilename); - + error("Could not open resource file '%s%s'", _datafilePath.c_str(), datafileName); - _gameVersion = detectGameVersion(_resourceFile->size()); + if (_resourceFile->readUint32BE() == 'QTBL') { + readTableCompResource(); + } else { + _gameVersion = detectGameVersion(_resourceFile->size()); - if (!readTableFile()) { - //check if it is the english floppy version, for which we have a hardcoded version of the tables - if (!strcmp(_gameVersion->versionString, _gameVersions[VER_ENG_FLOPPY].versionString)) { - _gameVersion = &_gameVersions[VER_ENG_FLOPPY]; - _resourceEntries = 1076; - _resourceTable = _resourceTablePEM10; - } else { - error("Couldn't find tablefile '%s%s'", _datafilePath.c_str(), tableFilename); + if (!readTableFile()) { + //check if it is the english floppy version, for which we have a hardcoded version of the tables + if (!strcmp(_gameVersion->versionString, _gameVersions[VER_ENG_FLOPPY].versionString)) { + _gameVersion = &_gameVersions[VER_ENG_FLOPPY]; + _resourceEntries = 1076; + _resourceTable = _resourceTablePEM10; + } else { + error("Couldn't find tablefile '%s%s'", _datafilePath.c_str(), tableFilename); + } } } - if (strcmp(_gameVersion->versionString, JASVersion())) error("Verifying game version failed! (expected: '%s', found: '%s')", _gameVersion->versionString, JASVersion()); @@ -250,5 +251,32 @@ bool Resource::readTableFile() { return false; } +void Resource::readTableCompResource() { + GameVersion *gv = new GameVersion; + _resourceFile->read(gv->versionString, 6); + gv->isFloppy = _resourceFile->readByte() != 0; + gv->isDemo = _resourceFile->readByte() != 0; + _compression = _resourceFile->readByte(); + _resourceEntries = _resourceFile->readUint16BE(); + _gameVersion = gv; + + _resourceFile->seek(15, SEEK_SET); + _resourceTable = new ResourceEntry[_resourceEntries]; + ResourceEntry *pre = _resourceTable; + for (uint32 i = 0; i < _resourceEntries; ++i, ++pre) { + _resourceFile->read(pre->filename, 12); + pre->filename[12] = '\0'; + pre->inBundle = _resourceFile->readByte(); + pre->offset = _resourceFile->readUint32BE(); + pre->size = _resourceFile->readUint32BE(); + } +} + +File *Resource::giveMP3(const char *filename) { + assert(strstr(filename, ".SB")); + _resourceFile->seek(fileOffset(filename), SEEK_SET); + return _resourceFile; +} + } // End of namespace Queen diff --git a/queen/resource.h b/queen/resource.h index 84ee8bc137..cc9e0ac7dc 100644 --- a/queen/resource.h +++ b/queen/resource.h @@ -58,14 +58,16 @@ struct GameVersion { class Resource { public: - Resource(const Common::String &datafilePath); + Resource(const Common::String &datafilePath, const char *datafileName); ~Resource(void); uint8 *loadFile(const char *filename, uint32 skipBytes = 0, byte *dstBuf = NULL); char *getJAS2Line(); bool exists(const char *filename); bool isDemo(); bool isFloppy(); + uint8 compression() { return _compression; } uint32 fileSize(const char *filename); + File *giveMP3(const char *filename); Language getLanguage(); const char *JASVersion(); @@ -73,6 +75,7 @@ protected: File *_resourceFile; char *_JAS2Ptr; uint32 _JAS2Pos; + uint8 _compression; const Common::String _datafilePath; const GameVersion *_gameVersion; uint32 _resourceEntries; @@ -83,6 +86,7 @@ protected: int32 resourceIndex(const char *filename); uint32 fileOffset(const char *filename); bool readTableFile(); + void readTableCompResource(); static const GameVersion *detectGameVersion(uint32 dataFilesize); }; |