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
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (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, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef ASYLUM_RESOURCES_DATA_H
24 #define ASYLUM_RESOURCES_DATA_H
25 
26 #include "common/rect.h"
27 #include "common/serializer.h"
28 
29 #include "engines/asylum/shared.h"
30 
31 namespace Asylum {
32 
33 //////////////////////////////////////////////////////////////////////////
34 // Flags
35 enum GlobalFlag {
36 	kFlag1,
37 	kFlag2,
38 	kFlag3,
39 	kFlagRedraw,
40 	kFlagSkipDrawScene,
41 	kFlagSceneRectChanged,
42 	kFlagScene1,
43 	kFlagSkipScriptProcessing,
44 	kFlagIsEncounterRunning,
45 	kFlagEncounterDisablePlayerOnExit,
46 	kFlagActorUpdateEnabledCheck,
47 	kFlagActorUpdateStatus15Check
48 };
49 
50 class SharedData;
51 
52 class CrowsData {
53 public:
CrowsData(SharedData * sharedData)54 	CrowsData(SharedData *sharedData) : /* _sharedData(sharedData), */_data() { memset(_data, 0, sizeof(_data)); }
55 	int32 &operator [](uint32 index);
56 private:
57 	int32 _data[84];
58 	//SharedData *_sharedData;
59 };
60 
61 /**
62  * Shared data
63  * -----------
64  *  uint32 {1}      - actorEnableForStatus7
65  *
66  *  uint32 {1}      - global direction
67  *  uint32 {1}      - lastScreenUpdate
68  *
69  *  uint32 {1}      - actor update counter
70  *
71  *  uint32 {1}      - matte bar height
72  *
73  *  Lots of data
74  *
75  *  -- Scene data (reset on scene load)
76  *  uint32 {15}    - ambient flags
77  *  uint32 {15}    - ambient ticks
78  *  uint32 {1}     - UNUSED
79  *  uint32 {1}     - UNUSED (scene updateScreen calls count)
80  *  -- Script queue (stored in ScriptManager)
81  *  uint32 {1}     - global Object X
82  *  uint32 {1}     - global Object Y
83  *  uint32 {1}     - Skip script processing flag
84  *  uint32 {1}     - Encounter running flag
85  *  uint32 {1}     - Player ActorIndex
86  *  uint32 {1}     - scene xLeft
87  *  uint32 {1}     - scene yTop
88  *  uint32 {1}     - scene offset
89  *  uint32 {1}     - scene offsetAdd
90  *  uint32 {1}     - UNUSED
91  *  uint32 {13}    - cursor resources
92  *  uint32 {3}     - scene fonts (3)
93  *  uint32 {5}     - Chapter2 actor data (part 1)
94  *  uint32 {1}     - small cursor Up
95  *  uint32 {1}     - small cursor Down
96  *  uint32 {1}     - Encounter frame background
97  *  uint32 {1}     - Flag skip draw scene
98  *  uint32 {1}     - matte var 1
99  *  uint32 {1}     - actorUpdateEnabledCheck
100  *  uint32 {1}     - matte Initialized
101  *  uint32 {1}     - matte playSound
102  *  uint32 {1}     - currentScreenUpdatesCount
103  *  uint32 {9}     - Chapter2 actor data (part 2)
104  *  uint32 {1}     - Chapter 2 counter 1
105  *  uint32 {1}     - Chapter 2 counter 2
106  *  uint32 {1}     - Chapter 2 counter 3
107  *  uint32 {1}     - Chapter 2 counter 4
108  *  uint32 {23}    - Chapter2 actor data (part 3)
109  *  uint32 {1}     - Special 2 counter 5
110  *  uint32 {1}     - Chapter 2 frameIndex Offset
111  *  uint32 {1}     - Chapter 2 Actor index
112  *  uint32 {1}     - Event update flag
113  *  uint32 {1}     - Chapter 2 counter 6
114  *  uint32 {1}     - Chapter 2 counter 7
115  *  uint32 {1}     - Chapter 2 counter 8
116  *  uint32 {18}    - Chapter2 actor data (part 4)
117  *  uint32 {1}     - actorUpdateStatusEnabledCounter
118  *  uint32 {9}     - Chapter2 actor data (part 5)
119  *  uint32 {1}     - Encounter disablePlayerOnExit
120  *  uint32 {1}     - Scene flag 1
121  *  uint32 {1}     - nextScreenUpdate
122  *  uint32 {49}    - Viewed movies
123  *  uint32 {1}     - actorUpdateStatus15Check
124  *  -- Skip opening movie command line flag (not used)
125  *  -- Encounter flag 3
126  *  uint32 {1}     - Flag 2
127  *  uint32 {1}     - Flag Redraw
128  *  -- scripts (reset on scene load)
129  *  -- polygons (reset on scene load)
130  */
131 class SharedData : public Common::Serializable {
132 public:
133 	SharedData();
~SharedData()134 	virtual ~SharedData() {};
135 
136 	// Public variables
137 	int32           cdNumber;
138 	uint32          movieIndex;
139 	uint32          sceneCounter;
140 	Common::Point   vector1;
141 	Common::Point   vector2;
142 	bool            actorEnableForStatus7;
143 	ActorDirection  globalDirection;
144 	CrowsData       crowsData;
145 
146 	// Used by Actor::enableActorsChapter2 (and maybe others)
147 	void resetChapter2Data();
148 	void reset();  // called during game reset
149 
150 	// Flags
151 	bool getFlag(GlobalFlag flag) const;
152 	void setFlag(GlobalFlag flag, bool state);
153 
154 	// Serializer
155 	void saveLoadAmbientSoundData(Common::Serializer &s);
156 	void saveLoadWithSerializer(Common::Serializer &s);
157 
158 	//////////////////////////////////////////////////////////////////////////
159 	// Accessors
160 	//////////////////////////////////////////////////////////////////////////
161 
162 	// Ambient sound data
163 	uint32 getAmbientTick(uint32 index) const;
164 	void setAmbientTick(uint32 index, uint32 val);
165 	uint32 getAmbientFlag(uint32 index) const;
166 	void setAmbientFlag(uint32 index, uint32 val);
167 	void resetAmbientFlags();
168 
169 	/**
170 	 * Return the index of the player actor
171 	 */
getPlayerIndex()172 	ActorIndex getPlayerIndex() { return _playerIndex; }
173 
174 	/**
175 	 * Sets the player actor index.
176 	 *
177 	 * @param index index of the player actor
178 	 */
setPlayerIndex(ActorIndex index)179 	void setPlayerIndex(ActorIndex index) { _playerIndex = index; }
180 
181 	// Coordinates
getGlobalPoint()182 	Common::Point getGlobalPoint() { return _globalPoint; }
setGlobalPoint(const Common::Point & point)183 	void setGlobalPoint(const Common::Point &point) { _globalPoint = point; }
getSceneCoords()184 	Common::Point getSceneCoords() { return _sceneCoords; }
setSceneCoords(const Common::Point & point)185 	void setSceneCoords(const Common::Point &point) { _sceneCoords = point; }
getSceneOffset()186 	int16 getSceneOffset() { return _sceneOffset; }
setSceneOffset(int16 sceneOffset)187 	void setSceneOffset(int16 sceneOffset) { _sceneOffset = sceneOffset; }
getSceneOffsetAdd()188 	int16 getSceneOffsetAdd() { return _sceneOffsetAdd; }
setSceneOffsetAdd(int16 sceneOffsetAdd)189 	void setSceneOffsetAdd(int16 sceneOffsetAdd) { _sceneOffsetAdd = sceneOffsetAdd; }
190 
191 	// Saved scene data
192 	void saveCursorResources(ResourceId *resources, uint32 size);
193 	void loadCursorResources(ResourceId *resources, uint32 size) const;
194 	void saveSceneFonts(ResourceId font1, ResourceId font2, ResourceId font3);
195 	void loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3) const;
196 	void saveSmallCursor(int32 smallCurUp, int32 smallCurDown);
197 	void loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown) const;
saveEncounterFrameBackground(ResourceId encounterFrameBg)198 	void saveEncounterFrameBackground(ResourceId encounterFrameBg) { _encounterFrameBg = encounterFrameBg; }
loadEncounterFrameBackground(ResourceId * encounterFrameBg)199 	void loadEncounterFrameBackground(ResourceId *encounterFrameBg) { *encounterFrameBg = _encounterFrameBg; }
200 
201 	// Matte data
getMatteVar1()202 	int32 getMatteVar1() const { return _matteVar1; }
setMatteVar1(int32 val)203 	void setMatteVar1(int32 val) { _matteVar1 = val; }
getMatteVar2()204 	uint32 getMatteVar2() const { return _matteVar2; }
setMatteVar2(uint32 val)205 	void setMatteVar2(uint32 val) { _matteVar2 = val; }
getMatteBarHeight()206 	int16 getMatteBarHeight() const { return _matteBarHeight; }
setMatteBarHeight(int16 val)207 	void setMatteBarHeight(int16 val) { _matteBarHeight = val; }
getMatteInitialized()208 	bool getMatteInitialized() const { return _matteInitialized; }
setMatteInitialized(bool val)209 	void setMatteInitialized(bool val) { _matteInitialized = val; }
getMattePlaySound()210 	bool getMattePlaySound() const { return _mattePlaySound; }
setMattePlaySound(bool val)211 	void setMattePlaySound(bool val) { _mattePlaySound = val; }
212 
213 	// Chapter 2 data
214 	void setChapter2Counter(uint32 index, int32 val);
215 	int32 getChapter2Counter(uint32 index) const;
getChapter2FrameIndexOffset()216 	int32 getChapter2FrameIndexOffset() const { return _chapter2FrameIndexOffset; }
setChapter2FrameIndexOffset(int32 val)217 	void setChapter2FrameIndexOffset(int32 val) { _chapter2FrameIndexOffset = val; }
getChapter2ActorIndex()218 	ActorIndex getChapter2ActorIndex() const { return _chapter2ActorIndex; }
setChapter2ActorIndex(ActorIndex val)219 	void setChapter2ActorIndex(ActorIndex val) { _chapter2ActorIndex = val; }
220 
221 	// Misc
getActorUpdateStatusEnabledCounter()222 	int32 getActorUpdateStatusEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
setActorUpdateStatusEnabledCounter(int32 val)223 	void setActorUpdateStatusEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }
224 
225 	// Screen updates
getEventUpdate()226 	int32 getEventUpdate() { return _eventUpdate; }
setEventUpdate(int32 val)227 	void setEventUpdate(int32 val) { _eventUpdate = val; }
getNextScreenUpdate()228 	uint32 getNextScreenUpdate() { return _nextScreenUpdate; }
setNextScreenUpdate(uint32 nextScreenUpdate)229 	void setNextScreenUpdate(uint32 nextScreenUpdate) { _nextScreenUpdate = nextScreenUpdate; }
230 
231 private:
232 	uint32          _ambientFlags[15];
233 	uint32          _ambientTicks[15];
234 	Common::Point   _globalPoint; // global point
235 	bool            _flagSkipScriptProcessing;
236 	bool            _flagIsEncounterRunning;
237 	int32           _playerIndex;
238 	Common::Point   _sceneCoords;
239 	int16           _sceneOffset;
240 	int16           _sceneOffsetAdd;
241 	ResourceId      _cursorResources[13];
242 	ResourceId      _sceneFonts[3];
243 	uint32          _chapter2Data1[5];
244 	int32           _smallCurUp;
245 	int32           _smallCurDown;
246 	ResourceId      _encounterFrameBg;
247 	bool            _flagSkipDrawScene;
248 	int32           _matteVar1;
249 	bool            _flagActorUpdateEnabledCheck;
250 	bool            _matteInitialized;
251 	bool            _mattePlaySound;
252 	int32           _currentScreenUpdatesCount;
253 	uint32          _chapter2Data2[9];
254 	int32           _chapter2Counters[8];
255 	int32           _chapter2Data3[23];
256 	int32           _chapter2FrameIndexOffset;
257 	ActorIndex      _chapter2ActorIndex;
258 	int32           _eventUpdate;
259 	uint32          _chapter2Data4[18];
260 	int32           _actorUpdateStatusEnabledCounter;
261 	uint32          _chapter2Data5[9];
262 	bool            _flagEncounterDisablePlayerOnExit;
263 	bool            _flag1;
264 	uint32          _nextScreenUpdate;
265 	//byte            _moviesViewed[196];
266 	bool            _flagActorUpdateStatus15Check;
267 
268 	// Non-saved data
269 	bool            _flag2;
270 	bool            _flag3;
271 	bool            _flagScene1;
272 	bool            _flagRedraw;
273 
274 	int16           _matteBarHeight;
275 	uint32          _matteVar2;
276 
277 	friend class CrowsData;
278 };
279 
280 } // End of namespace Asylum
281 
282 #endif // ASYLUM_RESOURCES_DATA_H
283