Initial commit

This commit is contained in:
2026-02-02 04:50:13 +01:00
commit 5b11698731
22592 changed files with 7677434 additions and 0 deletions

149
engines/got/data/actor.cpp Normal file
View File

@@ -0,0 +1,149 @@
/* 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/>.
*
*/
#include "got/data/actor.h"
#include "common/algorithm.h"
#include "common/memstream.h"
namespace Got {
void Actor::loadFixed(Common::SeekableReadStream *src) {
_moveType = src->readByte();
_width = src->readByte();
_height = src->readByte();
_directions = src->readByte();
_framesPerDirection = src->readByte();
_frameSpeed = src->readByte();
src->read(_frameSequence, 4);
_speed = src->readByte();
_sizeX = src->readByte();
_sizeY = src->readByte();
_hitStrength = src->readByte();
_health = src->readByte();
_numMoves = src->readByte();
_shotType = src->readByte();
_shotPattern = src->readByte();
_numShotsAllowed = src->readByte();
_solid = src->readByte();
_flying = src->readByte() == 1;
_dropRating = src->readByte();
_type = src->readByte();
src->read(_name, 9);
_funcNum = src->readByte();
_funcPass = src->readByte();
_magicHurts = src->readSint16LE();
src->skip(4);
}
void Actor::loadFixed(const byte *src) {
Common::MemoryReadStream stream(src, 40);
loadFixed(&stream);
}
void Actor::copyFixedAndPics(const Actor &src) {
_moveType = src._moveType;
_width = src._width;
_height = src._height;
_directions = src._directions;
_framesPerDirection = src._framesPerDirection;
_frameSpeed = src._frameSpeed;
Common::copy(src._frameSequence, src._frameSequence + 4, _frameSequence);
_speed = src._speed;
_sizeX = src._sizeX;
_sizeY = src._sizeY;
_hitStrength = src._hitStrength;
_health = src._health;
_numMoves = src._numMoves;
_shotType = src._shotType;
_shotPattern = src._shotPattern;
_numShotsAllowed = src._numShotsAllowed;
_solid = src._solid;
_flying = src._flying;
_dropRating = src._dropRating;
_type = src._type;
Common::copy(src._name, src._name + 9, _name);
_funcNum = src._funcNum;
_funcPass = src._funcPass;
_magicHurts = src._magicHurts;
// Copy all the surfaces for all the directions over
for (int d = 0; d < DIRECTION_COUNT; ++d) {
for (int f = 0; f < FRAME_COUNT; ++f)
pic[d][f].copyFrom(src.pic[d][f]);
}
}
Actor &Actor::operator=(const Actor &src) {
// First copy the fixed portion and the pics
copyFixedAndPics(src);
// Copy temporary fields
_frameCount = src._frameCount;
_dir = src._dir;
_lastDir = src._lastDir;
_x = src._x;
_y = src._y;
_center = src._center;
Common::copy(src._lastX, src._lastX + 2, _lastX);
Common::copy(src._lastY, src._lastY + 2, _lastY);
_active = src._active;
_nextFrame = src._nextFrame;
_moveCountdown = src._moveCountdown;
_vulnerableCountdown = src._vulnerableCountdown;
_shotCountdown = src._shotCountdown;
_currNumShots = src._currNumShots;
_creator = src._creator;
_unpauseCountdown = src._unpauseCountdown;
_actorNum = src._actorNum;
_moveCount = src._moveCount;
_dead = src._dead;
_toggle = src._toggle;
_centerX = src._centerX;
_centerY = src._centerY;
_show = src._show;
_temp1 = src._temp1;
_temp2 = src._temp2;
_counter = src._counter;
_moveCounter = src._moveCounter;
_edgeCounter = src._edgeCounter;
_temp3 = src._temp3;
_temp4 = src._temp4;
_temp5 = src._temp5;
_hitThor = src._hitThor;
_rand = src._rand;
_initDir = src._initDir;
_passValue = src._passValue;
_shotActor = src._shotActor;
_magicHit = src._magicHit;
_temp6 = src._temp6;
_i1 = src._i1;
_i2 = src._i2;
_i3 = src._i3;
_i4 = src._i4;
_i5 = src._i5;
_i6 = src._i6;
_initHealth = src._initHealth;
_talkCounter = src._talkCounter;
return *this;
}
} // namespace Got

123
engines/got/data/actor.h Normal file
View File

