File: data.h

package info (click to toggle)
scummvm 2.9.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 450,268 kB
  • sloc: cpp: 4,297,604; asm: 28,322; python: 12,901; sh: 11,219; java: 8,477; xml: 7,843; perl: 2,633; ansic: 2,465; yacc: 1,670; javascript: 1,020; makefile: 933; lex: 578; awk: 275; objc: 82; sed: 11; php: 1
file content (281 lines) | stat: -rw-r--r-- 9,859 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
/* ScummVM - Graphic Adventure Engine
 *
 * ScummVM is the legal property of its developers, whose names
 * are too numerous to list here. Please refer to the COPYRIGHT
 * file distributed with this source distribution.
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.

 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.

 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 */

#ifndef ASYLUM_RESOURCES_DATA_H
#define ASYLUM_RESOURCES_DATA_H

#include "common/rect.h"
#include "common/serializer.h"

#include "engines/asylum/shared.h"

namespace Asylum {

//////////////////////////////////////////////////////////////////////////
// Flags
enum GlobalFlag {
	kFlag1,
	kFlag2,
	kFlag3,
	kFlagRedraw,
	kFlagSkipDrawScene,
	kFlagSceneRectChanged,
	kFlagScene1,
	kFlagSkipScriptProcessing,
	kFlagIsEncounterRunning,
	kFlagEncounterDisablePlayerOnExit,
	kFlagActorUpdateEnabledCheck,
	kFlagActorUpdateStatus15Check
};

class SharedData;

class CrowsData {
public:
	CrowsData(SharedData *sharedData) : /* _sharedData(sharedData), */_data() { memset(_data, 0, sizeof(_data)); }
	int32 &operator [](uint32 index);
private:
	int32 _data[84];
	//SharedData *_sharedData;
};

/**
 * Shared data
 * -----------
 *  uint32 {1}      - actorEnableForStatus7
 *
 *  uint32 {1}      - global direction
 *  uint32 {1}      - lastScreenUpdate
 *
 *  uint32 {1}      - actor update counter
 *
 *  uint32 {1}      - matte bar height
 *
 *  Lots of data
 *
 *  -- Scene data (reset on scene load)
 *  uint32 {15}    - ambient flags
 *  uint32 {15}    - ambient ticks
 *  uint32 {1}     - UNUSED
 *  uint32 {1}     - UNUSED (scene updateScreen calls count)
 *  -- Script queue (stored in ScriptManager)
 *  uint32 {1}     - global Object X
 *  uint32 {1}     - global Object Y
 *  uint32 {1}     - Skip script processing flag
 *  uint32 {1}     - Encounter running flag
 *  uint32 {1}     - Player ActorIndex
 *  uint32 {1}     - scene xLeft
 *  uint32 {1}     - scene yTop
 *  uint32 {1}     - scene offset
 *  uint32 {1}     - scene offsetAdd
 *  uint32 {1}     - UNUSED
 *  uint32 {13}    - cursor resources
 *  uint32 {3}     - scene fonts (3)
 *  uint32 {5}     - Chapter2 actor data (part 1)
 *  uint32 {1}     - small cursor Up
 *  uint32 {1}     - small cursor Down
 *  uint32 {1}     - Encounter frame background
 *  uint32 {1}     - Flag skip draw scene
 *  uint32 {1}     - matte var 1
 *  uint32 {1}     - actorUpdateEnabledCheck
 *  uint32 {1}     - matte Initialized
 *  uint32 {1}     - matte playSound
 *  uint32 {1}     - currentScreenUpdatesCount
 *  uint32 {9}     - Chapter2 actor data (part 2)
 *  uint32 {1}     - Chapter 2 counter 1
 *  uint32 {1}     - Chapter 2 counter 2
 *  uint32 {1}     - Chapter 2 counter 3
 *  uint32 {1}     - Chapter 2 counter 4
 *  uint32 {23}    - Chapter2 actor data (part 3)
 *  uint32 {1}     - Special 2 counter 5
 *  uint32 {1}     - Chapter 2 frameIndex Offset
 *  uint32 {1}     - Chapter 2 Actor index
 *  uint32 {1}     - Event update flag
 *  uint32 {1}     - Chapter 2 counter 6
 *  uint32 {1}     - Chapter 2 counter 7
 *  uint32 {1}     - Chapter 2 counter 8
 *  uint32 {18}    - Chapter2 actor data (part 4)
 *  uint32 {1}     - actorUpdateStatusEnabledCounter
 *  uint32 {9}     - Chapter2 actor data (part 5)
 *  uint32 {1}     - Encounter disablePlayerOnExit
 *  uint32 {1}     - Scene flag 1
 *  uint32 {1}     - nextScreenUpdate
 *  uint32 {49}    - Viewed movies
 *  uint32 {1}     - actorUpdateStatus15Check
 *  -- Skip opening movie command line flag (not used)
 *  -- Encounter flag 3
 *  uint32 {1}     - Flag 2
 *  uint32 {1}     - Flag Redraw
 *  -- scripts (reset on scene load)
 *  -- polygons (reset on scene load)
 */
class SharedData : public Common::Serializable {
public:
	SharedData();
	virtual ~SharedData() {};

