ScummVM API documentation
game_maddog2.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_MADDOG2_H
23 #define ALG_GAME_MADDOG2_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, GameMaddog2> MD2ScriptFunctionScene;
36 typedef Common::Functor1Mem<Rect *, void, GameMaddog2> MD2ScriptFunctionRect;
37 typedef Common::Functor1Mem<Common::Point *, void, GameMaddog2> MD2ScriptFunctionPoint;
38 typedef Common::HashMap<Common::String, MD2ScriptFunctionScene *> MD2ScriptFunctionSceneMap;
39 typedef Common::HashMap<Common::String, MD2ScriptFunctionRect *> MD2ScriptFunctionRectMap;
40 typedef Common::HashMap<Common::String, MD2ScriptFunctionPoint *> MD2ScriptFunctionPointMap;
41 
42 class GameMaddog2 : 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:
56  ~GameMaddog2() 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  MD2ScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
65  MD2ScriptFunctionRect getScriptFunctionRectHit(Common::String name);
66  MD2ScriptFunctionScene 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  MD2ScriptFunctionPointMap _zonePtrFb;
72  MD2ScriptFunctionRectMap _rectHitFuncs;
73  MD2ScriptFunctionSceneMap _scenePreOps;
74  MD2ScriptFunctionSceneMap _sceneShowMsg;
75  MD2ScriptFunctionSceneMap _sceneInsOps;
76  MD2ScriptFunctionSceneMap _sceneWepDwn;
77  MD2ScriptFunctionSceneMap _sceneScnScr;
78  MD2ScriptFunctionSceneMap _sceneNxtFrm;
79  MD2ScriptFunctionSceneMap _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 int16 _sbClue[3] = {0x67, 0x68, 0x69};
93  const int16 _bbClue[3] = {0x47, 0x49, 0x48};
94  const int16 _tpClue[3] = {0x84, 0x85, 0x86};
95  const int16 _sbScenes[14] = {0x4A, 0x50, 0xB8, 0x55, 0x57, 0x66, 0xBE, 0x94, 0x87, 0x93, 0xCD, 0x95, 0xE3, -1};
96  const int16 _bbScenes[14] = {0x33, 0x39, 0xB4, 0x41, 0x43, 0x46, 0xA2, 0x8D, 0x87, 0x8F, 0xCD, 0x8E, 0xE3, -1};
97  const int16 _tpScenes[14] = {0x6A, 0xC3, 0x76, 0x81, 0xAD, 0x83, 0xDC, 0x92, 0x87, 0x90, 0xCD, 0x91, 0xE3, -1};
98  const int16 _villageScenes[6] = {0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62};
99  const int16 _cowboyScenes[7] = {0xCD, 0xCF, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA};
100  const int16 _farmyardScenes[4] = {0xDC, 0xDE, 0x129, 0xE1};
101  const int16 _caveScenes[5] = {0xE4, 0xE6, 0xE8, 0xEA, 0xEC};
102  const int16 _ezShootOuts[5] = {0xAB, 0xBC, 0xC5, 0xC7, 0xCB};
103  const int16 _shootOuts[6] = {0xAB, 0xBC, 0xC5, 0xC7, 0xC9, 0xCB};
104  const int16 _ggScenes[3] = {0x87, 0x88, 0x89};
105  const int16 _dieScenes[6] = {0x96, 0x97, 0x98, 0x9B, 0x9F, 0xA1};
106 
107  const uint16 _diffPos[3][2] = {{0x0FA, 0x6E}, {0xFA, 0x8E}, {0xFA, 0xAF}};
108  const uint16 _livePos[3][2] = {{0x81, 0xBE}, {0x70, 0xBE}, {0x5F, 0xBE}};
109  const uint16 _shotPos[12][2] = {{0x96, 0xBD}, {0x9A, 0xBD}, {0x9E, 0xBD}, {0x0A2, 0xBD}, {0x0A6, 0xBD}, {0x0AA, 0xBD}, {0x0AE, 0xBD}, {0x0B2, 0xBD}, {0x0B6, 0xBD}, {0x0BA, 0xBD}, {0x0BE, 0xBD}, {0x0C2, 0xBD}};
110 
111  // gamestate
112  uint16 _dieBits = 0;
113  uint16 _gotTo = 0;
114  uint16 _sbGotTo = 0;
115  uint16 _bbGotTo = 0;
116  uint16 _tpGotTo = 0;
117  bool _hadSkull = false;
118  int16 _thisGuide = 0;
119  uint16 _doneGuide = 0;
120  uint16 _shootOutBits = 0;
121  int16 _lastShootOut = 0;
122  uint16 _startLives = 3;
123  bool _wasAShootout = false;
124  bool _shootoutFromDie = false;
125  uint16 _whichPadre = 0;
126  uint16 _whichGatlingGun = 0;
127  bool _inShootout = false;
128  uint16 _pickMask = 0;
129  uint16 _lastPick = 0;
130  uint16 _placeBits = 0;
131  uint16 _randomCount = 0;
132  uint16 _shootOutCnt = 0;
133  uint16 _totalDies = 0;
134 
135  // base functions
136  void newGame();
137  void resetParams();
138  void doMenu();
139  void updateStat();
140  void changeDifficulty(uint8 newDifficulty);
141  void showDifficulty(uint8 newDifficulty, bool updateCursor);
142  void updateCursor();
143  void updateMouse();
144  void moveMouse();
145  void displayScore();
146  bool weaponDown();
147  bool saveState();
148  bool loadState();
149 
150  // misc game functions
151  Common::String numToScene(int n);
152  uint16 sceneToNum(Common::String sceneName);
153  void defaultBullethole(Common::Point *point);
154  uint16 die();
155  uint16 pickBits(uint16 *bits, uint8 max);
156  uint16 pickShootout();
157  void nextSB();
158  void nextBB();
159  void nextTP();
160  void ggPickMan();
161  void genericNext();
162  void playerWon();
163 
164  // Script functions: Zone
165  void zoneBullethole(Common::Point *point);
166  void zoneSkullhole(Common::Point *point);
167 
168  // Script functions: RectHit
169  void rectShotmenu(Rect *rect);
170  void rectSave(Rect *rect);
171  void rectLoad(Rect *rect);
172  void rectContinue(Rect *rect);
173  void rectStart(Rect *rect);
174  void rectSkull(Rect *rect);
175  void rectKillInnocentMan(Rect *rect);
176  void rectKillInnocentWoman(Rect *rect);
177  void rectSelectBeaver(Rect *rect);
178  void rectSelectBonnie(Rect *rect);
179  void rectSelectProfessor(Rect *rect);
180  void rectShotAmmo(Rect *rect);
181  void rectShotGin(Rect *rect);
182  void rectShotLantern(Rect *rect);
183  void rectShootSkull(Rect *rect);
184 
185  // Script functions: Scene PreOps
186  void scenePsoShootout(Scene *scene);
187  void scenePsoMDShootout(Scene *scene);
188 
189  // Script functions: Scene InsOps
190  void sceneIsoShootpast(Scene *scene);
191  void sceneIsoShootpastPause(Scene *scene);
192  void sceneIsoStagecoach(Scene *scene);
193  void sceneIsoDifferentPadres(Scene *scene);
194  void sceneIsoDifferentPadresPause(Scene *scene);
195  void sceneIsoDontPopNext(Scene *scene);
196  void sceneIsoGetIntoRock(Scene *scene);
197  void sceneIsoBenAtCave(Scene *scene);
198  void sceneIsoSkullAtCave(Scene *scene);
199  void sceneIsoStartOfTrain(Scene *scene);
200  void sceneIsoMission(Scene *scene);
201  void sceneIsoMDShootout(Scene *scene);
202  void sceneIsoStartOfBoardinghouse(Scene *scene);
203  void sceneIsoDontContinue(Scene *scene);
204  void sceneIsoDoShootout(Scene *scene);
205 
206  // Script functions: Scene NxtScn
207  void sceneDefaultNxtscn(Scene *scene);
208  void sceneNxtscnDied(Scene *scene);
209  void sceneNxtscnKillInnocentMan(Scene *scene);
210  void sceneNxtscnKillInnocentWoman(Scene *scene);
211  void sceneNxtscnKillGuide(Scene *scene);
212  void sceneNxtscnShootSkull(Scene *scene);
213  void sceneNxtscnCallAttract(Scene *scene);
214  void sceneNxtscnPickUndertaker(Scene *scene);
215  void sceneNxtscnChoosePadre(Scene *scene);
216  void sceneNxtscnSelectGuide(Scene *scene);
217  void sceneNxtscnSaveBonnie(Scene *scene);
218  void sceneNxtscnFinishBonnie(Scene *scene);
219  void sceneNxtscnShowGGClue(Scene *scene);
220  void sceneNxtscnBBAfterClue(Scene *scene);
221  void sceneNxtscnAsFarSheGoes(Scene *scene);
222  void sceneNxtscnSaveBeaver(Scene *scene);
223  void sceneNxtscnFinishBeaver(Scene *scene);
224  void sceneNxtscnToGatlingGunSBClue(Scene *scene);
225  void sceneNxtscnToGuideafterClue(Scene *scene);
226  void sceneNxtscnToGuideCave(Scene *scene);
227  void sceneNxtscnInitRandomVillage(Scene *scene);
228  void sceneNxtscnPickVillageScenes(Scene *scene);
229  void sceneNxtscnSaveProfessor(Scene *scene);
230  void sceneNxtscnFinishProfessor(Scene *scene);
231  void sceneNxtscnToGatlingGunTPClue(Scene *scene);
232  void sceneNxtscnTPAfterClue(Scene *scene);
233  void sceneNxtscnFinishGatlingGun1(Scene *scene);
234  void sceneNxtscnFinishGuyAtGG(Scene *scene);
235  void sceneNxtscnFinishGatlingGun2(Scene *scene);
236  void sceneNxtscnHowWeDid(Scene *scene);
237  void sceneNxtscnPlayerWon(Scene *scene);
238  void sceneNxtscnBackToNextGuide(Scene *scene);
239  void sceneNxtscnFinishGenericScene(Scene *scene);
240  void sceneNxtscnInitRandomCowboys(Scene *scene);
241  void sceneNxtscnToCowboyScenes(Scene *scene);
242  void sceneNxtscnInitRandomFarmyard(Scene *scene);
243  void sceneNxtscnToFarmyardScenes(Scene *scene);
244  void sceneNxtscnInitRandomCave(Scene *scene);
245  void sceneNxtscnToCaveScenes(Scene *scene);
246  void sceneNxtscnPickSkullAtCave(Scene *scene);
247  void sceneNxtscnDrawGun(Scene *scene);
248 
249  // Script functions: Scene WepDwn
250  void sceneDefaultWepdwn(Scene *scene);
251 };
252 
254 public:
256  bool cmdWarpTo(int argc, const char **argv);
257  bool cmdDumpLib(int argc, const char **argv);
258 
259 private:
260  GameMaddog2 *_game;
261 };
262 
263 } // End of namespace Alg
264 
265 #endif
Definition: scene.h:72
Definition: game_maddog2.h:42
Definition: scene.h:102
Definition: str.h:59
Definition: surface.h:67
Definition: error.h:81
Definition: debugger.h:41
Definition: game_maddog2.h:253
Definition: alg.h:30
Definition: func.h:452
Definition: rect.h:144
Definition: game.h:36
Definition: alg.h:46
Definition: detection.h:39