ScummVM API documentation
game_maddog.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 ALG_GAME_MADDOG_H
23 #define ALG_GAME_MADDOG_H
24 
25 #include "common/hashmap.h"
26 #include "common/rect.h"
27 
28 #include "gui/debugger.h"
29 
30 #include "alg/game.h"
31 #include "alg/scene.h"
32 
33 namespace Alg {
34 
35 typedef Common::Functor1Mem<Scene *, void, GameMaddog> MDScriptFunctionScene;
36 typedef Common::Functor1Mem<Rect *, void, GameMaddog> MDScriptFunctionRect;
37 typedef Common::Functor1Mem<Common::Point *, void, GameMaddog> MDScriptFunctionPoint;
38 typedef Common::HashMap<Common::String, MDScriptFunctionScene *> MDScriptFunctionSceneMap;
39 typedef Common::HashMap<Common::String, MDScriptFunctionRect *> MDScriptFunctionRectMap;
40 typedef Common::HashMap<Common::String, MDScriptFunctionPoint *> MDScriptFunctionPointMap;
41 
42 class GameMaddog : public Game {
43 
44  enum SceneFuncType {
45  PREOP = 1,
46  SHOWMSG = 2,
47  INSOP = 3,
48  WEPDWN = 4,
49  SCNSCR = 5,
50  NXTFRM = 6,
51  NXTSCN = 7
52  };
53 
54 public:
55  GameMaddog(AlgEngine *vm, const AlgGameDescription *gd);
56  ~GameMaddog() override;
57  Common::Error run() override;
58  void runCursorTimer();
59  void debug_warpTo(int val);
60 
61 private:
62  void init() override;
63  void registerScriptFunctions();
64  void verifyScriptFunctions();
65  void unregisterScriptFunctions();
66  MDScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
67  MDScriptFunctionRect getScriptFunctionRectHit(Common::String name);
68  MDScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
69  void callScriptFunctionZonePtrFb(Common::String name, Common::Point *point);
70  void callScriptFunctionRectHit(Common::String name, Rect *rect);
71  void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
72 
73  MDScriptFunctionPointMap _zonePtrFb;
74  MDScriptFunctionRectMap _rectHitFuncs;
75  MDScriptFunctionSceneMap _scenePreOps;
76  MDScriptFunctionSceneMap _sceneShowMsg;
77  MDScriptFunctionSceneMap _sceneInsOps;
78  MDScriptFunctionSceneMap _sceneWepDwn;
79  MDScriptFunctionSceneMap _sceneScnScr;
80  MDScriptFunctionSceneMap _sceneNxtFrm;
81  MDScriptFunctionSceneMap _sceneNxtScn;
82 
83  // images
84  Graphics::Surface *_shotIcon = nullptr;
85  Graphics::Surface *_emptyIcon = nullptr;
86  Graphics::Surface *_liveIcon = nullptr;
87  Graphics::Surface *_deadIcon = nullptr;
88  Graphics::Surface *_reloadIcon = nullptr;
89  Graphics::Surface *_drawIcon = nullptr;
90  Graphics::Surface *_knifeIcon = nullptr;
91  Graphics::Surface *_bulletholeIcon = nullptr;
92  Common::Array<Graphics::Surface *> *_gun = nullptr;
93  Common::Array<Graphics::Surface *> *_numbers = nullptr;
94 
95  // sounds
96  Audio::SeekableAudioStream *_saveSound = nullptr;
97  Audio::SeekableAudioStream *_loadSound = nullptr;
98  Audio::SeekableAudioStream *_easySound = nullptr;
99  Audio::SeekableAudioStream *_avgSound = nullptr;
100  Audio::SeekableAudioStream *_hardSound = nullptr;
101  Audio::SeekableAudioStream *_skullSound = nullptr;
102  Audio::SeekableAudioStream *_shotSound = nullptr;
103  Audio::SeekableAudioStream *_emptySound = nullptr;
104 
105  // constants
106  const uint16 _fight[3] = {208, 228, 243};
107  const uint16 _ambush[3] = {192, 193, 192};
108  const uint16 _hotelScenes[10] = {77, 77, 87, 87, 89, 89, 97, 97, 105, 105};
109  const uint16 _bottleToss[14] = {171, 171, 174, 174, 175, 175, 178, 178, 179, 179, 182, 182, 183, 183};
110 
111  const uint16 _diffPos[4][2] = {{0, 0}, {0x4D, 0x43}, {0x4E, 0x66}, {0x4F, 0x80}};
112  const uint16 _livePos[3][2] = {{0x03, 0x5E}, {0x03, 0x76}, {0x03, 0x8E}};
113  const uint16 _shotPos[12][2] = {{0x3, 0x5}, {0x0D, 0x5}, {0x17, 0x5}, {0x21, 0x5}, {0x3, 0x21}, {0x0D, 0x21}, {0x17, 0x21}, {0x21, 0x21}, {0x3, 0x3D}, {0x0D, 0x3D}, {0x17, 0x3D}, {0x21, 0x3D}};
114 
115  // gamestate
116  uint8 _difficulty = 1;
117  uint8 _emptyCount = 0;
118  bool _holster = false;
119  uint8 _oldDifficulty = 1;
120  uint8 _inHolster = 0;
121  int8 _lives = 0;
122  int8 _oldLives = 0;
123  int32 _score = 0;
124  int32 _oldScore = -1;
125  bool _shotFired = false;
126  uint16 _shots = 0;
127  uint8 _oldShots = 0;
128  uint8 _whichGun = 0;
129  uint8 _oldWhichGun = 0xFF;
130  long int _minF = 0;
131  long int _maxF = 0;
132 
133  uint8 _badMen = 0;
134  uint8 _badMenBits = 0;
135  bool _bartenderAlive = false;
136  uint16 _beenTo = 0;
137  uint8 _bottles = 0;
138  uint8 _bottlesMask = 0;
139  bool _gotClue = false;
140  uint16 _gotInto = 0;
141  uint8 _gunTime = 0;
142  bool _hadSkull = false;
143  bool _hadLantern = false;
144  bool _hideOutFront = false;
145  bool _inShootout = false;
146  int8 _map0 = 0;
147  int8 _map1 = 0;
148  int8 _map2 = 0;
149  uint8 _mapPos = 0;
150  uint8 _maxMapPos = 0;
151  uint8 _peopleKilled = 0;
152  uint8 _proClue = 0;
153  uint8 _sheriffCnt = 0; // unused
154  uint8 _shootOutCnt = 0;
155 
156  Common::String _retScene;
157  Common::String _subScene;
158 
159  uint32 _thisGameTimer = 0;
160 
161  // base functions
162  void newGame();
163  void resetParams();
164  void doMenu();
165  void updateStat();
166  void changeDifficulty(uint8 newDifficulty);
167  void showDifficulty(uint8 newDifficulty, bool updateCursor);
168  void adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty);
169  void updateCursor();
170  void updateMouse();
171  void moveMouse();
172  void displayScore();
173  bool weaponDown();
174  bool saveState(Common::OutSaveFile *saveFile) override;
175  bool loadState(Common::InSaveFile *inSaveFile) override;
176  Zone *checkZones(Scene *scene, Rect *&hitRect, Common::Point *point);
177 
178  // misc game functions
179  void defaultBullethole(Common::Point *point);
180  void die();
181  uint8 pickRand(uint8 *bits, uint8 max);
182  uint8 pickBad(uint8 max);
183  Common::String pickTown();
184  Common::String pickMap();
185  Common::String pickSign();
186  Common::String mapRight();
187  Common::String mapLeft();
188 
189  // Timer
190  void setupCursorTimer();
191  void removeCursorTimer();
192 
193  // Script functions: Zone
194  void zoneBullethole(Common::Point *point);
195  void zoneSkullhole(Common::Point *point);
196 
197  // Script functions: RectHit
198  void rectNewScene(Rect *rect);
199  void rectShotMenu(Rect *rect);
200  void rectContinue(Rect *rect);
201  void rectSave(Rect *rect);
202  void rectLoad(Rect *rect);
203  void rectStart(Rect *rect);
204  void rectStartBottles(Rect *rect);
205  void rectEasy(Rect *rect);
206  void rectAverage(Rect *rect);
207  void rectHard(Rect *rect);
208  void rectExit(Rect *rect);
209  void rectHideFront(Rect *rect);
210  void rectHideRear(Rect *rect);
211  void rectMenuSelect(Rect *rect);
212  void rectSkull(Rect *rect);
213  void rectKillMan(Rect *rect);
214  void rectKillWoman(Rect *rect);
215  void rectProspSign(Rect *rect);
216  void rectMineSign(Rect *rect);
217  void rectMineItem1(Rect *rect);
218  void rectMineItem2(Rect *rect);
219  void rectMineItem3(Rect *rect);
220  void rectMineLantern(Rect *rect);
221  void rectShotHideout(Rect *rect);
222  void rectShotRight(Rect *rect);
223  void rectShotLeft(Rect *rect);
224 
225  // Script functions: Scene PreOps
226  void scenePsoShootout(Scene *scene);
227  void scenePsoMDShootout(Scene *scene);
228 
229  // Script functions: Scene InsOps
230  void sceneIsoShootPast(Scene *scene);
231  void sceneIsoShootPastPause(Scene *scene);
232  void sceneIsoSkipSaloon(Scene *scene);
233  void sceneIsoSkipSaloon2(Scene *scene);
234  void sceneIsoCheckSaloon(Scene *scene);
235  void sceneIsoIntoStable(Scene *scene);
236  void sceneIsoIntoOffice(Scene *scene);
237  void sceneIsoIntoBank(Scene *scene);
238  void sceneIsoCheckBartender(Scene *scene);
239  void sceneIsoDidHideout(Scene *scene);
240  void sceneIsoDidSignPost(Scene *scene);
241  void sceneIsoDoShootout(Scene *scene);
242  void sceneIsoMDShootout(Scene *scene);
243  void sceneIsoShotInto116(Scene *scene);
244 
245  // Script functions: Scene NxtScn
246  void sceneDefaultNxtscn(Scene *scene);
247  void sceneNxtscnPickBottle(Scene *scene);
248  void sceneNxtscnDied(Scene *scene);
249  void sceneNxtscnAutoSelect(Scene *scene);
250  void sceneNxtscnFinishSaloon(Scene *scene);
251  void sceneNxtscnFinishOffice(Scene *scene);
252  void sceneNxtscnFinishStable(Scene *scene);
253  void sceneNxtscnFinishBank(Scene *scene);
254  void sceneNxtscnPicSaloon(Scene *scene);
255  void sceneNxtscnKillMan(Scene *scene);
256  void sceneNxtscnKillWoman(Scene *scene);
257  void sceneNxtscnBank(Scene *scene);
258  void sceneNxtscnStable(Scene *scene);
259  void sceneNxtscnSavProsp(Scene *scene);
260  void sceneNxtscnPickToss(Scene *scene);
261  void sceneNxtscnHitToss(Scene *scene);
262  void sceneNxtscnMissToss(Scene *scene);
263  void sceneNxtscnPickSign(Scene *scene);
264  void sceneNxtscnBRockMan(Scene *scene);
265  void sceneNxtscnLRockMan(Scene *scene);
266  void sceneNxtscnHotelMen(Scene *scene);
267 
268  // Script functions: Scene WepDwn
269  void sceneDefaultWepdwn(Scene *scene);
270 
271  // Script functions: ScnScr
272  void sceneDefaultScore(Scene *scene);
273 };
274 
276 public:
277  DebuggerMaddog(GameMaddog *game);
278  bool cmdWarpTo(int argc, const char **argv);
279  bool cmdDumpLib(int argc, const char **argv);
280 
281 private:
282  GameMaddog *_game;
283 };
284 
285 } // End of namespace Alg
286 
287 #endif
Definition: scene.h:72
Definition: scene.h:101
Definition: str.h:59
Definition: surface.h:67
Definition: savefile.h:54
Definition: error.h:81
Definition: debugger.h:41
Definition: stream.h:745
Definition: audiostream.h:212
Definition: alg.h:30
Definition: game_maddog.h:42
Definition: func.h:452
Definition: rect.h:144
Definition: scene.h:85
Definition: game.h:36
Definition: alg.h:46
Definition: game_maddog.h:275
Definition: detection.h:39