@@ -0,0 +1,123 @@
/* 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 GOT_DATA_ACTOR_H
#define GOT_DATA_ACTOR_H
#include "common/stream.h"
#include "graphics/managed_surface.h"
namespace Got {
#define DIRECTION_COUNT 4
#define FRAME_COUNT 4
struct Actor {
// First part loaded from disk
byte _moveType = 0; // Movement pattern (0=none)
byte _width = 0; // Physical width
byte _height = 0; // Physical height
byte _directions = 0; // 1, 2 or 4 (1=uni-directional)
byte _framesPerDirection = 0; // # frames per direction
byte _frameSpeed = 0; // # cycles between frame changes
byte _frameSequence[4] = {}; // Sequence
byte _speed = 0; // Move every Nth cycle
byte _sizeX = 0; // Non-physical padding on X coordinate
byte _sizeY = 0; // Non-physical padding on Y coordinate
byte _hitStrength = 0; // Hit strength
byte _health = 0; //
byte _numMoves = 0; // # of moves every <_speed> cycles
byte _shotType = 0; // Actor # of shot
byte _shotPattern = 0; // Func number to decide to shoot
byte _numShotsAllowed = 0; // # shots allowed on screen
byte _solid = 0; // 1=solid (not ghost,etc)
bool _flying = false; //
byte _dropRating = 0; // rnd(100) < _dropRating = jewel
byte _type = 0; // Actor (0 = thor, 1 = hammer, 2 = enemy, 3 = shot)
char _name[9] = {}; // Actors name
byte _funcNum = 0; // Special function when thor touches
byte _funcPass = 0; // Value to pass to func
uint16 _magicHurts = 0; // Bitwise magic hurts flags
// The rest is dynamic //size=216
// Direction/frame surfaces
Graphics::ManagedSurface pic[DIRECTION_COUNT][FRAME_COUNT];
byte _frameCount = 0; // Count to switch frames
byte _dir = 0; // Direction of travel
byte _lastDir = 0; // Last direction of travel
int _x = 0; // Actual X coordinate
int _y = 0; // Actual Y coordinate
int _center = 0; // Center of object
int _lastX[2] = {}; // Last X coordinate on each page
int _lastY[2] = {}; // Last Y coordinate on each page
bool _active = false; // true=active, false=not active
byte _nextFrame = 0; // Next frame to be shown
byte _moveCountdown = 0; // Count down to movement
byte _vulnerableCountdown = 0; // Count down to vulnerability
byte _shotCountdown = 0; // Count down to another shot
byte _currNumShots = 0; // # of shots currently on screen
byte _creator = 0; // Which actor # created this actor
byte _unpauseCountdown = 0; // Must be 0 to move
byte _actorNum = 0;
byte _moveCount = 0;
byte _dead = 0;
byte _toggle = 0;
byte _centerX = 0;
byte _centerY = 0;
byte _show = 0; // Display or not (for blinking)
byte _temp1 = 0;
byte _temp2 = 0;
byte _counter = 0;
byte _moveCounter = 0;
byte _edgeCounter = 0;
byte _temp3 = 0;
byte _temp4 = 0;
byte _temp5 = 0;
bool _hitThor = false;
int _rand = 0;
byte _initDir = 0;
byte _passValue = 0;
byte _shotActor = 0;
byte _magicHit = 0;
byte _temp6 = 0;
int _i1 = 0, _i2 = 0, _i3 = 0, _i4 = 0, _i5 = 0, _i6 = 0;
byte _initHealth = 0;
byte _talkCounter = 0;
void loadFixed(Common::SeekableReadStream *src);
void loadFixed(const byte *src);
/**
* Copies the fixed portion and pics from a source actor.
*/
void copyFixedAndPics(const Actor &src);
Actor &operator=(const Actor &src);
int getPos() const {
return ((_x + 7) / 16) + (((_y + 8) / 16) * 20);
}
};
} // namespace Got
#endif

View File

