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