ScummVM API documentation
game_johnnyrock.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_JOHNNYROCK_H
23 #define ALG_GAME_JOHNNYROCK_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, GameJohnnyRock> JRScriptFunctionScene;
36 typedef Common::Functor1Mem<Rect *, void, GameJohnnyRock> JRScriptFunctionRect;
38 typedef Common::HashMap<Common::String, JRScriptFunctionScene *> JRScriptFunctionSceneMap;
39 typedef Common::HashMap<Common::String, JRScriptFunctionRect *> JRScriptFunctionRectMap;
40 typedef Common::HashMap<Common::String, JRScriptFunctionPoint *> JRScriptFunctionPointMap;
41 
42 class GameJohnnyRock : 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  ~GameJohnnyRock() override;
57  Common::Error run() override;
58  void debugWarpTo(int val);
59 
60 private:
61  void init() override;
62  void registerScriptFunctions();
63  void verifyScriptFunctions();
64  JRScriptFunctionPoint getScriptFunctionZonePtrFb(Common::String name);
65  JRScriptFunctionRect getScriptFunctionRectHit(Common::String name);
66  JRScriptFunctionScene getScriptFunctionScene(SceneFuncType type, Common::String name);
67  void callScriptFunctionZonePtrFb(Common::String name, Common::Point *point);
68  void callScriptFunctionRectHit(Common::String name, Rect *rect);
69  void callScriptFunctionScene(SceneFuncType type, Common::String name, Scene *scene);
70 
71  JRScriptFunctionPointMap _zonePtrFb;
72  JRScriptFunctionRectMap _rectHitFuncs;
73  JRScriptFunctionSceneMap _scenePreOps;
74  JRScriptFunctionSceneMap _sceneShowMsg;
75  JRScriptFunctionSceneMap _sceneInsOps;
76  JRScriptFunctionSceneMap _sceneWepDwn;
77  JRScriptFunctionSceneMap _sceneScnScr;
78  JRScriptFunctionSceneMap _sceneNxtFrm;
79  JRScriptFunctionSceneMap _sceneNxtScn;
80 
81  // images
82  Common::Array<Graphics::Surface *> *_difficultyIcon;
83  Graphics::Surface *_levelIcon;
84  Graphics::Surface *_bulletholeIcon;
85 
86  // constants
87  const int16 _randomRooftop[6] = {2, -4, 0x104, 0x1E, 0x100, 0x102};
88  const int16 _randomTheater[9] = {5, -5, 0x111, 0x1E, 0x107, 0x109, 0x10B, 0x10D, 0x10F};
89  const int16 _randomAlley[10] = {6, -4, 0, 0x1E, 0x113, 0x115, 0x117, 0x119, 0x11B, 0x11D};
90  const int16 _randomFuneralMR[10] = {6, -5, 0x12B, 0x1E, 0x11F, 0x121, 0x123, 0x125, 0x127, 0x129};
91  const int16 _randomBookMR[8] = {4, 5, 0, 0x1E, 0x12E, 0x130, 0x132, 0x134};
92  const int16 _randomStairway[8] = {4, -3, 0, 0x1E, 0x139, 0x13B, 0x13D, 0x13F};
93  const int16 _randomHall[8] = {4, -5, 0, 0x1E, 0x141, 0x143, 0x145, 0x146};
94  const int16 _randomWindows[10] = {6, -3, 0, 0x1E, 0x154, 0x156, 0x158, 0x15A, 0x15C, 0x15E};
95  const int16 _randomCar[5] = {1, 1, 0, 0, 0x0FE};
96  const int16 _randomHall1[5] = {1, 1, 0, 0x1E, 0x148};
97  const int16 _randomElevator[5] = {1, 1, 0, 0, 0x14C};
98  const int16 _randomBaby[5] = {1, 1, 0, 0, 0x160};
99  const int16 *_randomPlaces[6] = {_randomWindows, _randomStairway, _randomCar, _randomHall1, _randomElevator, _randomBaby};
100  const int16 *_randomPlacesMR[8] = {_randomBookMR, _randomFuneralMR, _randomAlley, _randomTheater, _randomHall, _randomWindows, _randomHall1, _randomRooftop};
101 
102  const int16 _officeTable[5] = {0xA7, 0x9F, 0x9E, 0x0A0, 0x0AD};
103 
104  const uint16 _diffPos[4][2] = {{0, 0}, {0xCD, 0x35}, {0xD2, 0x53}, {0xD2, 0x6E}};
105 
106  // gamestate
107  uint16 _totalDies = 0;
108  int16 _gameMoney = 0;
109  int16 _oldGameMoney = 0;
110  uint16 _ammoAgain = 0;
111  uint16 _mapTimeout = 0;
112  uint8 _luckyNumber = 0;
113  uint8 _thisMap = 0;
114  uint16 _clues = 0;
115  uint16 _placeBits = 0;
116  uint8 _randomCount = 0;
117  uint16 _doctorBits = 0;
118  uint16 _undertakerBits = 0;
119  uint16 _thisClue = 0;
120  uint8 _gotThisNumber = 0;
121  uint8 _casino = 0;
122  uint8 _poolHall = 0;
123  uint8 _warehouse = 0;
124  uint8 _garage = 0;
125  uint8 _office = 0;
126  uint8 _casinoType = 0;
127  uint8 _poolHallType = 0;
128  uint8 _warehouseType = 0;
129  uint8 _garageType = 0;
130  uint8 _mansion = 0;
131  uint8 _inWarehouse = 0;
132  uint8 _inOffice = 0;
133  uint16 _gotTo = 0;
134  uint8 _whoDidIt = 0;
135  uint8 _hadGoToMansion = 0;
136  uint16 _officeCount = 0;
137  uint16 _randomPlaceBits = 0;
138  uint8 _maxRandomCount = 0;
139  uint16 _gotoAfterRandom = 0;
140  uint16 _repeatRandomPlace = 0;
141  uint16 _maxRepeat = 0;
142  uint16 _gotThisClue = 0;
143  uint16 _didContinue = 0;
144  uint16 _thisGameTime = 0;
145  uint8 _thisDifficulty = 0;
146  uint8 _clueTable[4];
147  uint8 _combinations[4];
148  uint16 _entranceIndex[20];
149  const int16 *_randomScenes = nullptr;
150  uint8 _randomScenesSavestateIndex = 0;
151  uint16 _randomScenesIndex[10];
152  Common::String _moneyScene = "";
153  uint8 _mgunCnt = 0;
154  uint32 _machGunTimer = 0;
155 
156  // base functions
157  bool fired(Common::Point *point);
158  void newGame();
159  void resetParams();
160  void outShots();
161  void doMenu();
162  void updateStat();
163  void displayScore();
164  void showDifficulty(uint8 newDifficulty, bool updateCursor);
165  void changeDifficulty(uint8 newDifficulty);
166  void updateCursor();
167  void updateMouse();
168  void moveMouse();
169  bool weaponDown();
170  bool saveState();
171  bool loadState();
172  void doMoneySound();
173 
174  // misc game functions
175  Common::String numToScene(int n);
176  uint16 sceneToNum(Common::String sceneName);
177  void defaultBullethole(Common::Point *point);
178  uint16 pickBits(uint16 *bits, uint8 max);
179  uint16 pickRandomPlace(uint8 place);
180  void showCombination();
181  void shotClue(uint8 clue);
182  void shotCombination(uint8 combination, bool combinationB);
183  void shotLuckyNumber(uint8 number);
184 
185  // Script functions: Zone
186  void zoneBullethole(Common::Point *point);
187 
188  // Script functions: RectHit
189  void rectShotMenu(Rect *rect);
190  void rectSave(Rect *rect);
191  void rectLoad(Rect *rect);
192  void rectContinue(Rect *rect);
193  void rectStart(Rect *rect);
194  void rectKillInnocent(Rect *rect);
195  void rectSelectCasino(Rect *rect);
196  void rectSelectPoolhall(Rect *rect);
197  void rectSelectWarehouse(Rect *rect);
198  void rectSelectGarage(Rect *rect);
199  void rectSelectMansion(Rect *rect);
200  void rectSelectAmmo(Rect *rect);
201  void rectSelectOffice(Rect *rect);
202  void rectShotManBust(Rect *rect);
203  void rectShotWomanBust(Rect *rect);
204  void rectShotBlueVase(Rect *rect);
205  void rectShotCat(Rect *rect);
206  void rectShotIndian(Rect *rect);
207  void rectShotPlate(Rect *rect);
208  void rectShotBlueDressPic(Rect *rect);
209  void rectShotModernPic(Rect *rect);
210  void rectShotMonaLisa(Rect *rect);
211  void rectShotGWashington(Rect *rect);
212  void rectShotBoyInRedPic(Rect *rect);
213  void rectShotCoatOfArms(Rect *rect);
214  void rectShotCombinationA0(Rect *rect);
215  void rectShotCombinationA1(Rect *rect);
216  void rectShotCombinationA2(Rect *rect);
217  void rectShotCombinationA3(Rect *rect);
218  void rectShotCombinationA4(Rect *rect);
219  void rectShotCombinationA5(Rect *rect);
220  void rectShotCombinationB0(Rect *rect);
221  void rectShotCombinationB1(Rect *rect);
222  void rectShotCombinationB2(Rect *rect);
223  void rectShotCombinationB3(Rect *rect);
224  void rectShotCombinationB4(Rect *rect);
225  void rectShotCombinationB5(Rect *rect);
226  void rectShotLuckyNumber0(Rect *rect);
227  void rectShotLuckyNumber1(Rect *rect);
228  void rectShotLuckyNumber2(Rect *rect);
229  void rectShotLuckyNumber3(Rect *rect);
230  void rectShotLuckyNumber4(Rect *rect);
231  void rectShotLuckyNumber5(Rect *rect);
232 
233  // Script functions: Scene InsOps
234  void sceneIsoShootpast(Scene *scene);
235  void sceneIsoShootpastPause(Scene *scene);
236  void sceneIsoGotoCasino(Scene *scene);
237  void sceneIsoGotoPoolhall(Scene *scene);
238  void sceneIsoGotoWarehouse(Scene *scene);
239  void sceneIsoInWarehouse2(Scene *scene);
240  void sceneIsoInwarehouse3(Scene *scene);
241  void sceneIsoGotoGarage(Scene *scene);
242  void sceneIsoGotoMansion(Scene *scene);
243  void sceneIsoInMansion1(Scene *scene);
244 
245  // Script functions: Scene NxtScn
246  void sceneNxtscnDied(Scene *scene);
247  void sceneNxtscnBombDead(Scene *scene);
248  void sceneNxtscnPickUndertaker(Scene *scene);
249  void sceneNxtscnCallAttract(Scene *scene);
250  void sceneNxtscnPickLuckyNumber(Scene *scene);
251  void sceneNxtscnPickMap(Scene *scene);
252  void sceneNxtscnPickClue(Scene *scene);
253  void sceneNxtscnMapTimeout(Scene *scene);
254  void sceneNxtscnEnterCasino(Scene *scene);
255  void sceneNxtscnCasinoWhat(Scene *scene);
256  void sceneNxtscnEnterPoolhall(Scene *scene);
257  void sceneNxtscnPoolhallClue(Scene *scene);
258  void sceneNxtscnEnterWarehouse(Scene *scene);
259  void sceneNxtscnWarehouseClue(Scene *scene);
260  void sceneNxtscnEnterGarage(Scene *scene);
261  void sceneNxtscnGarageClue(Scene *scene);
262  void sceneNxtscnEnterMansion(Scene *scene);
263  void sceneNxtscnGiveClue(Scene *scene);
264  void sceneNxtscnPickFlowerMan(Scene *scene);
265  void sceneNxtscnRandomScene(Scene *scene);
266  void sceneNxtscnEndRandScene(Scene *scene);
267  void sceneNxtscnKillInnocent(Scene *scene);
268 
269  // Script functions: Scene WepDwn
270  void sceneDefaultWepdwn(Scene *scene);
271 };
272 
274 public:
276  bool cmdWarpTo(int argc, const char **argv);
277  bool cmdDumpLib(int argc, const char **argv);
278 
279 private:
280  GameJohnnyRock *_game;
281 };
282 
283 } // End of namespace Alg
284 
285 #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: alg.h:30
Definition: func.h:452
Definition: rect.h:144
Definition: game_johnnyrock.h:273
Definition: game.h:36
Definition: alg.h:46
Definition: game_johnnyrock.h:42
Definition: detection.h:39