aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hugo')
-rw-r--r--engines/hugo/file.cpp591
-rw-r--r--engines/hugo/file.h68
-rw-r--r--engines/hugo/global.h2
-rw-r--r--engines/hugo/hugo.cpp11
4 files changed, 498 insertions, 174 deletions
diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp
index b4645c4d0b..41eb3c88e4 100644
--- a/engines/hugo/file.cpp
+++ b/engines/hugo/file.cpp
@@ -44,7 +44,9 @@
namespace Hugo {
FileManager::FileManager(HugoEngine &vm) : _vm(vm) {
+}
+FileManager::~FileManager() {
}
byte *FileManager::convertPCC(byte *p, uint16 y, uint16 bpl, image_pt dataPtr) {
@@ -235,44 +237,6 @@ void FileManager::readImage(int objNum, object_t *objPtr) {
_objectsArchive.close();
}
-void FileManager::readBackground(int screenIndex) {
-// Read a PCX image into dib_a
- seq_t seq; // Image sequence structure for Read_pcx
- sceneBlock_t sceneBlock; // Read a database header entry
-
- debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
-
- if (_vm.isPacked()) {
- _sceneryArchive.seek((uint32) screenIndex * sizeof(sceneBlock_t), SEEK_SET);
-
- sceneBlock.scene_off = _sceneryArchive.readUint32LE();
- sceneBlock.scene_len = _sceneryArchive.readUint32LE();
- sceneBlock.b_off = _sceneryArchive.readUint32LE();
- sceneBlock.b_len = _sceneryArchive.readUint32LE();
- sceneBlock.o_off = _sceneryArchive.readUint32LE();
- sceneBlock.o_len = _sceneryArchive.readUint32LE();
- sceneBlock.ob_off = _sceneryArchive.readUint32LE();
- sceneBlock.ob_len = _sceneryArchive.readUint32LE();
-
- _sceneryArchive.seek(sceneBlock.scene_off, SEEK_SET);
- } else {
- char *buf = (char *) malloc(2048 + 1); // Buffer for file access
- strcat(strcat(strcpy(buf, _vm._picDir), _vm._screenNames[screenIndex]), BKGEXT);
- if (!_sceneryArchive.open(buf)) {
- warning("File %s not found, trying again with %s.ART", buf, _vm._screenNames[screenIndex]);
- strcat(strcpy(buf, _vm._screenNames[screenIndex]), ".ART");
- if (!_sceneryArchive.open(buf))
- Utils::Error(FILE_ERR, "%s", buf);
- }
- }
-
- // Read the image into dummy seq and static dib_a
- readPCX(_sceneryArchive, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
-
- if (!_vm.isPacked())
- _sceneryArchive.close();
-}
-
sound_pt FileManager::getSound(int16 sound, uint16 *size) {
// Read sound (or music) file data. Call with SILENCE to free-up
// any allocated memory. Also returns size of data
@@ -333,100 +297,6 @@ bool FileManager::fileExists(char *filename) {
return false;
}
-void FileManager::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
-// Open and read in an overlay file, close file
- uint32 i = 0;
- int16 j, k;
- int8 data; // Must be 8 bits signed
- image_pt tmpImage = image; // temp ptr to overlay file
- sceneBlock_t sceneBlock; // Database header entry
-
- debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum);
-
- if (_vm.isPacked()) {
- _sceneryArchive.seek((uint32)screenNum * sizeof(sceneBlock_t), SEEK_SET);
-
- sceneBlock.scene_off = _sceneryArchive.readUint32LE();
- sceneBlock.scene_len = _sceneryArchive.readUint32LE();
- sceneBlock.b_off = _sceneryArchive.readUint32LE();
- sceneBlock.b_len = _sceneryArchive.readUint32LE();
- sceneBlock.o_off = _sceneryArchive.readUint32LE();
- sceneBlock.o_len = _sceneryArchive.readUint32LE();
- sceneBlock.ob_off = _sceneryArchive.readUint32LE();
- sceneBlock.ob_len = _sceneryArchive.readUint32LE();
-
- switch (overlayType) {
- case BOUNDARY:
- _sceneryArchive.seek(sceneBlock.b_off, SEEK_SET);
- i = sceneBlock.b_len;
- break;
- case OVERLAY:
- _sceneryArchive.seek(sceneBlock.o_off, SEEK_SET);
- i = sceneBlock.o_len;
- break;
- case OVLBASE:
- _sceneryArchive.seek(sceneBlock.ob_off, SEEK_SET);
- i = sceneBlock.ob_len;
- break;
- default:
- Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
- break;
- }
- if (i == 0) {
- for (i = 0; i < OVL_SIZE; i++)
- image[i] = 0;
- return;
- }
- } else {
- const char *ovl_ext[] = {".b", ".o", ".ob"};
- char *buf = (char *) malloc(2048 + 1); // Buffer for file access
-
- strcat(strcpy(buf, _vm._screenNames[screenNum]), ovl_ext[overlayType]);
-
- if (!fileExists(buf)) {
- for (i = 0; i < OVL_SIZE; i++)
- image[i] = 0;
- return;
- }
-
- if (!_sceneryArchive.open(buf))
- Utils::Error(FILE_ERR, "%s", buf);
-
-// if (eof(f_scenery)) {
-// _lclose(f_scenery);
-// return;
-// }
- }
-
- switch (_vm._gameVariant) {
- case 0: // Hugo 1 DOS and WIN don't pack data
- case 3:
- _sceneryArchive.read(tmpImage, OVL_SIZE);
- break;
- default:
- // Read in the overlay file using MAC Packbits. (We're not proud!)
- k = 0; // byte count
- do {
- data = _sceneryArchive.readByte(); // Read a code byte
- if ((byte)data == 0x80) // Noop
- k = k;
- else if (data >= 0) { // Copy next data+1 literally
- for (i = 0; i <= (byte)data; i++, k++)
- *tmpImage++ = _sceneryArchive.readByte();
- } else { // Repeat next byte -data+1 times
- j = _sceneryArchive.readByte();
-
- for (i = 0; i < (byte)(-data + 1); i++, k++)
- *tmpImage++ = j;
- }
- } while (k < OVL_SIZE);
- break;
- }
-
- if (!_vm.isPacked())
- _sceneryArchive.close();
-}
-
void FileManager::saveSeq(object_t *obj) {
// Save sequence number and image number in given object
byte j, k;
@@ -681,33 +551,6 @@ void FileManager::closePlaybackFile() {
fclose(fpb);
}
-void FileManager::openDatabaseFiles() {
-//TODO : HUGO 1 DOS uses _stringtData instead of a strings.dat
-//This should be tested adequately and should be handled by an error and not by a warning.
- debugC(1, kDebugFile, "openDatabaseFiles");
-
- if (!_stringArchive.open(STRING_FILE))
-// Error(FILE_ERR, "%s", STRING_FILE);
- warning("Hugo Error: File not found %s", STRING_FILE);
- if (_vm.isPacked()) {
- if (!_sceneryArchive.open(SCENERY_FILE))
- Utils::Error(FILE_ERR, "%s", SCENERY_FILE);
- if (!_objectsArchive.open(OBJECTS_FILE))
- Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
- }
-}
-
-void FileManager::closeDatabaseFiles() {
-// TODO: stringArchive shouldn't be closed in Hugo 1 DOS
- debugC(1, kDebugFile, "closeDatabaseFiles");
-
- _stringArchive.close();
- if (_vm.isPacked()) {
- _sceneryArchive.close();
- _objectsArchive.close();
- }
-}
-
char *FileManager::fetchString(int index) {
//TODO : HUGO 1 DOS uses _stringtData instead of a strings.dat
// Fetch string from file, decode and return ptr to string in memory
@@ -901,4 +744,434 @@ void FileManager::instructions() {
f.close();
}
+
+FileManager_v1::FileManager_v1(HugoEngine &vm) : FileManager(vm) {
+}
+
+FileManager_v1::~FileManager_v1() {
+}
+
+void FileManager_v1::openDatabaseFiles() {
+ debugC(1, kDebugFile, "openDatabaseFiles");
+}
+
+void FileManager_v1::closeDatabaseFiles() {
+ debugC(1, kDebugFile, "closeDatabaseFiles");
+}
+
+void FileManager_v1::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
+// Open and read in an overlay file, close file
+ uint32 i = 0;
+ image_pt tmpImage = image; // temp ptr to overlay file
+
+ debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum);
+
+ const char *ovl_ext[] = {".b", ".o", ".ob"};
+ char *buf = (char *) malloc(2048 + 1); // Buffer for file access
+
+ strcat(strcpy(buf, _vm._screenNames[screenNum]), ovl_ext[overlayType]);
+
+ if (!fileExists(buf)) {
+ for (i = 0; i < OVL_SIZE; i++)
+ image[i] = 0;
+ return;
+ }
+
+ if (!_sceneryArchive1.open(buf))
+ Utils::Error(FILE_ERR, "%s", buf);
+
+ _sceneryArchive1.read(tmpImage, OVL_SIZE);
+ _sceneryArchive1.close();
+}
+
+void FileManager_v1::readBackground(int screenIndex) {
+// Read a PCX image into dib_a
+ seq_t seq; // Image sequence structure for Read_pcx
+
+ debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
+
+ char *buf = (char *) malloc(2048 + 1); // Buffer for file access
+ strcat(strcat(strcpy(buf, _vm._picDir), _vm._screenNames[screenIndex]), BKGEXT);
+ if (!_sceneryArchive1.open(buf)) {
+ warning("File %s not found, trying again with %s.ART", buf, _vm._screenNames[screenIndex]);
+ strcat(strcpy(buf, _vm._screenNames[screenIndex]), ".ART");
+ if (!_sceneryArchive1.open(buf))
+ Utils::Error(FILE_ERR, "%s", buf);
+ }
+ // Read the image into dummy seq and static dib_a
+ readPCX(_sceneryArchive1, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+
+ _sceneryArchive1.close();
+}
+
+FileManager_v2::FileManager_v2(HugoEngine &vm) : FileManager(vm) {
+}
+
+FileManager_v2::~FileManager_v2() {
+}
+
+void FileManager_v2::openDatabaseFiles() {
+ debugC(1, kDebugFile, "openDatabaseFiles");
+
+ if (!_stringArchive.open(STRING_FILE))
+ Utils::Error(FILE_ERR, "%s", STRING_FILE);
+ if (!_sceneryArchive1.open("scenery.dat"))
+ Utils::Error(FILE_ERR, "%s", "scenery.dat");
+ if (!_objectsArchive.open(OBJECTS_FILE))
+ Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
+}
+
+void FileManager_v2::closeDatabaseFiles() {
+ debugC(1, kDebugFile, "closeDatabaseFiles");
+
+ _stringArchive.close();
+ _sceneryArchive1.close();
+ _objectsArchive.close();
+}
+
+void FileManager_v2::readBackground(int screenIndex) {
+// Read a PCX image into dib_a
+ seq_t seq; // Image sequence structure for Read_pcx
+ sceneBlock_t sceneBlock; // Read a database header entry
+
+ debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
+
+ _sceneryArchive1.seek((uint32) screenIndex * sizeof(sceneBlock_t), SEEK_SET);
+
+ sceneBlock.scene_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.scene_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_len = _sceneryArchive1.readUint32LE();
+
+ _sceneryArchive1.seek(sceneBlock.scene_off, SEEK_SET);
+
+ // Read the image into dummy seq and static dib_a
+ readPCX(_sceneryArchive1, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+}
+
+void FileManager_v2::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
+// Open and read in an overlay file, close file
+ uint32 i = 0;
+ int16 j, k;
+ int8 data; // Must be 8 bits signed
+ image_pt tmpImage = image; // temp ptr to overlay file
+ sceneBlock_t sceneBlock; // Database header entry
+
+ debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum);
+
+ _sceneryArchive1.seek((uint32)screenNum * sizeof(sceneBlock_t), SEEK_SET);
+
+ sceneBlock.scene_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.scene_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_len = _sceneryArchive1.readUint32LE();
+
+ switch (overlayType) {
+ case BOUNDARY:
+ _sceneryArchive1.seek(sceneBlock.b_off, SEEK_SET);
+ i = sceneBlock.b_len;
+ break;
+ case OVERLAY:
+ _sceneryArchive1.seek(sceneBlock.o_off, SEEK_SET);
+ i = sceneBlock.o_len;
+ break;
+ case OVLBASE:
+ _sceneryArchive1.seek(sceneBlock.ob_off, SEEK_SET);
+ i = sceneBlock.ob_len;
+ break;
+ default:
+ Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+ break;
+ }
+ if (i == 0) {
+ for (i = 0; i < OVL_SIZE; i++)
+ image[i] = 0;
+ return;
+ }
+
+ // Read in the overlay file using MAC Packbits. (We're not proud!)
+ k = 0; // byte count
+ do {
+ data = _sceneryArchive1.readByte(); // Read a code byte
+ if ((byte)data == 0x80) // Noop
+ k = k;
+ else if (data >= 0) { // Copy next data+1 literally
+ for (i = 0; i <= (byte)data; i++, k++)
+ *tmpImage++ = _sceneryArchive1.readByte();
+ } else { // Repeat next byte -data+1 times
+ j = _sceneryArchive1.readByte();
+
+ for (i = 0; i < (byte)(-data + 1); i++, k++)
+ *tmpImage++ = j;
+ }
+ } while (k < OVL_SIZE);
+}
+
+FileManager_v3::FileManager_v3(HugoEngine &vm) : FileManager(vm) {
+}
+
+FileManager_v3::~FileManager_v3() {
+}
+
+void FileManager_v3::openDatabaseFiles() {
+ debugC(1, kDebugFile, "openDatabaseFiles");
+
+ if (!_stringArchive.open(STRING_FILE))
+ Utils::Error(FILE_ERR, "%s", STRING_FILE);
+ if (!_sceneryArchive1.open("scenery.dat"))
+ Utils::Error(FILE_ERR, "%s", "scenery.dat");
+ if (!_objectsArchive.open(OBJECTS_FILE))
+ Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
+}
+
+void FileManager_v3::closeDatabaseFiles() {
+ debugC(1, kDebugFile, "closeDatabaseFiles");
+
+ _stringArchive.close();
+ _sceneryArchive1.close();
+ _objectsArchive.close();
+}
+
+void FileManager_v3::readBackground(int screenIndex) {
+// Read a PCX image into dib_a
+ seq_t seq; // Image sequence structure for Read_pcx
+ sceneBlock_t sceneBlock; // Read a database header entry
+
+ debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
+
+ _sceneryArchive1.seek((uint32) screenIndex * sizeof(sceneBlock_t), SEEK_SET);
+
+ sceneBlock.scene_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.scene_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_len = _sceneryArchive1.readUint32LE();
+
+ _sceneryArchive1.seek(sceneBlock.scene_off, SEEK_SET);
+
+ // Read the image into dummy seq and static dib_a
+ readPCX(_sceneryArchive1, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+}
+
+void FileManager_v3::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
+// Open and read in an overlay file, close file
+ uint32 i = 0;
+ image_pt tmpImage = image; // temp ptr to overlay file
+ sceneBlock_t sceneBlock; // Database header entry
+
+ debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum);
+
+ _sceneryArchive1.seek((uint32)screenNum * sizeof(sceneBlock_t), SEEK_SET);
+
+ sceneBlock.scene_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.scene_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_len = _sceneryArchive1.readUint32LE();
+
+ switch (overlayType) {
+ case BOUNDARY:
+ _sceneryArchive1.seek(sceneBlock.b_off, SEEK_SET);
+ i = sceneBlock.b_len;
+ break;
+ case OVERLAY:
+ _sceneryArchive1.seek(sceneBlock.o_off, SEEK_SET);
+ i = sceneBlock.o_len;
+ break;
+ case OVLBASE:
+ _sceneryArchive1.seek(sceneBlock.ob_off, SEEK_SET);
+ i = sceneBlock.ob_len;
+ break;
+ default:
+ Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+ break;
+ }
+ if (i == 0) {
+ for (i = 0; i < OVL_SIZE; i++)
+ image[i] = 0;
+ return;
+ }
+
+ _sceneryArchive1.read(tmpImage, OVL_SIZE);
+}
+
+FileManager_v4::FileManager_v4(HugoEngine &vm) : FileManager(vm) {
+}
+
+FileManager_v4::~FileManager_v4() {
+}
+
+void FileManager_v4::readBackground(int screenIndex) {
+// Read a PCX image into dib_a
+ seq_t seq; // Image sequence structure for Read_pcx
+ sceneBlock_t sceneBlock; // Read a database header entry
+ Common::File sceneryArchive;
+
+ debugC(1, kDebugFile, "readBackground(%d)", screenIndex);
+
+ _sceneryArchive1.seek((uint32) screenIndex * sizeof(sceneBlock_t), SEEK_SET);
+
+ sceneBlock.scene_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.scene_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_len = _sceneryArchive1.readUint32LE();
+
+ if (screenIndex < 20) {
+ _sceneryArchive1.seek(sceneBlock.scene_off, SEEK_SET);
+
+ // Read the image into dummy seq and static dib_a
+ readPCX(_sceneryArchive1, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+ } else {
+ _sceneryArchive2.seek(sceneBlock.scene_off, SEEK_SET);
+
+ // Read the image into dummy seq and static dib_a
+ readPCX(_sceneryArchive2, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+ }
+}
+
+void FileManager_v4::openDatabaseFiles() {
+ debugC(1, kDebugFile, "openDatabaseFiles");
+
+ if (!_stringArchive.open(STRING_FILE))
+ Utils::Error(FILE_ERR, "%s", STRING_FILE);
+ if (!_sceneryArchive1.open("scenery1.dat"))
+ Utils::Error(FILE_ERR, "%s", "scenery1.dat");
+ if (!_sceneryArchive2.open("scenery2.dat"))
+ Utils::Error(FILE_ERR, "%s", "scenery2.dat");
+ if (!_objectsArchive.open(OBJECTS_FILE))
+ Utils::Error(FILE_ERR, "%s", OBJECTS_FILE);
+}
+
+void FileManager_v4::closeDatabaseFiles() {
+ debugC(1, kDebugFile, "closeDatabaseFiles");
+
+ _stringArchive.close();
+ _sceneryArchive1.close();
+ _sceneryArchive2.close();
+ _objectsArchive.close();
+}
+
+void FileManager_v4::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
+// Open and read in an overlay file, close file
+ uint32 i = 0;
+ int16 j, k;
+ int8 data; // Must be 8 bits signed
+ image_pt tmpImage = image; // temp ptr to overlay file
+ sceneBlock_t sceneBlock; // Database header entry
+ Common::File sceneryArchive;
+
+ debugC(1, kDebugFile, "readOverlay(%d, ...)", screenNum);
+
+ _sceneryArchive1.seek((uint32)screenNum * sizeof(sceneBlock_t), SEEK_SET);
+
+ sceneBlock.scene_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.scene_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.b_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.o_len = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_off = _sceneryArchive1.readUint32LE();
+ sceneBlock.ob_len = _sceneryArchive1.readUint32LE();
+
+ if (screenNum < 20) {
+ switch (overlayType) {
+ case BOUNDARY:
+ _sceneryArchive1.seek(sceneBlock.b_off, SEEK_SET);
+ i = sceneBlock.b_len;
+ break;
+ case OVERLAY:
+ _sceneryArchive1.seek(sceneBlock.o_off, SEEK_SET);
+ i = sceneBlock.o_len;
+ break;
+ case OVLBASE:
+ _sceneryArchive1.seek(sceneBlock.ob_off, SEEK_SET);
+ i = sceneBlock.ob_len;
+ break;
+ default:
+ Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+ break;
+ }
+ if (i == 0) {
+ for (i = 0; i < OVL_SIZE; i++)
+ image[i] = 0;
+ return;
+ }
+
+ // Read in the overlay file using MAC Packbits. (We're not proud!)
+ k = 0; // byte count
+ do {
+ data = _sceneryArchive1.readByte(); // Read a code byte
+ if ((byte)data == 0x80) // Noop
+ k = k;
+ else if (data >= 0) { // Copy next data+1 literally
+ for (i = 0; i <= (byte)data; i++, k++)
+ *tmpImage++ = _sceneryArchive1.readByte();
+ } else { // Repeat next byte -data+1 times
+ j = _sceneryArchive1.readByte();
+
+ for (i = 0; i < (byte)(-data + 1); i++, k++)
+ *tmpImage++ = j;
+ }
+ } while (k < OVL_SIZE);
+ } else {
+ switch (overlayType) {
+ case BOUNDARY:
+ _sceneryArchive2.seek(sceneBlock.b_off, SEEK_SET);
+ i = sceneBlock.b_len;
+ break;
+ case OVERLAY:
+ _sceneryArchive2.seek(sceneBlock.o_off, SEEK_SET);
+ i = sceneBlock.o_len;
+ break;
+ case OVLBASE:
+ _sceneryArchive2.seek(sceneBlock.ob_off, SEEK_SET);
+ i = sceneBlock.ob_len;
+ break;
+ default:
+ Utils::Error(FILE_ERR, "%s", "Bad ovl_type");
+ break;
+ }
+ if (i == 0) {
+ for (i = 0; i < OVL_SIZE; i++)
+ image[i] = 0;
+ return;
+ }
+
+ // Read in the overlay file using MAC Packbits. (We're not proud!)
+ k = 0; // byte count
+ do {
+ data = _sceneryArchive2.readByte(); // Read a code byte
+ if ((byte)data == 0x80) // Noop
+ k = k;
+ else if (data >= 0) { // Copy next data+1 literally
+ for (i = 0; i <= (byte)data; i++, k++)
+ *tmpImage++ = _sceneryArchive2.readByte();
+ } else { // Repeat next byte -data+1 times
+ j = _sceneryArchive2.readByte();
+
+ for (i = 0; i < (byte)(-data + 1); i++, k++)
+ *tmpImage++ = j;
+ }
+ } while (k < OVL_SIZE);
+ }
+}
} // End of namespace Hugo
+
diff --git a/engines/hugo/file.h b/engines/hugo/file.h
index c044a7307f..71bd0bf75c 100644
--- a/engines/hugo/file.h
+++ b/engines/hugo/file.h
@@ -42,38 +42,41 @@ namespace Hugo {
class FileManager {
public:
FileManager(HugoEngine &vm);
+ virtual ~FileManager();
bool fileExists(char *filename);
-
char *fetchString(int index);
-
sound_pt getSound(short sound, uint16 *size);
void closePlaybackFile();
- void closeDatabaseFiles();
void initSavedGame();
void instructions();
- void openDatabaseFiles();
- void readBackground(int screenIndex);
void readBootFile();
void readImage(int objNum, object_t *objPtr);
- void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
void readUIFItem(short id, byte *buf);
void restoreGame(short slot);
void restoreSeq(object_t *obj);
void saveGame(short slot, const char *descrip);
void saveSeq(object_t *obj);
-private:
+ virtual void openDatabaseFiles() = 0;
+ virtual void closeDatabaseFiles() = 0;
+
+ virtual void readBackground(int screenIndex) = 0;
+ virtual void readOverlay(int screenNum, image_pt image, ovl_t overlayType) = 0;
+
+protected:
HugoEngine &_vm;
Common::File _stringArchive; /* Handle for string file */
- Common::File _sceneryArchive; /* Handle for scenery file */
+ Common::File _sceneryArchive1; /* Handle for scenery file */
Common::File _objectsArchive; /* Handle for objects file */
- byte *convertPCC(byte *p, uint16 y, uint16 bpl, image_pt data_p);
seq_t *readPCX(Common::File &f, seq_t *seqPtr, byte *imagePtr, bool firstFl, const char *name);
+private:
+
+ byte *convertPCC(byte *p, uint16 y, uint16 bpl, image_pt data_p);
uif_hdr_t *getUIFHeader(uif_t id);
//Strangerke : Not used?
@@ -83,6 +86,51 @@ private:
// char pbget();
};
-} // End of namespace Hugo
+class FileManager_v1 : public FileManager {
+public:
+ FileManager_v1(HugoEngine &vm);
+ ~FileManager_v1();
+ void openDatabaseFiles();
+ void closeDatabaseFiles();
+ void readBackground(int screenIndex);
+ void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+};
+
+class FileManager_v2 : public FileManager {
+public:
+ FileManager_v2(HugoEngine &vm);
+ ~FileManager_v2();
+
+ void openDatabaseFiles();
+ void closeDatabaseFiles();
+ void readBackground(int screenIndex);
+ void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+};
+
+class FileManager_v3 : public FileManager {
+public:
+ FileManager_v3(HugoEngine &vm);
+ ~FileManager_v3();
+
+ void openDatabaseFiles();
+ void closeDatabaseFiles();
+ void readBackground(int screenIndex);
+ void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+};
+
+class FileManager_v4 : public FileManager {
+public:
+ FileManager_v4(HugoEngine &vm);
+ ~FileManager_v4();
+
+ void openDatabaseFiles();
+ void closeDatabaseFiles();
+ void readBackground(int screenIndex);
+ void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+private:
+ Common::File _sceneryArchive2; /* Handle for scenery file */
+
+};
+} // End of namespace Hugo
#endif //HUGO_FILE_H
diff --git a/engines/hugo/global.h b/engines/hugo/global.h
index 110a5957fe..1437eb3734 100644
--- a/engines/hugo/global.h
+++ b/engines/hugo/global.h
@@ -37,12 +37,10 @@ namespace Hugo {
#define DESCRIPLEN 32 /* Length of description string */
#define MAX_SOUNDS 64 /* Max number of sounds */
#define BOOTFILE "HUGO.BSF" /* Name of boot structure file */
-#define CONFIGFILE "CONFIG.DAT" /* Name of config file */
#define LEN_MASK 0x3F /* Lower 6 bits are length */
#define PBFILE "playback.dat"
/* Name scenery and objects picture databases */
-#define SCENERY_FILE "scenery.dat"
#define OBJECTS_FILE "objects.dat"
#define STRING_FILE "strings.dat"
#define SOUND_FILE "sounds.dat"
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 58f4dc444e..316c16f018 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -140,7 +140,6 @@ Common::Error HugoEngine::run() {
s_Engine = this;
initGraphics(320, 200, false);
- _fileManager = new FileManager(*this);
_screen = new Screen(*this);
_mouseHandler = new MouseHandler(*this);
_inventoryHandler = new InventoryHandler(*this);
@@ -149,27 +148,33 @@ Common::Error HugoEngine::run() {
_soundHandler = new SoundHandler(*this);
switch (_gameVariant) {
- case 0:
+ case 0: // H1 Win
+ _fileManager = new FileManager_v3(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_1w(*this);
break;
case 1:
+ _fileManager = new FileManager_v2(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_2w(*this);
break;
case 2:
+ _fileManager = new FileManager_v2(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_3w(*this);
break;
- case 3:
+ case 3: // H1 DOS
+ _fileManager = new FileManager_v1(*this);
_scheduler = new Scheduler_v1(*this);
_introHandler = new intro_1d(*this);
break;
case 4:
+ _fileManager = new FileManager_v2(*this);
_scheduler = new Scheduler_v1(*this);
_introHandler = new intro_2d(*this);
break;
case 5:
+ _fileManager = new FileManager_v4(*this);
_scheduler = new Scheduler_v2(*this);
_introHandler = new intro_3d(*this);
break;