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 enum ACCESSActions {
72  kActionNone,
73  kActionMoveUp,
74  kActionMoveDown,
75  kActionMoveLeft,
76  kActionMoveRight,
77  kActionMoveUpLeft,
78  kActionMoveUpRight,
79  kActionMoveDownLeft,
80  kActionMoveDownRight,
81  kActionLook,
82  kActionUse,
83  kActionTake,
84  kActionInventory,
85  kActionClimb,
86  kActionTalk,
87  kActionWalk,
88  kActionHelp,
89  kActionOpen,
90  kActionMove,
91  kActionTravel,
92  kActionSkip,
93  kActionSaveLoad,
94 };
95 
97  ACCESSActions _action;
98  int8 _code;
99 };
100 
101 static const AccessActionCode AMAZON_ACTION_CODES[] = {
102  { kActionLook, 1 },
103  { kActionUse, 2 },
104  { kActionTake, 3 },
105  { kActionInventory, 4 },
106  { kActionClimb, 5 },
107  { kActionTalk, 6 },
108  { kActionWalk, 7 },
109  { kActionHelp, 8 },
110  { kActionSaveLoad, -2 },
111  { kActionNone, -1 },
112 };
113 
114 static const AccessActionCode MARTIAN_ACTION_CODES[] = {
115  { kActionLook, 0 },
116  { kActionOpen, 1 },
117  { kActionMove, 2 },
118  { kActionTake, 3 },
119  { kActionUse, 4 },
120  { kActionWalk, 5 },
121  { kActionTalk, 6 },
122  { kActionTravel, 7 },
123  { kActionHelp, 8 },
124  { kActionSaveLoad, -2 },
125  { kActionNone, -1 },
126 };
127 
128 #define ACCESS_SAVEGAME_VERSION 1
129 
131  uint8 _version;
132  Common::String _saveName;
133  Graphics::Surface *_thumbnail;
134  int _year, _month, _day;
135  int _hour, _minute;
136  int _totalFrames;
137 };
138 
139 class AccessEngine : public Engine {
140 private:
141  uint32 _lastTime, _curTime;
142 
146  SpriteResource *_icons;
147 
151  void initialize();
152 
156  void setVGA();
157 
158 protected:
159  const AccessGameDescription *_gameDescription;
160  Common::RandomSource _randomSource;
161  int _loadSaveSlot;
162 
166  void doRoom();
167 
171  void playVideo(int videoNum, const Common::Point &pt);
172 
173  // Engine APIs
174  Common::Error run() override;
175  bool hasFeature(EngineFeature f) const override;
176 protected:
180  virtual void playGame() = 0;
181 
185  virtual void synchronize(Common::Serializer &s);
186 public:
187  AnimationManager *_animation;
188  BubbleBox *_bubbleBox;
189  BubbleBox *_helpBox;
190  BubbleBox *_travelBox;
191  BubbleBox *_invBox;
192  BubbleBox *_aboutBox;
193  CharManager *_char;
194  EventsManager *_events;
195  FileManager *_files;
196  InventoryManager *_inventory;
197  Player *_player;
198  Resources *_res;
199  Room *_room;
200  Screen *_screen;
201  Scripts *_scripts;
202  SoundManager *_sound;
203  MusicManager *_midi;
204  VideoPlayer *_video;
205 
206  BaseSurface *_destIn;
207  BaseSurface *_current;
208  ASurface _buffer1;
209  ASurface _buffer2;
210  ASurface _vidBuf;
211  int _vidX, _vidY;
212  SpriteResource *_objectsTable[100];
213  bool _establishTable[100];
214  bool _establishFlag;
215  int _establishMode;
216  int _establishGroup;
217  int _establishCtrlTblOfs;
218  TimerList _timers;
219  DeathList _deaths;
220  FontManager _fonts;
221  Common::Array<Common::Rect> _newRects;
222  Common::Array<Common::Rect> _oldRects;
223  Common::Array<ExtraCell> _extraCells;
224  ImageEntryList _images;
225  int _mouseMode;
226 
227  uint8 _playerDataCount;
228  int _currentManOld;
229  int _converseMode;
230  bool _currentCharFlag;
231  bool _boxSelect;
232  int _scale;
233  int _scaleH1, _scaleH2;
234  int _scaleN1;
235  int _scaleT1;
236  int _scaleMaxY;
237  int _scaleI;
238  int _scrollX, _scrollY;
239  int _scrollCol, _scrollRow;
240  bool _imgUnscaled;
241  bool _canSaveLoad;
242 
243  Resource *_establish;
244  int _printEnd;
245  int _txtPages;
246  int _narateFile;
247  int _sndSubFile;
248  int _countTbl[6];
249 
250  // Fields that are included in savegames
251  int _conversation;
252  int _currentMan;
253  uint32 _newTime;
254  uint32 _newDate;
255  int _flags[256];
256 
257  // Fields used by MM
258  // TODO: Refactor
259  byte _travel[60];
260  byte _ask[40];
261  int _startTravelItem;
262  int _startTravelBox;
263  int _startAboutItem;
264  int _startAboutBox;
265  int _boxDataStart;
266  bool _boxDataEnd;
267  int _boxSelectY;
268  int _boxSelectYOld;
269  int _numLines;
270  byte _byte26CB5;
271  int _bcnt;
272 
273  bool _vidEnd;
274  bool _clearSummaryFlag;
275  bool _cheatFl;
276  bool _restartFl;
277  // Fields mapped into the flags array
278  int &_useItem;
279  int &_startup;
280  int &_manScaleOff;
281  int &_pictureTaken;
282 
283 public:
284  AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
285  ~AccessEngine() override;
286 
287  virtual void dead(int deathId) = 0;
288 
289  uint32 getFeatures() const;
290  bool isCD() const;
291  bool isDemo() const;
292  Common::Language getLanguage() const;
293  Common::Platform getPlatform() const;
294  uint16 getVersion() const;
295  uint32 getGameID() const;
296  uint32 getGameFeatures() const;
297  bool shouldQuitOrRestart();
298 
299  int getRandomNumber(int maxNumber);
300 
301  const SpriteResource *getIcons();
302 
303  void loadCells(const Common::Array<CellIdent> &cells);
304 
308  void freeCells();
309 
310  virtual void establish(int esatabIndex, int sub) = 0;
311 
312  void plotList();
313  void plotList1();
314 
315  void copyBlocks();
316 
317  void copyRects();
318 
319  void copyBF1BF2();
320 
321  void copyBF2Vid();
322 
323  void freeChar();
324 
328  void printText(BaseSurface *s, const Common::String &msg);
329  void speakText(BaseSurface *s, const Common::String &msg);
330 
334  Common::Error loadGameState(int slot) override;
335 
339  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
340 
344  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
345 
349  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
350 
354  WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail = true);
355 
359  void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header);
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:130
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:139
Definition: scripts.h:40
Definition: random.h:44
Definition: path.h:52
Definition: stream.h:745
Definition: player.h:47
Definition: serializer.h:79
Definition: asurface.h:42
Definition: sound.h:86
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:96
Platform
Definition: platform.h:93
Definition: screen.h:49
Definition: bubble_box.h:40
Language
Definition: language.h:45
Definition: char.h:48