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 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447
|
/* ResidualVM - A 3D game interpreter
*
* ResidualVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the AUTHORS
* 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 VARIABLES_H_
#define VARIABLES_H_
#include "common/hashmap.h"
#include "common/hash-str.h"
#include "common/savefile.h"
#include "common/serializer.h"
#include "engines/myst3/myst3.h"
namespace Myst3 {
class Database;
// View type
enum ViewType {
kCube = 1,
kFrame = 2,
kMenu = 3
};
#define DECLARE_VAR(name) \
void set##name(int32 value) { engineSet(#name, value); } \
int32 get##name() { return engineGet(#name); } \
bool hasVar##name() { return _varDescriptions.contains(#name); }
class GameState {
public:
GameState(const Common::Platform platform, Database *database);
virtual ~GameState();
void newGame();
bool load(Common::InSaveFile *saveFile);
bool save(Common::OutSaveFile *saveFile);
int32 getVar(uint16 var);
void setVar(uint16 var, int32 value);
bool evaluate(int16 condition);
int32 valueOrVarValue(int16 value);
const Common::String describeVar(uint16 var);
const Common::String describeCondition(int16 condition);
DECLARE_VAR(CursorTransparency)
DECLARE_VAR(ProjectorAngleX)
DECLARE_VAR(ProjectorAngleY)
DECLARE_VAR(ProjectorAngleZoom)
DECLARE_VAR(ProjectorAngleBlur)
DECLARE_VAR(DraggedWeight)
DECLARE_VAR(DragEnded)
DECLARE_VAR(DragLeverSpeed)
DECLARE_VAR(DragPositionFound)
DECLARE_VAR(DragLeverPositionChanged)
DECLARE_VAR(LocationAge)
DECLARE_VAR(LocationRoom)
DECLARE_VAR(LocationNode)
DECLARE_VAR(BookSavedAge)
DECLARE_VAR(BookSavedRoom)
DECLARE_VAR(BookSavedNode)
DECLARE_VAR(MenuSavedAge)
DECLARE_VAR(MenuSavedRoom)
DECLARE_VAR(MenuSavedNode)
DECLARE_VAR(SecondsCountdown)
DECLARE_VAR(TickCountdown)
DECLARE_VAR(SweepEnabled)
DECLARE_VAR(SweepValue)
DECLARE_VAR(SweepStep)
DECLARE_VAR(SweepMin)
DECLARE_VAR(SweepMax)
DECLARE_VAR(InputMousePressed)
DECLARE_VAR(InputEscapePressed)
DECLARE_VAR(InputTildePressed)
DECLARE_VAR(InputSpacePressed)
DECLARE_VAR(HotspotActiveRect)
DECLARE_VAR(WaterEffectRunning)
DECLARE_VAR(WaterEffectActive)
DECLARE_VAR(WaterEffectSpeed)
DECLARE_VAR(WaterEffectAttenuation)
DECLARE_VAR(WaterEffectFrequency)
DECLARE_VAR(WaterEffectAmpl)
DECLARE_VAR(WaterEffectMaxStep)
DECLARE_VAR(WaterEffectAmplOffset)
DECLARE_VAR(LavaEffectActive)
DECLARE_VAR(LavaEffectSpeed)
DECLARE_VAR(LavaEffectAmpl)
DECLARE_VAR(LavaEffectStepSize)
DECLARE_VAR(MagnetEffectActive)
DECLARE_VAR(MagnetEffectSpeed)
DECLARE_VAR(MagnetEffectUnk1)
DECLARE_VAR(MagnetEffectUnk2)
DECLARE_VAR(MagnetEffectSound)
DECLARE_VAR(MagnetEffectNode)
DECLARE_VAR(MagnetEffectUnk3)
DECLARE_VAR(ShakeEffectAmpl)
DECLARE_VAR(ShakeEffectTickPeriod)
DECLARE_VAR(RotationEffectSpeed)
DECLARE_VAR(SunspotIntensity)
DECLARE_VAR(SunspotColor)
DECLARE_VAR(SunspotRadius)
DECLARE_VAR(AmbiantFadeOutDelay)
DECLARE_VAR(AmbiantPreviousFadeOutDelay)
DECLARE_VAR(AmbientOverrideFadeOutDelay)
DECLARE_VAR(SoundScriptsSuspended)
DECLARE_VAR(SoundNextMultipleSounds)
DECLARE_VAR(SoundNextIsChoosen)
DECLARE_VAR(SoundNextId)
DECLARE_VAR(SoundNextIsLast)
DECLARE_VAR(SoundScriptsTimer)
DECLARE_VAR(SoundScriptsPaused)
DECLARE_VAR(SoundScriptFadeOutDelay)
DECLARE_VAR(CursorLocked)
DECLARE_VAR(CursorHidden)
DECLARE_VAR(CameraPitch)
DECLARE_VAR(CameraHeading)
DECLARE_VAR(CameraMinPitch)
DECLARE_VAR(CameraMaxPitch)
DECLARE_VAR(MovieStartFrame)
DECLARE_VAR(MovieEndFrame)
DECLARE_VAR(MovieVolume1)
DECLARE_VAR(MovieVolume2)
DECLARE_VAR(MovieOverrideSubtitles)
DECLARE_VAR(MovieConditionBit)
DECLARE_VAR(MoviePreloadToMemory)
DECLARE_VAR(MovieScriptDriven)
DECLARE_VAR(MovieNextFrameSetVar)
DECLARE_VAR(MovieNextFrameGetVar)
DECLARE_VAR(MovieStartFrameVar)
DECLARE_VAR(MovieEndFrameVar)
DECLARE_VAR(MovieForce2d)
DECLARE_VAR(MovieVolumeVar)
DECLARE_VAR(MovieSoundHeading)
DECLARE_VAR(MoviePanningStrenght)
DECLARE_VAR(MovieSynchronized)
DECLARE_VAR(MovieOverrideCondition)
DECLARE_VAR(MovieUVar)
DECLARE_VAR(MovieVVar)
DECLARE_VAR(MovieOverridePosition)
DECLARE_VAR(MovieOverridePosU)
DECLARE_VAR(MovieOverridePosV)
DECLARE_VAR(MovieAdditiveBlending)
DECLARE_VAR(MovieTransparency)
DECLARE_VAR(MovieTransparencyVar)
DECLARE_VAR(MoviePlayingVar)
DECLARE_VAR(MovieStartSoundId)
DECLARE_VAR(MovieStartSoundVolume)
DECLARE_VAR(MovieStartSoundHeading)
DECLARE_VAR(MovieStartSoundAttenuation)
DECLARE_VAR(MovieUseBackground)
DECLARE_VAR(CameraSkipAnimation)
DECLARE_VAR(MovieAmbiantScriptStartFrame)
DECLARE_VAR(MovieAmbiantScript)
DECLARE_VAR(MovieScriptStartFrame)
DECLARE_VAR(MovieScript)
DECLARE_VAR(CameraMoveSpeed)
DECLARE_VAR(TransitionSound)
DECLARE_VAR(TransitionSoundVolume)
DECLARE_VAR(LocationNextNode)
DECLARE_VAR(LocationNextRoom)
DECLARE_VAR(LocationNextAge)
DECLARE_VAR(BallPosition)
DECLARE_VAR(BallFrame)
DECLARE_VAR(BallLeverLeft)
DECLARE_VAR(BallLeverRight)
DECLARE_VAR(BallDoorOpen)
DECLARE_VAR(ProjectorX)
DECLARE_VAR(ProjectorY)
DECLARE_VAR(ProjectorZoom)
DECLARE_VAR(ProjectorBlur)
DECLARE_VAR(ProjectorAngleXOffset)
DECLARE_VAR(ProjectorAngleYOffset)
DECLARE_VAR(ProjectorAngleZoomOffset)
DECLARE_VAR(ProjectorAngleBlurOffset)
DECLARE_VAR(JournalAtrusState)
DECLARE_VAR(JournalSaavedroState)
DECLARE_VAR(JournalSaavedroClosed)
DECLARE_VAR(JournalSaavedroOpen)
DECLARE_VAR(JournalSaavedroLastPage)
DECLARE_VAR(JournalSaavedroChapter)
DECLARE_VAR(JournalSaavedroPageInChapter)
DECLARE_VAR(TeslaAllAligned)
DECLARE_VAR(TeslaTopAligned)
DECLARE_VAR(TeslaMiddleAligned)
DECLARE_VAR(TeslaBottomAligned)
DECLARE_VAR(TeslaMovieStart)
DECLARE_VAR(AmateriaSecondsCounter)
DECLARE_VAR(AmateriaTicksCounter)
DECLARE_VAR(ResonanceRingsSolved)
DECLARE_VAR(PinballRemainingPegs)
DECLARE_VAR(OuterShieldUp)
DECLARE_VAR(InnerShieldUp)
DECLARE_VAR(SaavedroStatus)
DECLARE_VAR(BookStateTomahna)
DECLARE_VAR(BookStateReleeshahn)
DECLARE_VAR(SymbolCode2Solved)
DECLARE_VAR(SymbolCode1AllSolved)
DECLARE_VAR(SymbolCode1CurrentSolved)
DECLARE_VAR(SymbolCode1TopSolved)
DECLARE_VAR(SymbolCode1LeftSolved)
DECLARE_VAR(SymbolCode1RightSolved)
DECLARE_VAR(SoundVoltaicUnk540)
DECLARE_VAR(SoundEdannaUnk587)
DECLARE_VAR(SoundAmateriaUnk627)
DECLARE_VAR(SoundAmateriaUnk930)
DECLARE_VAR(SoundEdannaUnk1031)
DECLARE_VAR(SoundVoltaicUnk1146)
DECLARE_VAR(ZipModeEnabled)
DECLARE_VAR(SubtitlesEnabled)
DECLARE_VAR(WaterEffects)
DECLARE_VAR(TransitionSpeed)
DECLARE_VAR(MouseSpeed)
DECLARE_VAR(DialogResult)
DECLARE_VAR(MenuEscapePressed)
DECLARE_VAR(MenuNextAction)
DECLARE_VAR(MenuLoadBack)
DECLARE_VAR(MenuSaveBack)
DECLARE_VAR(MenuSaveAction)
DECLARE_VAR(MenuOptionsBack)
DECLARE_VAR(MenuSaveLoadPageLeft)
DECLARE_VAR(MenuSaveLoadPageRight)
DECLARE_VAR(MenuSaveLoadSelectedItem)
DECLARE_VAR(MenuSaveLoadCurrentPage)
DECLARE_VAR(OverallVolume)
DECLARE_VAR(MusicVolume)
DECLARE_VAR(MusicFrequency)
DECLARE_VAR(LanguageAudio)
DECLARE_VAR(LanguageText)
DECLARE_VAR(HotspotIgnoreClick)
DECLARE_VAR(HotspotHovered)
DECLARE_VAR(SpotSubtitle)
DECLARE_VAR(DragLeverLimited)
DECLARE_VAR(DragLeverLimitMin)
DECLARE_VAR(DragLeverLimitMax)
DECLARE_VAR(ShieldEffectActive)
// Xbox specific variables
DECLARE_VAR(GamePadActionPressed)
DECLARE_VAR(GamePadDownPressed)
DECLARE_VAR(GamePadUpPressed)
DECLARE_VAR(GamePadLeftPressed)
DECLARE_VAR(GamePadRightPressed)
DECLARE_VAR(GamePadCancelPressed)
DECLARE_VAR(DragWithDirectionKeys)
DECLARE_VAR(MenuSavesAvailable)
DECLARE_VAR(MenuSelectedSave)
DECLARE_VAR(MenuAttractCountDown)
DECLARE_VAR(MovieOptional)
DECLARE_VAR(VibrationEnabled)
DECLARE_VAR(StateCanSave)
void updateFrameCounters();
uint getTickCount() const;
/** Ensture the counters are correct when the engine is paused or resumed */
void pauseEngine(bool pause);
ViewType getViewType() { return static_cast<ViewType>(_data.currentNodeType); }
void setViewType(ViewType t) { _data.currentNodeType = t; }
float getLookAtFOV() { return _data.lookatFOV; }
void setLookAtFOV(float fov) { _data.lookatFOV = fov; }
float getLookAtPitch() { return _data.lookatPitch; }
float getLookAtHeading() { return _data.lookatHeading; }
void lookAt(float pitch, float heading) { _data.lookatPitch = pitch; _data.lookatHeading = heading; }
void limitCubeCamera(float minPitch, float maxPitch, float minHeading, float maxHeading);
void freeCubeCamera() { _data.limitCubeCamera = false; }
bool isCameraLimited() { return _data.limitCubeCamera != 0; }
float getMinPitch() { return _data.minPitch; }
float getMaxPitch() { return _data.maxPitch; }
float getMinHeading() { return _data.minHeading; }
float getMaxHeading() { return _data.maxHeading; }
void markNodeAsVisited(uint16 node, uint16 room, uint32 age);
bool isZipDestinationAvailable(uint16 node, uint16 room, uint32 age);
Graphics::Surface *getSaveThumbnail() const;
void setSaveThumbnail(Graphics::Surface *thumb);
Common::String formatSaveTime();
void setSaveDescription(const Common::String &description) { _data.saveDescription = description; }
Common::Array<uint16> getInventory();
void updateInventory(const Common::Array<uint16> &items);
struct StateData {
uint32 version;
uint32 gameRunning;
uint32 tickCount;
uint32 nextSecondsUpdate;
uint32 secondsPlayed;
uint32 dword_4C2C44;
uint32 dword_4C2C48;
uint32 dword_4C2C4C;
uint32 dword_4C2C50;
uint32 dword_4C2C54;
uint32 dword_4C2C58;
uint32 dword_4C2C5C;
uint32 dword_4C2C60;
uint32 currentNodeType;
float lookatPitch;
float lookatHeading;
float lookatFOV;
float pitchOffset;
float headingOffset;
uint32 limitCubeCamera;
float minPitch;
float maxPitch;
float minHeading;
float maxHeading;
uint32 dword_4C2C90;
int32 vars[2048];
uint32 inventoryCount;
uint32 inventoryList[7];
uint32 zipDestinations[64];
uint8 saveDay;
uint8 saveMonth;
uint16 saveYear;
uint8 saveHour;
uint8 saveMinute;
Common::String saveDescription;
Common::SharedPtr<Graphics::Surface> thumbnail;
StateData();
void syncWithSaveGame(Common::Serializer &s);
void resizeThumbnail(Graphics::Surface *small) const;
};
static const uint kThumbnailWidth = 240;
static const uint kThumbnailHeight = 135;
private:
const Common::Platform _platform;
Database *_db;
static const uint32 kSaveVersion = 149;
StateData _data;
static const uint32 kTickDuration = 1000 / 30;
uint32 _lastTickStartTime;
struct VarDescription {
VarDescription() : var(0), name(0), unknown(0) {}
VarDescription(uint16 v, const char *n, bool u) : var(v), name(n), unknown(u) {}
uint16 var;
const char *name;
bool unknown;
};
typedef Common::HashMap<Common::String, VarDescription> VarMap;
VarMap _varDescriptions;
void checkRange(uint16 var);
const VarDescription findDescription(uint16 var);
void shiftVariables(uint16 base, int32 value);
int32 engineGet(const Common::String &varName);
void engineSet(const Common::String &varName, int32 value);
static void syncFloat(Common::Serializer &s, float &val,
Common::Serializer::Version minVersion = 0,
Common::Serializer::Version maxVersion = Common::Serializer::kLastVersion);
void updateTickCounters();
};
/**
* Save files related utility functions
*/
struct Saves {
/** Build a save file name according to the game platform */
static Common::String buildName(const char *name, Common::Platform platform);
/** List all the save file names for the game platform, sorted alphabetically */
static Common::StringArray list(Common::SaveFileManager *saveFileManager, Common::Platform platform);
};
} // End of namespace Myst3
#endif // VARIABLES_H_
|