ScummVM API documentation
game_drugwars.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_DRUGWARS_H
23 #define ALG_GAME_DRUGWARS_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, GameDrugWars> DWScriptFunctionScene;
36 typedef Common::Functor1Mem<Rect *, void, GameDrugWars> DWScriptFunctionRect;
37 typedef Common::HashMap<Common::String, DWScriptFunctionScene *> DWScriptFunctionSceneMap;
38 typedef Common::HashMap<Common::String, DWScriptFunctionRect *> DWScriptFunctionRectMap;
39 
40 class GameDrugWars : 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  ~GameDrugWars() override;
55  Common::Error run() override;
56  void debugWarpTo(int val);
57 
58 private:
59  void init() override;
60  void registerScriptFunctions();
61  void verifyScriptFunctions();
62  DWScriptFunctionRect getScriptFunctionRectHit(const Common::String &name);
63  DWScriptFunctionScene getScriptFunctionScene(SceneFuncType type, const Common::String &name);
64  void callScriptFunctionRectHit(const Common::String &name, Rect *rect);
65  void callScriptFunctionScene(SceneFuncType type, const Common::String &name, Scene *scene);
66 
67  DWScriptFunctionRectMap _rectHitFuncs;
68  DWScriptFunctionSceneMap _scenePreOps;
69  DWScriptFunctionSceneMap _sceneShowMsg;
70  DWScriptFunctionSceneMap _sceneInsOps;
71  DWScriptFunctionSceneMap _sceneWepDwn;
72  DWScriptFunctionSceneMap _sceneScnScr;
73  DWScriptFunctionSceneMap _sceneNxtFrm;
74  DWScriptFunctionSceneMap _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 _randomScenes0[7] = {0x29, 0x2B, 0x2D, 0x2F, 0x31, 0x33, 0};
86  const int16 _randomScenes1[6] = {0x37, 0x39, 0x3B, 0x3D, 0x3F, 0};
87  const int16 _randomScenes4[8] = {0xA8, 0xAA, 0xAC, 0xAE, 0xB0, 0xB2, 0xB4, 0};
88  const int16 _randomScenes8[8] = {0xC0, 0xC2, 0xC4, 0xC6, 0xC8, 0xCA, 0xCC, 0};
89  const int16 _randomScenes9[6] = {0xFE, 0x0100, 0x0102, 0x01A3, 0x0105, 0};
90  const int16 _randomScenes10[8] = {0x0161, 0x0163, 0x0165, 0x0167, 0x016A, 0x016C, 0x016E, 0};
91  const int16 _randomScenes11[9] = {0x010B, 0x010D, 0x010F, 0x0111, 0x0113, 0x0115, 0x0117, 0x0119, 0};
92  const int16 _randomScenes12[10] = {0x014C, 0x014E, 0x0150, 0x0152, 0x0154, 0x0156, 0x0158, 0x015A, 0x015C, 0};
93 
94  const int16 *_randomScenes[14] = {_randomScenes0, _randomScenes1, nullptr, nullptr, _randomScenes4, nullptr, nullptr, nullptr,
95  _randomScenes8, _randomScenes9, _randomScenes10, _randomScenes11, _randomScenes12, nullptr};
96  const uint8 _randomScenesDifficulty[14] = {6, 4, 0, 0, 6, 0, 0, 0, 5, 6, 7, 8, 8, 0};
97  const uint16 _randomScenesContinue[14] = {0x51, 0x41, 0, 0, 0x01B5, 0, 0, 0, 0xCE, 0x0107, 0x0170, 0x011B, 0x015E, 0};
98 
99  const int16 _diedScenesStage0[4] = {0x52, 0x53, 0x54, 0};
100  const int16 _diedScenesStage1[5] = {0x85, 0x86, 0x88, 0x89, 0};
101  const int16 _diedScenesStage2[3] = {0xEF, 0xF0, 0};
102  const int16 _diedScenesStage3[3] = {0x0135, 0x0136, 0};
103  const int16 _diedScenesStage4[3] = {0x0135, 0x0136, 0};
104 
105  const int16 *_diedScenesByStage[5] = {_diedScenesStage0, _diedScenesStage1, _diedScenesStage2, _diedScenesStage3, _diedScenesStage4};
106 
107  uint16 _deadScenes[5] = {0x56, 0x8A, 0xF2, 0x0134, 0x0134};
108 
109  const uint16 _stageStartScenes[5] = {0x51, 0x83, 0xEE, 0x0132, 0x017F};
110 
111  const uint16 _scenarioStartScenes[14] = {0x27, 0x36, 0x4A, 0x57, 0x9D, 0x8B, 0x74, 0xD8, 0xBF, 0xB8, 0x0160, 0x010A, 0x0137, 0x017F};
112 
113  // gamestate
114  uint8 _continues = 0;
115  uint16 _gotTo[14] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
116  int8 _gotToIndex = 0;
117  int8 _stage = 0;
118  int8 _oldStage = -1;
119  uint8 _randomSceneCount = 0;
120  uint8 _randomMax = 0;
121  uint16 _randomMask = 0;
122  uint16 _randomPicked = 0;
123  uint16 _deathMask = 0;
124  int16 _deathPicked = 0;
125  uint8 _deathSceneCount = 0;
126  uint16 _finalStageScene = _stageStartScenes[4];
127 
128  // base functions
129  void newGame();
130  void resetParams();
131  void doMenu();
132  void changeDifficulty(uint8 newDifficulty);
133  void showDifficulty(uint8 newDifficulty, bool updateCursor);
134  void updateCursor();
135  void updateMouse();
136  void moveMouse();
137  void displayLivesLeft();
138  void displayScores();
139  void displayShotsLeft();
140  bool weaponDown();
141  bool saveState();
142  bool loadState();
143 
144  // misc game functions
145  void displayShotFiredImage(Common::Point *point);
146  void enableVideoFadeIn();
147  uint16 sceneToNumber(Scene *scene);
148  uint16 pickRandomScene(uint8 index, uint8 max);
149  uint16 pickDeathScene();
150  void sceneNxtscnGeneric(uint8 index);
151  void rectSelectGeneric(uint8 index);
152 
153  // Script functions: RectHit
154  void rectShotMenu(Rect *rect);
155  void rectSave(Rect *rect);
156  void rectLoad(Rect *rect);
157  void rectContinue(Rect *rect);
158  void rectStart(Rect *rect);
159  void rectSelectTargetPractice(Rect *rect);
160  void rectSelectBar(Rect *rect);
161  void rectSelectCarChase(Rect *rect);
162  void rectSelectDrugHouse(Rect *rect);
163  void rectSelectOffice(Rect *rect);
164  void rectSelectCourt(Rect *rect);
165  void rectSelectBus(Rect *rect);
166  void rectSelectDocks(Rect *rect);
167  void rectSelectHouseBoat(Rect *rect);
168  void rectSelectParty(Rect *rect);
169  void rectSelectAirport(Rect *rect);
170  void rectSelectMansion(Rect *rect);
171  void rectSelectVillage(Rect *rect);
172 
173  // Script functions: Scene PreOps
174  void scenePsoGotTo(Scene *scene);
175 
176  // Script functions: Scene NxtScn
177  void sceneNxtscnGameWon(Scene *scene);
178  void sceneNxtscnLoseALife(Scene *scene);
179  void sceneNxtscnContinueGame(Scene *scene);
180  void sceneNxtscnDidNotContinue(Scene *scene);
181  void sceneNxtscnKillInnocentMan(Scene *scene);
182  void sceneNxtscnKillInnocentWoman(Scene *scene);
183  void sceneNxtscnAfterDie(Scene *scene);
184  void sceneNxtscnInitRandom(Scene *scene);
185  void sceneNxtscnContinueRandom(Scene *scene);
186  void sceneNxtscnSelectScenario(Scene *scene);
187  void sceneNxtscnFinishScenario(Scene *scene);
188 
189  // Script functions: Scene WepDwn
190  void sceneDefaultWepdwn(Scene *scene);
191 };
192 
194 public:
196  bool cmdWarpTo(int argc, const char **argv);
197  bool cmdDumpLib(int argc, const char **argv);
198 
199 private:
200  GameDrugWars *_game;
201 };
202 
203 } // End of namespace Alg
204 
205 #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_drugwars.h:40
Definition: alg.h:30
Definition: func.h:452
Definition: game_drugwars.h:193
Definition: rect.h:144
Definition: game.h:36
Definition: alg.h:46
Definition: detection.h:39