diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/hopkins/files.cpp | 54 | ||||
-rw-r--r-- | engines/hopkins/files.h | 2 | ||||
-rw-r--r-- | engines/hopkins/graphics.cpp | 21 | ||||
-rw-r--r-- | engines/hopkins/objects.cpp | 17 | ||||
-rw-r--r-- | engines/hopkins/sound.cpp | 81 | ||||
-rw-r--r-- | engines/hopkins/talk.cpp | 25 |
6 files changed, 120 insertions, 80 deletions
diff --git a/engines/hopkins/files.cpp b/engines/hopkins/files.cpp index 13d30029ca..3f7c4e48dd 100644 --- a/engines/hopkins/files.cpp +++ b/engines/hopkins/files.cpp @@ -96,8 +96,9 @@ bool FileManager::fileExists(const Common::String &file) { /** * Search file in Cat file */ -byte *FileManager::searchCat(const Common::String &file, CatMode mode) { +byte *FileManager::searchCat(const Common::String &file, CatMode mode, bool &fileFoundFl) { byte *ptr = NULL; + fileFoundFl = true; Common::File f; Common::String filename = file; @@ -106,54 +107,68 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) { switch (mode) { case RES_INI: - if (!f.exists("RES_INI.CAT")) - return g_PTRNUL; + if (!f.exists("RES_INI.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_INI.CAT"); secondaryFilename = "RES_INI.RES"; break; case RES_REP: - if (!f.exists("RES_REP.CAT")) - return g_PTRNUL; + if (!f.exists("RES_REP.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_REP.CAT"); secondaryFilename = "RES_REP.RES"; break; case RES_LIN: - if (!f.exists("RES_LIN.CAT")) - return g_PTRNUL; + if (!f.exists("RES_LIN.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_LIN.CAT"); secondaryFilename = "RES_LIN.RES"; break; case RES_PER: - if (!f.exists("RES_PER.CAT")) - return g_PTRNUL; + if (!f.exists("RES_PER.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_PER.CAT"); secondaryFilename = "RES_PER.RES"; break; case RES_PIC: - if (!f.exists("PIC.CAT")) - return g_PTRNUL; + if (!f.exists("PIC.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("PIC.CAT"); break; case RES_SAN: - if (!f.exists("RES_SAN.CAT")) - return g_PTRNUL; + if (!f.exists("RES_SAN.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_SAN.CAT"); break; case RES_SLI: - if (!f.exists("RES_SLI.CAT")) - return g_PTRNUL; + if (!f.exists("RES_SLI.CAT")) { + fileFoundFl = false; + return NULL; + } ptr = loadFile("RES_SLI.CAT"); break; @@ -177,8 +192,10 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) { } } - if (!f.exists(tmpFilename)) - return g_PTRNUL; + if (!f.exists(tmpFilename)) { + fileFoundFl = false; + return NULL; + } ptr = loadFile(tmpFilename); break; @@ -206,7 +223,8 @@ byte *FileManager::searchCat(const Common::String &file, CatMode mode) { if (name == "FINIS") { _vm->_globals->freeMemory(ptr); - return g_PTRNUL; + fileFoundFl = false; + return NULL; } offsetVal += 23; diff --git a/engines/hopkins/files.h b/engines/hopkins/files.h index 6d2904a21e..307c2f820a 100644 --- a/engines/hopkins/files.h +++ b/engines/hopkins/files.h @@ -49,7 +49,7 @@ public: byte *loadFile(const Common::String &file); int readStream(Common::ReadStream &stream, void *buf, size_t nbytes); void initCensorship(); - byte *searchCat(const Common::String &file, CatMode mode); + byte *searchCat(const Common::String &file, CatMode mode, bool &fileFoundFl); uint32 fileSize(const Common::String &filename); }; diff --git a/engines/hopkins/graphics.cpp b/engines/hopkins/graphics.cpp index 9d1093edf9..a903462ecb 100644 --- a/engines/hopkins/graphics.cpp +++ b/engines/hopkins/graphics.cpp @@ -201,7 +201,9 @@ void GraphicsManager::loadScreen(const Common::String &file) { assert(!_videoPtr); bool flag = true; - if (_vm->_fileManager->searchCat(file, RES_PIC) == g_PTRNUL) { + bool fileFoundFl = false; + _vm->_fileManager->searchCat(file, RES_PIC, fileFoundFl); + if (!fileFoundFl) { if (!f.open(file)) error("loadScreen - %s", file.c_str()); @@ -1680,17 +1682,21 @@ void GraphicsManager::displayFont(byte *surface, const byte *spriteData, int xp, void GraphicsManager::initScreen(const Common::String &file, int mode, bool initializeScreen) { Common::String filename = file + ".ini"; - byte *ptr = _vm->_fileManager->searchCat(filename, RES_INI); + bool fileFoundFl = false; - if (ptr == g_PTRNUL) { + byte *ptr = _vm->_fileManager->searchCat(filename, RES_INI, fileFoundFl); + + if (!fileFoundFl) { ptr = _vm->_fileManager->loadFile(filename); } + if (!mode) { filename = file + ".spr"; _vm->_globals->_levelSpriteBuf = _vm->_globals->freeMemory(_vm->_globals->_levelSpriteBuf); if (initializeScreen) { - _vm->_globals->_levelSpriteBuf = _vm->_fileManager->searchCat(filename, RES_SLI); - if (_vm->_globals->_levelSpriteBuf) { + fileFoundFl = false; + _vm->_globals->_levelSpriteBuf = _vm->_fileManager->searchCat(filename, RES_SLI, fileFoundFl); + if (!fileFoundFl) { _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile(filename); } else { _vm->_globals->_levelSpriteBuf = _vm->_fileManager->loadFile("RES_SLI.RES"); @@ -1724,8 +1730,9 @@ void GraphicsManager::initScreen(const Common::String &file, int mode, bool init _vm->_globals->_answerBuffer = _vm->_globals->freeMemory(_vm->_globals->_answerBuffer); filename = file + ".rep"; - byte *dataP = _vm->_fileManager->searchCat(filename, RES_REP); - if (dataP == g_PTRNUL) + fileFoundFl = false; + byte *dataP = _vm->_fileManager->searchCat(filename, RES_REP, fileFoundFl); + if (!fileFoundFl) dataP = _vm->_fileManager->loadFile(filename); _vm->_globals->_answerBuffer = dataP; diff --git a/engines/hopkins/objects.cpp b/engines/hopkins/objects.cpp index f8679890fb..6e6d539ea2 100644 --- a/engines/hopkins/objects.cpp +++ b/engines/hopkins/objects.cpp @@ -2602,8 +2602,9 @@ void ObjectsManager::loadObjectIniFile() { int lastOpcodeResult = 1; file = "OBJET1.ini"; - data = _vm->_fileManager->searchCat(file, RES_INI); - if (data == g_PTRNUL) { + bool fileFoundFl = false; + data = _vm->_fileManager->searchCat(file, RES_INI, fileFoundFl); + if (!fileFoundFl) { data = _vm->_fileManager->loadFile(file); if (data == g_PTRNUL) error("INI file %s not found", file.c_str()); @@ -3101,15 +3102,16 @@ int ObjectsManager::getBobPosX(int idx) { void ObjectsManager::loadLinkFile(const Common::String &file, bool skipDetails) { Common::File f; Common::String filename = file + ".LNK"; - byte *ptr = _vm->_fileManager->searchCat(filename, RES_LIN); + bool fileFoundFl = false; + byte *ptr = _vm->_fileManager->searchCat(filename, RES_LIN, fileFoundFl); size_t nbytes = _vm->_fileManager->_catalogSize; - if (ptr == g_PTRNUL) { + if (!fileFoundFl) { if (!f.open(filename)) error("Error opening file - %s", filename.c_str()); nbytes = f.size(); ptr = _vm->_globals->allocMemory(nbytes); - if (g_PTRNUL == ptr) + if (ptr == g_PTRNUL) error("INILINK"); _vm->_fileManager->readStream(f, ptr, nbytes); f.close(); @@ -3122,9 +3124,10 @@ void ObjectsManager::loadLinkFile(const Common::String &file, bool skipDetails) Common::String filename2 = Common::String((const char *)ptr + 1000); if (!filename2.empty()) { - _hidingItemData[1] = _vm->_fileManager->searchCat(filename2, RES_SLI); + fileFoundFl = false; + _hidingItemData[1] = _vm->_fileManager->searchCat(filename2, RES_SLI, fileFoundFl); - if (_hidingItemData[1]) { + if (!fileFoundFl) { _hidingItemData[1] = _vm->_fileManager->loadFile(filename2); } else { _hidingItemData[1] = _vm->_fileManager->loadFile("RES_SLI.RES"); diff --git a/engines/hopkins/sound.cpp b/engines/hopkins/sound.cpp index 246e611642..e192516707 100644 --- a/engines/hopkins/sound.cpp +++ b/engines/hopkins/sound.cpp @@ -517,33 +517,9 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { filename = Common::String::format("%s%d", prefix.c_str(), mappedFileNumber); - if (!_vm->_fileManager->searchCat(filename + ".WAV", RES_VOI)) { - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - filename = "ENG_VOI.RES"; - // Win95 and Linux versions uses another set of names - else if (_vm->_globals->_language == LANG_FR) - filename = "RES_VFR.RES"; - else if (_vm->_globals->_language == LANG_EN) - filename = "RES_VAN.RES"; - else if (_vm->_globals->_language == LANG_SP) - filename = "RES_VES.RES"; - - catPos = _vm->_fileManager->_catalogPos; - catLen = _vm->_fileManager->_catalogSize; - } else if (!_vm->_fileManager->searchCat(filename + ".APC", RES_VOI)) { - if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) - filename = "ENG_VOI.RES"; - // Win95 and Linux versions uses another set of names - else if (_vm->_globals->_language == LANG_FR) - filename = "RES_VFR.RES"; - else if (_vm->_globals->_language == LANG_EN) - filename = "RES_VAN.RES"; - else if (_vm->_globals->_language == LANG_SP) - filename = "RES_VES.RES"; - - catPos = _vm->_fileManager->_catalogPos; - catLen = _vm->_fileManager->_catalogSize; - } else if (!_vm->_fileManager->searchCat(filename + ".RAW", RES_VOI)) { + bool fileFoundFl = false; + _vm->_fileManager->searchCat(filename + ".WAV", RES_VOI, fileFoundFl); + if (fileFoundFl) { if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) filename = "ENG_VOI.RES"; // Win95 and Linux versions uses another set of names @@ -557,17 +533,48 @@ bool SoundManager::mixVoice(int voiceId, int voiceMode, bool dispTxtFl) { catPos = _vm->_fileManager->_catalogPos; catLen = _vm->_fileManager->_catalogSize; } else { - if (!f.exists(filename + ".WAV")) { - if (!f.exists(filename + ".APC")) - return false; - filename = filename + ".APC"; - } else - filename = filename + ".WAV"; - - catPos = 0; - catLen = 0; + _vm->_fileManager->searchCat(filename + ".APC", RES_VOI, fileFoundFl); + if (fileFoundFl) { + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + filename = "ENG_VOI.RES"; + // Win95 and Linux versions uses another set of names + else if (_vm->_globals->_language == LANG_FR) + filename = "RES_VFR.RES"; + else if (_vm->_globals->_language == LANG_EN) + filename = "RES_VAN.RES"; + else if (_vm->_globals->_language == LANG_SP) + filename = "RES_VES.RES"; + + catPos = _vm->_fileManager->_catalogPos; + catLen = _vm->_fileManager->_catalogSize; + } else { + _vm->_fileManager->searchCat(filename + ".RAW", RES_VOI, fileFoundFl); + if (fileFoundFl) { + if (_vm->getPlatform() == Common::kPlatformOS2 || _vm->getPlatform() == Common::kPlatformBeOS) + filename = "ENG_VOI.RES"; + // Win95 and Linux versions uses another set of names + else if (_vm->_globals->_language == LANG_FR) + filename = "RES_VFR.RES"; + else if (_vm->_globals->_language == LANG_EN) + filename = "RES_VAN.RES"; + else if (_vm->_globals->_language == LANG_SP) + filename = "RES_VES.RES"; + + catPos = _vm->_fileManager->_catalogPos; + catLen = _vm->_fileManager->_catalogSize; + } else { + if (!f.exists(filename + ".WAV")) { + if (!f.exists(filename + ".APC")) + return false; + filename = filename + ".APC"; + } else + filename = filename + ".WAV"; + + catPos = 0; + catLen = 0; + } + } } - oldMusicVol = _musicVolume; if (!loadVoice(filename, catPos, catLen, _sWav[20])) { // This case only concerns the English Win95 demo diff --git a/engines/hopkins/talk.cpp b/engines/hopkins/talk.cpp index fea3b196a2..819f6bc467 100644 --- a/engines/hopkins/talk.cpp +++ b/engines/hopkins/talk.cpp @@ -55,9 +55,10 @@ void TalkManager::startAnimatedCharacterDialogue(const Common::String &filename) _vm->_graphicsManager->_scrollStatus = 1; bool oldDisableInventFl = _vm->_globals->_disableInventFl; _vm->_globals->_disableInventFl = true; - _characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER); + bool fileFoundFl = false; + _characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER, fileFoundFl); _characterSize = _vm->_fileManager->_catalogSize; - if (_characterBuffer == g_PTRNUL) { + if (!fileFoundFl) { _characterBuffer = _vm->_fileManager->loadFile(filename); _characterSize = _vm->_fileManager->fileSize(filename); } @@ -76,8 +77,9 @@ void TalkManager::startAnimatedCharacterDialogue(const Common::String &filename) } _dialogueMesgId1 = READ_LE_INT16((uint16 *)_characterBuffer + 40); _paletteBufferIdx = 20 * READ_LE_INT16((uint16 *)_characterBuffer + 42) + 110; - _characterSprite = _vm->_fileManager->searchCat(spriteFilename, RES_SAN); - if (_characterSprite) { + fileFoundFl = false; + _characterSprite = _vm->_fileManager->searchCat(spriteFilename, RES_SAN, fileFoundFl); + if (!fileFoundFl) { _characterSprite = _vm->_objectsManager->loadSprite(spriteFilename); } else { _characterSprite = _vm->_objectsManager->loadSprite("RES_SAN.RES"); @@ -151,9 +153,10 @@ void TalkManager::startStaticCharacterDialogue(const Common::String &filename) { // TODO: The original disables the mouse cursor here bool oldDisableInventFl = _vm->_globals->_disableInventFl; _vm->_globals->_disableInventFl = true; - _characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER); + bool fileFoundFl = false; + _characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER, fileFoundFl); _characterSize = _vm->_fileManager->_catalogSize; - if (_characterBuffer == g_PTRNUL) { + if (!fileFoundFl) { _characterBuffer = _vm->_fileManager->loadFile(filename); _characterSize = _vm->_fileManager->fileSize(filename); } @@ -971,9 +974,10 @@ void TalkManager::animateObject(const Common::String &filename) { _vm->_objectsManager->_zoneNum = -1; _vm->_eventsManager->_mouseCursorId = 4; _vm->_eventsManager->changeMouseCursor(0); - _characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER); + bool fileFoundFl = false; + _characterBuffer = _vm->_fileManager->searchCat(filename, RES_PER, fileFoundFl); _characterSize = _vm->_fileManager->_catalogSize; - if (_characterBuffer == g_PTRNUL) { + if (!fileFoundFl) { _characterBuffer = _vm->_fileManager->loadFile(filename); _characterSize = _vm->_fileManager->fileSize(filename); } @@ -987,8 +991,9 @@ void TalkManager::animateObject(const Common::String &filename) { if (curScreenFilename == "NULL") curScreenFilename = Common::String::format("IM%d", _vm->_globals->_screenId); - _characterSprite = _vm->_fileManager->searchCat(spriteFilename, RES_SAN); - if (_characterSprite) + fileFoundFl = false; + _characterSprite = _vm->_fileManager->searchCat(spriteFilename, RES_SAN, fileFoundFl); + if (!fileFoundFl) _characterSprite = _vm->_objectsManager->loadSprite(spriteFilename); else _characterSprite = _vm->_objectsManager->loadSprite("RES_SAN.RES"); |