ScummVM API documentation
access.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 ACCESS_ACCESS_H
23#define ACCESS_ACCESS_H
24
25#include "common/scummsys.h"
26#include "common/system.h"
27#include "common/error.h"
28#include "common/random.h"
29#include "common/savefile.h"
30#include "common/serializer.h"
31#include "common/util.h"
32
33#include "engines/engine.h"
34
35#include "graphics/surface.h"
36
37#include "access/animation.h"
38#include "access/bubble_box.h"
39#include "access/char.h"
40#include "access/data.h"
41#include "access/events.h"
42#include "access/files.h"
43#include "access/font.h"
44#include "access/inventory.h"
45#include "access/player.h"
46#include "access/resources.h"
47#include "access/room.h"
48#include "access/screen.h"
49#include "access/scripts.h"
50#include "access/sound.h"
51#include "access/video.h"
52#include "access/detection.h"
53
62namespace Access {
63
64enum AccessDebugChannels {
65 kDebugPath = 1,
66 kDebugScripts,
67 kDebugGraphics,
68 kDebugSound,
69};
70
71/* typed enum to match unsignedness of Common::CustomEventType */
72enum ACCESSActions : Common::CustomEventType {
73 kActionNone,
74 kActionMoveUp,
75 kActionMoveDown,
76 kActionMoveLeft,
77 kActionMoveRight,
78 kActionMoveUpLeft,
79 kActionMoveUpRight,
80 kActionMoveDownLeft,
81 kActionMoveDownRight,
82 kActionLook,
83 kActionUse,
84 kActionTake, // aka GET
85 kActionInventory,
86 kActionClimb,
87 kActionTalk,
88 kActionWalk, // aka GOTO
89 kActionHelp,
90 kActionOpen,
91 kActionMove,
92 kActionTravel,
93 kActionSkip,
94 kActionSaveLoad,
95 kActionOptions,
96};
97
98/* These are the commands for MM. Noctropolis uses different numbers */
99enum MartianCommands {
100 kMartianCmdLook = 0,
101 kMartianCmdOpen = 1,
102 kMartianCmdMove = 2,
103 kMartianCmdGetTake = 3,
104 kMartianCmdUse = 4,
105 kMartianCmdGoto = 5, // aka walk-to
106 kMartianCmdTalk = 6,
107};
108
109
110/* These are the commands for MM and Amazon. Noctropolis uses different numbers */
111enum AmazonCommands {
112 kAmazonCmdLook = 0,
113 kAmazonCmdOpen = 1,
114 kAmazonCmdMove = 2,
115 kAmazonCmdGetTake = 3,
116 kAmazonCmdUse = 4,
117 kAmazonCmdGoto = 5, // aka walk-to
118 kAmazonCmdTalk = 6,
119 kAmazonCmdWalkToCursor = 7,
120 kAmazonCmdHelp = 8,
121};
122
123
125 ACCESSActions _action;
126 int8 _code;
127};
128
129#define ACCESS_SAVEGAME_VERSION 1
130
132 uint8 _version;
133 Common::String _saveName;
134 Graphics::Surface *_thumbnail;
135 int _year, _month, _day;
136 int _hour, _minute;
137 int _totalFrames;
138 int _totalPlayTime;
139};
140
141class AccessEngine : public Engine {
142private:
143 uint32 _lastTime, _curTime;
144
148 SpriteResource *_icons;
149
153 Common::Language _lang;
154
158 void initialize();
159
163 void setVGA();
164
168 void addHotspotHighlights();
169
170protected:
171 const AccessGameDescription *_gameDescription;
172 Common::RandomSource _randomSource;
173 int _loadSaveSlot;
174
178 void doRoom();
179
183 void playVideo(int videoNum, const Common::Point &pt);
184
185 // Engine APIs
186 Common::Error run() override;
187 bool hasFeature(EngineFeature f) const override;
188protected:
192 virtual void playGame() = 0;
193
198
202 virtual void initObjects() = 0;
203
207 virtual void setupGame() = 0;
208
212 virtual Common::Path getIconPath() const { return Common::Path("ICONS.LZ"); }
213
214public:
215 AnimationManager *_animation;
216 BubbleBox *_bubbleBox;
217 BubbleBox *_helpBox;
218 BubbleBox *_travelBox;
219 BubbleBox *_invBox;
220 BubbleBox *_aboutBox;
221 CharManager *_char;
222 EventsManager *_events;
223 FileManager *_files;
224 InventoryManager *_inventory;
225 Player *_player;
226 Player *_curPlayer; // current player being animated (only changes in Noctropolis)
227 Resources *_res;
228 Room *_room;
229 Screen *_screen;
230 Scripts *_scripts;
231 SoundManager *_sound;
232 MusicManager *_midi;
233 VideoPlayer *_video;
234
235 BaseSurface *_destIn;
236 BaseSurface *_current;
237 ASurface _buffer1;
238 ASurface _buffer2;
239 ASurface _vidBuf;
240 int _vidX, _vidY;
241 SpriteResource *_objectsTable[128];
242 bool _establishTable[128];
243 bool _establishFlag;
244 int _establishMode; // Amazon only?
245 int _establishGroup; // Amazon only?
246 int _establishCtrlTblOfs; // Amazon only?
247 TimerList _timers;
248 DeathList _deaths;
249 FontManager _fonts;
252 Common::Array<ExtraCell> _extraCells;
253 ImageEntryList _images;
254 int _mouseMode;
255
256 uint8 _playerDataCount;
257 int _currentManOld; // Amazon only
258 int _converseMode; // Set but never read?
259 bool _currentCharFlag;
260 bool _boxSelect;
261
262 int _scale;
263 int _scaleH1, _scaleH2;
264 int _scaleN1;
265 int _scaleT1;
266 int _scaleMaxY;
267 int _scaleI;
268 int _scrollX, _scrollY;
269 int _scrollCol, _scrollRow;
270 bool _canSaveLoad;
271
272 Resource *_establish;
273 int _printEnd; // Amazon only
274 int _txtPages; // Amazon only
275 int _narateFile; // Used in speakText, only called in Amazon?
276 int _sndSubFile; // Used in speakText, only called in Amazon?
277 int _countTbl[6]; // Used in speakText, only called in Amazon?
278
279 // Fields that are included in savegames
280 int _conversation;
281 int _currentMan;
282 uint32 _newTime;
283 uint32 _newDate;
284 int _flags[256];
285
286 // Fields used by MM and sometimes Noctropolis
287 // TODO: Refactor
288 byte _travel[60]; // only first ~15 used in MM
289 byte _ask[40];
290 byte _asked[40]; // Noctropolis only
291 int _startTravelItem;
292 int _startTravelBox;
293 int _startAboutItem;
294 int _startAboutBox;
295
296 int _boxDataStart;
297 bool _boxDataEnd;
298 int _boxSelectY;
299 int _boxSelectYOld;
300 int _numLines;
301 int _bcnt;
302
303 bool _clearSummaryFlag; // amazon only
304 bool _cheatFl; // cheats are enabled
305 bool _restartFl; // game should restart
306 bool _textFlag; // whether subtitles are enabled
307 bool _hotspotFl; // whether hotspot highlighting is enabled (for debug)
308 bool _exitBox; // whether the current hotspot is an exit (Noctropolis only)
309 uint16 _stilScaleOff;
310
311 // Fields mapped into the flags array
312 int &_useItem;
313 int &_startup;
314 int &_manScaleOff;
315 int &_pictureTaken; // Only used in MM
316
317public:
318 AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
319 ~AccessEngine() override;
320
321 virtual void dead(int deathId) = 0;
322
323 uint32 getFeatures() const;
324 bool isCD() const;
325 bool isDemo() const;
326 Common::Language getLanguage() const;
327 Common::Platform getPlatform() const;
328 uint16 getVersion() const;
329 AccessGameType getGameID() const;
330 bool gameIs(AccessGameType game) const;
331 uint32 getGameFeatures() const;
332 bool shouldQuitOrRestart();
333
334 int getRandomNumber(int maxNumber);
335
336 const SpriteResource *getIcons();
337
338 void loadCells(const Common::Array<CellIdent> &cells);
339
343 void freeCells();
344
345 virtual void establish(int esatabIndex, int sub) = 0;
346
347 void plotList();
348 void plotList1();
349 void clearPlotImagesIn(int16 x, int16 y, int16 w, int16 h);
350 void clearPlotVidsIn(int16 x, int16 y, int16 w, int16 h);
351
352 void copyBlocks();
353
354 void copyRects();
355
356 void copyBF1BF2();
357
358 void copyBF2Vid();
359
360 void freeChar();
361
362 virtual int16 getScreenWidth() const { return 320; }
363 virtual int16 getScreenHeight() const { return 200; }
364
369 void speakText(BaseSurface *s, const Common::String &msg);
370
371 void syncSoundSettings() override;
372
376 Common::Error loadGameState(int slot) override;
378
382 Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
386 bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
387
391 bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
392
397
398 bool playMovie(const Common::Path &filename, const Common::Point &pos);
399
400 const AccessActionCode *getActionCodes();
401
405 virtual void drawOverlays();
406
407};
408
409} // End of namespace Access
410
411#endif /* ACCESS_ACCESS_H */
Definition: asurface.h:129
Definition: access.h:141
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
virtual void drawOverlays()
virtual void playGame()=0
static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail=true)
Common::Error loadGameStream(Common::SeekableReadStream *stream) override
virtual void setupGame()=0
void playVideo(int videoNum, const Common::Point &pt)
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Common::Error run() override
bool hasFeature(EngineFeature f) const override
virtual void initObjects()=0
void syncSoundSettings() override
void printText(BaseSurface *s, const Common::String &msg)
Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave=false) override
virtual Common::Path getIconPath() const
Definition: access.h:212
Common::Error loadGameState(int slot) override
virtual Common::Error synchronize(Common::Serializer &s)
Definition: animation.h:38
Definition: asurface.h:42
Definition: bubble_box.h:51
Definition: char.h:48
Definition: data.h:100
Definition: events.h:55
Definition: files.h:72
Definition: font.h:150
Definition: asurface.h:183
Definition: inventory.h:53
Definition: sound.h:102
Definition: player.h:48
Definition: files.h:55
Definition: resources.h:41
Definition: room.h:71
Definition: screen.h:49
Definition: scripts.h:40
Definition: sound.h:40
Definition: asurface.h:146
Definition: data.h:59
Definition: video.h:38
Definition: error.h:81
Definition: path.h:52
Definition: random.h:44
Definition: stream.h:745
Definition: serializer.h:80
Definition: str.h:59
Definition: ustr.h:57
Definition: stream.h:77
Definition: engine.h:155
EngineFeature
Definition: engine.h:293
Definition: system.h:166
uint32 CustomEventType
Definition: events.h:212
Language
Definition: language.h:45
Platform
Definition: platform.h:93
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: access.h:62
Definition: access.h:124
Definition: detection.h:37
Definition: access.h:131
Definition: rect.h:144
Definition: surface.h:67