diff options
Diffstat (limited to 'engines/hugo/file_v2d.cpp')
-rw-r--r-- | engines/hugo/file_v2d.cpp | 45 |
1 files changed, 29 insertions, 16 deletions
diff --git a/engines/hugo/file_v2d.cpp b/engines/hugo/file_v2d.cpp index 43de3fac4c..baf7f4c97f 100644 --- a/engines/hugo/file_v2d.cpp +++ b/engines/hugo/file_v2d.cpp @@ -40,23 +40,29 @@ #include "hugo/util.h" namespace Hugo { -FileManager_v2d::FileManager_v2d(HugoEngine &vm) : FileManager(vm) { +FileManager_v2d::FileManager_v2d(HugoEngine *vm) : FileManager(vm) { } FileManager_v2d::~FileManager_v2d() { } +/** +* Open "database" file (packed files) +*/ void FileManager_v2d::openDatabaseFiles() { debugC(1, kDebugFile, "openDatabaseFiles"); if (!_stringArchive.open(STRING_FILE)) - Utils::Error(FILE_ERR, "%s", STRING_FILE); + error("File not found: %s", STRING_FILE); if (!_sceneryArchive1.open("scenery.dat")) - Utils::Error(FILE_ERR, "%s", "scenery.dat"); + error("File not found: scenery.dat"); if (!_objectsArchive.open(OBJECTS_FILE)) - Utils::Error(FILE_ERR, "%s", OBJECTS_FILE); + error("File not found: %s", OBJECTS_FILE); } +/** +* Close "Database" files +*/ void FileManager_v2d::closeDatabaseFiles() { debugC(1, kDebugFile, "closeDatabaseFiles"); @@ -65,8 +71,10 @@ void FileManager_v2d::closeDatabaseFiles() { _objectsArchive.close(); } +/** +* Read a PCX image into dib_a +*/ void FileManager_v2d::readBackground(int screenIndex) { -// Read a PCX image into dib_a debugC(1, kDebugFile, "readBackground(%d)", screenIndex); _sceneryArchive1.seek((uint32) screenIndex * sizeof(sceneBlock_t), SEEK_SET); @@ -84,15 +92,18 @@ void FileManager_v2d::readBackground(int screenIndex) { _sceneryArchive1.seek(sceneBlock.scene_off, SEEK_SET); // Read the image into dummy seq and static dib_a - seq_t dummySeq; // Image sequence structure for Read_pcx - readPCX(_sceneryArchive1, &dummySeq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]); + seq_t *dummySeq; // Image sequence structure for Read_pcx + dummySeq = readPCX(_sceneryArchive1, 0, _vm->_screen->getFrontBuffer(), true, _vm->_screenNames[screenIndex]); + free(dummySeq); } +/** +* Open and read in an overlay file, close file +*/ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayType) { -// Open and read in an overlay file, close file debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum); - image_pt tmpImage = image; // temp ptr to overlay file + image_pt tmpImage = image; // temp ptr to overlay file _sceneryArchive1.seek((uint32)screenNum * sizeof(sceneBlock_t), SEEK_SET); sceneBlock_t sceneBlock; // Database header entry @@ -120,7 +131,7 @@ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy i = sceneBlock.ob_len; break; default: - Utils::Error(FILE_ERR, "%s", "Bad ovl_type"); + error("Bad overlayType: %d", overlayType); break; } if (i == 0) { @@ -147,30 +158,32 @@ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy } while (k < OVL_SIZE); } +/** +* Fetch string from file, decode and return ptr to string in memory +*/ char *FileManager_v2d::fetchString(int index) { -// Fetch string from file, decode and return ptr to string in memory debugC(1, kDebugFile, "fetchString(%d)", index); // Get offset to string[index] (and next for length calculation) _stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET); uint32 off1, off2; if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0) - Utils::Error(FILE_ERR, "%s", "String offset"); + error("An error has occurred: bad String offset"); if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0) - Utils::Error(FILE_ERR, "%s", "String offset"); + error("An error has occurred: bad String offset"); // Check size of string if ((off2 - off1) >= MAX_BOX) - Utils::Error(FILE_ERR, "%s", "Fetched string too long!"); + error("Fetched string too long!"); // Position to string and read it into gen purpose _textBoxBuffer _stringArchive.seek(off1, SEEK_SET); if (_stringArchive.read(_textBoxBuffer, (uint16)(off2 - off1)) == 0) - Utils::Error(FILE_ERR, "%s", "Fetch_string"); + error("An error has occurred: fetchString"); // Null terminate, decode and return it _textBoxBuffer[off2-off1] = '\0'; - _vm.scheduler().decodeString(_textBoxBuffer); + _vm->_scheduler->decodeString(_textBoxBuffer); return _textBoxBuffer; } } // End of namespace Hugo |