	// Public variables
	int32           cdNumber;
	uint32          movieIndex;
	uint32          sceneCounter;
	Common::Point   vector1;
	Common::Point   vector2;
	bool            actorEnableForStatus7;
	ActorDirection  globalDirection;
	CrowsData       crowsData;

	// Used by Actor::enableActorsChapter2 (and maybe others)
	void resetChapter2Data();
	void reset();  // called during game reset

	// Flags
	bool getFlag(GlobalFlag flag) const;
	void setFlag(GlobalFlag flag, bool state);

	// Serializer
	void saveLoadAmbientSoundData(Common::Serializer &s);
	void saveLoadWithSerializer(Common::Serializer &s);

	//////////////////////////////////////////////////////////////////////////
	// Accessors
	//////////////////////////////////////////////////////////////////////////

	// Ambient sound data
	uint32 getAmbientTick(uint32 index) const;
	void setAmbientTick(uint32 index, uint32 val);
	uint32 getAmbientFlag(uint32 index) const;
	void setAmbientFlag(uint32 index, uint32 val);
	void resetAmbientFlags();

	/**
	 * Return the index of the player actor
	 */
	ActorIndex getPlayerIndex() { return _playerIndex; }

	/**
	 * Sets the player actor index.
	 *
	 * @param index index of the player actor
	 */
	void setPlayerIndex(ActorIndex index) { _playerIndex = index; }

	// Coordinates
	Common::Point getGlobalPoint() { return _globalPoint; }
	void setGlobalPoint(const Common::Point &point) { _globalPoint = point; }
	Common::Point getSceneCoords() { return _sceneCoords; }
	void setSceneCoords(const Common::Point &point) { _sceneCoords = point; }
	int16 getSceneOffset() { return _sceneOffset; }
	void setSceneOffset(int16 sceneOffset) { _sceneOffset = sceneOffset; }
	int16 getSceneOffsetAdd() { return _sceneOffsetAdd; }
	void setSceneOffsetAdd(int16 sceneOffsetAdd) { _sceneOffsetAdd = sceneOffsetAdd; }

	// Saved scene data
	void saveCursorResources(ResourceId *resources, uint32 size);
	void loadCursorResources(ResourceId *resources, uint32 size) const;
	void saveSceneFonts(ResourceId font1, ResourceId font2, ResourceId font3);
	void loadSceneFonts(ResourceId *font1, ResourceId *font2, ResourceId *font3) const;
	void saveSmallCursor(int32 smallCurUp, int32 smallCurDown);
	void loadSmallCursor(int32 *smallCurUp, int32 *smallCurDown) const;
	void saveEncounterFrameBackground(ResourceId encounterFrameBg) { _encounterFrameBg = encounterFrameBg; }
	void loadEncounterFrameBackground(ResourceId *encounterFrameBg) { *encounterFrameBg = _encounterFrameBg; }

