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