ScummVM API documentation
illusions.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 ILLUSIONS_ILLUSIONS_H
23 #define ILLUSIONS_ILLUSIONS_H
24 
25 #include "illusions/graphics.h"
26 #include "audio/mixer.h"
27 #include "audio/decoders/aiff.h"
28 
29 #include "common/array.h"
30 #include "common/events.h"
31 #include "common/file.h"
32 #include "common/memstream.h"
33 #include "common/random.h"
34 #include "common/str.h"
35 #include "common/substream.h"
36 #include "common/system.h"
37 
38 #include "engines/engine.h"
39 #include "graphics/surface.h"
40 #include "illusions/detection.h"
41 
42 namespace Illusions {
43 
44 enum ILLUSIONSAction {
45  kActionNone,
46  kActionCursorUp,
47  kActionCursorDown,
48  kActionCursorLeft,
49  kActionCursorRight,
50  kActionInventory,
51  kActionAbort,
52  kActionSkip,
53  kActionCheatMode
54 };
55 
56 char *debugW2I(uint16 *wstr);
57 void swapBytesInWideString(byte * wstr);
58 
59 #define ILLUSIONS_SAVEGAME_VERSION 0
60 
61 class ResourceSystem;
62 class BaseResourceReader;
63 
64 struct SurfInfo;
65 
66 class ActorInstanceList;
67 struct ActorType;
68 class BackgroundInstanceList;
69 class BackgroundResource;
70 class Camera;
71 class Control;
72 class Controls;
73 class Cursor;
74 class Dictionary;
75 struct Fader;
76 class FramesList;
77 class Input;
78 class Screen;
79 class ScreenText;
80 class ScriptOpcodes;
81 class ScriptResource;
82 class ScriptStack;
83 struct Sequence;
84 class SoundMan;
85 class SpecialCode;
86 class TalkInstanceList;
87 class ThreadList;
88 class UpdateFunctions;
89 class GameState;
90 class ScreenPaletteBase;
91 
92 class IllusionsEngine : public Engine {
93 public:
95  ~IllusionsEngine() override;
96  const Common::String getTargetName() { return _targetName; }
97 private:
98  const IllusionsGameDescription *_gameDescription;
99  Graphics::PixelFormat _pixelFormat;
100 public:
101 
102  Common::RandomSource *_random;
103  Dictionary *_dict;
104  ResourceSystem *_resSys;
105  BaseResourceReader *_resReader;
106  UpdateFunctions *_updateFunctions;
107  GameState *_gameState;
108 
109  void updateEvents();
110 
111  Screen *_screen;
112  ScreenPaletteBase *_screenPalette;
113  ScreenText *_screenText;
114  Input *_input;
115  ActorInstanceList *_actorInstances;
116  BackgroundInstanceList *_backgroundInstances;
117  Camera *_camera;
118  Controls *_controls;
119  TalkInstanceList *_talkItems;
120  ScriptOpcodes *_scriptOpcodes;
121  SpecialCode *_specialCode;
122  ThreadList *_threads;
123  SoundMan *_soundMan;
124 
125  uint32 _nextTempThreadId;
126  bool _doScriptThreadInit;
127  ScriptStack *_stack;
128  ScriptResource *_scriptResource;
129  bool _rerunThreads;
130 
131  Fader *_fader;
132 
133  int _pauseCtr;
134 
135  int _resGetCtr;
136  uint32 _resGetTime;
137  bool _unpauseControlActorFlag;
138  uint32 _lastUpdateTime;
139 
140  int _resumeFromSavegameRequested;
141  int _savegameSlotNum;
142  Common::String _savegameDescription;
143  uint32 _savegameSceneId;
144  uint32 _savegameThreadId;
145 
146  uint32 _fontId;
147  int _field8;
148  uint32 _fieldA;
149  uint32 _subtitleDuration;
150 
151  WidthHeight _defaultTextDimensions;
152  Common::Point _defaultTextPosition;
153 
154  int16 _menuChoiceOfs;
155 
156  int getGameId() const;
157  Common::Language getGameLanguage() const;
158 
159  void runUpdateFunctions();
160  int updateActors(uint flags);
161  int updateSequences(uint flags);
162  int updateGraphics(uint flags);
163  int updateSoundMan(uint flags);
164  int updateSprites(uint flags);
165 
166  uint32 getElapsedUpdateTime();
167  Common::Point *getObjectActorPositionPtr(uint32 objectId);
168  int getRandom(int max);
169  int convertPanXCoord(int16 x);
170  bool calcPointDirection(Common::Point &srcPt, Common::Point &dstPt, uint &facing);
171  bool isSoundActive();
172 
173  virtual void updateFader() {};
174  virtual void clearFader() {};
175  virtual void pauseFader() {};
176  virtual void unpauseFader() {};
177  virtual bool isVideoPlaying() { return false; }
178 
179  void setCurrFontId(uint32 fontId);
180  bool checkActiveTalkThreads();
181  void setTextDuration(int kind, uint32 duration);
182  uint32 clipTextDuration(uint32 duration);
183  void getDefaultTextDimensions(WidthHeight &dimensions);
184  void setDefaultTextDimensions(WidthHeight &dimensions);
185  void getDefaultTextPosition(Common::Point &position);
186  void setDefaultTextPosition(Common::Point &position);
187 
188  uint16 getSubtitleDuration();
189  void setSubtitleDuration(uint16 duration);
190 
191  FramesList *findActorSequenceFrames(Sequence *sequence);
192 
193  virtual void setDefaultTextCoords() = 0;
194  virtual void loadSpecialCode(uint32 resId) = 0;
195  virtual void unloadSpecialCode(uint32 resId) = 0;
196  virtual void notifyThreadId(uint32 &threadId) = 0;
197  virtual bool testMainActorFastWalk(Control *control) = 0;
198  virtual bool testMainActorCollision(Control *control) = 0;
199  virtual Control *getObjectControl(uint32 objectId) = 0;
200  virtual Common::Point getNamedPointPosition(uint32 namedPointId) = 0;
201  virtual uint32 getPriorityFromBase(int16 priority) = 0;
202  virtual uint32 getPrevScene() = 0;
203  virtual uint32 getCurrentScene() = 0;
204  virtual bool isCursorObject(uint32 actorTypeId, uint32 objectId) = 0;
205  virtual void setCursorControlRoutine(Control *control) = 0;
206  virtual void placeCursorControl(Control *control, uint32 sequenceId) = 0;
207  virtual void setCursorControl(Control *control) = 0;
208  virtual void showCursor() = 0;
209  virtual void hideCursor() = 0;
210  virtual void startScriptThreadSimple(uint32 threadId, uint32 callingThreadId) = 0;
211  virtual uint32 startTempScriptThread(byte *scriptCodeIp, uint32 callingThreadId,
212  uint32 value8, uint32 valueC, uint32 value10) = 0;
213 
214  // Savegame API
215 
216  enum kReadSaveHeaderError {
217  kRSHENoError = 0,
218  kRSHEInvalidType = 1,
219  kRSHEInvalidVersion = 2,
220  kRSHEIoError = 3
221  };
222 
223  struct SaveHeader {
224  Common::String description;
225  uint32 version;
226  byte gameID;
227  uint32 flags;
228  uint32 saveDate;
229  uint32 saveTime;
230  uint32 playTime;
231  Graphics::Surface *thumbnail;
232  };
233 
234  bool _isSaveAllowed;
235 
236  bool canLoadGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
237  bool canSaveGameStateCurrently(Common::U32String *msg = nullptr) override { return _isSaveAllowed; }
238  Common::Error loadGameState(int slot) override;
239  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
240  Common::Error removeGameState(int slot);
241  bool savegame(const char *filename, const char *description);
242  bool loadgame(const char *filename);
243  bool existsSavegame(int num);
244  static Common::String getSavegameFilename(const Common::String &target, int num);
245  static kReadSaveHeaderError readSaveHeader(Common::SeekableReadStream *in, SaveHeader &header, bool skipThumbnail = true);
246 
247 };
248 
249 } // End of namespace Illusions
250 
251 #endif // ILLUSIONS_ILLUSIONS_H
Definition: input.h:78
Definition: backgroundresource.h:209
Definition: screen.h:99
Definition: str.h:59
Definition: screen.h:113
Definition: surface.h:67
Definition: talkresource.h:78
Definition: dictionary.h:85
Definition: error.h:84
Definition: pixelformat.h:138
Definition: resourcesystem.h:85
bool canLoadGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: illusions.h:236
Definition: random.h:44
Definition: actor.h:34
Definition: actor.h:245
Definition: detection.h:34
Definition: atari-screen.h:60
Definition: stream.h:745
Definition: illusions.h:223
Definition: screen.h:154
Definition: graphics.h:31
Definition: sound.h:127
Definition: ustr.h:57
Definition: atari-cursor.h:38
bool canSaveGameStateCurrently(Common::U32String *msg=nullptr) override
Definition: illusions.h:237
Definition: scriptopcodes.h:48
Definition: camera.h:65
Definition: rect.h:45
bool skipThumbnail(Common::SeekableReadStream &in)
Definition: specialcode.h:44
Definition: resourcereader.h:29
Definition: screentext.h:56
const Common::String _targetName
Definition: engine.h:181
Common::Error loadGameState(int slot) override
Definition: scriptstack.h:27
Definition: actorresource.h:51
Definition: gamestate.h:30
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave=false) override
Definition: system.h:161
Definition: actorresource.h:112
Definition: actor.h:180
Definition: scriptresource.h:114
Definition: thread.h:80
Definition: engine.h:144
Definition: updatefunctions.h:49
Definition: illusions.h:92
Definition: actorresource.h:76
Language
Definition: language.h:45