aboutsummaryrefslogtreecommitdiff
path: root/engines/tony/globals.h
blob: 1cff57fd166b76321c4308888a212f562ca65f4a (plain)
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
282
283
284
285
286
287
288
/* 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 2
 * 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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *
 */

#ifndef TONY_GLOBALS
#define TONY_GLOBALS

#include "common/savefile.h"
#include "tony/gfxengine.h"
#include "tony/input.h"
#include "tony/inventory.h"
#include "tony/loc.h"
#include "tony/tonychar.h"
#include "tony/mpal/mpal.h"
#include "tony/mpal/mpaldll.h"

namespace Tony {

#define AMBIANCE_CRICKETS 1
#define AMBIANCE_CRICKETSMUFFLED 2
#define AMBIANCE_CRICKETSWIND 3
#define AMBIANCE_CRICKETSWIND1 4
#define AMBIANCE_WIND 5
#define AMBIANCE_SEA 6
#define AMBIANCE_SEAHALFVOLUME 7

struct CharacterStruct {
	uint32 _code;
	RMItem *_item;
	byte _r, _g, _b;
	int _talkPattern;
	int _standPattern;
	int _startTalkPattern, _endTalkPattern;
	int _numTexts;

	void save(Common::OutSaveFile *f) {
		f->writeUint32LE(_code);
		f->writeUint32LE(0);
		f->writeByte(_r);
		f->writeByte(_g);
		f->writeByte(_b);
		f->writeUint32LE(_talkPattern);
		f->writeUint32LE(_standPattern);
		f->writeUint32LE(_startTalkPattern);
		f->writeUint32LE(_endTalkPattern);
		f->writeUint32LE(_numTexts);
	}

	void load(Common::InSaveFile *f) {
		_code = f->readUint32LE();
		f->readUint32LE();
		_item = NULL;
		_r = f->readByte();
		_g = f->readByte();
		_b = f->readByte();
		_talkPattern = f->readUint32LE();
		_standPattern = f->readUint32LE();
		_startTalkPattern = f->readUint32LE();
		_endTalkPattern = f->readUint32LE();
		_numTexts = f->readUint32LE();
	}
};

struct MCharacterStruct {
	uint32 _code;
	RMItem *_item;
	byte _r, _g, _b;
	int _x, _y;
	int _numTalks[10];
	int _curGroup;
	int _numTexts;
	bool _bInTexts;
	int _curTalk;
	bool _bAlwaysBack;

	void save(Common::OutSaveFile *f) {
		f->writeUint32LE(_code);
		f->writeUint32LE(0);
		f->writeByte(_r);
		f->writeByte(_g);
		f->writeByte(_b);
		f->writeUint32LE(_x);
		f->writeUint32LE(_y);
		for (int i = 0; i < 10; ++i)
			f->writeUint32LE(_numTalks[i]);
		f->writeUint32LE(_curGroup);
		f->writeUint32LE(_numTexts);
		f->writeByte(_bInTexts);
		f->writeUint32LE(_curTalk);
		f->writeByte(_bAlwaysBack);
	}

	void load(Common::InSaveFile *f) {
		_code = f->readUint32LE();
		f->readUint32LE();
		_item = NULL;
		_r = f->readByte();
		_g = f->readByte();
		_b = f->readByte();
		_x = f->readUint32LE();
		_y = f->readUint32LE();
		for (int i = 0; i < 10; ++i)
			_numTalks[i] = f->readUint32LE();
		_curGroup = f->readUint32LE();
		_numTexts = f->readUint32LE();
		_bInTexts = f->readByte();
		_curTalk = f->readUint32LE();
		_bAlwaysBack = f->readByte();
	}
};

struct ChangedHotspotStruct {
	uint32 _dwCode;
	uint32 _nX, _nY;

	void save(Common::OutSaveFile *f) {
		f->writeUint32LE(_dwCode);
		f->writeUint32LE(_nX);
		f->writeUint32LE(_nY);
	}

	void load(Common::InSaveFile *f) {
		_dwCode = f->readUint32LE();
		_nX = f->readUint32LE();
		_nY = f->readUint32LE();
	}
};

/**
 * Description of a call to a custom function.
 */
typedef struct {
	int _nCf;
	int _arg1, _arg2, _arg3, _arg4;
} CfCall;

typedef CfCall *LpCfCall;

struct CoroutineMutex {
	CoroutineMutex() : _eventId(0), _ownerPid(0), _lockCount(0) { }

