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