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  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 
160 protected:
161  const AccessGameDescription *_gameDescription;
162  Common::RandomSource _randomSource;
163  int _loadSaveSlot;
164 
168  void doRoom();
169 
173  void playVideo(int videoNum, const Common::Point &pt);
174 
175  // Engine APIs
176  Common::Error run() override;
177  bool hasFeature(EngineFeature f) const override;
178 protected:
182  virtual void playGame() = 0;
183 
187  virtual Common::Error synchronize(Common::Serializer &s);
188 
189 public:
190  AnimationManager *_animation;
191  BubbleBox *_bubbleBox;
192  BubbleBox *_helpBox;
193  BubbleBox *_travelBox;
194  BubbleBox *_invBox;
195  BubbleBox *_aboutBox;
196  CharManager *_char;
197  EventsManager *_events;
198  FileManager *_files;
199  InventoryManager *_inventory;
200  Player *_player;
201  Resources *_res;
202  Room *_room;
203  Screen *_screen;
204  Scripts *_scripts;
205  SoundManager *_sound;
206  MusicManager *_midi;
207  VideoPlayer *_video;
208 
209  BaseSurface *_destIn;
210  BaseSurface *_current;
211  ASurface _buffer1;
212  ASurface _buffer2;
213  ASurface _vidBuf;
214  int _vidX, _vidY;
215  SpriteResource *_objectsTable[100];
216  bool _establishTable[100];
217  bool _establishFlag;
218  int _establishMode;
219  int _establishGroup;
220  int _establishCtrlTblOfs;
221  TimerList _timers;
222  DeathList _deaths;
223  FontManager _fonts;
224  Common::Array<Common::Rect> _newRects;
225  Common::Array<Common::Rect> _oldRects;
226  Common::Array<ExtraCell> _extraCells;
227  ImageEntryList _images;
228  int _mouseMode;
229 
230  uint8 _playerDataCount;
231  int _currentManOld;
232  int _converseMode;
233  bool _currentCharFlag;
234  bool _boxSelect;
235  int _scale;
236  int _scaleH1, _scaleH2;
237  int _scaleN1;
238  int _scaleT1;
239  int _scaleMaxY;
240  int _scaleI;
241  int _scrollX, _scrollY;
242  int _scrollCol, _scrollRow;
243  bool _imgUnscaled;
244  bool _canSaveLoad;
245 
246  Resource *_establish;
247  int _printEnd;
248  int _txtPages;
249  int _narateFile;
250  int _sndSubFile;
251  int _countTbl[6];
252 
253  // Fields that are included in savegames
254  int _conversation;
255  int _currentMan;
256  uint32 _newTime;
257  uint32 _newDate;
258  int _flags[256];
259 
260  // Fields used by MM
261  // TODO: Refactor
262  byte _travel[60];
263  byte _ask[40];
264  int _startTravelItem;
265  int _startTravelBox;
266  int _startAboutItem;
267  int _startAboutBox;
268  int _boxDataStart;
269  bool _boxDataEnd;
270  int _boxSelectY;
271  int _boxSelectYOld;
272  int _numLines;
273  byte _byte26CB5;
274  int _bcnt;
275 
276  bool _vidEnd;
277  bool _clearSummaryFlag;
278  bool _cheatFl;
279  bool _restartFl;
280  // Fields mapped into the flags array
281  int &_useItem;
282  int &_startup;
283  int &_manScaleOff;
284  int &_pictureTaken;
285 
286 public:
287  AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
288  ~AccessEngine() override;
289 
290  virtual void dead(int deathId) = 0;
291 
292  uint32 getFeatures() const;
293  bool isCD() const;
294  bool isDemo() const;
295  Common::Language getLanguage() const;
296  Common::Platform getPlatform() const;
297  uint16 getVersion() const;
298  uint32 getGameID() const;
299  uint32 getGameFeatures() const;
300  bool shouldQuitOrRestart();
301 
302  int getRandomNumber(int maxNumber);
303 
304  const SpriteResource *getIcons();
305 
306  void loadCells(const Common::Array<CellIdent> &cells);
307 
311  void freeCells();
312 
313  virtual void establish(int esatabIndex, int sub) = 0;
314 
315  void plotList();
316  void plotList1();
317 
318  void copyBlocks();
319 
320  void copyRects();
321 
322  void copyBF1BF2();
323 
324  void copyBF2Vid();
325 
326  void freeChar();
327 
331  void printText(BaseSurface *s, const Common::String &msg);
332  void speakText(BaseSurface *s, const Common::String &msg);
333 
334  void syncSoundSettings() override;
335 
339  Common::Error loadGameState(int slot) override;
340  Common::Error loadGameStream(Common::SeekableReadStream *stream) override;
341 
345  Common::Error saveGameStream(Common::WriteStream *stream, bool isAutosave = false) override;
349  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
350 
354  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
355 
359  static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail = true);
360 
361  bool playMovie(const Common::Path &filename, const Common::Point &pos);
362 };
363 
364 } // End of namespace Access
365 
366 #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: 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: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:164
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