ScummVM API documentation
kingdom.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 KINGDOM_KINGDOM_H
23 #define KINGDOM_KINGDOM_H
24 
25 #include "common/system.h"
26 #include "common/scummsys.h"
27 #include "common/random.h"
28 #include "engines/advancedDetector.h"
29 #include "common/error.h"
30 #include "engines/engine.h"
31 
32 #include "audio/mixer.h"
33 #include "common/file.h"
34 #include "graphics/screen.h"
35 #include "graphics/surface.h"
36 
37 #include "common/serializer.h"
38 
39 #include "kingdom/console.h"
40 #include "kingdom/logic.h"
41 
42 namespace Kingdom {
43  enum KingdomDebugChannels {
44  kDebugGeneral = 1 << 0
45  };
46 
47  struct KingArtEntry {
48  uint8 _width;
49  uint8 _height;
50  byte* _data;
51  };
52 
53  struct HotSpot {
54  uint16 x1, y1, x2, y2;
55  int16 _mouseValue;
56 
57  bool contains(const Common::Point &p) const {
58  return (x1 <= p.x) && (p.x < x2) && (y1 <= p.y) && (p.y < y2);
59  }
60 
61  bool dummy() const {
62  return !(x1 || x2 || y1 || y2);
63  }
64  };
65 
66  extern const byte _finalFrameTable[];
67  extern const char * const _rezNames[];
68  extern const uint16 _mapExit[];
69  extern const uint8 _emlTable[];
70  extern const uint8 _zoomTable[81][9][2];
71  extern const uint8 _iconActTable[82][7];
72  extern const uint8 _cursorTable[96];
73  extern const uint8 _teaSeq[6][2];
74  extern const uint8 _hgaSeq[4][2];
75  extern const HotSpot _mouseMapMSFull[51];
76  extern const HotSpot _mouseMapMSDemo[51];
77  extern const HotSpot _mouseMapASFull[128][16];
78  extern const HotSpot _mouseMapASDemo[128][16];
79 
81  uint32 _signature;
82  uint8 _version;
83  Common::String _saveName;
84  Graphics::Surface *_thumbnail;
85  int _year, _month, _day;
86  int _hour, _minute;
87  };
88 
89  class KingdomGame : public Engine {
90  public:
91  KingdomGame(OSystem *syst, const ADGameDescription *gameDesc);
92  ~KingdomGame() override;
93 
94  bool hasFeature(EngineFeature f) const override;
95  Common::Error run() override;
96 
97  // Detection related functions
98  const ADGameDescription *_gameDescription;
99  const char *getGameId() const;
100  Common::Platform getPlatform() const;
101  static bool readSavegameHeader(Common::InSaveFile *in, KingdomSavegameHeader &header);
102  bool isDemo() const;
103 
104  private:
105  Logic *_logic;
106 
107  KingArtEntry *_kingartEntries;
108  uint32 _kingartCount;
109 
110  void displayDebugHotSpots();
111 
112  public:
113  Common::RandomSource *_rnd;
114 
115  bool _showHotspots;
116  bool _loopFlag;
117  int _gameMode;
118  bool _fstFwd;
119  bool _noIFScreen;
120  bool _sound;
121  bool _lastSound;
122  bool _fullScreen;
123  int _frameStop;
124  int _daelonCntr;
125  bool _itemInhibit;
126  bool _asMode;
127  bool _aTimerFlag;
128  bool _bTimerFlag;
129  bool _cTimerFlag;
130  bool _skylarTimerFlag;
131  int _aTimer;
132  int _bTimer;
133  int _cTimer;
134  int _skylarTimer;
135  bool _mapEx;
136  int _healthTmr;
137  int _treeEyeTimer;
138  int _treeEyePic;
139  int _treeEyeSta;
140  int _treeHGTimer;
141  int _treeHGPic;
142  int _treeHGUPic;
143  int _treeLeftPic;
144  int _treeRightPic;
145  int _treeRightSta;
146  int _treeHGSta;
147  bool _tsIconOnly;
148  bool _noMusic; // TODO: Synchronize this flag with the launcher
149  byte *_asPtr;
150  int _asMap;
151  int _oldTLS;
152  int _oldTRS;
153  int _treeLeftSta;
154  bool _iconsClosed;
155  bool _oldIconsClosed;
156  int _pMovie;
157  bool _demoMovieSkipped;
158  bool _keyActive;
159  bool _iconRedraw;
160  bool _quit;
161  bool _cursorDrawn; // CHECKME: Useless
162  bool _wizard;
163  int _zoom;
164  int _mouseValue;
165  int _cursorDef; // TODO: Could be removed by using the return value of CursorTypeExit()
166  int _oldCursorDef; // CHECKME: Unused in our implementation?
167 
168  Common::Point _cursorPos;
169  Common::Point _oldCursorPos; // CHECKME: Unused in out implementation?
170 
171  int _iconSel;
172  int _iconSelect;
173  bool _mouseDebound;
174  int _soundNumber;
175  bool _palStepFlag;
176  Audio::SoundHandle _soundHandle;
177  int _tickCount;
178  uint32 _oldTime;
179 
180  int _iconPic[7];
181  uint16 _userInput;
182  uint16 _mouseButton;
183 
184  void drawScreen();
185  void setupPics();
186  void initTools();
187  void titlePage();
188  void initPlay();
189  void initHelp();
190  void fadeToBlack1();
191  void fadeToBlack2();
192  Common::SeekableReadStream *loadAResource(int reznum);
193  void showPic(int reznum);
194  void fShowPic(int reznum);
195  void initCursor();
196  void initMouse();
197  void setMouse();
198  void readMouse();
199  void initMPlayer();
200  void playMovie(int movieNum);
201  void saveAS(); // TODO: Rename later as saveVideoBackground
202  void restoreAS(); // TODO: Rename later as restoreVideoBackground
203  void drawHelpScreen();
204  void drawRect(uint minX, uint minY, uint maxX, uint maxY, int color);
205  void drawHotSpot(const HotSpot &hs, int color);
206  void drawInventory();
207  void playSound(int idx);
208  void eraseCursor();
209  void getUserInput();
210  void eraseCursorAsm();
211  void drawLocation();
212  void processMap(int mapNum, int zoom);
213  void processMapInput(int mapNum);
214  void drawPic(int reznum);
215  void displayIcon(int reznum);
216  void setATimer();
217  void refreshSound();
218  void checkMainScreen();
219  void switchAtoM();
220  void switchMtoA();
221  void drawIcon(int x, int y, int index);
222  int waitKey();
223  void drawCursor();
224  void cursorType();
225  void loadKingArt();
226  void unloadKingArt();
227  void setCursor(int cursor);
228  int getAKey();
229  int checkMouseMapAS();
230  void cursorTypeExit();
231  void saveGame();
232  void restoreGame();
233  Common::Error loadGameState(int slot) override;
234  Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave = false) override;
235  Common::String getSavegameFilename(int slot);
236  void writeSavegameHeader(Common::OutSaveFile *out, KingdomSavegameHeader &header);
237  void synchronize(Common::Serializer &s);
238  void refreshScreen();
239  void checkTimers();
240  void initVariables();
241  };
242 } // End of namespace Kingdom
243 
244 #endif
Definition: str.h:59
Definition: kingdom.h:89
Definition: surface.h:67
EngineFeature
Definition: engine.h:253
Definition: kingdom.h:47
Definition: savefile.h:54
Definition: error.h:84
Definition: advancedDetector.h:163
Definition: random.h:44
Definition: stream.h:745
Definition: serializer.h:79
Definition: mixer.h:49
Definition: kingdom.h:80
Definition: kingdom.h:53
Definition: logic.h:29
Definition: rect.h:45
int16 x
Definition: rect.h:46
int16 y
Definition: rect.h:47
Definition: console.h:27
Definition: system.h:161
Definition: engine.h:144
Platform
Definition: platform.h:46