ScummVM API documentation
zvision.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
23#ifndef ZVISION_ZVISION_H
24#define ZVISION_ZVISION_H
25
26#include "common/events.h"
27#include "common/random.h"
28#include "common/system.h"
29#include "engines/engine.h"
30#include "graphics/pixelformat.h"
31#include "gui/debugger.h"
32#include "zvision/detection.h"
33#include "zvision/core/clock.h"
34
35namespace Common {
36class Keymap;
37}
38
39namespace Video {
40class VideoDecoder;
41}
42
53namespace ZVision {
54
55struct ZvisionGameDescription;
56
57class Console;
58class ScriptManager;
59class RenderManager;
60class CursorManager;
61class StringManager;
62class FileManager;
63class SaveManager;
64class RLFDecoder;
65class MenuManager;
66class SubtitleManager;
67class TextRenderer;
68class Subtitle;
69class MidiManager;
70class VolumeManager;
71
73 Common::Rect screenArea; // Original screen resolution
74 Common::Rect menuArea; // Menu display area, relative to original screen
75 Common::Rect workingArea; // Playfield & video playback area, relative to original screen
76 Common::Rect textArea; // Subtitle & message area, relative to original screen
77};
78
79// NB Footage of original DOS Nemesis engine indicates playfield was centrally placed on screen.
80// Subtitle scripts, however, suggest playfield was higher up, otherwise they run off the bottom of the screen.
81// This could just be an error in the scripts or an artefact of the original game's development, so we will continue to use as-released central placement.
82
83static const ScreenLayout nemesisLayout {
84 Common::Rect(640, 480), // Screen
85 Common::Rect(Common::Point(64, 0), 512, 32), // Menu
86 Common::Rect(Common::Point(64, 80), 512, 320), // Working; aspect ratio 1.6
87 Common::Rect(Common::Point(64, 420), 512, 60) // Text
88};
89
90static const ScreenLayout zgiLayout {
91 Common::Rect(640, 480), // Screen
92 Common::Rect(Common::Point(0, 0), 640, 32), // Menu
93 Common::Rect(Common::Point(0, 68), 640, 344), // Working; aspect ratio 1.86
94 Common::Rect(Common::Point(0, 412), 640, 68) // Text
95};
96
97enum {
98
99 ROTATION_SCREEN_EDGE_OFFSET = 60,
100 MAX_ROTATION_SPEED = 400, // Pixels per second
101
102 KEYBUF_SIZE = 20
103};
104
105enum ZVisionAction {
106 kZVisionActionNone,
107 kZVisionActionUp,
108 kZVisionActionDown,
109 kZVisionActionLeft,
110 kZVisionActionRight,
111 kZVisionActionSave,
112 kZVisionActionRestore,
113 kZVisionActionQuit,
114 kZVisionActionPreferences,
115 kZVisionActionShowFPS,
116 kZVisionActionSkipCutscene,
117
118 kZVisionActionCount
119};
120
121extern const char *mainKeymapId;
122extern const char *gameKeymapId;
123extern const char *cutscenesKeymapId;
124
125class ZVision : public Engine {
126public:
127 ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc);
128 ~ZVision() override;
129
130public:
131 const Graphics::PixelFormat _resourcePixelFormat;
132
133private:
134 const ZVisionGameDescription *_gameDescription;
135
136
137 // We need random numbers
139
140 // Managers
141 ScriptManager *_scriptManager;
142 RenderManager *_renderManager;
143 CursorManager *_cursorManager;
144 StringManager *_stringManager;
145 TextRenderer *_textRenderer;
146 MidiManager *_midiManager;
147 FileManager *_fileManager;
148 SaveManager *_saveManager;
149 MenuManager *_menu;
150 SubtitleManager *_subtitleManager;
151 VolumeManager *_volumeManager;
152
153 // Clock
154 Clock _clock;
155
156 // Audio ID
157 int _audioId;
158
159 // To prevent allocation every time we process events
160 Common::Event _event;
161
162 Common::Keymap *_gameKeymap, *_cutscenesKeymap;
163
164 int _frameRenderDelay;
165 int _renderedFrameCount;
166 int _fps;
167 int16 _mouseVelocity;
168 int16 _keyboardVelocity;
169 bool _doubleFPS;
170 bool _widescreen;
171 bool _videoIsPlaying;
172 bool _breakMainLoop = false;
173
174 uint8 _cheatBuffer[KEYBUF_SIZE];
175
176public:
177 Common::Error run() override;
178 void pauseEngineIntern(bool pause) override;
179
180 ZVisionGameId getGameId() const;
181 Common::Language getLanguage() const;
182 uint32 getFeatures() const;
183
184 ScriptManager *getScriptManager() const {
185 return _scriptManager;
186 }
187 RenderManager *getRenderManager() const {
188 return _renderManager;
189 }
190 CursorManager *getCursorManager() const {
191 return _cursorManager;
192 }
193 FileManager *getFileManager() const {
194 return _fileManager;
195 }
196 SaveManager *getSaveManager() const {
197 return _saveManager;
198 }
199 StringManager *getStringManager() const {
200 return _stringManager;
201 }
202 TextRenderer *getTextRenderer() const {
203 return _textRenderer;
204 }
205 MidiManager *getMidiManager() const {
206 return _midiManager;
207 }
208 MenuManager *getMenuManager() const {
209 return _menu;
210 }
211 SubtitleManager *getSubtitleManager() const {
212 return _subtitleManager;
213 }
214 VolumeManager *getVolumeManager() const {
215 return _volumeManager;
216 }
217 Common::Keymap *getGameKeymap() const {
218 return _gameKeymap;
219 }
220 Common::RandomSource *getRandomSource() const {
221 return _rnd;
222 }
223 int16 getKeyboardVelocity() const {
224 return _keyboardVelocity;
225 }
226 int16 getMouseVelocity() const {
227 return _mouseVelocity;
228 }
229
230 uint8 getZvisionKey(Common::KeyCode scummKeyCode);
231
232 void startClock() {
233 _clock.start();
234 }
235
236 void stopClock() {
237 _clock.stop();
238 }
239
240 void initScreen(bool hiRes = false);
241
252 void playVideo(Video::VideoDecoder &videoDecoder, Common::Rect destRect = Common::Rect(0, 0, 0, 0), bool skippable = true, uint16 sub = 0, Common::Rect srcRect = Common::Rect(0, 0, 0, 0));
253 Video::VideoDecoder *loadAnimation(const Common::Path &fileName);
254
255 void setRenderDelay(uint);
256 bool canRender();
257 static void fpsTimerCallback(void *refCon);
258 void fpsTimer();
259 int getFPS() const {
260 return _fps;
261 }
262
263 bool isWidescreen() {
264 return _widescreen;
265 }
266
267 void syncSoundSettings() override;
268
269 void loadSettings();
270 void saveSettings();
271
272 bool quit(bool askFirst = true, bool streaming = false);
273
274 // Engine features
275 bool hasFeature(EngineFeature f) const override;
276 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
277 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
278 Common::Error loadGameState(int slot) override;
279 Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
280
281 // Used to update cursor on a location change
282 void onMouseMove() {
283 onMouseMove(_system->getEventManager()->getMousePos());
284 }
285
286private:
287 Common::Error initialize();
288 void initFonts();
289
290 void initializePath(const Common::FSNode &gamePath) override;
291
292 void parseStrFile(const Common::String &fileName);
293
295 void processEvents();
296
297 void onMouseMove(const Common::Point &pos);
298
299 void registerDefaultSettings();
300
301 void cheatCodes(uint8 key);
302 void pushKeyToCheatBuf(uint8 key);
303 bool checkCode(const char *code);
304 uint8 getBufferedKey(uint8 pos);
305};
306
307} // End of namespace ZVision
308
309#endif
Definition: error.h:81
Definition: fs.h:69
Definition: keymap.h:66
Definition: path.h:52
Definition: random.h:44
Definition: str.h:59
Definition: ustr.h:57
Definition: engine.h:149
EngineFeature
Definition: engine.h:282
Definition: system.h:166
Definition: video_decoder.h:53
Definition: clock.h:32
Definition: cursor_manager.h:57
Definition: file_manager.h:31
Definition: menu.h:86
Definition: midi.h:29
Definition: render_manager.h:48
Definition: save_manager.h:49
Definition: script_manager.h:143
Definition: string_manager.h:35
Definition: subtitle_manager.h:78
Definition: text.h:73
Definition: volume_manager.h:42
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
bool hasFeature(EngineFeature f) const override
Common::Error run() override
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
void pauseEngineIntern(bool pause) override
void syncSoundSettings() override
Common::Error loadGameState(int slot) override
void playVideo(Video::VideoDecoder &videoDecoder, Common::Rect destRect=Common::Rect(0, 0, 0, 0), bool skippable=true, uint16 sub=0, Common::Rect srcRect=Common::Rect(0, 0, 0, 0))
Language
Definition: language.h:45
Definition: algorithm.h:29
Definition: focus_list.h:27
Definition: events.h:218
Definition: rect.h:144
Definition: rect.h:536
Definition: pixelformat.h:138
Definition: zvision.h:72
Definition: detection.h:52