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 runCursorTimer();
59  void debug_warpTo(int val);
60 
61 private:
62  void init() override;
63  void registerScriptFunctions();
64  void verifyScriptFunctions();
65  void unregisterScriptFunctions();
66  MD2ScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
67  MD2ScriptFunctionRect getScriptFunctionRectHit(Common::String name);
68  MD2ScriptFunctionScene 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  MD2ScriptFunctionPointMap _zonePtrFb;
74  MD2ScriptFunctionRectMap _rectHitFuncs;
75  MD2ScriptFunctionSceneMap _scenePreOps;
76  MD2ScriptFunctionSceneMap _sceneShowMsg;
77  MD2ScriptFunctionSceneMap _sceneInsOps;
78  MD2ScriptFunctionSceneMap _sceneWepDwn;
79  MD2ScriptFunctionSceneMap _sceneScnScr;
80  MD2ScriptFunctionSceneMap _sceneNxtFrm;
81  MD2ScriptFunctionSceneMap _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 *_skullSound = nullptr;
99  Audio::SeekableAudioStream *_shotSound = nullptr;
100  Audio::SeekableAudioStream *_emptySound = nullptr;
101 
102  // constants
103  const int16 _sbClue[3] = {0x67, 0x68, 0x69};
104  const int16 _bbClue[3] = {0x47, 0x49, 0x48};
105  const int16 _tpClue[3] = {0x84, 0x85, 0x86};
106  const int16 _sbScenes[14] = {0x4A, 0x50, 0xB8, 0x55, 0x57, 0x66, 0xBE, 0x94, 0x87, 0x93, 0xCD, 0x95, 0xE3, -1};
107  const int16 _bbScenes[14] = {0x33, 0x39, 0xB4, 0x41, 0x43, 0x46, 0xA2, 0x8D, 0x87, 0x8F, 0xCD, 0x8E, 0xE3, -1};
108  const int16 _tpScenes[14] = {0x6A, 0xC3, 0x76, 0x81, 0xAD, 0x83, 0xDC, 0x92, 0x87, 0x90, 0xCD, 0x91, 0xE3, -1};
109  const int16 _villageScenes[6] = {0x58, 0x5A, 0x5C, 0x5E, 0x60, 0x62};
110  const int16 _cowboyScenes[7] = {0xCD, 0xCF, 0xD2, 0xD4, 0xD6, 0xD8, 0xDA};
111  const int16 _farmyardScenes[4] = {0xDC, 0xDE, 0x129, 0xE1};
112  const int16 _caveScenes[5] = {0xE4, 0xE6, 0xE8, 0xEA, 0xEC};
113  const int16 _ezShootOuts[5] = {0xAB, 0xBC, 0xC5, 0xC7, 0xCB};
114  const int16 _shootOuts[6] = {0xAB, 0xBC, 0xC5, 0xC7, 0xC9, 0xCB};
115  const int16 _ggScenes[3] = {0x87, 0x88, 0x89};
116  const int16 _dieScenes[6] = {0x96, 0x97, 0x98, 0x9B, 0x9F, 0xA1};
117 
118  const uint16 _diffPos[3][2] = {{0x0FA, 0x6E}, {0xFA, 0x8E}, {0xFA, 0xAF}};
119  const uint16 _livePos[3][2] = {{0x81, 0xBE}, {0x70, 0xBE}, {0x5F, 0xBE}};
120  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}};
121 
122  // gamestate
123  uint8 _difficulty = 1;
124  uint8 _emptyCount = 0;
125  bool _holster = false;
126  uint8 _oldDifficulty = 1;
127  uint8 _inHolster = 0;
128  int8 _lives = 0;
129  int8 _oldLives = 0;
130  int32 _score = 0;
131  int32 _oldScore = -1;
132  bool _shotFired = false;
133  uint16 _shots = 0;
134  uint8 _oldShots = 0;
135  uint8 _whichGun = 0;
136  uint8 _oldWhichGun = 0xFF;
137  long int _minF = 0;
138  long int _maxF = 0;
139 
140  uint16 _dieBits = 0;
141  uint16 _gotTo = 0;
142  uint16 _sbGotTo = 0;
143  uint16 _bbGotTo = 0;
144  uint16 _tpGotTo = 0;
145  bool _hadSkull = false;
146  int16 _thisGuide = 0;
147  uint16 _doneGuide = 0;
148  uint16 _shootOutBits = 0;
149  int16 _lastShootOut = 0;
150  uint16 _startLives = 3;
151  bool _wasAShootout = false;
152  bool _shootoutFromDie = false;
153  uint16 _whichPadre = 0;
154  uint16 _whichGatlingGun = 0;
155  bool _inShootout = false;
156  uint16 _pickMask = 0;
157  uint16 _lastPick = 0;
158  uint16 _placeBits = 0;
159  uint16 _randomCount = 0;
160  uint16 _shootOutCnt = 0;
161  uint16 _totalDies = 0;
162 
163  Common::String _lastScene;
164  Common::String _retScene;
165  Common::String _subScene;
166 
167  uint32 _thisGameTimer = 0;
168 
169  // base functions
170  void newGame();
171  void resetParams();
172  void doMenu();
173  void updateStat();
174  void changeDifficulty(uint8 newDifficulty);
175  void showDifficulty(uint8 newDifficulty, bool updateCursor);
176  void adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty);
177  void updateCursor();
178  void updateMouse();
179  void moveMouse();
180  void displayScore();
181  bool weaponDown();
182  bool saveState(Common::OutSaveFile *saveFile) override;
183  bool loadState(Common::InSaveFile *inSaveFile) override;
184  Zone *checkZones(Scene *scene, Rect *&hitRect, Common::Point *point);
185 
186  // misc game functions
187  Common::String numToScene(int n);
188  uint16 sceneToNum(Common::String sceneName);
189  void defaultBullethole(Common::Point *point);
190  uint16 die();
191  uint16 pickBits(uint16 *bits, uint8 max);
192  uint16 pickShootout();
193  void nextSB();
194  void nextBB();
195  void nextTP();
196  void ggPickMan();
197  void genericNext();
198  void playerWon();
199 
200  // Timer
201  void setupCursorTimer();
202  void removeCursorTimer();
203 
204  // Script functions: Zone
205  void zoneBullethole(Common::Point *point);
206  void zoneSkullhole(Common::Point *point);
207 
208  // Script functions: RectHit
209  void rectNewScene(Rect *rect);
210  void rectShotmenu(Rect *rect);
211  void rectSave(Rect *rect);
212  void rectLoad(Rect *rect);
213  void rectContinue(Rect *rect);
214  void rectStart(Rect *rect);
215  void rectEasy(Rect *rect);
216  void rectAverage(Rect *rect);
217  void rectHard(Rect *rect);
218  void rectExit(Rect *rect);
219  void rectSkull(Rect *rect);
220  void rectKillInnocentMan(Rect *rect);
221  void rectKillInnocentWoman(Rect *rect);
222  void rectSelectBeaver(Rect *rect);
223  void rectSelectBonnie(Rect *rect);
224  void rectSelectProfessor(Rect *rect);
225  void rectShotAmmo(Rect *rect);
226  void rectShotGin(Rect *rect);
227  void rectShotLantern(Rect *rect);
228  void rectShootSkull(Rect *rect);
229 
230  // Script functions: Scene PreOps
231  void scenePsoShootout(Scene *scene);
232  void scenePsoMDShootout(Scene *scene);
233 
234  // Script functions: Scene InsOps
235  void sceneIsoShootpast(Scene *scene);
236  void sceneIsoShootpastPause(Scene *scene);
237  void sceneIsoStagecoach(Scene *scene);
238  void sceneIsoDifferentPadres(Scene *scene);
239  void sceneIsoDifferentPadresPause(Scene *scene);
240  void sceneIsoDontPopNext(Scene *scene);
241  void sceneIsoGetIntoRock(Scene *scene);
242  void sceneIsoBenAtCave(Scene *scene);
243  void sceneIsoSkullAtCave(Scene *scene);
244  void sceneIsoStartOfTrain(Scene *scene);
245  void sceneIsoMission(Scene *scene);
246  void sceneIsoMDShootout(Scene *scene);
247  void sceneIsoStartOfBoardinghouse(Scene *scene);
248  void sceneIsoDontContinue(Scene *scene);
249  void sceneIsoDoShootout(Scene *scene);
250 
251  // Script functions: Scene NxtScn
252  void sceneDefaultNxtscn(Scene *scene);
253  void sceneNxtscnDied(Scene *scene);
254  void sceneNxtscnKillInnocentMan(Scene *scene);
255  void sceneNxtscnKillInnocentWoman(Scene *scene);
256  void sceneNxtscnKillGuide(Scene *scene);
257  void sceneNxtscnShootSkull(Scene *scene);
258  void sceneNxtscnCallAttract(Scene *scene);
259  void sceneNxtscnPickUndertaker(Scene *scene);
260  void sceneNxtscnChoosePadre(Scene *scene);
261  void sceneNxtscnSelectGuide(Scene *scene);
262  void sceneNxtscnSaveBonnie(Scene *scene);
263  void sceneNxtscnFinishBonnie(Scene *scene);
264  void sceneNxtscnShowGGClue(Scene *scene);
265  void sceneNxtscnBBAfterClue(Scene *scene);
266  void sceneNxtscnAsFarSheGoes(Scene *scene);
267  void sceneNxtscnSaveBeaver(Scene *scene);
268  void sceneNxtscnFinishBeaver(Scene *scene);
269  void sceneNxtscnToGatlingGunSBClue(Scene *scene);
270  void sceneNxtscnToGuideafterClue(Scene *scene);
271  void sceneNxtscnToGuideCave(Scene *scene);
272  void sceneNxtscnInitRandomVillage(Scene *scene);
273  void sceneNxtscnPickVillageScenes(Scene *scene);
274  void sceneNxtscnSaveProfessor(Scene *scene);
275  void sceneNxtscnFinishProfessor(Scene *scene);
276  void sceneNxtscnToGatlingGunTPClue(Scene *scene);
277  void sceneNxtscnTPAfterClue(Scene *scene);
278  void sceneNxtscnFinishGatlingGun1(Scene *scene);
279  void sceneNxtscnFinishGuyAtGG(Scene *scene);
280  void sceneNxtscnFinishGatlingGun2(Scene *scene);
281  void sceneNxtscnHowWeDid(Scene *scene);
282  void sceneNxtscnPlayerWon(Scene *scene);
283  void sceneNxtscnBackToNextGuide(Scene *scene);
284  void sceneNxtscnFinishGenericScene(Scene *scene);
285  void sceneNxtscnInitRandomCowboys(Scene *scene);
286  void sceneNxtscnToCowboyScenes(Scene *scene);
287  void sceneNxtscnInitRandomFarmyard(Scene *scene);
288  void sceneNxtscnToFarmyardScenes(Scene *scene);
289  void sceneNxtscnInitRandomCave(Scene *scene);
290  void sceneNxtscnToCaveScenes(Scene *scene);
291  void sceneNxtscnPickSkullAtCave(Scene *scene);
292  void sceneNxtscnDrawGun(Scene *scene);
293 
294  // Script functions: Scene WepDwn
295  void sceneDefaultWepdwn(Scene *scene);
296 
297  // Script functions: ScnScr
298  void sceneDefaultScore(Scene *scene);
299 };
300 
302 public:
304  bool cmdWarpTo(int argc, const char **argv);
305  bool cmdDumpLib(int argc, const char **argv);
306 
307 private:
308  GameMaddog2 *_game;
309 };
310 
311 } // End of namespace Alg
312 
313 #endif
Definition: scene.h:72
Definition: game_maddog2.h:42
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: game_maddog2.h:301
Definition: stream.h:745
Definition: audiostream.h:212
Definition: alg.h:30
Definition: func.h:452
Definition: rect.h:144
Definition: scene.h:85
Definition: game.h:36
Definition: alg.h:46
Definition: detection.h:39