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 << 0,
66  kDebugScripts = 1 << 1,
67  kDebugGraphics = 1 << 2,
68  kDebugSound = 1 << 3
69 };
70 
71 extern const char *const _estTable[];
72 
73 #define ACCESS_SAVEGAME_VERSION 1
74 
76  uint8 _version;
77  Common::String _saveName;
78  Graphics::Surface *_thumbnail;
79  int _year, _month, _day;
80  int _hour, _minute;
81  int _totalFrames;
82 };
83 
84 class AccessEngine : public Engine {
85 private:
86  uint32 _lastTime, _curTime;
87 
91  void initialize();
92 
96  void setVGA();
97 
98 protected:
99  const AccessGameDescription *_gameDescription;
100  Common::RandomSource _randomSource;
101  int _loadSaveSlot;
102 
106  void doRoom();
107 
111  void playVideo(int videoNum, const Common::Point &pt);
112 
113  // Engine APIs
114  Common::Error run() override;
115  bool hasFeature(EngineFeature f) const override;
116 protected:
120  virtual void playGame() = 0;
121 
125  virtual void synchronize(Common::Serializer &s);
126 public:
127  AnimationManager *_animation;
128  BubbleBox *_bubbleBox;
129  BubbleBox *_helpBox;
130  BubbleBox *_travelBox;
131  BubbleBox *_invBox;
132  BubbleBox *_aboutBox;
133  CharManager *_char;
134  EventsManager *_events;
135  FileManager *_files;
136  InventoryManager *_inventory;
137  Player *_player;
138  Resources *_res;
139  Room *_room;
140  Screen *_screen;
141  Scripts *_scripts;
142  SoundManager *_sound;
143  MusicManager *_midi;
144  VideoPlayer *_video;
145 
146  BaseSurface *_destIn;
147  BaseSurface *_current;
148  ASurface _buffer1;
149  ASurface _buffer2;
150  ASurface _vidBuf;
151  int _vidX, _vidY;
152  Common::Array<CharEntry *> _charTable;
153  SpriteResource *_objectsTable[100];
154  bool _establishTable[100];
155  bool _establishFlag;
156  int _establishMode;
157  int _establishGroup;
158  int _establishCtrlTblOfs;
159  int _numAnimTimers;
160  TimerList _timers;
161  DeathList _deaths;
162  FontManager _fonts;
163  Common::Array<Common::Rect> _newRects;
164  Common::Array<Common::Rect> _oldRects;
165  Common::Array<ExtraCell> _extraCells;
166  ImageEntryList _images;
167  int _mouseMode;
168 
169  uint8 _playerDataCount;
170  int _currentManOld;
171  int _converseMode;
172  bool _currentCharFlag;
173  bool _boxSelect;
174  int _scale;
175  int _scaleH1, _scaleH2;
176  int _scaleN1;
177  int _scaleT1;
178  int _scaleMaxY;
179  int _scaleI;
180  int _scrollX, _scrollY;
181  int _scrollCol, _scrollRow;
182  bool _imgUnscaled;
183  bool _canSaveLoad;
184 
185  Resource *_establish;
186  int _printEnd;
187  int _txtPages;
188  int _narateFile;
189  int _sndSubFile;
190  int _countTbl[6];
191 
192  // Fields that are included in savegames
193  int _conversation;
194  int _currentMan;
195  uint32 _newTime;
196  uint32 _newDate;
197  int _flags[256];
198 
199  // Fields used by MM
200  // TODO: Refactor
201  int _travel[60];
202  int _ask[40];
203  int _startTravelItem;
204  int _startTravelBox;
205  int _startAboutItem;
206  int _startAboutBox;
207  int _boxDataStart;
208  bool _boxDataEnd;
209  int _boxSelectY;
210  int _boxSelectYOld;
211  int _numLines;
212  byte _byte26CB5;
213  int _bcnt;
214  byte *_tempList;
215  int _pictureTaken;
216  //
217 
218  bool _vidEnd;
219  bool _clearSummaryFlag;
220  bool _cheatFl;
221  bool _restartFl;
222  // Fields mapped into the flags array
223  int &_useItem;
224  int &_startup;
225  int &_manScaleOff;
226 
227 public:
228  AccessEngine(OSystem *syst, const AccessGameDescription *gameDesc);
229  ~AccessEngine() override;
230 
231  virtual void dead(int deathId) = 0;
232 
233  uint32 getFeatures() const;
234  bool isCD() const;
235  bool isDemo() const;
236  Common::Language getLanguage() const;
237  Common::Platform getPlatform() const;
238  uint16 getVersion() const;
239  uint32 getGameID() const;
240  uint32 getGameFeatures() const;
241  bool shouldQuitOrRestart();
242 
243  int getRandomNumber(int maxNumber);
244 
245  void loadCells(Common::Array<CellIdent> &cells);
246 
250  void freeCells();
251 
252  virtual void establish(int esatabIndex, int sub) = 0;
253 
254  void plotList();
255  void plotList1();
256 
257  void copyBlocks();
258 
259  void copyRects();
260 
261  void copyBF1BF2();
262 
263  void copyBF2Vid();
264 
265  void freeChar();
266 
270  void printText(BaseSurface *s, const Common::String &msg);
271  void speakText(BaseSurface *s, const Common::String &msg);
272 
276  Common::Error loadGameState(int slot) override;
277 
281  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
282 
286  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override;
287 
291  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override;
292 
296  WARN_UNUSED_RESULT static bool readSavegameHeader(Common::InSaveFile *in, AccessSavegameHeader &header, bool skipThumbnail = true);
297 
301  void writeSavegameHeader(Common::OutSaveFile *out, AccessSavegameHeader &header);
302 
303  void SPRINTCHR(char c, int fontNum);
304  void PRINTCHR(Common::String msg, int fontNum);
305 
306  bool playMovie(const Common::Path &filename, const Common::Point &pos);
307 };
308 
309 } // End of namespace Access
310 
311 #endif /* ACCESS_ACCESS_H */
Definition: video.h:35
Definition: access.h:75
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:253
Definition: events.h:44
Definition: savefile.h:54
Definition: error.h:84
Definition: access.h:84
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:45
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: animation.h:38
Definition: data.h:95
Definition: asurface.h:121
Definition: system.h:161
Definition: room.h:62
Definition: access.h:62
Definition: engine.h:144
Platform
Definition: platform.h:46
Definition: screen.h:49
Definition: bubble_box.h:40
Language
Definition: language.h:45
Definition: char.h:48