	uint32 _eventId;
	uint32 _ownerPid;
	uint32 _lockCount;
};

/****************************************************************************\
*       Global variables
\****************************************************************************/

/**
 * Globals class
 */
class Globals {
public:
	Globals();

	Common::String _nextMusic;
	bool _nextLoop;
	int _nextChannel;
	int _nextSync;
	int _curChannel;
	int _flipflop;
	CharacterStruct _character[16];
	MCharacterStruct _mCharacter[10];
	ChangedHotspotStruct _changedHotspot[256];
	bool _isMChar[16];
	bool _bAlwaysDisplay;
	RMPoint _saveTonyPos;
	int _saveTonyLoc;
	RMTextDialog *_curBackText;
	bool _bTonyIsSpeaking;
	int _curChangedHotspot;
	bool _bCfgInvLocked;
	bool _bCfgInvNoScroll;
	bool _bCfgTimerizedText;
	bool _bCfgInvUp;
	bool _bCfgAnni30;
	bool _bCfgAntiAlias;
	bool _bShowSubtitles;
	bool _bCfgTransparence;
	bool _bCfgInterTips;
	bool _bCfgDubbing;
	bool _bCfgMusic;
	bool _bCfgSFX;
	int _nCfgTonySpeed;
	int _nCfgTextSpeed;
	int _nCfgDubbingVolume;
	int _nCfgMusicVolume;
	int _nCfgSFXVolume;
	bool _bSkipSfxNoLoop;
	bool _bIdleExited;
	bool _bNoBullsEye;
	int _curDialog;
	int _curSoundEffect;
	bool _bFadeOutStop;

	RMTony *_tony;
	RMPointer *_pointer;
	RMGameBoxes *_boxes;
	RMLocation *_loc;
	RMInventory *_inventory;
	RMInput *_input;
	RMGfxEngine *_gfxEngine;

	void (*EnableGUI)();
	void (*DisableGUI)();

	uint32 _dwTonyNumTexts;
	bool _bTonyInTexts;
	bool _bStaticTalk;
	RMTony::CharacterTalkType _nTonyNextTalkType;

	RMPoint _startLocPos[256];
	CoroutineMutex _mut[10];

	bool _bSkipIdle;
	uint32 _hSkipIdle;

	int _lastMusic, _lastTappeto;

	int _ambiance[200];
	RMPoint _fullScreenMessagePt;
	int _fullScreenMessageLoc;

	/**
	 * @defgroup MPAL variables
	 */
	uint32              _mpalError;
	LPITEMIRQFUNCTION   _lpiifCustom;
	LPLPCUSTOMFUNCTION  _lplpFunctions;
	Common::String     *_lplpFunctionStrings;
	uint16              _nObjs;
	uint16              _nVars;
	MpalHandle          _hVars;
	LpMpalVar           _lpmvVars;
	uint16              _nMsgs;
	MpalHandle          _hMsgs;
	LpMpalMsg           _lpmmMsgs;
	uint16              _nDialogs;
	MpalHandle          _hDialogs;
	LpMpalDialog        _lpmdDialogs;
	uint16              _nItems;
	MpalHandle          _hItems;
	LpMpalItem          _lpmiItems;
	uint16              _nLocations;
	MpalHandle          _hLocations;
	LpMpalLocation      _lpmlLocations;
	uint16              _nScripts;
	MpalHandle          _hScripts;
	LpMpalScript        _lpmsScripts;
	Common::File        _hMpr;
	uint16              _nResources;
	uint32             *_lpResources;
	bool                _bExecutingAction;
	bool                _bExecutingDialog;
	uint32              _nPollingLocations[MAXPOLLINGLOCATIONS];
	uint32              _hEndPollingLocations[MAXPOLLINGLOCATIONS];
	uint32              _pollingThreads[MAXPOLLINGLOCATIONS];
	uint32              _hAskChoice;
	uint32              _hDoneChoice;
	uint32              _nExecutingAction;
	uint32              _nExecutingDialog;
	uint32              _nExecutingChoice;
	uint32              _nSelectedChoice;
};

} // End of namespace Tony

#endif // TONY_GLOBALS