Qt: Fix saving overrides
Jeffrey Pfau jeffrey@endrift.com
Tue, 20 Sep 2016 16:33:56 -0700
8 files changed,
37 insertions(+),
1 deletions(-)
M
CHANGES
→
CHANGES
@@ -4,6 +4,7 @@ - GB MBC: Fix MBC7 when size is incorrectly specified
- GB Video: Setting LYC=LY during mode 2 should trigger an IRQ - GBA Cheats: Fix holding onto pointers that may get invalidated - Qt: Fix "close" button on Overrides view + - Qt: Fix saving overrides Misc: - All: Only update version info if needed
M
src/platform/qt/GBAOverride.cpp
→
src/platform/qt/GBAOverride.cpp
@@ -18,6 +18,15 @@ }
GBAOverrideApply(static_cast<GBA*>(core->board), &override); } +void GBAOverride::identify(const struct mCore* core) { + if (core->platform(core) != PLATFORM_GBA) { + return; + } + char gameId[8]; + core->getGameCode(core, gameId); + memcpy(override.id, &gameId[4], 4); +} + void GBAOverride::save(struct Configuration* config) const { GBAOverrideSave(config, &override); }
M
src/platform/qt/GBAOverride.h
→
src/platform/qt/GBAOverride.h
@@ -17,6 +17,7 @@
class GBAOverride : public Override { public: void apply(struct mCore*) override; + void identify(const struct mCore*) override; void save(struct Configuration*) const override; struct GBACartridgeOverride override;
M
src/platform/qt/GBOverride.cpp
→
src/platform/qt/GBOverride.cpp
@@ -7,6 +7,8 @@ #include "GBOverride.h"
extern "C" { #include "core/core.h" +#include "gb/gb.h" +#include "util/crc32.h" } using namespace QGBA;@@ -16,6 +18,17 @@ if (core->platform(core) != PLATFORM_GB) {
return; } GBOverrideApply(static_cast<GB*>(core->board), &override); +} + +void GBOverride::identify(const struct mCore* core) { + if (core->platform(core) != PLATFORM_GB) { + return; + } + GB* gb = static_cast<GB*>(core->board); + if (!gb->memory.rom || gb->memory.romSize < sizeof(struct GBCartridge) + 0x100) { + return; + } + override.headerCrc32 = doCrc32(&gb->memory.rom[0x100], sizeof(struct GBCartridge)); } void GBOverride::save(struct Configuration* config) const {
M
src/platform/qt/GBOverride.h
→
src/platform/qt/GBOverride.h
@@ -17,6 +17,7 @@
class GBOverride : public Override { public: void apply(struct mCore*) override; + void identify(const struct mCore*) override; void save(struct Configuration*) const override; struct GBCartridgeOverride override;
M
src/platform/qt/GameController.cpp
→
src/platform/qt/GameController.cpp
@@ -284,6 +284,15 @@ m_multiplayer->detachGame(this);
m_multiplayer = nullptr; } +void GameController::setOverride(Override* override) { + m_override = override; + if (isLoaded()) { + threadInterrupt(); + m_override->identify(m_threadContext.core); + threadContinue(); + } +} + void GameController::clearOverride() { delete m_override; m_override = nullptr;@@ -437,6 +446,7 @@ }
m_vf = nullptr; if (m_override) { + m_override->identify(m_threadContext.core); m_override->apply(m_threadContext.core); }
M
src/platform/qt/GameController.h
→
src/platform/qt/GameController.h
@@ -72,7 +72,7 @@ void setMultiplayerController(MultiplayerController* controller);
MultiplayerController* multiplayerController() { return m_multiplayer; } void clearMultiplayerController(); - void setOverride(Override* override) { m_override = override; } + void setOverride(Override* override); Override* override() { return m_override; } void clearOverride();
M
src/platform/qt/Override.h
→
src/platform/qt/Override.h
@@ -16,6 +16,7 @@ public:
virtual ~Override() {} virtual void apply(struct mCore*) = 0; + virtual void identify(const struct mCore*) = 0; virtual void save(struct Configuration*) const = 0; };