ScummVM API documentation
globals.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 DGDS_GLOBALS_H
23#define DGDS_GLOBALS_H
24
25#include "common/types.h"
26#include "common/array.h"
27
28#include "dgds/dgds.h"
29
30namespace Dgds {
31
32class Clock;
33
44class Global {
45public:
46 Global(uint16 num) : _num(num) {}
47 virtual ~Global() {}
48 virtual int16 get() = 0;
49 virtual int16 set(int16 val) = 0;
50 virtual uint16 getNum() const { return _num; }
51 virtual void setRaw(int16 val) = 0;
52private:
53 uint16 _num;
54};
55
56/*
57 This is a bit of a misnomer - the global is readonly during play,
58 but it can be set by load/save or restart operations
59*/
60template<typename T> class ReadOnlyGlobal : public Global {
61public:
62 ReadOnlyGlobal(uint16 num, T *val) : Global(num), _val(val) {}
63 int16 get() override { return *_val; }
64 int16 set(int16 val) override { return *_val; }
65 void setRaw(int16 val) override { *_val = val; }
66private:
67 T *_val;
68};
69
70template<typename T> class ReadWriteGlobal : public Global {
71public:
72 ReadWriteGlobal(uint16 num, T *val) : Global(num), _val(val) {}
73 int16 get() override { return *_val; }
74 int16 set(int16 val) override { *_val = val; return *_val; }
75 void setRaw(int16 val) override { *_val = val; }
76private:
77 T *_val;
78};
79
80
81class Globals {
82public:
83 Globals(Clock &clock);
84 virtual ~Globals();
85
86 int16 getGlobal(uint16 num);
87 int16 setGlobal(uint16 num, int16 val);
88
89 virtual Common::Error syncState(Common::Serializer &s); // note: children should call parent first
90 Common::Array<Global *> &getAllGlobals() { return _globals; }
91
92 int16 getGameMinsToAddOnUse() const { return _gameMinsToAddOnUse; }
93 int16 getGameMinsToAddOnPickUp() const { return _gameMinsToAddOnPickUp; }
94 int16 getGameMinsToAddOnLook() const { return _gameMinsToAddOnLook; }
95 int16 getGameMinsToAddOnDrop() const { return _gameMinsToAddOnDrop; }
96 int16 getGameMinsToAddOnObjInteraction() const { return _gameMinsToAddOnObjInteraction; }
97 int16 getGameIsInteractiveGlobal() { return _gameIsInteractiveGlobal; }
98
99 void setLastSceneNum(int16 num) { _lastOpcode1SceneChangeNum = num; }
100 int16 getLastSceneNum() const { return _lastOpcode1SceneChangeNum; }
101
102protected:
103
104 // these ones seem to be common between games
105 int16 _lastOpcode1SceneChangeNum;
106 int16 _sceneOp12SceneNum;
107 int16 _currentSelectedItem;
108 int16 _gameMinsToAddOnUse;
109 int16 _gameMinsToAddOnPickUp;
110 int16 _gameMinsToAddOnLook;
111 int16 _gameMinsToAddOnDrop;
112 int16 _gameMinsToAddOnObjInteraction;
113 int16 _gameIsInteractiveGlobal; // used to decide if the game can start a "meanwhile" sequence
114 int16 _sceneOpcode15FromScene;
115 int16 _sceneOpcode15ToScene;
116
118};
119
120// TODO: Work out what this table is even for..
122public:
124 uint16 getValueFromTable();
125
126 int16 _row;
127 int16 _col;
128 int16 _divBy4;
129 int16 _output;
130
131private:
132 int getOffsetForVal(uint16 val) const;
133};
134
135
136class DragonGlobals : public Globals {
137public:
138 DragonGlobals(Clock &clock);
139
140 int16 getArcadeState() const { return _arcadeState; }
141 void setArcadeState(int16 state) { _arcadeState = state; }
142
143private:
144 // Dragon-specific globals
145 int16 _sceneOpcode100Var;
146 int16 _arcadeState;
147 int16 _opcode106EndMinutes;
148 DragonDataTable _table;
149
150 Common::Error syncState(Common::Serializer &s) override;
151};
152
153class HocGlobals : public Globals {
154public:
155 HocGlobals(Clock &clock);
156
157 int16 getSheckels() const { return _sheckels; }
158
159 int16 getShellBet() const { return _shellBet; }
160
161 int16 getShellPea() const { return _shellPea; }
162 void setShellPea(int16 pea) { _shellPea = pea; }
163
164 int16 getNativeGameState() const { return _nativeGameState; }
165 void setNativeGameState(int16 state) { _nativeGameState = state; }
166
167 int16 getTrainState() const { return _trainState; }
168 void setTrainState(int16 state) { _trainState = state; }
169
170 int16 getIntroState() const { return _introState; }
171 void setIntroState(int16 state) { _introState = state; }
172
173private:
174 // HoC-specific globals
175 int16 _introState;
176 int16 _startScene;
177 int16 _trainState;
178 int16 _shellPea;
179 int16 _shellBet;
180 int16 _sheckels;
181 int16 _palFade;
182 int16 _unk46;
183 int16 _unk47;
184 int16 _tankState;
185 int16 _nativeGameState; // state for the shell game, tank game, etc.
186 int16 _tankFinished;
187 int16 _currentCharacter;
188 int16 _currentCharacter2;
189 int16 _partnerDlgDlgNum; // Dialog shown when right-clicking
190 int16 _partnerDlgFileNum; // on character swap button
191 int16 _unk55;
192
193 Common::Error syncState(Common::Serializer &s) override;
194};
195
196class WillyGlobals : public Globals {
197public:
198 WillyGlobals(Clock &clock);
199
200 void setPalFade(int16 val) { _palFade = val; }
201 int16 getPalFade() const { return _palFade; }
202
203 void setDroppedItemNum(int16 val) { _droppedItemNum = val; }
204 bool isHideMouseCursor() const { return _hideMouseCursor != 0; }
205 bool isDrawTimeSkipButtons() const { return _invDrawTimeSkipButtons != 0; }
206
207private:
208 // Willy-specific globals
209 int16 _trouble;
210 int16 _money;
211 int16 _invDrawTimeSkipButtons;
212 int16 _hideMouseCursor;
213 int16 _unk74;
214 int16 _unk75;
215 int16 _palFade;
216 int16 _droppedItemNum;
217 int16 _characterStance;
218 int16 _characterPos;
219 int16 _unk81;
220 int16 _unk82;
221
222 Common::Error syncState(Common::Serializer &s) override;
223};
224
225} // end namespace Dgds
226
227#endif // DGDS_GLOBALS_H
Definition: array.h:52
Definition: error.h:81
Definition: serializer.h:80
Definition: clock.h:38
Definition: globals.h:121
Definition: globals.h:136
Definition: globals.h:44
Definition: globals.h:81
Definition: globals.h:153
Definition: globals.h:60
Definition: globals.h:70
Definition: globals.h:196