ScummVM API documentation
game.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_H
23 #define ALG_GAME_H
24 
25 #include "common/random.h"
26 
27 #include "audio/audiostream.h"
28 #include "audio/mixer.h"
29 
30 #include "alg/alg.h"
31 #include "alg/scene.h"
32 #include "alg/video.h"
33 
34 namespace Alg {
35 
36 class Game {
37 
38 public:
39  Game(AlgEngine *vm);
40  virtual ~Game();
41  virtual void init();
42  virtual Common::Error run();
43  bool debug_dumpLibFile();
44  void runCursorTimer();
45  bool _debug_drawRects = false;
46  bool _debug_godMode = false;
47  bool _debug_unlimitedAmmo = false;
48 
49 protected:
50  AlgEngine *_vm;
51  AlgVideoDecoder *_videoDecoder;
52  SceneInfo *_sceneInfo;
54 
55  Common::File _libFile;
57 
58  uint8 *_palette;
59  bool _paletteDirty;
60 
61  Graphics::Surface *_background;
62  Graphics::Surface *_screen;
65 
66  Audio::SeekableAudioStream *_saveSound = nullptr;
67  Audio::SeekableAudioStream *_loadSound = nullptr;
68  Audio::SeekableAudioStream *_easySound = nullptr;
69  Audio::SeekableAudioStream *_avgSound = nullptr;
70  Audio::SeekableAudioStream *_hardSound = nullptr;
71  Audio::SeekableAudioStream *_skullSound = nullptr;
72  Audio::SeekableAudioStream *_shotSound = nullptr;
73  Audio::SeekableAudioStream *_emptySound = nullptr;
74 
75  Audio::SoundHandle _sfxAudioHandle;
76 
77  Zone *_menuzone;
78  Zone *_submenzone;
79 
80  bool _leftDown = false;
81  bool _rightDown = false;
82  Common::Point _mousePos;
83 
84  const uint32 _pauseDiffScale[3] = {0x10000, 0x8000, 0x4000};
85  const uint32 _rectDiffScale[3] = {0x10000, 0x0C000, 0x8000};
86 
87  void shutdown();
88  bool pollEvents();
89  void loadLibArchive(const Common::Path &path);
90  Audio::SeekableAudioStream *loadSoundFile(const Common::Path &path);
91  void playSound(Audio::SeekableAudioStream *stream);
92  bool loadScene(Scene *scene);
93  void updateScreen();
94  uint32 getMsTime();
95  bool fired(Common::Point *point);
96  Rect *checkZone(Zone *zone, Common::Point *point);
97  Zone *checkZonesV1(Scene *scene, Rect *&hitRect, Common::Point *point);
98  Zone *checkZonesV2(Scene *scene, Rect *&hitRect, Common::Point *point);
99  uint32 getFrame(Scene *scene);
100  void adjustDifficulty(uint8 newDifficulty, uint8 oldDifficulty);
101  int8 skipToNewScene(Scene *scene);
102  uint16 randomUnusedInt(uint8 max, uint16 *mask, uint16 exclude);
103  void debug_drawZoneRects();
104 
105  // Sounds
106  void doDiffSound(uint8 difficulty);
107  void doSaveSound();
108  void doLoadSound();
109  void doSkullSound();
110  void doShot();
111 
112  // Timer
113  void setupCursorTimer();
114  void removeCursorTimer();
115 
116  // Script functions: Zone
117  void zoneGlobalHit(Common::Point *point);
118  // Script functions: RectHit
119  void rectHitDoNothing(Rect *rect);
120  void rectNewScene(Rect *rect);
121  void rectExit(Rect *rect);
122  void rectEasy(Rect *rect);
123  void rectAverage(Rect *rect);
124  void rectHard(Rect *rect);
125  // Script functions: Scene PreOps
126  void scenePsoDrawRct(Scene *scene);
127  void scenePsoPause(Scene *scene);
128  void scenePsoDrawRctFadeIn(Scene *scene);
129  void scenePsoFadeIn(Scene *scene);
130  void scenePsoPauseFadeIn(Scene *scene);
131  void scenePsoPreRead(Scene *scene);
132  void scenePsoPausePreRead(Scene *scene);
133  // Script functions: Scene Scene InsOps
134  void sceneIsoDoNothing(Scene *scene);
135  void sceneIsoStartGame(Scene *scene);
136  void sceneIsoPause(Scene *scene);
137  // Script functions: Scene Scene NxtScn
138  void sceneNxtscnDoNothing(Scene *scene);
139  void sceneDefaultNxtscn(Scene *scene);
140  // Script functions: ShowMsg
141  void sceneSmDonothing(Scene *scene);
142  // Script functions: ScnScr
143  void sceneDefaultScore(Scene *scene);
144  // Script functions: ScnNxtFrm
145  void sceneNxtfrm(Scene *scene);
146 
147  bool _buttonDown = false;
148  uint8 _difficulty = 1;
149  uint8 _emptyCount = 0;
150  bool _fired = false;
151  uint32 _currentFrame;
152  bool _gameInProgress = false;
153  uint32 _thisGameTimer = 0;
154  bool _hadPause = false;
155  bool _holster = false;
156  bool _inMenu = false;
157  uint8 _inHolster = 0;
158  int8 _lives = 0;
159  long int _minF;
160  long int _maxF;
161  uint8 _oldWhichGun = 0xFF;
162  uint8 _oldDifficulty = 1;
163  int8 _oldLives = 0;
164  int32 _oldScore = -1;
165  uint8 _oldShots = 0;
166  uint32 _pauseTime = 0;
167  bool _sceneSkipped = false;
168  int32 _score = 0;
169  bool _shotFired = false;
170  uint16 _shots = 0;
171  uint32 _videoFrameSkip = 3;
172  uint32 _nextFrameTime = 0;
173  uint16 _videoPosX;
174  uint16 _videoPosY;
175  uint8 _whichGun = 0;
176 
177  Common::String _curScene;
178  Common::String _subScene;
179  Common::String _retScene;
180  Common::String _lastScene;
181  Common::String _startScene;
182 };
183 
184 } // End of namespace Alg
185 
186 #endif
Definition: scene.h:72
Definition: video.h:32
Definition: scene.h:102
Definition: str.h:59
Definition: surface.h:67
Definition: error.h:81
Definition: random.h:44
Definition: path.h:52
Definition: audiostream.h:212
Definition: mixer.h:49
Definition: file.h:47
Definition: alg.h:30
Definition: rect.h:144
Definition: scene.h:88
Definition: game.h:36
Definition: alg.h:46
Definition: scene.h:136