aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArnaud Boutonné2010-09-17 22:40:53 +0000
committerArnaud Boutonné2010-09-17 22:40:53 +0000
commit1e9e8cd64a97ade7d8f9ff891e511d47b98da70d (patch)
tree6c6ab680cfd943bb6915536a64bfe3eae09d09cb
parent99cc8051816fca07a185d1b2612271ff04098d65 (diff)
downloadscummvm-rg350-1e9e8cd64a97ade7d8f9ff891e511d47b98da70d.tar.gz
scummvm-rg350-1e9e8cd64a97ade7d8f9ff891e511d47b98da70d.tar.bz2
scummvm-rg350-1e9e8cd64a97ade7d8f9ff891e511d47b98da70d.zip
HUGO: Fix crash in the first screen of H1 Dos
- Fix crash in the first screen of H1 Dos - Clean up svn-id: r52787
-rw-r--r--engines/hugo/file.cpp99
-rw-r--r--engines/hugo/file.h26
-rw-r--r--engines/hugo/game.h86
-rw-r--r--engines/hugo/hugo.cpp8
-rw-r--r--engines/hugo/hugo.h11
-rw-r--r--engines/hugo/parser.cpp2
6 files changed, 98 insertions, 134 deletions
diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp
index 3219ec44b9..6a0abadcf4 100644
--- a/engines/hugo/file.cpp
+++ b/engines/hugo/file.cpp
@@ -553,35 +553,6 @@ void FileManager::closePlaybackFile() {
fclose(fpb);
}
-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
- uint32 off1, off2;
-
- debugC(1, kDebugFile, "fetchString(%d)", index);
-
- // Get offset to string[index] (and next for length calculation)
- _stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET);
- if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0)
- Utils::Error(FILE_ERR, "%s", "String offset");
- if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0)
- Utils::Error(FILE_ERR, "%s", "String offset");
-
- // Check size of string
- if ((off2 - off1) >= MAX_BOX)
- Utils::Error(FILE_ERR, "%s", "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");
-
- // Null terminate, decode and return it
- _textBoxBuffer[off2-off1] = '\0';
- _vm.scheduler().decodeString(_textBoxBuffer);
- return _textBoxBuffer;
-}
-
void FileManager::printBootText() {
// Read the encrypted text from the boot file and print it
Common::File ofp;
@@ -802,6 +773,12 @@ void FileManager_v1d::readBackground(int screenIndex) {
_sceneryArchive1.close();
}
+char *FileManager_v1d::fetchString(int index) {
+ debugC(1, kDebugFile, "fetchString(%d)", index);
+
+ return _vm._stringtData[index];
+}
+
FileManager_v2d::FileManager_v2d(HugoEngine &vm) : FileManager(vm) {
}
@@ -913,53 +890,39 @@ void FileManager_v2d::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
} while (k < OVL_SIZE);
}
-FileManager_v1w::FileManager_v1w(HugoEngine &vm) : FileManager(vm) {
-}
+char *FileManager_v2d::fetchString(int index) {
+// Fetch string from file, decode and return ptr to string in memory
+ uint32 off1, off2;
-FileManager_v1w::~FileManager_v1w() {
-}
+ debugC(1, kDebugFile, "fetchString(%d)", index);
-void FileManager_v1w::openDatabaseFiles() {
- debugC(1, kDebugFile, "openDatabaseFiles");
+ // Get offset to string[index] (and next for length calculation)
+ _stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET);
+ if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0)
+ Utils::Error(FILE_ERR, "%s", "String offset");
+ if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0)
+ Utils::Error(FILE_ERR, "%s", "String offset");
- 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);
-}
+ // Check size of string
+ if ((off2 - off1) >= MAX_BOX)
+ Utils::Error(FILE_ERR, "%s", "Fetched string too long!");
-void FileManager_v1w::closeDatabaseFiles() {
- debugC(1, kDebugFile, "closeDatabaseFiles");
+ // 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");
- _stringArchive.close();
- _sceneryArchive1.close();
- _objectsArchive.close();
+ // Null terminate, decode and return it
+ _textBoxBuffer[off2-off1] = '\0';
+ _vm.scheduler().decodeString(_textBoxBuffer);
+ return _textBoxBuffer;
}
-void FileManager_v1w::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);
+FileManager_v1w::FileManager_v1w(HugoEngine &vm) : FileManager_v2d(vm) {
+}
- // Read the image into dummy seq and static dib_a
- readPCX(_sceneryArchive1, &seq, _vm.screen().getFrontBuffer(), true, _vm._screenNames[screenIndex]);
+FileManager_v1w::~FileManager_v1w() {
}
void FileManager_v1w::readOverlay(int screenNum, image_pt image, ovl_t overlayType) {
@@ -1007,7 +970,7 @@ void FileManager_v1w::readOverlay(int screenNum, image_pt image, ovl_t overlayTy
_sceneryArchive1.read(tmpImage, OVL_SIZE);
}
-FileManager_v3d::FileManager_v3d(HugoEngine &vm) : FileManager(vm) {
+FileManager_v3d::FileManager_v3d(HugoEngine &vm) : FileManager_v2d(vm) {
}
FileManager_v3d::~FileManager_v3d() {
diff --git a/engines/hugo/file.h b/engines/hugo/file.h
index 446be0aa70..8a0188f2f3 100644
--- a/engines/hugo/file.h
+++ b/engines/hugo/file.h
@@ -46,7 +46,6 @@ public:
bool fileExists(char *filename);
- char *fetchString(int index);
sound_pt getSound(short sound, uint16 *size);
void closePlaybackFile();
@@ -66,6 +65,8 @@ public:
virtual void readBackground(int screenIndex) = 0;
virtual void readOverlay(int screenNum, image_pt image, ovl_t overlayType) = 0;
+ virtual char *fetchString(int index) = 0;
+
protected:
HugoEngine &_vm;
@@ -95,6 +96,7 @@ public:
void closeDatabaseFiles();
void readBackground(int screenIndex);
void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+ char *fetchString(int index);
};
class FileManager_v2d : public FileManager {
@@ -106,20 +108,10 @@ public:
void closeDatabaseFiles();
void readBackground(int screenIndex);
void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
+ char *fetchString(int index);
};
-class FileManager_v1w : public FileManager {
-public:
- FileManager_v1w(HugoEngine &vm);
- ~FileManager_v1w();
-
- void openDatabaseFiles();
- void closeDatabaseFiles();
- void readBackground(int screenIndex);
- void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
-};
-
-class FileManager_v3d : public FileManager {
+class FileManager_v3d : public FileManager_v2d {
public:
FileManager_v3d(HugoEngine &vm);
~FileManager_v3d();
@@ -130,7 +122,15 @@ public:
void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
private:
Common::File _sceneryArchive2; /* Handle for scenery file */
+};
+class FileManager_v1w : public FileManager_v2d {
+public:
+ FileManager_v1w(HugoEngine &vm);
+ ~FileManager_v1w();
+
+ void readOverlay(int screenNum, image_pt image, ovl_t overlayType);
};
+
} // End of namespace Hugo
#endif //HUGO_FILE_H
diff --git a/engines/hugo/game.h b/engines/hugo/game.h
index d032a4b817..7b6713c1de 100644
--- a/engines/hugo/game.h
+++ b/engines/hugo/game.h
@@ -48,12 +48,6 @@ namespace Hugo {
// Copy helpedit\hugow_?.hlp to .\hugowin?.hlp
// Type "PPG" in the game to enter cheat mode.
-#define DEBUG false // Allow me to do special things (EDIT, GOTO)
-#define STORY true // Skip any intro stuff if FALSE
-//#define DATABASE TRUE // Use database instead of individual files. Individual files are used by Hugo1 DOS!
-//#define BETA FALSE // Puts big msg in intro/about box
-#define EPISODE_NUM 1 // Episode we are building
-#define TITLE "Hugo for Windows"
#define COPYRIGHT "Copyright © 1995-97, David P. Gray"
// Started code on 04/01/95
// Don't forget to update Hugowin.rc2 with version info
@@ -62,7 +56,7 @@ namespace Hugo {
//#define VER "v1.2"// 10/12/95 Added "background music" checkbox in volume dlg
//#define VER "v1.3"// 10/23/95 Support game 1 as shareware
//#define VER "v1.4"// 12/06/95 Faster graphics, logical palette
-#define VER "v1.5" // 10/07/97 Added order form, new web site
+//#define VER "v1.5" // 10/07/97 Added order form, new web site
// Game specific equates
#define MAX_TUNES 16 // Max number of tunes
@@ -111,41 +105,23 @@ namespace Hugo {
// Macros:
#define TPS ((_config.turboFl) ? TURBO_TPS : NORMAL_TPS)
-
-enum TEXTCOLORS {
- _TBLACK, _TBLUE, _TGREEN, _TCYAN,
- _TRED, _TMAGENTA, _TBROWN, _TWHITE,
- _TGRAY, _TLIGHTBLUE, _TLIGHTGREEN, _TLIGHTCYAN,
- _TLIGHTRED, _TLIGHTMAGENTA, _TLIGHTYELLOW, _TBRIGHTWHITE
-};
-
-#define CRYPT "Copyright 1992, David P Gray, Gray Design Associates"
-
-struct hugo_boot_t { // Common HUGO boot file
- char checksum; // Checksum for boot structure (not exit text)
- char registered; // TRUE if registered version, else FALSE
- char pbswitch[8]; // Playback switch string
- char distrib[32]; // Distributor branding string
- uint16 exit_len; // Length of exit text (next in file)
-};
-
#define MAX_UIFS 32 // Max possible uif items in hdr
#define NUM_FONTS 3 // Number of dib fonts
#define FIRST_FONT U_FONT5
#define FONT_LEN 128 // Number of chars in font
#define FONTSIZE 1200 // Max size of font data
-struct uif_hdr_t { // UIF font/image look up
- uint16 size; // Size of uif item
- uint32 offset; // Offset of item in file
+#define CRYPT "Copyright 1992, David P Gray, Gray Design Associates"
+
+enum TEXTCOLORS {
+ _TBLACK, _TBLUE, _TGREEN, _TCYAN,
+ _TRED, _TMAGENTA, _TBROWN, _TWHITE,
+ _TGRAY, _TLIGHTBLUE, _TLIGHTGREEN, _TLIGHTCYAN,
+ _TLIGHTRED, _TLIGHTMAGENTA, _TLIGHTYELLOW, _TBRIGHTWHITE
};
enum uif_t {U_FONT5, U_FONT6, U_FONT8, UIF_IMAGES, NUM_UIF_ITEMS};
-// Game specific type definitions
-typedef byte *image_pt; // ptr to an object image (sprite)
-typedef byte *sound_pt; // ptr to sound (or music) data
-
// Enumerate overlay file types
enum ovl_t {BOUNDARY, OVERLAY, OVLBASE};
@@ -213,21 +189,6 @@ enum invact_t {INV_INIT, INV_LEFT, INV_RIGHT, INV_GET};
// Purpose of an automatic route
enum go_t {GO_SPACE, GO_EXIT, GO_LOOK, GO_GET};
-// Following are points for achieving certain actions.
-struct point_t {
- byte score; // The value of the point
- bool scoredFl; // Whether scored yet
-};
-
-// Structure for initializing maze processing
-struct maze_t {
- bool enabledFl; // TRUE when maze processing enabled
- byte size; // Size of (square) maze matrix
- int x1, y1, x2, y2; // maze hotspot bounding box
- int x3, x4; // north, south x entry coordinates
- byte firstScreenIndex; // index of first screen in maze
-};
-
// Following defines the action types and action list
enum action_t { // Parameters:
ANULL = 0xff, // Special NOP used to 'delete' events in DEL_EVENTS
@@ -284,6 +245,37 @@ enum action_t { // Parameters:
OLD_SONG = 49 // Added by Strangerke - Set currently playing sound, old way: that is, using a string index instead of a reference in a file
};
+struct hugo_boot_t { // Common HUGO boot file
+ char checksum; // Checksum for boot structure (not exit text)
+ char registered; // TRUE if registered version, else FALSE
+ char pbswitch[8]; // Playback switch string
+ char distrib[32]; // Distributor branding string
+ uint16 exit_len; // Length of exit text (next in file)
+};
+
+struct uif_hdr_t { // UIF font/image look up
+ uint16 size; // Size of uif item
+ uint32 offset; // Offset of item in file
+};
+
+// Game specific type definitions
+typedef byte *image_pt; // ptr to an object image (sprite)
+typedef byte *sound_pt; // ptr to sound (or music) data
+
+// Following are points for achieving certain actions.
+struct point_t {
+ byte score; // The value of the point
+ bool scoredFl; // Whether scored yet
+};
+
+// Structure for initializing maze processing
+struct maze_t {
+ bool enabledFl; // TRUE when maze processing enabled
+ byte size; // Size of (square) maze matrix
+ int x1, y1, x2, y2; // maze hotspot bounding box
+ int x3, x4; // north, south x entry coordinates
+ byte firstScreenIndex; // index of first screen in maze
+};
struct act0 { // Type 0 - Schedule
action_t actType; // The type of action
diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp
index 80ae532cf9..9f6a933bbe 100644
--- a/engines/hugo/hugo.cpp
+++ b/engines/hugo/hugo.cpp
@@ -67,6 +67,9 @@ HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(sy
DebugMan.addDebugChannel(kDebugFile, "File", "File IO debug level");
DebugMan.addDebugChannel(kDebugRoute, "Route", "Route debug level");
DebugMan.addDebugChannel(kDebugInventory, "Inventory", "Inventory debug level");
+
+ for (int j = 0; j < NUM_FONTS; j++)
+ _arrayFont[j] = 0;
}
HugoEngine::~HugoEngine() {
@@ -258,7 +261,7 @@ Common::Error HugoEngine::run() {
}
void HugoEngine::initMachine() {
- if (_gameVariant == 3)
+ if (_gameVariant == kGameVariantH1Dos)
readScreenFiles(0);
else
file().readBackground(_numScreens - 1); // Splash screen
@@ -1349,9 +1352,6 @@ bool HugoEngine::loadHugoDat() {
_alNewscrIndex = numElem;
}
- for (int j = 0; j < NUM_FONTS; j++)
- _arrayFont[j] = 0;
-
if (_gameVariant > 2) {
_arrayFontSize[0] = in.readUint16BE();
_arrayFont[0] = (byte *)malloc(sizeof(byte) * _arrayFontSize[0]);
diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h
index e59c4dfdf5..3dea391d4b 100644
--- a/engines/hugo/hugo.h
+++ b/engines/hugo/hugo.h
@@ -33,7 +33,7 @@
#include "hugo/game.h"
#define HUGO_DAT_VER_MAJ 0 // 1 byte
-#define HUGO_DAT_VER_MIN 22 // 1 byte
+#define HUGO_DAT_VER_MIN 23 // 1 byte
#define DATAALIGNMENT 4
namespace Common {
@@ -48,6 +48,15 @@ enum GameType {
kGameTypeHugo3
};
+enum GameVariant {
+ kGameVariantH1Win = 0,
+ kGameVariantH2Win,
+ kGameVariantH3Win,
+ kGameVariantH1Dos,
+ kGameVariantH2Dos,
+ kGameVariantH3Dos
+};
+
enum HugoDebugChannels {
kDebugSchedule = 1 << 0,
kDebugEngine = 1 << 1,
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index 061e8e597d..e4d7364b61 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -266,7 +266,7 @@ void Parser::lineHandler() {
// fetch <object name> Hero carries named object
// fetch all Hero carries all possible objects
// find <object name> Takes hero to screen containing named object
- if (DEBUG || gameStatus.godModeFl) {
+ if (gameStatus.godModeFl) {
// Special code to allow me to go straight to any screen
if (strstr(_line, "goto"))
for (int i = 0; i < _vm._numScreens; i++)