	// Matte data
	int32 getMatteVar1() const { return _matteVar1; }
	void setMatteVar1(int32 val) { _matteVar1 = val; }
	uint32 getMatteVar2() const { return _matteVar2; }
	void setMatteVar2(uint32 val) { _matteVar2 = val; }
	int16 getMatteBarHeight() const { return _matteBarHeight; }
	void setMatteBarHeight(int16 val) { _matteBarHeight = val; }
	bool getMatteInitialized() const { return _matteInitialized; }
	void setMatteInitialized(bool val) { _matteInitialized = val; }
	bool getMattePlaySound() const { return _mattePlaySound; }
	void setMattePlaySound(bool val) { _mattePlaySound = val; }

	// Chapter 2 data
	void setChapter2Counter(uint32 index, int32 val);
	int32 getChapter2Counter(uint32 index) const;
	int32 getChapter2FrameIndexOffset() const { return _chapter2FrameIndexOffset; }
	void setChapter2FrameIndexOffset(int32 val) { _chapter2FrameIndexOffset = val; }
	ActorIndex getChapter2ActorIndex() const { return _chapter2ActorIndex; }
	void setChapter2ActorIndex(ActorIndex val) { _chapter2ActorIndex = val; }

	// Misc
	int32 getActorUpdateStatusEnabledCounter() { return _actorUpdateStatusEnabledCounter; }
	void setActorUpdateStatusEnabledCounter(int32 val) { _actorUpdateStatusEnabledCounter = val; }

	// Screen updates
	int32 getEventUpdate() { return _eventUpdate; }
	void setEventUpdate(int32 val) { _eventUpdate = val; }
	uint32 getNextScreenUpdate() { return _nextScreenUpdate; }
	void setNextScreenUpdate(uint32 nextScreenUpdate) { _nextScreenUpdate = nextScreenUpdate; }

private:
	uint32          _ambientFlags[15];
	uint32          _ambientTicks[15];
	Common::Point   _globalPoint; // global point
	bool            _flagSkipScriptProcessing;
	bool            _flagIsEncounterRunning;
	int32           _playerIndex;
	Common::Point   _sceneCoords;
	int16           _sceneOffset;
	int16           _sceneOffsetAdd;
	ResourceId      _cursorResources[13];
	ResourceId      _sceneFonts[3];
	uint32          _chapter2Data1[5];
	int32           _smallCurUp;
	int32           _smallCurDown;
	ResourceId      _encounterFrameBg;
	bool            _flagSkipDrawScene;
	int32           _matteVar1;
	bool            _flagActorUpdateEnabledCheck;
	bool            _matteInitialized;
	bool            _mattePlaySound;
	int32           _currentScreenUpdatesCount;
	uint32          _chapter2Data2[9];
	int32           _chapter2Counters[8];
	int32           _chapter2Data3[23];
	int32           _chapter2FrameIndexOffset;
	ActorIndex      _chapter2ActorIndex;
	int32           _eventUpdate;
	uint32          _chapter2Data4[18];
	int32           _actorUpdateStatusEnabledCounter;
	uint32          _chapter2Data5[9];
	bool            _flagEncounterDisablePlayerOnExit;
	bool            _flag1;
	uint32          _nextScreenUpdate;
	//byte            _moviesViewed[196];
	bool            _flagActorUpdateStatus15Check;

	// Non-saved data
	bool            _flag2;
	bool            _flag3;
	bool            _flagScene1;
	bool            _flagRedraw;

	int16           _matteBarHeight;
	uint32          _matteVar2;

	friend class CrowsData;
};

} // End of namespace Asylum

#endif // ASYLUM_RESOURCES_DATA_H