ScummVM API documentation
game_crimepatrol.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_CRIMEPATROL_H
23 #define ALG_GAME_CRIMEPATROL_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, GameCrimePatrol> CPScriptFunctionScene;
36 typedef Common::Functor1Mem<Rect *, void, GameCrimePatrol> CPScriptFunctionRect;
37 typedef Common::HashMap<Common::String, CPScriptFunctionScene *> CPScriptFunctionSceneMap;
38 typedef Common::HashMap<Common::String, CPScriptFunctionRect *> CPScriptFunctionRectMap;
39 
40 class GameCrimePatrol : public Game {
41 
42  enum SceneFuncType {
43  PREOP = 1,
44  SHOWMSG = 2,
45  INSOP = 3,
46  WEPDWN = 4,
47  SCNSCR = 5,
48  NXTFRM = 6,
49  NXTSCN = 7
50  };
51 
52 public:
54  ~GameCrimePatrol() override;
55  void init() override;
56  void debugWarpTo(int val);
57 
58 private:
59  Common::Error run() override;
60  void registerScriptFunctions();
61  void verifyScriptFunctions();
62  CPScriptFunctionRect getScriptFunctionRectHit(Common::String name);
63  CPScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
64  void callScriptFunctionRectHit(Common::String name, Rect *rect);
65  void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
66 
67  CPScriptFunctionRectMap _rectHitFuncs;
68  CPScriptFunctionSceneMap _scenePreOps;
69  CPScriptFunctionSceneMap _sceneShowMsg;
70  CPScriptFunctionSceneMap _sceneInsOps;
71  CPScriptFunctionSceneMap _sceneWepDwn;
72  CPScriptFunctionSceneMap _sceneScnScr;
73  CPScriptFunctionSceneMap _sceneNxtFrm;
74  CPScriptFunctionSceneMap _sceneNxtScn;
75 
76  // images
77  Graphics::Surface *_shotIcon;
78  Graphics::Surface *_emptyIcon;
79  Graphics::Surface *_liveIcon;
80  Graphics::Surface *_deadIcon;
81  Graphics::Surface *_difficultyIcon;
82  Graphics::Surface *_bulletholeIcon;
83 
84  // constants
85  const int16 _scenesLevel0[2] = {0x0191, 0};
86  const int16 _scenesLevel1[3] = {0x27, 0x01B7, 0};
87  const int16 _scenesLevel2[4] = {0x33, 0x01C7, 0x01B8, 0};
88  const int16 _scenesLevel3[3] = {0x48, 0x01C8, 0};
89  const int16 _scenesLevel4[2] = {0x53, 0};
90  const int16 _scenesLevel5[2] = {0x60, 0};
91  const int16 _scenesLevel6[2] = {0x82, 0};
92  const int16 _scenesLevel7[2] = {0x9B, 0};
93  const int16 _scenesLevel8[2] = {0xC7, 0};
94  const int16 _scenesLevel9[2] = {0xB6, 0};
95  const int16 _scenesLevel10[6] = {0xE0, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0};
96  const int16 _scenesLevel11[3] = {0x0136, 0x01C3, 0};
97  const int16 _scenesLevel12[4] = {0x0119, 0x01C5, 0x0131, 0};
98  const int16 _scenesLevel13[2] = {0x014C, 0};
99  const int16 _scenesLevel14[13] = {0x01B1, 0x01B2, 0x01B3, 0x01B4, 0x01B5, 0x01B6, 0};
100  const int16 _scenesLevel15[5] = {0x3B, 0x3C, 0x3F, 0x41, 0};
101  const int16 _scenesLevel16[3] = {0x61, 0x65, 0};
102  const int16 _scenesLevel17[7] = {0x68, 0x6A, 0x6C, 0x6E, 0x70, 0x72, 0};
103  const int16 _scenesLevel18[8] = {0x83, 0x85, 0x87, 0x8A, 0x8C, 0x8F, 0x90, 0};
104  const int16 _scenesLevel19[7] = {0x9C, 0x9E, 0xA0, 0xA2, 0xA4, 0xA6, 0};
105  const int16 _scenesLevel20[5] = {0xC8, 0xCA, 0xCC, 0xCE, 0};
106  const int16 _scenesLevel21[3] = {0xE8, 0xE9, 0};
107  const int16 _scenesLevel22[11] = {0xF4, 0xF6, 0xF8, 0xFA, 0xFC, 0xFE, 0x0100, 0x0102, 0x0104, 0x0106, 0};
108  const int16 _scenesLevel23[3] = {0x010E, 0x0113, 0};
109  const int16 _scenesLevel24[8] = {0x011D, 0x011F, 0x0121, 0x0123, 0x0125, 0x0127, 0x0129, 0};
110  const int16 _scenesLevel25[6] = {0x013D, 0x013F, 0x0141, 0x0143, 0x0145, 0};
111  const int16 _scenesLevel26[10] = {0x0157, 0x0159, 0x015B, 0x015D, 0x015F, 0x0161, 0x0163, 0x0165, 0x0167, 0};
112 
113  const int16 *_levelScenes[27] = {_scenesLevel0, _scenesLevel1, _scenesLevel2, _scenesLevel3, _scenesLevel4, _scenesLevel5, _scenesLevel6,
114  _scenesLevel7, _scenesLevel8, _scenesLevel9, _scenesLevel10, _scenesLevel11, _scenesLevel12, _scenesLevel13,
115  _scenesLevel14, _scenesLevel15, _scenesLevel16, _scenesLevel17, _scenesLevel18, _scenesLevel19, _scenesLevel20,
116  _scenesLevel21, _scenesLevel22, _scenesLevel23, _scenesLevel24, _scenesLevel25, _scenesLevel26};
117 
118  const int16 _diedScenesStage0[5] = {0x30, 0x31, 0x47, 0x51, 0};
119  const int16 _diedScenesStage1[7] = {0x5E, 0x5F, 0x7E, 0x7F, 0x98, 0x99, 0};
120  const int16 _diedScenesStage2[4] = {0xB2, 0xC5, 0xDB, 0};
121  const int16 _diedScenesStage3[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
122  const int16 _diedScenesStage4[7] = {0x0115, 0x0116, 0x0135, 0x014A, 0x0175, 0x0190, 0};
123 
124  const int16 *_diedScenesByStage[5] = {_diedScenesStage0, _diedScenesStage1, _diedScenesStage2, _diedScenesStage3, _diedScenesStage4};
125 
126  const uint16 _deadScenes[5] = {0x32, 0x80, 0xDC, 0x018D, 0x018D};
127 
128  const uint16 _stageStartScenes[5] = {0x26, 0x52, 0x9A, 0xDF, 0x014C};
129 
130  const int16 _practiceTargetLeft[5] = {0xE1, 0x45, 0xA8, 0x73, 0xE1};
131  const int16 _practiceTargetTop[5] = {0x0A, 0x3E, 0x41, 0x6E, 0x6E};
132  const int16 _practiceTargetRight[5] = {0x0104, 0x6D, 0xCB, 0x95, 0x0104};
133  const int16 _practiceTargetBottom[5] = {0x3D, 0x79, 0x7B, 0xA1, 0xA1};
134 
135  // gamestate
136  uint16 _gotTo[15] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
137  int8 _stage = 0;
138  int8 _oldStage = -1;
139  uint8 _randomSceneCount = 0;
140  uint8 _randomMax = 0;
141  uint16 _randomMask = 0;
142  uint16 _randomPicked = 0;
143  uint16 _deathMask = 0;
144  int16 _deathPicked = 0;
145  uint8 _deathSceneCount = 0;
146  uint8 _practiceMask = 0;
147  uint16 _finalStageScene = _stageStartScenes[4];
148 
149  // base functions
150  void newGame();
151  void resetParams();
152  void doMenu();
153  void changeDifficulty(uint8 newDifficulty);
154  void showDifficulty(uint8 newDifficulty, bool updateCursor);
155  void updateCursor();
156  void updateMouse();
157  void moveMouse();
158  void displayLivesLeft();
159  void displayScores();
160  void displayShotsLeft();
161  bool weaponDown();
162  bool saveState();
163  bool loadState();
164 
165  // misc game functions
166  void displayShotFiredImage(Common::Point *point);
167  void enableVideoFadeIn();
168  uint16 sceneToNumber(Scene *scene);
169  uint16 pickRandomScene(uint8 index, uint8 max);
170  uint16 pickDeathScene();
171  void sceneNxtscnGeneric(uint8 index);
172  void rectSelectGeneric(uint8 index);
173  void sceneIsoGotToGeneric(uint8 index, uint16 sceneId);
174 
175  // Script functions: RectHit
176  void rectShotMenu(Rect *rect);
177  void rectSave(Rect *rect);
178  void rectLoad(Rect *rect);
179  void rectContinue(Rect *rect);
180  void rectStart(Rect *rect);
181  void rectTargetPractice(Rect *rect);
182  void rectSelectTargetPractice(Rect *rect);
183  void rectSelectGangFight(Rect *rect);
184  void rectSelectWarehouse(Rect *rect);
185  void rectSelectWestcoastSound(Rect *rect);
186  void rectSelectDrugDeal(Rect *rect);
187  void rectSelectCarRing(Rect *rect);
188  void rectSelectBar(Rect *rect);
189  void rectSelectBank(Rect *rect);
190  void rectSelectCrackHouse(Rect *rect);
191  void rectSelectMethLab(Rect *rect);
192  void rectSelectAirplane(Rect *rect);
193  void rectSelectNukeTransport(Rect *rect);
194  void rectSelectAirport(Rect *rect);
195  void rectKillInnocentMan(Rect *rect);
196 
197  // Script functions: Scene PreOps
198  void scenePsoWarehouseGotTo(Scene *scene);
199  void scenePsoGangFightGotTo(Scene *scene);
200  void scenePsoWestcoastSoundGotTo(Scene *scene);
201  void scenePsoDrugDealGotTo(Scene *scene);
202  void scenePsoCarRingGotTo(Scene *scene);
203  void scenePsoBankGotTo(Scene *scene);
204  void scenePsoCrackHouseGotTo(Scene *scene);
205  void scenePsoMethLabGotTo(Scene *scene);
206  void scenePsoAirplaneGotTo(Scene *scene);
207  void scenePsoAirportGotTo(Scene *scene);
208  void scenePsoNukeTransportGotTo(Scene *scene);
209  void scenePsoPowerPlantGotTo(Scene *scene);
210 
211  // Script functions: Scene NxtScn
212  void sceneNxtscnGameWon(Scene *scene);
213  void sceneNxtscnLoseALife(Scene *scene);
214  void sceneNxtscnDidNotContinue(Scene *scene);
215  void sceneNxtscnKillInnocentMan(Scene *scene);
216  void sceneNxtscnKillInnocentWoman(Scene *scene);
217  void sceneNxtscnAfterDie(Scene *scene);
218  void sceneNxtscnSelectLanguage1(Scene *scene);
219  void sceneNxtscnSelectLanguage2(Scene *scene);
220  void sceneNxtscnSelectRookieScenario(Scene *scene);
221  void sceneNxtscnSelectUndercoverScenario(Scene *scene);
222  void sceneNxtscnSelectSwatScenario(Scene *scene);
223  void sceneNxtscnSelectDeltaScenario(Scene *scene);
224  void sceneNxtscnInitRandomTargetPractice(Scene *scene);
225  void sceneNxtscnContinueTargetPractice(Scene *scene);
226  void sceneNxtscnFinishGangFight(Scene *scene);
227  void sceneNxtscnFinishWestcoastSound(Scene *scene);
228  void sceneNxtscnFinishWarehouse(Scene *scene);
229  void sceneNxtscnInitRandomWarehouse(Scene *scene);
230  void sceneNxtscnContinueWarehouse(Scene *scene);
231  void sceneNxtscnFinishDrugDeal(Scene *scene);
232  void sceneNxtscnInitRandomCarRingLeader(Scene *scene);
233  void sceneNxtscnContinueCarRingLeader1(Scene *scene);
234  void sceneNxtscnContinueCarRingLeader2(Scene *scene);
235  void sceneNxtscnInitRandomCarRing(Scene *scene);
236  void sceneNxtscnContinueCarRing(Scene *scene);
237  void sceneNxtscnFinishCarRing(Scene *scene);
238  void sceneNxtscnFinishBar(Scene *scene);
239  void sceneNxtscnFinishBank(Scene *scene);
240  void sceneNxtscnFinishCrackHouse(Scene *scene);
241  void sceneNxtscnFinishMethLab(Scene *scene);
242  void sceneNxtscnFinishAirplane(Scene *scene);
243  void sceneNxtscnFinishAirport(Scene *scene);
244  void sceneNxtscnFinishNukeTransport(Scene *scene);
245  void sceneNxtscnInitRandomBar(Scene *scene);
246  void sceneNxtscnContinueBar(Scene *scene);
247  void sceneNxtscnInitRandomBank(Scene *scene);
248  void sceneNxtscnContinueBank(Scene *scene);
249  void sceneNxtscnInitRandomMethLab(Scene *scene);
250  void sceneNxtscnContinueMethLab(Scene *scene);
251  void sceneNxtscnPickRandomRapeller(Scene *scene);
252  void sceneNxtscnInitRandomAirplane(Scene *scene);
253  void sceneNxtscnContinueAirplane(Scene *scene);
254  void sceneNxtscnPickRandomAirplaneFront(Scene *scene);
255  void sceneNxtscnInitRandomAirport(Scene *scene);
256  void sceneNxtscnContinueAirport(Scene *scene);
257  void sceneNxtscnInitRandomNukeTransport(Scene *scene);
258  void sceneNxtscnContinueNukeTransport(Scene *scene);
259  void sceneNxtscnInitRandomPowerplant(Scene *scene);
260  void sceneNxtscnContinuePowerplant(Scene *scene);
261 
262  // Script functions: Scene WepDwn
263  void sceneDefaultWepdwn(Scene *scene);
264  void debugDrawPracticeRects();
265 };
266 
268 public:
270  bool cmdWarpTo(int argc, const char **argv);
271  bool cmdDumpLib(int argc, const char **argv);
272 
273 private:
274  GameCrimePatrol *_game;
275 };
276 
277 } // End of namespace Alg
278 
279 #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: game_crimepatrol.h:40
Definition: alg.h:30
Definition: func.h:452
Definition: rect.h:144
Definition: game_crimepatrol.h:267
Definition: game.h:36
Definition: alg.h:46
Definition: detection.h:39