@@ -0,0 +1,72 @@
/* 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 GOT_DATA_DEFINES_H
#define GOT_DATA_DEFINES_H
#include "common/scummsys.h"
#include "common/serializer.h"
#include "got/data/actor.h"
namespace Got {
struct Header {
long _offset = 0;
long _length = 0;
void load(Common::SeekableReadStream *src) {
_offset = src->readUint32LE();
_length = src->readUint32LE();
}
};
//==========================================================================
// Defines
#define MAX_ACTORS 35
#define MAX_ENEMIES 16
#define STAMINA 20
#define GOT_Z 44
#define GOT_B 48
#define TMP_SIZE 5800
#define GAME1 (_G(area) == 1)
#define GAME2 (_G(area) == 2)
#define GAME3 (_G(area) == 3)
#define APPLE_MAGIC 1
#define LIGHTNING_MAGIC 2
#define BOOTS_MAGIC 4
#define WIND_MAGIC 8
#define SHIELD_MAGIC 16
#define THUNDER_MAGIC 32
#define BOSS_LEVEL1 59
#define BOSS_LEVEL2 60
#define BOSS_LEVEL3 95
#define ENDING_SCREEN 106
#define DEMO_LEN 3600
} // namespace Got
#endif

33
engines/got/data/flags.h Normal file
View File

@@ -0,0 +1,33 @@
/* 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 GOT_DATA_FLAGS_H
#define GOT_DATA_FLAGS_H
#include "got/data/defines.h"
namespace Got {
#define HERMIT_HAS_DOLL _G(setup).f04
} // namespace Got
#endif

View File

@@ -0,0 +1,106 @@
/* 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/>.
*
*/
#include "common/file.h"
#include "common/savefile.h"
#include "common/system.h"
#include "got/data/highscores.h"
#include "got/got.h"
namespace Got {
static const char *DEFAULT_NAMES[HIGH_SCORES_PER_AREA] = {
"Ron Davis", "Gary Sirois", "Adam Pedersen", "Jason Blochowiak",
"Roy Davis", "Wayne Timmerman", "Dan Linton"};
void HighScore::sync(Common::Serializer &s) {
s.syncAsUint16LE(_unused);
s.syncAsUint32LE(_total);
s.syncBytes((byte *)_name, 32);
}
void HighScores::sync(Common::Serializer &s) {
for (int area = 0; area < 3; ++area) {
for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
_scores[area][num].sync(s);
}
}
void HighScores::load() {
Common::File f;
const Common::String scoresName = g_engine->getHighScoresSaveName();
Common::InSaveFile *sf = g_system->getSavefileManager()->openForLoading(scoresName);
if (sf != nullptr) {
// ScummVM high scores data present
Common::Serializer s(sf, nullptr);
sync(s);
delete sf;
} else if (f.open("config.got")) {
// Otherwise fall back on original generated config.got
f.seek(0x32);
Common::Serializer s(&f, nullptr);
sync(s);
} else {
// Generate new data
for (int area = 0; area < 3; ++area) {
for (int num = 0; num < HIGH_SCORES_PER_AREA; ++num)
_scores[area][num] = HighScore(DEFAULT_NAMES[num], 10000 - (num * 1000));
}
}
}
void HighScores::save() {
Common::OutSaveFile *sf = g_system->getSavefileManager()->openForSaving(g_engine->getHighScoresSaveName());
if (!sf)
error("Error creating high scores save file");
Common::Serializer s(nullptr, sf);
sync(s);
sf->finalize();
delete sf;
}
void HighScores::add(const int area, const Common::String &name, const uint total) {
// Find the index for the new score in the list
int newIndex;
for (newIndex = 0; newIndex < HIGH_SCORES_PER_AREA && total < _scores[area - 1][newIndex]._total; ++newIndex) {
}
if (newIndex == HIGH_SCORES_PER_AREA)
// Lower than all current scores, so ignore it
return;
// Shift any lower scores to make space
for (int i = HIGH_SCORES_PER_AREA - 1; i > newIndex; --i)
_scores[area - 1][i] = _scores[area - 1][i - 1];
// Insert in new score
HighScore &hs = _scores[area - 1][newIndex];
Common::fill(hs._name, hs._name + 32, 0);
Common::strcpy_s(hs._name, name.c_str());
hs._total = total;
// Save the resulting table
save();
}
} // namespace Got

View File

