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 
62 namespace Access {
63 
64 enum AccessDebugChannels {
65  kDebugPath = 1,
66  kDebugScripts,
67  kDebugGraphics,
68  kDebugSound,
69 };
70 
71 /* typed enum to match unsignedness of Common::CustomEventType */
72 enum 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 */
99 enum 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 */
111 enum 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 
141 class AccessEngine : public Engine {
142 private:
143  uint32 _lastTime, _curTime;
144 
148  SpriteResource *_icons;
149 
153  void initialize();
154 
158  void setVGA();
159 
163  void addHotspotHighlights();
164 
165 protected:
166  const AccessGameDescription *_gameDescription;
167  Common::RandomSource _randomSource;
168  int _loadSaveSlot;
169 
173  void doRoom();
174 
178  void playVideo(int videoNum, const Common::Point &pt);
179 
180  // Engine APIs
181  Common::Error run() override;
182  bool hasFeature(EngineFeature f) const override;
183 protected:
187  virtual void playGame() = 0;
188 
192  virtual Common::Error synchronize(Common::Serializer &s);
193 
197  virtual void initObjects() = 0;
198 
202  virtual void setupGame() = 0;
203 
204 public:
205  AnimationManager *_animation;
206  BubbleBox *_bubbleBox;
207  BubbleBox *_helpBox;
208  BubbleBox *_travelBox;
209  BubbleBox *_invBox;
210  BubbleBox *_aboutBox;
211  CharManager *_char;
212  EventsManager *_events;
213  FileManager *_files;
214  InventoryManager *_inventory;
215  Player *_player;
216  Player *_curPlayer; // current player being animated (only changes in Noctropolis)
217  Resources *_res;
218  Room *_room;
219  Screen *_screen;
220  Scripts *_scripts;
221  SoundManager *_sound;
222  MusicManager *_midi;
223  VideoPlayer *_video;
224 
225  BaseSurface *_destIn;
226  BaseSurface *_current;
227  ASurface _buffer1;
228  ASurface _buffer2;
229  ASurface _vidBuf;
230  int _vidX, _vidY;
231  SpriteResource *_objectsTable[128];
232  bool _establishTable[128];
233  bool _establishFlag;
234  int _establishMode;
235  int _establishGroup;
236  int _establishCtrlTblOfs;
237  TimerList _timers;
238  DeathList _deaths;
239  FontManager _fonts;
240  Common::Array<Common::Rect> _newRects;
241  Common::Array<Common::Rect> _oldRects;
242  Common::Array<ExtraCell> _extraCells;
243  ImageEntryList _images;
244  int _mouseMode;
245 
246  uint8 _playerDataCount;
247  int _currentManOld;
248  int _converseMode;
249  bool _currentCharFlag;
250  bool _boxSelect;
251  int _scale;
252  int _scaleH1, _scaleH2;
253  int _scaleN1;
254  int _scaleT1;
255  int _scaleMaxY;
256  int _scaleI;
257  int _scrollX, _scrollY;
258  int _scrollCol, _scrollRow;
259  bool _canSaveLoad;
260 
261  Resource *_establish;
262  int _printEnd;
263  int _txtPages;
264  int _narateFile;
265  int _sndSubFile;
266  int _countTbl[6];
267 
268  // Fields that are included in savegames
269  int _conversation;
270  int _currentMan;
271  uint32 _newTime;
272  uint32 _newDate;
273  int _flags[256];
274 
275  // Fields used by MM and sometimes Noctropolis
276  // TODO: Refactor
277  byte _travel[60]; // only first ~15 used in MM
278  byte _ask[40];
279  byte _asked[40]; // Noctropolis only
280  int _startTravelItem;
281  int _startTravelBox;
282  int _startAboutItem;
283  int _startAboutBox;
284 
285  Common::Point _askBase; // Noctropolis only
286  bool _keepAskPosition; // Noctropolis only
287  int _boxDataStart;
288  bool _boxDataEnd;
289  int _boxSelectY;
290  int _boxSelectYOld;
291  int _numLines;
292  int _bcnt;
293 
294  bool _clearSummaryFlag; // amazon only
295  bool _cheatFl; // cheats are enabled
296  bool _restartFl; // game should restart
297  bool _textFlag; // whether subtitles are enabled
298  bool _hotspotFl; // whether hotspot highlighting is enabled (for debug)
299  bool _exitBox; // whether the current hotspot is an exit (Noctropolis only)
300  uint16 _stilScaleOff;
301 
302  // Fields mapped into the flags array
303  int &_useItem;
304  int &_startup;
305  int &_manScaleOff;
306  int &_pictureTaken;
307 
308 public:
309  AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
310  ~AccessEngine() override;
311 
312  virtual void dead(int deathId) = 0;
313 
314  uint32 getFeatures() const;
315  bool isCD() const;
316  bool isDemo() const;
317  Common::Language getLanguage() const;
318  Common::Platform getPlatform() const;
319  uint16 getVersion() const;
320  AccessGameType getGameID() const;
321  uint32 getGameFeatures() const;
322  bool shouldQuitOrRestart();
323 
324  int getRandomNumber(int maxNumber);
325 
326  const SpriteResource *getIcons();
327 
328  void loadCells(const Common::Array<CellIdent> &cells);
329 
333  void freeCells();
334 
335  virtual void establish(int esatabIndex, int sub) = 0;
336 
337  void plotList();
338  void plotList1();
339  void clearPlotImagesIn(int16 x, int16 y, int16 w, int16 h);
340  void clearPlotVidsIn(int16 x, int16 y, int16 w, int16 h);
341 
342  void copyBlocks();
343 
344  void copyRects();
345 
346  void copyBF1BF2();
347 
348  void copyBF2Vid();
349 
350  void freeChar();
351 
352  virtual int16 getScreenWidth() const { return 320; }
353  virtual int16 getScreenHeight() const { return 200; }
354 
358  void printText(BaseSurface *s, const Common::String &msg);
359  void speakText(BaseSurface *s, const Common::String &msg);
360 
361  void syncSoundSettings() override;
362 
366  Common::Error loadGameState(int slot) override;
367  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
368 
372  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
376  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
377 
381  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
382 
386  static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail = true);
387 
388  bool playMovie(const Common::Path &filename, const Common::Point &pos);
389 
390  const AccessActionCode *getActionCodes();
391 
395  virtual void drawOverlays();
396 
397 };
398 
399 } // End of namespace Access
400 
401 #endif /* ACCESS_ACCESS_H */
Definition: video.h:38
Definition: access.h:131
Definition: detection.h:37
Definition: asurface.h:179
Definition: resources.h:41
Definition: str.h:59
Definition: surface.h:67
Definition: inventory.h:53
EngineFeature
Definition: engine.h:258
Definition: events.h:55
Definition: stream.h:77
Definition: error.h:81
Definition: access.h:141
Definition: scripts.h:40
Definition: random.h:44
Definition: path.h:52
uint32 CustomEventType
Definition: events.h:204
Definition: stream.h:745
Definition: player.h:48
Definition: serializer.h:80
Definition: asurface.h:42
Definition: sound.h:102
Definition: files.h:55
Definition: asurface.h:146
Definition: ustr.h:57
Definition: data.h:59
Definition: font.h:150
Definition: files.h:72
Definition: sound.h:40
Definition: rect.h:144
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: animation.h:38
Definition: data.h:100
Definition: asurface.h:129
Definition: system.h:165
Definition: room.h:71
Definition: access.h:62
Definition: engine.h:144
Definition: access.h:124
Platform
Definition: platform.h:93
Definition: screen.h:49
Definition: bubble_box.h:49
Language
Definition: language.h:45
Definition: char.h:48