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