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