ScummVM API documentation
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 GameFeatures {
83  ADGF_TALKIE = 1 << 0
84 };
85 
86 enum HDBDebugChannels {
87  kDebugExample1 = 1 << 0,
88  kDebugExample2 = 1 << 1
89 };
90 
91 enum GameState {
92  GAME_TITLE,
93  GAME_MENU,
94  GAME_PLAY,
95  GAME_LOADING
96 };
97 
98 enum Flag {
99  kFlagOK = 0x0,
100  kFlagPlayerBlock = 0x1,
101  kFlagMonsterBlock = 0x2,
102  kFlagSolid = 0x3,
103  kFlagItemDie = 0x4,
104  kFlagPlayerDie = 0x8,
105  kFlagMonsterDie = 0x10,
106  kFlagInvisible = 0x20,
107  kFlagMetal = 0x40,
108  kFlagForeground = 0x80,
109  kFlagMonsterHurt = 0x100,
110  kFlagPushUp = 0x200,
111  kFlagPushRight = 0x400,
112  kFlagPushDown = 0x800,
113  kFlagPushLeft = 0x1000,
114  kFlagLightSink = 0x2000,
115  kFlagSlime = 0x201C,
116  kFlagHeavySink = 0x4000,
117  kFlagWater = 0x401C,
118  kFlagLightMelt = 0x8000,
119  kFlagHeavyMelt = 0x10000,
120  kFlagSlide = 0x20000,
121  kFlagEnergyFloor = 0x40000,
122  kFlagPlasmaFloor = 0x6000D,
123  kFlagRadFloor = 0x6800D,
124  kFlagTeleport = 0x80000,
125  kFlagSpecial = 0x100000,
126  kFlagIce = 0x120000,
127  kFlagStairBot = 0x200000,
128  kFlagStairTop = 0x400000,
129  kFlagAnimSlow = 0x800000,
130  kFlagAnimMedium = 0x1000000,
131  kFlagAnimFast = 0x1800000,
132  kFlagMasked = 0x2000000,
133  kFlagGrating = 0x4000000,
134  kFlagPlummet = 0x8000000
135 };
136 
137 struct Save {
138  char saveID[12];
139  int fileSlot;
140  char mapName[32];
141  uint32 seconds;
142 
143  Save() : fileSlot(0), seconds(0) {
144  saveID[0] = 0;
145  mapName[0] = 0;
146  }
147 };
148 
149 class HDBGame : public Engine {
150 public:
151  HDBGame(OSystem *syst, const ADGameDescription *gameDesc);
152  ~HDBGame() override;
153 
154  bool hasFeature(Engine::EngineFeature f) const override;
155  void initializePath(const Common::FSNode &gamePath) override;
156 
157  Common::Error run() override;
158  void syncSoundSettings() override;
159 
160  // Detection related members;
161  const ADGameDescription *_gameDescription;
162  const char *getGameId() const;
163  const char *getGameFile() const;
164  uint32 getGameFlags() const;
165  Common::Platform getPlatform() const;
166  bool isDemo() const;
167  bool isPPC() const;
168  bool isHandango() const;
169 
170  // Platform-Specific Constants
171 
172  int _screenWidth;
173  int _screenHeight;
174  int _screenDrawWidth; // visible pixels wide
175  int _screenDrawHeight;
176  int _progressY;
177 
178  /*
179  Game System Pointers
180  */
181 
182  FileMan *_fileMan;
183  Gfx *_gfx;
184  LuaScript *_lua;
185  Map *_map;
186  AI *_ai;
187  Input *_input;
188  Menu *_menu;
189  Sound *_sound;
190  Window *_window;
191 
192  // Random Source
193  Common::RandomSource *_rnd;
194 
195  // Game related members;
196 
197  bool init();
198  void save(Common::OutSaveFile *out);
199  void loadSaveFile(Common::InSaveFile *in);
200 
201  void start();
202  bool restartMap();
203  bool startMap(const char *name);
204 
205  void changeMap(const char *name) {
206  Common::strlcpy(_changeMapname, name, 64);
207  _changeLevel = true;
208  }
209 
210  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
211  Common::Error loadGameState(int slot) override;
212  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
213  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
214  void saveGame(Common::OutSaveFile *out);
215  void loadGame(Common::InSaveFile *in);
216 
217  Common::String genSaveFileName(uint slot, bool lua);
218 
219  void saveWhenReady(int slot) {
220  _saveInfo.active = true;
221  _saveInfo.slot = slot;
222  }
223 
224  void loadWhenReady(int slot) {
225  _loadInfo.active = true;
226  _loadInfo.slot = slot;
227  }
228 
229  void setGameState(GameState gs) {
230  _gameState = gs;
231  }
232  GameState getGameState() {
233  return _gameState;
234  }
235  void changeGameState();
236  void paint();
237  void moveMap(int x, int y); // Get Stylus Coords and Scroll
238  void startMoveMap(int x, int y); // Start Dragging Map
239 
240  void setTargetXY(int x, int y);
241  void useEntity(AIEntity *e);
242 
243  void setupProgressBar(int maxCount);
244  void drawProgressBar();
245  void makeProgress() {
246  _progressCurrent++;
247  drawProgressBar();
248  }
249  void checkProgress();
250  void stopProgress() {
251  _progressActive = false;
252  }
253  void drawLoadingScreen();
254 
255  int getActionMode() {
256  return _actionMode;
257  }
258  void setActionMode(int status) {
259  _actionMode = status;
260  }
261 
262  void togglePause() {
263  _pauseFlag ^= true;
264  }
265 
266  bool getPause() {
267  return _pauseFlag;
268  }
269 
270  void resetTimer() {
271  _timePlayed = _timeSeconds = 0;
272  }
273 
274  uint32 getTime() {
275  return _timePlayed / 1000;
276  }
277 
278  uint32 getTimeSlice() {
279  return _timeSlice;
280  }
281 
282  uint32 getTimeSliceDelta() {
283  return _timeSlice - _prevTimeSlice;
284  }
285 
286  const Common::String *getTargetName() {
287  return &_targetName;
288  }
289 
290  int getDebug() { return _debugFlag; }
291  void setDebug(int flag) { _debugFlag = flag; }
292 
293  bool isVoiceless() {
294  /*
295  FIXME: Add hyperspace-nv.mpc to gameDescriptions[]
296  in detection.cpp, and add a flag check for it.
297  Until then, the voiceless version is unsupported.
298  */
299  return false;
300  }
301 
302  char *lastMapName() { return _lastMapname; }
303  char *currentMapName() { return _currentMapname; }
304  char *getInMapName() { return _inMapName; }
305  void setInMapName(const char *name);
306 
307  void changeLevel(const char *name) {
308  Common::strlcpy(_changeMapname, name, 64);
309  _changeLevel = true;
310  }
311 
312  //
313  // monkeystone secret stars
314  //
315  int32 getStarsMonkeystone7() { return _monkeystone7; }
316  int32 getStarsMonkeystone14() { return _monkeystone14; }
317  int32 getStarsMonkeystone21() { return _monkeystone21; }
318 
319  void setStarsMonkeystone7(int32 value) { _monkeystone7 = value; }
320  void setStarsMonkeystone14(int32 value) { _monkeystone14 = value; }
321  void setStarsMonkeystone21(int32 value) { _monkeystone21 = value; }
322 
323  void setCheatingOn() {
324  _cheating = true;
325  }
326  bool getCheatingOn() {
327  return _cheating;
328  }
329 
330  Save _saveHeader;
331  bool _gameShutdown;
332  Graphics::PixelFormat _format;
333 
334  Picture *_progressGfx, *_progressMarkGfx;
335  Picture *_loadingScreenGfx, *_logoGfx;
336  bool _progressActive;
337  int _progressCurrent, _progressXOffset, _progressMax;
338 
339  // FPS Variables
340  Common::Array<uint32> _frames;
341 
342  Common::OutSaveFile *_currentOutSaveFile;
343  Common::InSaveFile *_currentInSaveFile;
344 
345 private:
346 
347  uint32 _timePlayed;
348  uint32 _timeSlice, _prevTimeSlice;
349  uint32 _timeSeconds;
350 
351  uint32 _tiempo;
352 
353  // Game Variables
354 
355  bool _systemInit;
356  GameState _gameState;
357  int _actionMode; // 0 or 1
358 
359  // Misc Variables
360  bool _pauseFlag;
361  bool _cheating;
362  int _debugFlag;
363  Tile *_debugLogo;
364  int _dx, _dy; // DEBUG : for dragging map
365 
366  char _currentMapname[64];
367  char _lastMapname[64];
368 
369  char _currentLuaName[64];
370  char _lastLuaName[64];
371 
372  char _inMapName[32]; // Name Inside Map file
373 
374  int32 _monkeystone7;
375  int32 _monkeystone14;
376  int32 _monkeystone21;
377 
378  bool _changeLevel;
379  char _changeMapname[64];
380 
381  struct {
382  bool active;
383  int slot;
384  } _saveInfo, _loadInfo;
385 
386  bool _noMusicDriver; // If "Music Device" is set to "No Music" from Audio tab
387 };
388 
389 extern HDBGame *g_hdb;
390 
391 }// End of namespace HDB
392 
393 #endif
Definition: ai-player.h:25
Definition: gfx.h:71
Definition: str.h:59
EngineFeature
Definition: engine.h:250
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:120
Definition: random.h:44
Definition: hdb.h:149
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:167
Definition: menu.h:70
Definition: ai.h:872
Definition: engine.h:143
Platform
Definition: platform.h:46
Definition: gfx.h:234
Definition: sound.h:1493
Definition: hdb.h:137