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  Common::Language _lang;
154 
158  void initialize();
159 
163  void setVGA();
164 
168  void addHotspotHighlights();
169 
170 protected:
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;
188 protected:
192  virtual void playGame() = 0;
193 
197  virtual Common::Error synchronize(Common::Serializer &s);
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 
214 public:
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;
245  int _establishGroup;
246  int _establishCtrlTblOfs;
247  TimerList _timers;
248  DeathList _deaths;
249  FontManager _fonts;
250  Common::Array<Common::Rect> _newRects;
251  Common::Array<Common::Rect> _oldRects;
252  Common::Array<ExtraCell> _extraCells;
253  ImageEntryList _images;
254  int _mouseMode;
255 
256  uint8 _playerDataCount;
257  int _currentManOld;
258  int _converseMode;
259  bool _currentCharFlag;
260  bool _boxSelect;
261  int _scale;
262  int _scaleH1, _scaleH2;
263  int _scaleN1;
264  int _scaleT1;
265  int _scaleMaxY;
266  int _scaleI;
267  int _scrollX, _scrollY;
268  int _scrollCol, _scrollRow;
269  bool _canSaveLoad;
270 
271  Resource *_establish;
272  int _printEnd;
273  int _txtPages;
274  int _narateFile;
275  int _sndSubFile;
276  int _countTbl[6];
277 
278  // Fields that are included in savegames
279  int _conversation;
280  int _currentMan;
281  uint32 _newTime;
282  uint32 _newDate;
283  int _flags[256];
284 
285  // Fields used by MM and sometimes Noctropolis
286  // TODO: Refactor
287  byte _travel[60]; // only first ~15 used in MM
288  byte _ask[40];
289  byte _asked[40]; // Noctropolis only
290  int _startTravelItem;
291  int _startTravelBox;
292  int _startAboutItem;
293  int _startAboutBox;
294 
295  Common::Point _askBase; // Noctropolis only
296  bool _keepAskPosition; // Noctropolis only
297  int _boxDataStart;
298  bool _boxDataEnd;
299  int _boxSelectY;
300  int _boxSelectYOld;
301  int _numLines;
302  int _bcnt;
303 
304  bool _clearSummaryFlag; // amazon only
305  bool _cheatFl; // cheats are enabled
306  bool _restartFl; // game should restart
307  bool _textFlag; // whether subtitles are enabled
308  bool _hotspotFl; // whether hotspot highlighting is enabled (for debug)
309  bool _exitBox; // whether the current hotspot is an exit (Noctropolis only)
310  uint16 _stilScaleOff;
311 
312  // Fields mapped into the flags array
313  int &_useItem;
314  int &_startup;
315  int &_manScaleOff;
316  int &_pictureTaken;
317 
318 public:
319  AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
320  ~AccessEngine() override;
321 
322  virtual void dead(int deathId) = 0;
323 
324  uint32 getFeatures() const;
325  bool isCD() const;
326  bool isDemo() const;
327  Common::Language getLanguage() const;
328  Common::Platform getPlatform() const;
329  uint16 getVersion() const;
330  AccessGameType getGameID() 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 
368  void printText(BaseSurface *s, const Common::String &msg);
369  void speakText(BaseSurface *s, const Common::String &msg);
370 
371  void syncSoundSettings() override;
372 
376  Common::Error loadGameState(int slot) override;
377  Common::Error loadGameStream(Common::SeekableReadStream *stream) 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 
396  static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail = true);
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: 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:282
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:212
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
virtual Common::Path getIconPath() const
Definition: access.h:212
Definition: data.h:100
Definition: asurface.h:129
Definition: system.h:166
Definition: room.h:71
Definition: access.h:62
Definition: engine.h:149
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