@@ -0,0 +1,57 @@
/* 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 GOT_DATA_HIGH_SCORE_H
#define GOT_DATA_HIGH_SCORE_H
#include "common/serializer.h"
namespace Got {
#define HIGH_SCORES_PER_AREA 7
struct HighScore {
uint16 _unused = 0;
uint32 _total = 0;
char _name[32] = {};
HighScore() {}
HighScore(const char *name, uint32 total) : _total(total) {
Common::strcpy_s(_name, name);
}
void sync(Common::Serializer &s);
};
struct HighScores {
private:
void sync(Common::Serializer &s);
public:
HighScore _scores[3][HIGH_SCORES_PER_AREA];
void load();
void save();
void add(int area, const Common::String &name, uint total);
};
} // namespace Got
#endif

View File

@@ -0,0 +1,69 @@
/* 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/>.
*
*/
#include "common/algorithm.h"
#include "common/memstream.h"
#include "got/data/defines.h"
#include "got/vars.h"
namespace Got {
void Level::sync(Common::Serializer &s) {
for (int i = 0; i < 12; ++i)
s.syncBytes(_iconGrid[i], 20);
s.syncAsByte(_backgroundColor);
s.syncAsByte(_music);
s.syncBytes(_actorType, 16);
s.syncBytes(_actorLoc, 16);
s.syncBytes(_actorValue, 16);
s.syncBytes(_palColors, 3);
s.syncBytes(_actorInvis, 16);
s.syncBytes(_extra, 13);
s.syncBytes(_staticObject, 30);
for (int i = 0; i < 30; ++i)
s.syncAsSint16LE(_staticX[i]);
for (int i = 0; i < 30; ++i)
s.syncAsSint16LE(_staticY[i]);
s.syncBytes(_newLevel, 10);
s.syncBytes(_newLevelLocation, 10);
s.syncAsByte(_area);
s.syncBytes(_actorDir, 16);
s.syncBytes(_filler, 3);
}
void Level::load(const int level) {
Common::MemoryReadStream src(_G(sdData)[level], 512);
Common::Serializer s(&src, nullptr);
sync(s);
}
void Level::save(const int level) {
Common::MemoryWriteStream dest(_G(sdData)[level], 512);
Common::Serializer s(nullptr, &dest);
sync(s);
}
} // namespace Got

67
engines/got/data/level.h Normal file
View File

@@ -0,0 +1,67 @@
/* 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 GOT_DATA_LEVEL_H
#define GOT_DATA_LEVEL_H
#include "common/serializer.h"
namespace Got {
#define OBJECTS_COUNT 30
struct Level {
private:
void sync(Common::Serializer &s);
public:
byte _iconGrid[12][20] = {}; // Grid of icons
byte _backgroundColor = 0; // Background color
byte _music = 0; // Music
byte _actorType[16] = {}; // Type of enemies (12 max)
byte _actorLoc[16] = {}; // Location of enemies
byte _actorValue[16] = {}; // Pass value
byte _palColors[3] = {}; // Change 251,253,254 to these three
byte _actorInvis[16] = {};
byte _extra[13] = {};
byte _staticObject[OBJECTS_COUNT] = {}; // Static objects (treasure, keys,etc)
int _staticX[OBJECTS_COUNT] = {}; // X coordinates of static objects
int _staticY[OBJECTS_COUNT] = {}; // Y coordinates of static objects
byte _newLevel[10] = {}; // Level jump for icon 200-204
byte _newLevelLocation[10] = {}; // Grid location to jump in to
byte _area = 0; // Game area (1=forest,etc)
byte _actorDir[16] = {}; // Initial _dir
byte _filler[3] = {};
/**
* Loads level data from the global sd_data for the given level
*/
void load(int level);
/**
* Saves the level data to the global sd_data
*/
void save(int level);
};
} // namespace Got
#endif

View File

@@ -0,0 +1,51 @@
/* 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/>.
*
*/
#include "got/data/sd_data.h"
#include "got/utils/file.h"
namespace Got {
#define SD_DATA_SIZE 61440
SdData::SdData() {
_data = new byte[SD_DATA_SIZE];
}
SdData::~SdData() {
delete[] _data;
}
void SdData::load() {
const Common::String fname = Common::String::format("SDAT%d", _area);
resourceRead(fname, _data);
}
void SdData::setArea(int area) {
_area = area;
load();
}
void SdData::sync(Common::Serializer &s) {
s.syncBytes(_data, SD_DATA_SIZE);
}
} // namespace Got

View File

