2010-08-17 09:28:20 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef HUGO_H
|
|
|
|
#define HUGO_H
|
|
|
|
|
|
|
|
#include "engines/engine.h"
|
|
|
|
#include "common/file.h"
|
2010-11-07 15:04:47 +00:00
|
|
|
#include "hugo/console.h"
|
2011-02-27 23:50:06 +00:00
|
|
|
#include "hugo/dialogs.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
// This include is here temporarily while the engine is being refactored.
|
|
|
|
#include "hugo/game.h"
|
2010-11-29 17:42:08 +00:00
|
|
|
#include "hugo/file.h"
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2010-10-15 06:16:27 +00:00
|
|
|
#define HUGO_DAT_VER_MAJ 0 // 1 byte
|
2011-02-20 10:32:00 +00:00
|
|
|
#define HUGO_DAT_VER_MIN 42 // 1 byte
|
2010-10-15 06:16:27 +00:00
|
|
|
#define DATAALIGNMENT 4
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
class RandomSource;
|
|
|
|
}
|
|
|
|
|
2010-10-15 12:28:56 +00:00
|
|
|
/**
|
|
|
|
* This is the namespace of the Hugo engine.
|
|
|
|
*
|
|
|
|
* Status of this engine: ???
|
|
|
|
*
|
2010-10-15 12:48:19 +00:00
|
|
|
* Games using this engine:
|
|
|
|
* - Hugo's House of Horror
|
|
|
|
* - Whodunit?
|
|
|
|
* - Jungle of Doom
|
2010-11-07 22:10:29 +00:00
|
|
|
* - Hugo's Horrific Adventure
|
|
|
|
* - Hugo's Mystery Adventure
|
|
|
|
* - Hugo's Amazon Adventure
|
2010-10-15 12:28:56 +00:00
|
|
|
*/
|
2010-08-17 09:28:20 +00:00
|
|
|
namespace Hugo {
|
2010-10-15 12:28:56 +00:00
|
|
|
|
2011-03-07 23:19:30 +00:00
|
|
|
static const int kSavegameVersion = 6;
|
2011-01-23 00:05:52 +00:00
|
|
|
static const int kInvDx = 32; // Width of an inventory icon
|
|
|
|
static const int kInvDy = 32; // Height of inventory icon
|
|
|
|
static const int kMaxTunes = 16; // Max number of tunes
|
|
|
|
static const int kStepDx = 5; // Num pixels moved in x by HERO per step
|
|
|
|
static const int kStepDy = 4; // Num pixels moved in y by HERO per step
|
|
|
|
static const int kXPix = 320; // Width of pcx background file
|
|
|
|
static const int kYPix = 200; // Height of pcx background file
|
|
|
|
static const int kViewSizeX = kXPix; // Width of window view
|
2011-02-04 21:51:10 +00:00
|
|
|
static const int kViewSizeY = 192; // Height of window view. In original game: 184
|
2011-01-23 00:05:52 +00:00
|
|
|
static const int kDibOffY = 0; // Offset into dib SrcY (old status line area). In original game: 8
|
|
|
|
static const int kCompLineSize = 40; // number of bytes in a compressed line
|
|
|
|
static const int kMaxLineSize = kCompLineSize - 2; // Max length of user input line
|
|
|
|
static const int kMaxTextRows = 25; // Number of text lines in display
|
|
|
|
static const int kMaxBoxChar = kMaxLineSize * kMaxTextRows; // Max chars on screen
|
|
|
|
static const int kOvlSize = kCompLineSize * kYPix; // Size of an overlay file
|
|
|
|
static const int kStateDontCare = 0xFF; // Any state allowed in command verb
|
|
|
|
static const int kHeroIndex = 0; // In all enums, HERO is the first element
|
|
|
|
static const int kArrowNumb = 2; // Number of arrows (left/right)
|
|
|
|
static const int kLeftArrow = -2; // Cursor over Left arrow in inventory icon bar
|
|
|
|
static const int kRightArrow = -3; // Cursor over Right arrow in inventory icon bar
|
|
|
|
static const int kMaxPath = 256; // Max length of a full path name
|
|
|
|
static const int kHeroMaxWidth = 24; // Maximum width of hero
|
|
|
|
static const int kHeroMinWidth = 16; // Minimum width of hero
|
|
|
|
|
|
|
|
typedef char command_t[kMaxLineSize + 8]; // Command line (+spare for prompt,cursor)
|
|
|
|
|
|
|
|
struct config_t { // User's config (saved)
|
|
|
|
bool musicFl; // State of Music button/menu item
|
|
|
|
bool soundFl; // State of Sound button/menu item
|
|
|
|
bool turboFl; // State of Turbo button/menu item
|
|
|
|
bool playlist[kMaxTunes]; // Tune playlist
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef byte icondib_t[kXPix * kInvDy]; // Icon bar dib
|
|
|
|
typedef byte viewdib_t[(long)kXPix * kYPix]; // Viewport dib
|
|
|
|
typedef byte overlay_t[kOvlSize]; // Overlay file
|
2010-11-29 17:42:08 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
enum GameType {
|
|
|
|
kGameTypeNone = 0,
|
|
|
|
kGameTypeHugo1,
|
|
|
|
kGameTypeHugo2,
|
|
|
|
kGameTypeHugo3
|
|
|
|
};
|
|
|
|
|
2010-09-17 22:40:53 +00:00
|
|
|
enum GameVariant {
|
|
|
|
kGameVariantH1Win = 0,
|
|
|
|
kGameVariantH2Win,
|
|
|
|
kGameVariantH3Win,
|
|
|
|
kGameVariantH1Dos,
|
|
|
|
kGameVariantH2Dos,
|
|
|
|
kGameVariantH3Dos
|
|
|
|
};
|
|
|
|
|
2010-09-16 23:03:03 +00:00
|
|
|
enum HugoDebugChannels {
|
2010-10-25 14:03:01 +00:00
|
|
|
kDebugSchedule = 1 << 0,
|
|
|
|
kDebugEngine = 1 << 1,
|
|
|
|
kDebugDisplay = 1 << 2,
|
|
|
|
kDebugMouse = 1 << 3,
|
|
|
|
kDebugParser = 1 << 4,
|
|
|
|
kDebugFile = 1 << 5,
|
|
|
|
kDebugRoute = 1 << 6,
|
|
|
|
kDebugInventory = 1 << 7,
|
2010-12-22 09:09:38 +00:00
|
|
|
kDebugObject = 1 << 8,
|
|
|
|
kDebugMusic = 1 << 9
|
2010-08-17 09:28:20 +00:00
|
|
|
};
|
|
|
|
|
2011-03-07 18:40:20 +00:00
|
|
|
enum HugoRegistered {
|
|
|
|
kRegShareware = 0,
|
|
|
|
kRegRegistered,
|
|
|
|
kRegFreeware
|
|
|
|
};
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Inventory icon bar states
|
|
|
|
*/
|
2011-01-23 00:05:52 +00:00
|
|
|
enum istate_t {kInventoryOff, kInventoryUp, kInventoryDown, kInventoryActive};
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Game view state machine
|
|
|
|
*/
|
2011-01-23 00:05:52 +00:00
|
|
|
enum vstate_t {kViewIdle, kViewIntroInit, kViewIntro, kViewPlay, kViewInvent, kViewExit};
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Enumerate whether object is foreground, background or 'floating'
|
|
|
|
* If floating, HERO can collide with it and fore/back ground is determined
|
|
|
|
* by relative y-coord of object base. This is the general case.
|
|
|
|
* If fore or background, no collisions can take place and object is either
|
|
|
|
* behind or in front of all others, although can still be hidden by the
|
|
|
|
* the overlay plane. OVEROVL means the object is FLOATING (to other
|
|
|
|
* objects) but is never hidden by the overlay plane
|
|
|
|
*/
|
2011-01-23 00:05:52 +00:00
|
|
|
enum {kPriorityForeground, kPriorityBackground, kPriorityFloating, kPriorityOverOverlay};
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Display list functions
|
|
|
|
*/
|
2011-01-23 00:05:52 +00:00
|
|
|
enum dupdate_t {kDisplayInit, kDisplayAdd, kDisplayDisplay, kDisplayRestore};
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Priority for sound effect
|
|
|
|
*/
|
2011-01-23 00:05:52 +00:00
|
|
|
enum priority_t {kSoundPriorityLow, kSoundPriorityMedium, kSoundPriorityHigh};
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
enum HugoGameFeatures {
|
|
|
|
GF_PACKED = (1 << 0) // Database
|
|
|
|
};
|
|
|
|
|
2010-10-15 06:16:27 +00:00
|
|
|
// Strings used by the engine
|
|
|
|
enum seqTextEngine {
|
|
|
|
kEsAdvertise = 0
|
|
|
|
};
|
2011-01-23 00:05:52 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
struct HugoGameDescription;
|
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
struct status_t { // Game status (not saved)
|
|
|
|
bool storyModeFl; // Game is telling story - no commands
|
|
|
|
bool gameOverFl; // Game is over - hero knobbled
|
|
|
|
bool lookFl; // Toolbar "look" button pressed
|
|
|
|
bool recallFl; // Toolbar "recall" button pressed
|
|
|
|
bool newScreenFl; // New screen just loaded in dib_a
|
|
|
|
bool godModeFl; // Allow DEBUG features in live version
|
2011-05-25 18:23:02 +00:00
|
|
|
bool showBoundariesFl; // Flag used to show and hide boundaries,
|
|
|
|
// used by the console
|
2011-01-23 00:05:52 +00:00
|
|
|
bool doQuitFl;
|
|
|
|
bool skipIntroFl;
|
2011-04-25 12:28:19 +00:00
|
|
|
bool helpFl;
|
2011-01-23 00:05:52 +00:00
|
|
|
uint32 tick; // Current time in ticks
|
|
|
|
vstate_t viewState; // View state machine
|
|
|
|
int16 song; // Current song
|
|
|
|
|
|
|
|
// Strangerke - Suppress as related to playback
|
|
|
|
// bool playbackFl; // Game is in playback mode
|
|
|
|
// bool recordFl; // Game is in record mode
|
|
|
|
// Strangerke - Not used ?
|
2011-02-08 20:52:26 +00:00
|
|
|
// bool helpFl; // Calling WinHelp (don't disable music)
|
2011-01-23 00:05:52 +00:00
|
|
|
// bool mmtimeFl; // Multimedia timer supported
|
2011-02-08 20:52:26 +00:00
|
|
|
// bool demoFl; // Game is in demo mode
|
2011-04-25 12:28:19 +00:00
|
|
|
// bool textBoxFl; // Game is (halted) in text box
|
2011-01-23 00:05:52 +00:00
|
|
|
// int16 screenWidth; // Desktop screen width
|
|
|
|
// int16 saveSlot; // Current slot to save/restore game
|
2011-02-08 20:52:26 +00:00
|
|
|
// int16 cx, cy; // Cursor position (dib coords)
|
|
|
|
// uint32 saveTick; // Time of last save in ticks
|
|
|
|
//
|
|
|
|
// typedef char fpath_t[kMaxPath]; // File path
|
|
|
|
// fpath_t path; // Alternate path for saved files
|
2011-01-23 00:05:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2011-02-11 20:27:48 +00:00
|
|
|
* Structure to define an EXIT or other collision-activated hotspot
|
|
|
|
*/
|
2011-01-23 00:05:52 +00:00
|
|
|
struct hotspot_t {
|
|
|
|
int screenIndex; // Screen in which hotspot appears
|
|
|
|
int x1, y1, x2, y2; // Bounding box of hotspot
|
|
|
|
uint16 actIndex; // Actions to carry out if a 'hit'
|
|
|
|
int16 viewx, viewy, direction; // Used in auto-route mode
|
|
|
|
};
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
class FileManager;
|
|
|
|
class Scheduler;
|
|
|
|
class Screen;
|
|
|
|
class MouseHandler;
|
|
|
|
class InventoryHandler;
|
|
|
|
class Parser;
|
|
|
|
class Route;
|
|
|
|
class SoundHandler;
|
|
|
|
class IntroHandler;
|
2010-10-21 17:09:57 +00:00
|
|
|
class ObjectHandler;
|
2011-01-25 00:32:48 +00:00
|
|
|
class TextHandler;
|
2010-10-15 06:16:27 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
class HugoEngine : public Engine {
|
|
|
|
public:
|
|
|
|
HugoEngine(OSystem *syst, const HugoGameDescription *gd);
|
|
|
|
~HugoEngine();
|
|
|
|
|
2010-11-29 17:42:08 +00:00
|
|
|
OSystem *_system;
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
byte _numVariant;
|
|
|
|
byte _gameVariant;
|
2010-10-31 21:20:22 +00:00
|
|
|
int8 _soundSilence;
|
|
|
|
int8 _soundTest;
|
|
|
|
int8 _tunesNbr;
|
2010-08-17 09:28:20 +00:00
|
|
|
uint16 _numScreens;
|
2011-04-24 20:29:27 +00:00
|
|
|
uint16 _numStates;
|
2011-01-01 23:57:50 +00:00
|
|
|
int8 _normalTPS; // Number of ticks (frames) per second.
|
2011-01-23 00:05:52 +00:00
|
|
|
// 8 for Win versions, 9 for DOS versions
|
2010-08-17 09:28:20 +00:00
|
|
|
object_t *_hero;
|
|
|
|
byte *_screen_p;
|
|
|
|
byte _heroImage;
|
|
|
|
byte *_screenStates;
|
2011-01-23 00:05:52 +00:00
|
|
|
command_t _line; // Line of user text input
|
|
|
|
config_t _config; // User's config
|
2010-08-17 09:28:20 +00:00
|
|
|
int16 *_defltTunes;
|
|
|
|
uint16 _look;
|
|
|
|
uint16 _take;
|
|
|
|
uint16 _drop;
|
|
|
|
|
2011-02-20 09:37:41 +00:00
|
|
|
maze_t _maze; // Maze control structure
|
|
|
|
hugo_boot_t _boot; // Boot info structure
|
|
|
|
|
2011-02-18 21:24:32 +00:00
|
|
|
GUI::Debugger *getDebugger();
|
2010-11-07 15:04:47 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
Common::RandomSource *_rnd;
|
|
|
|
|
|
|
|
const char *_episode;
|
2011-01-30 23:08:05 +00:00
|
|
|
Common::String _picDir;
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2010-09-27 20:24:36 +00:00
|
|
|
command_t _statusLine;
|
|
|
|
command_t _scoreLine;
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
const HugoGameDescription *_gameDescription;
|
|
|
|
uint32 getFeatures() const;
|
2010-11-29 17:50:30 +00:00
|
|
|
const char *getGameId() const;
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
GameType getGameType() const;
|
|
|
|
Common::Platform getPlatform() const;
|
|
|
|
bool isPacked() const;
|
|
|
|
|
2011-02-20 09:37:41 +00:00
|
|
|
// Used by the qsort function
|
2010-08-17 09:28:20 +00:00
|
|
|
static HugoEngine &get() {
|
2010-10-03 08:08:42 +00:00
|
|
|
assert(s_Engine != 0);
|
2010-08-17 09:28:20 +00:00
|
|
|
return *s_Engine;
|
|
|
|
}
|
|
|
|
|
2011-02-07 22:58:22 +00:00
|
|
|
virtual bool canLoadGameStateCurrently();
|
|
|
|
virtual bool canSaveGameStateCurrently();
|
2010-08-17 09:28:20 +00:00
|
|
|
bool loadHugoDat();
|
|
|
|
|
2011-02-02 21:12:51 +00:00
|
|
|
int8 getTPS() const;
|
2010-12-12 07:40:00 +00:00
|
|
|
|
2010-11-29 17:42:08 +00:00
|
|
|
void initGame(const HugoGameDescription *gd);
|
|
|
|
void initGamePart(const HugoGameDescription *gd);
|
2010-08-17 09:28:20 +00:00
|
|
|
void endGame();
|
2011-02-18 21:24:32 +00:00
|
|
|
void gameOverMsg();
|
2010-10-21 17:09:57 +00:00
|
|
|
void initStatus();
|
2011-02-02 21:12:51 +00:00
|
|
|
void readScreenFiles(const int screen);
|
|
|
|
void setNewScreen(const int screen);
|
2010-08-17 09:28:20 +00:00
|
|
|
void shutdown();
|
2010-12-22 22:25:52 +00:00
|
|
|
void syncSoundSettings();
|
2010-10-21 17:09:57 +00:00
|
|
|
|
2011-02-18 21:24:32 +00:00
|
|
|
status_t &getGameStatus();
|
|
|
|
int getScore() const;
|
|
|
|
void setScore(const int newScore);
|
|
|
|
void adjustScore(const int adjustment);
|
|
|
|
int getMaxScore() const;
|
|
|
|
void setMaxScore(const int newScore);
|
2011-06-02 12:11:38 +00:00
|
|
|
Common::Error saveGameState(int slot, const Common::String &desc);
|
2011-02-18 21:24:32 +00:00
|
|
|
Common::Error loadGameState(int slot);
|
|
|
|
bool hasFeature(EngineFeature f) const;
|
|
|
|
const char *getCopyrightString() const;
|
2011-01-23 22:51:12 +00:00
|
|
|
|
2011-02-12 08:13:35 +00:00
|
|
|
Common::String getSavegameFilename(int slot);
|
2011-02-18 07:11:55 +00:00
|
|
|
uint16 **loadLongArray(Common::SeekableReadStream &in);
|
2011-01-23 22:51:12 +00:00
|
|
|
|
2010-10-21 17:09:57 +00:00
|
|
|
FileManager *_file;
|
|
|
|
Scheduler *_scheduler;
|
|
|
|
Screen *_screen;
|
|
|
|
MouseHandler *_mouse;
|
|
|
|
InventoryHandler *_inventory;
|
|
|
|
Parser *_parser;
|
|
|
|
Route *_route;
|
|
|
|
SoundHandler *_sound;
|
|
|
|
IntroHandler *_intro;
|
|
|
|
ObjectHandler *_object;
|
2011-01-25 00:32:48 +00:00
|
|
|
TextHandler *_text;
|
2011-01-03 12:38:13 +00:00
|
|
|
TopMenu *_topMenu;
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
protected:
|
|
|
|
|
|
|
|
// Engine APIs
|
|
|
|
Common::Error run();
|
|
|
|
|
|
|
|
private:
|
2011-01-23 00:05:52 +00:00
|
|
|
static const int kTurboTps = 16; // This many in turbo mode
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
status_t _status; // Game status structure
|
2011-02-03 18:25:38 +00:00
|
|
|
uint32 _lastTime;
|
|
|
|
uint32 _curTime;
|
2010-08-17 09:28:20 +00:00
|
|
|
|
|
|
|
static HugoEngine *s_Engine;
|
|
|
|
|
2010-11-07 15:04:47 +00:00
|
|
|
HugoConsole *_console;
|
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
GameType _gameType;
|
|
|
|
Common::Platform _platform;
|
|
|
|
bool _packedFl;
|
|
|
|
|
2010-11-06 13:21:18 +00:00
|
|
|
int _score; // Holds current score
|
|
|
|
int _maxscore; // Holds maximum score
|
2010-08-17 09:28:20 +00:00
|
|
|
|
2011-01-23 00:05:52 +00:00
|
|
|
void initPlaylist(bool playlist[kMaxTunes]);
|
|
|
|
void initConfig();
|
2010-08-17 09:28:20 +00:00
|
|
|
void initialize();
|
|
|
|
void initMachine();
|
2011-01-23 00:05:52 +00:00
|
|
|
void calcMaxScore();
|
|
|
|
void resetConfig();
|
2010-08-17 09:28:20 +00:00
|
|
|
void runMachine();
|
2010-08-26 23:41:39 +00:00
|
|
|
|
2010-08-17 09:28:20 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // End of namespace Hugo
|
|
|
|
|
|
|
|
#endif // Hugo_H
|