DGDS: Split game-specific globals

This commit is contained in:
Filippos Karapetis 2024-07-07 03:27:20 +03:00
parent 679e34ca70
commit d308c4cbae
3 changed files with 70 additions and 32 deletions

View File

@ -317,8 +317,7 @@ void DgdsEngine::loadGameFiles() {
reqParser.parse(&vcrRequestData, "DVCR.REQ");
break;
case GID_HOC:
// TODO: Create a better type for this..
_gameGlobals = new Globals(_clock);
_gameGlobals = new HocGlobals(_clock);
_gamePals->loadPalette("HOC.PAL");
_gdsScene->load("HOC.GDS", _resource, _decompressor);
_rstFileName = "HOC.RST";
@ -330,8 +329,7 @@ void DgdsEngine::loadGameFiles() {
reqParser.parse(&vcrRequestData, "HVCR.REQ");
break;
case GID_WILLY:
// TODO: Create a better type for this..
_gameGlobals = new Globals(_clock);
_gameGlobals = new WillyGlobals(_clock);
if (_resource->hasResource("WILLY.GDS")) {
_gdsScene->load("WILLY.GDS", _resource, _decompressor);
_rstFileName = "WILLY.RST";

View File

@ -60,9 +60,8 @@ Globals::Globals(Clock &clock) :
_lastOpcode1SceneChageNum(0), _sceneOp12SceneNum(0), _currentSelectedItem(0),
_gameMinsToAddOnLClick(0), _gameMinsToAddOnStartDrag(0), _gameMinsToAddOnRClick(0), _gameMinsToAddOnDragFinished(0),
_gameMinsToAddOnObjInteraction(0), _gameIsInteractiveGlobal(0), _sceneOpcode15FromScene(0),
_sceneOpcode15ToScene(0), _unk2(0), _unk5(0), _unk39(0), _unk40(0), _unk45(0), _unk51(0), _unk52(0), _unk54(0), _unk81(0) {
_sceneOpcode15ToScene(0) {
DgdsEngine *engine = static_cast<DgdsEngine *>(g_engine);
DgdsGameId gameId = engine->getGameId();
_globals.push_back(clock.getGameMinsAddedGlobal(1));
_globals.push_back(clock.getGameTicksUpGlobal(0x64));
@ -82,21 +81,6 @@ _sceneOpcode15ToScene(0), _unk2(0), _unk5(0), _unk39(0), _unk40(0), _unk45(0), _
_globals.push_back(clock.getDays2Global(0x56));
_globals.push_back(new RWI16Global(0x55, &_sceneOpcode15FromScene));
_globals.push_back(new RWI16Global(0x54, &_sceneOpcode15ToScene));
if (gameId == GID_HOC) {
_globals.push_back(new RWI16Global(0x36, &_unk54));
_globals.push_back(new RWI16Global(0x34, &_unk52));
_globals.push_back(new RWI16Global(0x33, &_unk51));
_globals.push_back(new RWI16Global(0x2D, &_unk45));
_globals.push_back(new RWI16Global(0x28, &_unk40));
_globals.push_back(new RWI16Global(0x27, &_unk39));
}
if (gameId == GID_WILLY) {
_globals.push_back(new RWI16Global(0x51, &_unk81));
_globals.push_back(new RWI16Global(0x05, &_unk5));
_globals.push_back(new RWI16Global(0x02, &_unk2));
}
}
Globals::~Globals() {
@ -225,4 +209,42 @@ Common::Error DragonGlobals::syncState(Common::Serializer &s) {
return Common::kNoError;
}
HocGlobals::HocGlobals(Clock &clock) : Globals(clock),
_unk39(0), _unk40(0), _unk45(0), _unk51(0), _unk52(0), _unk54(0) {
_globals.push_back(new RWI16Global(0x36, &_unk54));
_globals.push_back(new RWI16Global(0x34, &_unk52));
_globals.push_back(new RWI16Global(0x33, &_unk51));
_globals.push_back(new RWI16Global(0x2D, &_unk45));
_globals.push_back(new RWI16Global(0x28, &_unk40));
_globals.push_back(new RWI16Global(0x27, &_unk39));
}
Common::Error HocGlobals::syncState(Common::Serializer &s) {
Globals::syncState(s);
s.syncAsSint16LE(_unk39);
s.syncAsSint16LE(_unk40);
s.syncAsSint16LE(_unk45);
s.syncAsSint16LE(_unk51);
s.syncAsSint16LE(_unk52);
s.syncAsSint16LE(_unk54);
return Common::kNoError;
}
WillyGlobals::WillyGlobals(Clock &clock) : Globals(clock),
_unk2(0), _unk5(0), _unk81(0) {
_globals.push_back(new RWI16Global(0x51, &_unk81));
_globals.push_back(new RWI16Global(0x05, &_unk5));
_globals.push_back(new RWI16Global(0x02, &_unk2));
}
Common::Error WillyGlobals::syncState(Common::Serializer &s) {
Globals::syncState(s);
s.syncAsSint16LE(_unk2);
s.syncAsSint16LE(_unk5);
s.syncAsSint16LE(_unk81);
return Common::kNoError;
}
} // end namespace Dgds

View File

@ -110,17 +110,6 @@ protected:
int16 _gameIsInteractiveGlobal; // used to decide if the game can start a "meanwhile" sequence
int16 _sceneOpcode15FromScene;
int16 _sceneOpcode15ToScene;
// HoC
int16 _unk39;
int16 _unk40;
int16 _unk45;
int16 _unk51;
int16 _unk52;
int16 _unk54;
// Beamish
int16 _unk2;
int16 _unk5;
int16 _unk81;
Common::Array<Global *> _globals;
};
@ -155,6 +144,35 @@ private:
Common::Error syncState(Common::Serializer &s) override;
};
class HocGlobals : public Globals {
public:
HocGlobals(Clock &clock);
private:
// HoC-specific globals
int16 _unk39;
int16 _unk40;
int16 _unk45;
int16 _unk51;
int16 _unk52;
int16 _unk54;
Common::Error syncState(Common::Serializer &s) override;
};
class WillyGlobals : public Globals {
public:
WillyGlobals(Clock &clock);
private:
// Willy-specific globals
int16 _unk2;
int16 _unk5;
int16 _unk81;
Common::Error syncState(Common::Serializer &s) override;
};
} // end namespace Dgds
#endif // DGDS_GLOBALS_H