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,
85  kActionInventory,
86  kActionClimb,
87  kActionTalk,
88  kActionWalk,
89  kActionHelp,
90  kActionOpen,
91  kActionMove,
92  kActionTravel,
93  kActionSkip,
94  kActionSaveLoad,
95 };
96 
98  ACCESSActions _action;
99  int8 _code;
100 };
101 
102 static const AccessActionCode AMAZON_ACTION_CODES[] = {
103  { kActionLook, 1 },
104  { kActionUse, 2 },
105  { kActionTake, 3 },
106  { kActionInventory, 4 },
107  { kActionClimb, 5 },
108  { kActionTalk, 6 },
109  { kActionWalk, 7 },
110  { kActionHelp, 8 },
111  { kActionSaveLoad, -2 },
112  { kActionNone, -1 },
113 };
114 
115 static const AccessActionCode MARTIAN_ACTION_CODES[] = {
116  { kActionLook, 0 },
117  { kActionOpen, 1 },
118  { kActionMove, 2 },
119  { kActionTake, 3 },
120  { kActionUse, 4 },
121  { kActionWalk, 5 },
122  { kActionTalk, 6 },
123  { kActionTravel, 7 },
124  { kActionHelp, 8 },
125  { kActionSaveLoad, -2 },
126  { kActionNone, -1 },
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 };
139 
140 class AccessEngine : public Engine {
141 private:
142  uint32 _lastTime, _curTime;
143 
147  SpriteResource *_icons;
148 
152  void initialize();
153 
157  void setVGA();
158 
159 protected:
160  const AccessGameDescription *_gameDescription;
161  Common::RandomSource _randomSource;
162  int _loadSaveSlot;
163 
167  void doRoom();
168 
172  void playVideo(int videoNum, const Common::Point &pt);
173 
174  // Engine APIs
175  Common::Error run() override;
176  bool hasFeature(EngineFeature f) const override;
177 protected:
181  virtual void playGame() = 0;
182 
186  virtual void synchronize(Common::Serializer &s);
187 public:
188  AnimationManager *_animation;
189  BubbleBox *_bubbleBox;
190  BubbleBox *_helpBox;
191  BubbleBox *_travelBox;
192  BubbleBox *_invBox;
193  BubbleBox *_aboutBox;
194  CharManager *_char;
195  EventsManager *_events;
196  FileManager *_files;
197  InventoryManager *_inventory;
198  Player *_player;
199  Resources *_res;
200  Room *_room;
201  Screen *_screen;
202  Scripts *_scripts;
203  SoundManager *_sound;
204  MusicManager *_midi;
205  VideoPlayer *_video;
206 
207  BaseSurface *_destIn;
208  BaseSurface *_current;
209  ASurface _buffer1;
210  ASurface _buffer2;
211  ASurface _vidBuf;
212  int _vidX, _vidY;
213  SpriteResource *_objectsTable[100];
214  bool _establishTable[100];
215  bool _establishFlag;
216  int _establishMode;
217  int _establishGroup;
218  int _establishCtrlTblOfs;
219  TimerList _timers;
220  DeathList _deaths;
221  FontManager _fonts;
222  Common::Array<Common::Rect> _newRects;
223  Common::Array<Common::Rect> _oldRects;
224  Common::Array<ExtraCell> _extraCells;
225  ImageEntryList _images;
226  int _mouseMode;
227 
228  uint8 _playerDataCount;
229  int _currentManOld;
230  int _converseMode;
231  bool _currentCharFlag;
232  bool _boxSelect;
233  int _scale;
234  int _scaleH1, _scaleH2;
235  int _scaleN1;
236  int _scaleT1;
237  int _scaleMaxY;
238  int _scaleI;
239  int _scrollX, _scrollY;
240  int _scrollCol, _scrollRow;
241  bool _imgUnscaled;
242  bool _canSaveLoad;
243 
244  Resource *_establish;
245  int _printEnd;
246  int _txtPages;
247  int _narateFile;
248  int _sndSubFile;
249  int _countTbl[6];
250 
251  // Fields that are included in savegames
252  int _conversation;
253  int _currentMan;
254  uint32 _newTime;
255  uint32 _newDate;
256  int _flags[256];
257 
258  // Fields used by MM
259  // TODO: Refactor
260  byte _travel[60];
261  byte _ask[40];
262  int _startTravelItem;
263  int _startTravelBox;
264  int _startAboutItem;
265  int _startAboutBox;
266  int _boxDataStart;
267  bool _boxDataEnd;
268  int _boxSelectY;
269  int _boxSelectYOld;
270  int _numLines;
271  byte _byte26CB5;
272  int _bcnt;
273 
274  bool _vidEnd;
275  bool _clearSummaryFlag;
276  bool _cheatFl;
277  bool _restartFl;
278  // Fields mapped into the flags array
279  int &_useItem;
280  int &_startup;
281  int &_manScaleOff;
282  int &_pictureTaken;
283 
284 public:
285  AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
286  ~AccessEngine() override;
287 
288  virtual void dead(int deathId) = 0;
289 
290  uint32 getFeatures() const;
291  bool isCD() const;
292  bool isDemo() const;
293  Common::Language getLanguage() const;
294  Common::Platform getPlatform() const;
295  uint16 getVersion() const;
296  uint32 getGameID() const;
297  uint32 getGameFeatures() const;
298  bool shouldQuitOrRestart();
299 
300  int getRandomNumber(int maxNumber);
301 
302  const SpriteResource *getIcons();
303 
304  void loadCells(const Common::Array<CellIdent> &cells);
305 
309  void freeCells();
310 
311  virtual void establish(int esatabIndex, int sub) = 0;
312 
313  void plotList();
314  void plotList1();
315 
316  void copyBlocks();
317 
318  void copyRects();
319 
320  void copyBF1BF2();
321 
322  void copyBF2Vid();
323 
324  void freeChar();
325 
329  void printText(BaseSurface *s, const Common::String &msg);
330  void speakText(BaseSurface *s, const Common::String &msg);
331 
332  void syncSoundSettings() override;
333 
337  Common::Error loadGameState(int slot) override;
338 
342  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
343 
347  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
348 
352  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
353 
357  WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail = true);
358 
362  void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header);
363 
364  bool playMovie(const Common::Path &filename, const Common::Point &pos);
365 };
366 
367 } // End of namespace Access
368 
369 #endif /* ACCESS_ACCESS_H */
Definition: video.h:35
Definition: access.h:131
Definition: detection.h:35
Definition: asurface.h:170
Definition: resources.h:44
Definition: str.h:59
Definition: surface.h:67
Definition: inventory.h:53
EngineFeature
Definition: engine.h:258
Definition: events.h:44
Definition: savefile.h:54
Definition: error.h:81
Definition: access.h:140
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:47
Definition: serializer.h:79
Definition: asurface.h:42
Definition: sound.h:87
Definition: files.h:54
Definition: asurface.h:139
Definition: ustr.h:57
Definition: data.h:52
Definition: font.h:144
Definition: files.h:71
Definition: sound.h:48
Definition: rect.h:144
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: animation.h:38
Definition: data.h:92
Definition: asurface.h:122
Definition: system.h:163
Definition: room.h:62
Definition: access.h:62
Definition: engine.h:144
Definition: access.h:97
Platform
Definition: platform.h:93
Definition: screen.h:49
Definition: bubble_box.h:40
Language
Definition: language.h:45
Definition: char.h:48