Skip to content

Commit

Permalink
Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
SergioMartin86 committed May 28, 2024
1 parent 5e3e63a commit 464b2d0
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 43 deletions.
3 changes: 2 additions & 1 deletion emulators/quickerGPGX/quickerGPGX.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ class QuickerGPGX final : public Emulator
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
loadFullState(initialState);
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

// Now disabling state properties, as requested
Expand Down
3 changes: 2 additions & 1 deletion emulators/quickerRAW/quickerRAW.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ class QuickerRAW final : public Emulator
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
loadFullState(initialState);
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

_mutex.unlock();
Expand Down
34 changes: 7 additions & 27 deletions emulators/quickerSDLPoP/quickerSDLPoP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ class QuickerSDLPoP final : public Emulator
{
std::string stateFileData;
if (jaffarCommon::file::loadStringFromFile(stateFileData, _stateFilePath) == false) JAFFAR_THROW_LOGIC("Could not initial state file: %s\n", _stateFilePath.c_str());
loadFullState(stateFileData);

jaffarCommon::deserializer::Contiguous deserializer(state.data());
_QuickerSDLPoP->deserializeState(deserializer);
}

// Check if RNG elements need overriding
Expand All @@ -56,6 +58,9 @@ class QuickerSDLPoP final : public Emulator

// Check if copy protection needs initializing
if (_initializeCopyProtection) _QuickerSDLPoP->initializeCopyProtection();

// Resetting global step counter
_QuickerSDLPoP->getGameState()->globalStepCount = 0;
}

// State advancing function
Expand All @@ -69,31 +74,6 @@ class QuickerSDLPoP final : public Emulator

__INLINE__ void disableStateProperty(const std::string &property) override {}

__INLINE__ void loadFullState(const std::string &state) override
{
jaffarCommon::deserializer::Contiguous deserializer(state.data());
_QuickerSDLPoP->deserializeState(deserializer);

// Resetting global step counter
_QuickerSDLPoP->getGameState()->globalStepCount = 0;
}

__INLINE__ void saveFullState(std::string &state) override
{
jaffarCommon::serializer::Contiguous s(state.data(), state.size());
serializeState(s);
}

size_t getFullStateSize() override { return _QuickerSDLPoP->getFullStateSize(); }

__INLINE__ void printInfo() const override {}

property_t getProperty(const std::string &propertyName) const override
{
if (propertyName == "Game State") return property_t((uint8_t *)_QuickerSDLPoP->getGameState(), _QuickerSDLPoP->getFullStateSize());
JAFFAR_THROW_LOGIC("Property name: '%s' not found in emulator '%s'", propertyName.c_str(), getName().c_str());
}

// This function opens the video output (e.g., window)
void initializeVideoOutput() override
{
Expand Down Expand Up @@ -141,7 +121,7 @@ class QuickerSDLPoP final : public Emulator
deserializer.pop(&_renderInput, sizeof(_renderInput));
}

__INLINE__ size_t getRendererStateSize() const override { return _QuickerSDLPoP->getFullStateSize() + sizeof(_renderStepIdx) + sizeof(_renderInput); }
__INLINE__ size_t getRendererStateSize() const override { return _QuickerSDLPoP->getStateSize() + sizeof(_renderStepIdx) + sizeof(_renderInput); }

__INLINE__ void showRender() override { _QuickerSDLPoP->updateRenderer(_renderStepIdx, _renderInput); }

Expand Down
15 changes: 2 additions & 13 deletions emulators/quickerSMBC/quickerSMBC.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,6 @@ class QuickerSMBC final : public Emulator
// Getting initial state file from the configuration
_initialStateFilePath = jaffarCommon::json::getString(config, "Initial State File Path");

// For testing purposes, the initial state file can be overriden by environment variables
if (auto *value = std::getenv("JAFFAR_SMBC_OVERRIDE_INITIAL_STATE_FILE_PATH"))
{
// Even if we override, we'd like to test whether the originally specified rom still exists to ensure consistency in Github
std::string initialStateString;
bool status = jaffarCommon::file::loadStringFromFile(initialStateString, _initialStateFilePath.c_str());
if (status == false) JAFFAR_THROW_LOGIC("Could not find/read from ROM file: %s\n", _initialStateFilePath.c_str());

// Now do the proper override
_initialStateFilePath = std::string(value);
}

// Only load rom file if using player
#ifdef _JAFFAR_PLAYER

Expand Down Expand Up @@ -92,7 +80,8 @@ class QuickerSMBC final : public Emulator
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
loadFullState(initialState);
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

// Now disabling state properties, as requested
Expand Down
4 changes: 3 additions & 1 deletion emulators/quickerSnes9x/quickerSnes9x.hpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#pragma once

#include <jaffarCommon/deserializers/base.hpp>
#include <jaffarCommon/deserializers/contiguous.hpp>
#include <jaffarCommon/hash.hpp>
#include <jaffarCommon/json.hpp>
#include <jaffarCommon/logger.hpp>
Expand Down Expand Up @@ -84,7 +85,8 @@ class QuickerSnes9x final : public Emulator
if (success == false) JAFFAR_THROW_LOGIC("[ERROR] Could not find or read from initial state file: %s\n", _initialStateFilePath.c_str());

// Deserializing initial state into the emulator
loadFullState(initialState);
jaffarCommon::deserializer::Contiguous d(initialState.data(), initialState.size());
deserializeState(d);
}

// Now disabling state properties, as requested
Expand Down

0 comments on commit 464b2d0

Please sign in to comment.