@@ -0,0 +1,53 @@
/* 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 GOT_DATA_SD_DATA_H
#define GOT_DATA_SD_DATA_H
#include "common/serializer.h"
namespace Got {
class SdData {
private:
byte *_data;
int _area = 1;
public:
SdData();
~SdData();
void load();
bool getArea() const {
return _area;
}
void setArea(int area);
void sync(Common::Serializer &s);
byte *operator[](int level) const {
return _data + level * 512;
}
};
} // namespace Got
#endif

View File

@@ -0,0 +1,68 @@
/* 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/>.
*
*/
#include "got/data/setup.h"
#include "common/algorithm.h"
namespace Got {
SetupFlags &SetupFlags::operator=(const Got::SetupFlags &src) {
Common::copy(src._flags, src._flags + 64, _flags);
return *this;
}
void SetupFlags::sync(Common::Serializer &s) {
byte flags[8] = {};
if (s.isSaving()) {
for (int i = 0; i < 64; ++i) {
if (_flags[i])
flags[i / 8] = flags[i / 8] | (1 << (i % 8));
}
s.syncBytes(flags, 8);
} else {
s.syncBytes(flags, 8);
for (int i = 0; i < 64; ++i)
_flags[i] = (flags[i / 8] & (1 << (i % 8))) != 0;
}
}
void Setup::sync(Common::Serializer &s) {
// Sync the flags bit-fields
SetupFlags::sync(s);
s.syncBytes(_value, 16);
s.syncAsByte(_filler1);
s.syncAsByte(_game);
s.syncAsByte(_areaNum);
s.syncAsByte(_speakerSound);
s.syncAsByte(_digitalSound);
s.syncAsByte(_musicEnabled);
s.syncAsByte(_slowMode);
s.syncAsByte(_scrollFlag);
for (int i = 0; i < 3 ; ++i)
s.syncAsByte(_bossDead[i]);
s.syncAsByte(_difficultyLevel);
s.syncAsByte(_gameOver);
s.syncBytes(_filler2, 19);
}
} // namespace Got

122
engines/got/data/setup.h Normal file
View File

