ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
hdb.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef HDB_HDB_H
23 #define HDB_HDB_H
24 
25 #include "common/scummsys.h"
26 #include "common/system.h"
27 #include "common/savefile.h"
28 #include "common/fs.h"
29 
30 #include "engines/engine.h"
31 
32 namespace Common {
33  class RandomSource;
34 }
35 
36 namespace HDB {
37 class AI;
38 struct AIEntity;
39 class FileMan;
40 class Gfx;
41 class Input;
42 class LuaScript;
43 class Map;
44 class Menu;
45 class Tile;
46 class Picture;
47 class Sound;
48 class Window;
49 
50 #define CONFIG_MUSICVOL "music_volume"
51 #define CONFIG_SFXVOL "sfx_volume"
52 #define CONFIG_SPEECHVOL "speech_volume"
53 #define CONFIG_MSTONE7 "hdb_memory_heap"
54 #define CONFIG_MSTONE14 "lua_stack_offset"
55 #define CONFIG_MSTONE21 "fmod_mix_timer"
56 #define CONFIG_SOUNDCACHE "sound_cache_max" // Unused
57 #define CONFIG_GFXCACHE "gfx_cache_max" // Unused
58 #define CONFIG_CHEAT "hypercheat"
59 #define CONFIG_NOSPEECH "speech_mute"
60 #define CONFIG_MUTEALL "mute"
61 
62 enum {
63  kTileWidth = 32,
64  kTileHeight = 32,
65  kMaxSkies = 10,
66  kNum3DStars = 300,
67  kFontSpace = 5,
68  kFontIncrement = 1,
69  kGameFPS = 60,
70  kAnimFrameDelay = kGameFPS / 30,
71  kAnimSlowFrames = kAnimFrameDelay * 10,
72  kAnimMediumFrames = kAnimFrameDelay * 6,
73  kAnimFastFrames = kAnimFrameDelay * 2
74 };
75 
76 }
77 
78 struct ADGameDescription;
79 
80 namespace HDB {
81 
82 enum GameState {
83  GAME_TITLE,
84  GAME_MENU,
85  GAME_PLAY,
86  GAME_LOADING
87 };
88 
89 enum Flag {
90  kFlagOK = 0x0,
91  kFlagPlayerBlock = 0x1,
92  kFlagMonsterBlock = 0x2,
93  kFlagSolid = 0x3,
94  kFlagItemDie = 0x4,
95  kFlagPlayerDie = 0x8,
96  kFlagMonsterDie = 0x10,
97  kFlagInvisible = 0x20,
98  kFlagMetal = 0x40,
99  kFlagForeground = 0x80,
100  kFlagMonsterHurt = 0x100,
101  kFlagPushUp = 0x200,
102  kFlagPushRight = 0x400,
103  kFlagPushDown = 0x800,
104  kFlagPushLeft = 0x1000,
105  kFlagLightSink = 0x2000,
106  kFlagSlime = 0x201C,
107  kFlagHeavySink = 0x4000,
108  kFlagWater = 0x401C,
109  kFlagLightMelt = 0x8000,
110  kFlagHeavyMelt = 0x10000,
111  kFlagSlide = 0x20000,
112  kFlagEnergyFloor = 0x40000,
113  kFlagPlasmaFloor = 0x6000D,
114  kFlagRadFloor = 0x6800D,
115  kFlagTeleport = 0x80000,
116  kFlagSpecial = 0x100000,
117  kFlagIce = 0x120000,
118  kFlagStairBot = 0x200000,
119  kFlagStairTop = 0x400000,
120  kFlagAnimSlow = 0x800000,
121  kFlagAnimMedium = 0x1000000,
122  kFlagAnimFast = 0x1800000,
123  kFlagMasked = 0x2000000,
124  kFlagGrating = 0x4000000,
125  kFlagPlummet = 0x8000000
126 };
127 
128 struct Save {
129  char saveID[12];
130  int fileSlot;
131  char mapName[32];
132  uint32 seconds;
133 
134  Save() : fileSlot(0), seconds(0) {
135  saveID[0] = 0;
136  mapName[0] = 0;
137  }
138 };
139 
140 class HDBGame : public Engine {
141 public:
142  HDBGame(OSystem *syst, const ADGameDescription *gameDesc);
143  ~HDBGame() override;
144 
145  bool hasFeature(Engine::EngineFeature f) const override;
146  void initializePath(const Common::FSNode &gamePath) override;
147 
148  Common::Error run() override;
149  void syncSoundSettings() override;
150 
151  // Detection related members;
152  const ADGameDescription *_gameDescription;
153  const char *getGameId() const;
154  const char *getGameFile() const;
155  uint32 getGameFlags() const;
156  Common::Platform getPlatform() const;
157  bool isDemo() const;
158  bool isPPC() const;
159  bool isHandango() const;
160 
161  // Platform-Specific Constants
162 
163  int _screenWidth;
164  int _screenHeight;
165  int _screenDrawWidth; // visible pixels wide
166  int _screenDrawHeight;
167  int _progressY;
168 
169  /*
170  Game System Pointers
171  */
172 
173  FileMan *_fileMan;
174  Gfx *_gfx;
175  LuaScript *_lua;
176  Map *_map;
177  AI *_ai;
178  Input *_input;
179  Menu *_menu;
180  Sound *_sound;
181  Window *_window;
182 
183  // Random Source
184  Common::RandomSource *_rnd;
185 
186  // Game related members;
187 
188  bool init();
189  void save(Common::OutSaveFile *out);
190  void loadSaveFile(Common::InSaveFile *in);
191 
192  void start();
193  bool restartMap();
194  bool startMap(const char *name);
195 
196  void changeMap(const char *name) {
197  Common::strlcpy(_changeMapname, name, 64);
198  _changeLevel = true;
199  }
200 
201  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
202  Common::Error loadGameState(int slot) override;
203  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
204  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
205  void saveGame(Common::OutSaveFile *out);
206  void loadGame(Common::InSaveFile *in);
207 
208  Common::String genSaveFileName(uint slot, bool lua);
209 
210  void saveWhenReady(int slot) {
211  _saveInfo.active = true;
212  _saveInfo.slot = slot;
213  }
214 
215  void loadWhenReady(int slot) {
216  _loadInfo.active = true;
217  _loadInfo.slot = slot;
218  }
219 
220  void setGameState(GameState gs) {
221  _gameState = gs;
222  }
223  GameState getGameState() {
224  return _gameState;
225  }
226  void changeGameState();
227  void paint();
228  void moveMap(int x, int y); // Get Stylus Coords and Scroll
229  void startMoveMap(int x, int y); // Start Dragging Map
230 
231  void setTargetXY(int x, int y);
232  void useEntity(AIEntity *e);
233 
234  void setupProgressBar(int maxCount);
235  void drawProgressBar();
236  void makeProgress() {
237  _progressCurrent++;
238  drawProgressBar();
239  }
240  void checkProgress();
241  void stopProgress() {
242  _progressActive = false;
243  }
244  void drawLoadingScreen();
245 
246  int getActionMode() {
247  return _actionMode;
248  }
249  void setActionMode(int status) {
250  _actionMode = status;
251  }
252 
253  void togglePause() {
254  _pauseFlag ^= true;
255  }
256 
257  bool getPause() {
258  return _pauseFlag;
259  }
260 
261  void resetTimer() {
262  _timePlayed = _timeSeconds = 0;
263  }
264 
265  uint32 getTime() {
266  return _timePlayed / 1000;
267  }
268 
269  uint32 getTimeSlice() {
270  return _timeSlice;
271  }
272 
273  uint32 getTimeSliceDelta() {
274  return _timeSlice - _prevTimeSlice;
275  }
276 
277  const Common::String *getTargetName() {
278  return &_targetName;
279  }
280 
281  int getDebug() { return _debugFlag; }
282  void setDebug(int flag) { _debugFlag = flag; }
283 
284  bool isVoiceless() {
285  /*
286  FIXME: Add hyperspace-nv.mpc to gameDescriptions[]
287  in detection.cpp, and add a flag check for it.
288  Until then, the voiceless version is unsupported.
289  */
290  return false;
291  }
292 
293  char *lastMapName() { return _lastMapname; }
294  char *currentMapName() { return _currentMapname; }
295  char *getInMapName() { return _inMapName; }
296  void setInMapName(const char *name);
297 
298  void changeLevel(const char *name) {
299  Common::strlcpy(_changeMapname, name, 64);
300  _changeLevel = true;
301  }
302 
303  //
304  // monkeystone secret stars
305  //
306  int32 getStarsMonkeystone7() { return _monkeystone7; }
307  int32 getStarsMonkeystone14() { return _monkeystone14; }
308  int32 getStarsMonkeystone21() { return _monkeystone21; }
309 
310  void setStarsMonkeystone7(int32 value) { _monkeystone7 = value; }
311  void setStarsMonkeystone14(int32 value) { _monkeystone14 = value; }
312  void setStarsMonkeystone21(int32 value) { _monkeystone21 = value; }
313 
314  void setCheatingOn() {
315  _cheating = true;
316  }
317  bool getCheatingOn() {
318  return _cheating;
319  }
320 
321  Save _saveHeader;
322  bool _gameShutdown;
323  Graphics::PixelFormat _format;
324 
325  Picture *_progressGfx, *_progressMarkGfx;
326  Picture *_loadingScreenGfx, *_logoGfx;
327  bool _progressActive;
328  int _progressCurrent, _progressXOffset, _progressMax;
329 
330  // FPS Variables
331  Common::Array<uint32> _frames;
332 
333  Common::OutSaveFile *_currentOutSaveFile;
334  Common::InSaveFile *_currentInSaveFile;
335 
336 private:
337 
338  uint32 _timePlayed;
339  uint32 _timeSlice, _prevTimeSlice;
340  uint32 _timeSeconds;
341 
342  uint32 _tiempo;
343 
344  // Game Variables
345 
346  bool _systemInit;
347  GameState _gameState;
348  int _actionMode; // 0 or 1
349 
350  // Misc Variables
351  bool _pauseFlag;
352  bool _cheating;
353  int _debugFlag;
354  Tile *_debugLogo;
355  int _dx, _dy; // DEBUG : for dragging map
356 
357  char _currentMapname[64];
358  char _lastMapname[64];
359 
360  char _currentLuaName[64];
361  char _lastLuaName[64];
362 
363  char _inMapName[32]; // Name Inside Map file
364 
365  int32 _monkeystone7;
366  int32 _monkeystone14;
367  int32 _monkeystone21;
368 
369  bool _changeLevel;
370  char _changeMapname[64];
371 
372  struct {
373  bool active;
374  int slot;
375  } _saveInfo, _loadInfo;
376 
377  bool _noMusicDriver; // If "Music Device" is set to "No Music" from Audio tab
378 };
379 
380 extern HDBGame *g_hdb;
381 
382 }// End of namespace HDB
383 
384 #endif
Definition: ai-player.h:25
Definition: gfx.h:71
Definition: str.h:59
EngineFeature
Definition: engine.h:253
Definition: savefile.h:54
Definition: error.h:84
size_t strlcpy(char *dst, const char *src, size_t size)
Definition: pixelformat.h:138
Definition: advancedDetector.h:163
Definition: random.h:44
Definition: hdb.h:140
Definition: stream.h:745
Definition: window.h:168
Definition: file-manager.h:54
Definition: input.h:56
Definition: ai.h:388
Definition: ustr.h:57
Definition: gfx.h:256
Definition: algorithm.h:29
Definition: fs.h:69
Definition: map.h:67
Definition: lua-script.h:41
Definition: system.h:161
Definition: menu.h:70
Definition: ai.h:872
Definition: engine.h:144
Platform
Definition: platform.h:46
Definition: gfx.h:234
Definition: sound.h:1493
Definition: hdb.h:128