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 debugWarpTo(int val);
59 
60 private:
61  void init() override;
62  void registerScriptFunctions();
63  void verifyScriptFunctions();
64  MDScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
65  MDScriptFunctionRect getScriptFunctionRectHit(Common::String name);
66  MDScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
67  void callScriptFunctionZonePtrFb(Common::String name, Common::Point *point);
68  void callScriptFunctionRectHit(Common::String name, Rect *rect);
69  void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
70 
71  MDScriptFunctionPointMap _zonePtrFb;
72  MDScriptFunctionRectMap _rectHitFuncs;
73  MDScriptFunctionSceneMap _scenePreOps;
74  MDScriptFunctionSceneMap _sceneShowMsg;
75  MDScriptFunctionSceneMap _sceneInsOps;
76  MDScriptFunctionSceneMap _sceneWepDwn;
77  MDScriptFunctionSceneMap _sceneScnScr;
78  MDScriptFunctionSceneMap _sceneNxtFrm;
79  MDScriptFunctionSceneMap _sceneNxtScn;
80 
81  // images
82  Graphics::Surface *_shotIcon;
83  Graphics::Surface *_emptyIcon;
84  Graphics::Surface *_liveIcon;
85  Graphics::Surface *_deadIcon;
86  Graphics::Surface *_reloadIcon;
87  Graphics::Surface *_drawIcon;
88  Graphics::Surface *_knifeIcon;
89  Graphics::Surface *_bulletholeIcon;
90 
91  // constants
92  const uint16 _fight[3] = {208, 228, 243};
93  const uint16 _ambush[3] = {192, 193, 192};
94  const uint16 _hotelScenes[10] = {77, 77, 87, 87, 89, 89, 97, 97, 105, 105};
95  const uint16 _bottleToss[14] = {171, 171, 174, 174, 175, 175, 178, 178, 179, 179, 182, 182, 183, 183};
96 
97  const uint16 _diffPos[4][2] = {{0, 0}, {0x4D, 0x43}, {0x4E, 0x66}, {0x4F, 0x80}};
98  const uint16 _livePos[3][2] = {{0x03, 0x5E}, {0x03, 0x76}, {0x03, 0x8E}};
99  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}};
100 
101  // gamestate
102  uint8 _badMen = 0;
103  uint8 _badMenBits = 0;
104  bool _bartenderAlive = false;
105  uint16 _beenTo = 0;
106  uint8 _bottles = 0;
107  uint8 _bottlesMask = 0;
108  bool _gotClue = false;
109  uint16 _gotInto = 0;
110  uint8 _gunTime = 0;
111  bool _hadSkull = false;
112  bool _hadLantern = false;
113  bool _hideOutFront = false;
114  bool _inShootout = false;
115  int8 _map0 = 0;
116  int8 _map1 = 0;
117  int8 _map2 = 0;
118  uint8 _mapPos = 0;
119  uint8 _maxMapPos = 0;
120  uint8 _peopleKilled = 0;
121  uint8 _proClue = 0;
122  uint8 _sheriffCnt = 0; // unused
123  uint8 _shootOutCnt = 0;
124 
125  // base functions
126  void newGame();
127  void resetParams();
128  void doMenu();
129  void updateStat();
130  void changeDifficulty(uint8 newDifficulty);
131  void showDifficulty(uint8 newDifficulty, bool updateCursor);
132  void updateCursor();
133  void updateMouse();
134  void moveMouse();
135  void displayScore();
136  bool weaponDown();
137  bool saveState();
138  bool loadState();
139 
140  // misc game functions
141  void defaultBullethole(Common::Point *point);
142  void die();
143  uint8 pickRand(uint8 *bits, uint8 max);
144  uint8 pickBad(uint8 max);
145  Common::String pickTown();
146  Common::String pickMap();
147  Common::String pickSign();
148  Common::String mapRight();
149  Common::String mapLeft();
150 
151  // Script functions: Zone
152  void zoneBullethole(Common::Point *point);
153  void zoneSkullhole(Common::Point *point);
154 
155  // Script functions: RectHit
156  void rectShotMenu(Rect *rect);
157  void rectContinue(Rect *rect);
158  void rectSave(Rect *rect);
159  void rectLoad(Rect *rect);
160  void rectStart(Rect *rect);
161  void rectStartBottles(Rect *rect);
162  void rectHideFront(Rect *rect);
163  void rectHideRear(Rect *rect);
164  void rectMenuSelect(Rect *rect);
165  void rectSkull(Rect *rect);
166  void rectKillMan(Rect *rect);
167  void rectKillWoman(Rect *rect);
168  void rectProspSign(Rect *rect);
169  void rectMineSign(Rect *rect);
170  void rectMineItem1(Rect *rect);
171  void rectMineItem2(Rect *rect);
172  void rectMineItem3(Rect *rect);
173  void rectMineLantern(Rect *rect);
174  void rectShotHideout(Rect *rect);
175  void rectShotRight(Rect *rect);
176  void rectShotLeft(Rect *rect);
177 
178  // Script functions: Scene PreOps
179  void scenePsoShootout(Scene *scene);
180  void scenePsoMDShootout(Scene *scene);
181 
182  // Script functions: Scene InsOps
183  void sceneIsoShootPast(Scene *scene);
184  void sceneIsoShootPastPause(Scene *scene);
185  void sceneIsoSkipSaloon(Scene *scene);
186  void sceneIsoSkipSaloon2(Scene *scene);
187  void sceneIsoCheckSaloon(Scene *scene);
188  void sceneIsoIntoStable(Scene *scene);
189  void sceneIsoIntoOffice(Scene *scene);
190  void sceneIsoIntoBank(Scene *scene);
191  void sceneIsoCheckBartender(Scene *scene);
192  void sceneIsoDidHideout(Scene *scene);
193  void sceneIsoDidSignPost(Scene *scene);
194  void sceneIsoDoShootout(Scene *scene);
195  void sceneIsoMDShootout(Scene *scene);
196  void sceneIsoShotInto116(Scene *scene);
197 
198  // Script functions: Scene NxtScn
199  void sceneDefaultNxtscn(Scene *scene);
200  void sceneNxtscnPickBottle(Scene *scene);
201  void sceneNxtscnDied(Scene *scene);
202  void sceneNxtscnAutoSelect(Scene *scene);
203  void sceneNxtscnFinishSaloon(Scene *scene);
204  void sceneNxtscnFinishOffice(Scene *scene);
205  void sceneNxtscnFinishStable(Scene *scene);
206  void sceneNxtscnFinishBank(Scene *scene);
207  void sceneNxtscnPicSaloon(Scene *scene);
208  void sceneNxtscnKillMan(Scene *scene);
209  void sceneNxtscnKillWoman(Scene *scene);
210  void sceneNxtscnBank(Scene *scene);
211  void sceneNxtscnStable(Scene *scene);
212  void sceneNxtscnSavProsp(Scene *scene);
213  void sceneNxtscnPickToss(Scene *scene);
214  void sceneNxtscnHitToss(Scene *scene);
215  void sceneNxtscnMissToss(Scene *scene);
216  void sceneNxtscnPickSign(Scene *scene);
217  void sceneNxtscnBRockMan(Scene *scene);
218  void sceneNxtscnLRockMan(Scene *scene);
219  void sceneNxtscnHotelMen(Scene *scene);
220 
221  // Script functions: Scene WepDwn
222  void sceneDefaultWepdwn(Scene *scene);
223 };
224 
226 public:
227  DebuggerMaddog(GameMaddog *game);
228  bool cmdWarpTo(int argc, const char **argv);
229  bool cmdDumpLib(int argc, const char **argv);
230 
231 private:
232  GameMaddog *_game;
233 };
234 
235 } // End of namespace Alg
236 
237 #endif
Definition: scene.h:72
Definition: scene.h:102
Definition: str.h:59
Definition: surface.h:67
Definition: error.h:81
Definition: debugger.h:41
Definition: alg.h:30
Definition: game_maddog.h:42
Definition: func.h:452
Definition: rect.h:144
Definition: game.h:36
Definition: alg.h:46
Definition: game_maddog.h:225
Definition: detection.h:39