@@ -0,0 +1,122 @@
/* 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 GOT_DATA_SETUP_H
#define GOT_DATA_SETUP_H
#include "common/serializer.h"
namespace Got {
struct SetupFlags {
bool _flags[64] = {};
bool &f01 = _flags[0];
bool &f02 = _flags[1];
bool &f03 = _flags[2];
bool &f04 = _flags[3];
bool &f05 = _flags[4];
bool &f06 = _flags[5];
bool &f07 = _flags[6];
bool &f08 = _flags[7];
bool &f09 = _flags[8];
bool &f10 = _flags[9];
bool &f11 = _flags[10];
bool &f12 = _flags[11];
bool &f13 = _flags[12];
bool &f14 = _flags[13];
bool &f15 = _flags[14];
bool &f16 = _flags[15];
bool &f17 = _flags[16];
bool &f18 = _flags[17];
bool &f19 = _flags[18];
bool &f20 = _flags[19];
bool &f21 = _flags[20];
bool &f22 = _flags[21];
bool &f23 = _flags[22];
bool &f24 = _flags[23];
bool &f25 = _flags[24];
bool &f26 = _flags[25];
bool &f27 = _flags[26];
bool &f28 = _flags[27];
bool &f29 = _flags[28];
bool &f30 = _flags[29];
bool &f31 = _flags[30];
bool &f32 = _flags[31];
bool &f33 = _flags[32];
bool &f34 = _flags[33];
bool &f35 = _flags[34];
bool &f36 = _flags[35];
bool &f37 = _flags[36];
bool &f38 = _flags[37];
bool &f39 = _flags[38];
bool &f40 = _flags[39];
bool &f41 = _flags[40];
bool &f42 = _flags[41];
bool &f43 = _flags[42];
bool &f44 = _flags[43];
bool &f45 = _flags[44];
bool &f46 = _flags[45];
bool &f47 = _flags[46];
bool &f48 = _flags[47];
bool &f49 = _flags[48];
bool &f50 = _flags[49];
bool &f51 = _flags[50];
bool &f52 = _flags[51];
bool &f53 = _flags[52];
bool &f54 = _flags[53];
bool &f55 = _flags[54];
bool &f56 = _flags[55];
bool &f57 = _flags[56];
bool &f58 = _flags[57];
bool &f59 = _flags[58];
bool &f60 = _flags[59];
bool &f61 = _flags[60];
bool &f62 = _flags[61];
bool &f63 = _flags[62];
bool &f64 = _flags[63];
SetupFlags() {}
virtual ~SetupFlags() {}
virtual void sync(Common::Serializer &s);
SetupFlags &operator=(const Got::SetupFlags &src);
};
struct Setup : public SetupFlags {
byte _value[16] = {};
byte _filler1 = 0;
byte _game = 0; // Unused
byte _areaNum = 0; // 1,2,3
bool _speakerSound = false; // always disabled
bool _digitalSound = false; // true = enabled
bool _musicEnabled = false; // true = enabled
bool _slowMode = false; // true = slow mode (for slower 286's)
bool _scrollFlag = false; // true = scroll when changing from a room to the other
bool _bossDead[3] = {false, false, false};
byte _difficultyLevel = 0; // 0=easy, 1=normal, 2=hard
byte _gameOver = 0;
byte _filler2[19] = {};
void sync(Common::Serializer &s) override;
};
} // namespace Got
#endif

View File

@@ -0,0 +1,102 @@
/* 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
* as.syncAsUint32LE(with this program. If not, see <http://www.gnu.org/licenses/>.
*
*/
#include "common/algorithm.h"
#include "got/data/thorinfo.h"
#include "got/game/back.h"
namespace Got {
void ThorInfo::clear() {
_magic = 0;
_keys = 0;
_jewels = 0;
_lastArea = 0;
_lastScreen = 0;
_lastIcon = 0;
_lastDir = 0;
_inventory = 0;
_selectedItem = 0;
_lastHealth = 0;
_lastMagic = 0;
_lastJewels = 0;
_lastKeys = 0;
_lastItem = 0;
_lastInventory = 0;
_level = 0;
_score = 0;
_lastScore = 0;
_object = 0;
_objectName = nullptr;
_lastObject = 0;
_lastObjectName = nullptr;
_armor = 0;
#ifdef USE_TTS
_previousJewels = -1;
_previousScore = -1;
_previousKeys = -1;
#endif
Common::fill(_filler, _filler + 65, 0);
}
void ThorInfo::sync(Common::Serializer &s) {
uint32 ptr = 0;
s.syncAsByte(_magic);
s.syncAsByte(_keys);
s.syncAsSint16LE(_jewels);
s.syncAsByte(_lastArea);
s.syncAsByte(_lastScreen);
s.syncAsByte(_lastIcon);
s.syncAsByte(_lastDir);
s.syncAsSint16LE(_inventory);
s.syncAsByte(_selectedItem);
s.syncAsByte(_lastHealth);
s.syncAsByte(_lastMagic);
s.syncAsSint16LE(_lastJewels);
s.syncAsByte(_lastKeys);
s.syncAsByte(_lastItem);
s.syncAsSint16LE(_lastInventory);
s.syncAsByte(_level);
s.syncAsUint32LE(_score);
s.syncAsUint32LE(_lastScore);
s.syncAsByte(_object);
s.syncAsUint16LE(ptr);
s.syncAsByte(_lastObject);
s.syncAsUint16LE(ptr);
s.syncAsByte(_armor);
s.syncBytes(_filler, 65);
if (s.isLoading()) {
_objectName = (_object == 0) ? nullptr : OBJECT_NAMES[_object - 1];
_lastObjectName = (_lastObject == 0) ? nullptr : OBJECT_NAMES[_lastObject - 1];
#ifdef USE_TTS
_previousJewels = -1;
_previousScore = -1;
_previousKeys = -1;
#endif
}
}
} // namespace Got

View File

@@ -0,0 +1,66 @@
/* 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 GOT_DATA_THORINFO_H
#define GOT_DATA_THORINFO_H
#include "common/serializer.h"
namespace Got {
struct ThorInfo {
byte _magic = 0;
byte _keys = 0;
int _jewels = 0;
byte _lastArea = 0;
byte _lastScreen = 0;
byte _lastIcon = 0;
byte _lastDir = 0;
int _inventory = 0;
byte _selectedItem = 0; //currently selected item
byte _lastHealth = 0;
byte _lastMagic = 0;
int _lastJewels = 0;
byte _lastKeys = 0;
byte _lastItem = 0;
int _lastInventory = 0;
byte _level = 0; //current level (1,2,3)
long _score = 0;
long _lastScore = 0;
byte _object = 0;
const char *_objectName = nullptr;
byte _lastObject = 0;
const char *_lastObjectName = nullptr;
byte _armor = 0;
byte _filler[65] = {};
#ifdef USE_TTS
int _previousJewels = -1;
int _previousScore = -1;
int _previousKeys = -1;
#endif
void clear();
void sync(Common::Serializer &s);
};
} // namespace Got
#endif