mirror of https://github.com/mgba-emu/mgba.git
Qt: Fix saving overrides
This commit is contained in:
parent
bea6235c0a
commit
5c744a3f13
1
CHANGES
1
CHANGES
|
@ -4,6 +4,7 @@ Bugfixes:
|
||||||
- GB Video: Setting LYC=LY during mode 2 should trigger an IRQ
|
- GB Video: Setting LYC=LY during mode 2 should trigger an IRQ
|
||||||
- GBA Cheats: Fix holding onto pointers that may get invalidated
|
- GBA Cheats: Fix holding onto pointers that may get invalidated
|
||||||
- Qt: Fix "close" button on Overrides view
|
- Qt: Fix "close" button on Overrides view
|
||||||
|
- Qt: Fix saving overrides
|
||||||
Misc:
|
Misc:
|
||||||
- All: Only update version info if needed
|
- All: Only update version info if needed
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,15 @@ void GBAOverride::apply(struct mCore* core) {
|
||||||
GBAOverrideApply(static_cast<GBA*>(core->board), &override);
|
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 {
|
void GBAOverride::save(struct Configuration* config) const {
|
||||||
GBAOverrideSave(config, &override);
|
GBAOverrideSave(config, &override);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace QGBA {
|
||||||
class GBAOverride : public Override {
|
class GBAOverride : public Override {
|
||||||
public:
|
public:
|
||||||
void apply(struct mCore*) override;
|
void apply(struct mCore*) override;
|
||||||
|
void identify(const struct mCore*) override;
|
||||||
void save(struct Configuration*) const override;
|
void save(struct Configuration*) const override;
|
||||||
|
|
||||||
struct GBACartridgeOverride override;
|
struct GBACartridgeOverride override;
|
||||||
|
|
|
@ -7,6 +7,8 @@
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#include "core/core.h"
|
#include "core/core.h"
|
||||||
|
#include "gb/gb.h"
|
||||||
|
#include "util/crc32.h"
|
||||||
}
|
}
|
||||||
|
|
||||||
using namespace QGBA;
|
using namespace QGBA;
|
||||||
|
@ -18,6 +20,17 @@ void GBOverride::apply(struct mCore* core) {
|
||||||
GBOverrideApply(static_cast<GB*>(core->board), &override);
|
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 {
|
void GBOverride::save(struct Configuration* config) const {
|
||||||
GBOverrideSave(config, &override);
|
GBOverrideSave(config, &override);
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,7 @@ namespace QGBA {
|
||||||
class GBOverride : public Override {
|
class GBOverride : public Override {
|
||||||
public:
|
public:
|
||||||
void apply(struct mCore*) override;
|
void apply(struct mCore*) override;
|
||||||
|
void identify(const struct mCore*) override;
|
||||||
void save(struct Configuration*) const override;
|
void save(struct Configuration*) const override;
|
||||||
|
|
||||||
struct GBCartridgeOverride override;
|
struct GBCartridgeOverride override;
|
||||||
|
|
|
@ -284,6 +284,15 @@ void GameController::clearMultiplayerController() {
|
||||||
m_multiplayer = nullptr;
|
m_multiplayer = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameController::setOverride(Override* override) {
|
||||||
|
m_override = override;
|
||||||
|
if (isLoaded()) {
|
||||||
|
threadInterrupt();
|
||||||
|
m_override->identify(m_threadContext.core);
|
||||||
|
threadContinue();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void GameController::clearOverride() {
|
void GameController::clearOverride() {
|
||||||
delete m_override;
|
delete m_override;
|
||||||
m_override = nullptr;
|
m_override = nullptr;
|
||||||
|
@ -437,6 +446,7 @@ void GameController::openGame(bool biosOnly) {
|
||||||
m_vf = nullptr;
|
m_vf = nullptr;
|
||||||
|
|
||||||
if (m_override) {
|
if (m_override) {
|
||||||
|
m_override->identify(m_threadContext.core);
|
||||||
m_override->apply(m_threadContext.core);
|
m_override->apply(m_threadContext.core);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,7 @@ public:
|
||||||
MultiplayerController* multiplayerController() { return m_multiplayer; }
|
MultiplayerController* multiplayerController() { return m_multiplayer; }
|
||||||
void clearMultiplayerController();
|
void clearMultiplayerController();
|
||||||
|
|
||||||
void setOverride(Override* override) { m_override = override; }
|
void setOverride(Override* override);
|
||||||
Override* override() { return m_override; }
|
Override* override() { return m_override; }
|
||||||
void clearOverride();
|
void clearOverride();
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ public:
|
||||||
virtual ~Override() {}
|
virtual ~Override() {}
|
||||||
|
|
||||||
virtual void apply(struct mCore*) = 0;
|
virtual void apply(struct mCore*) = 0;
|
||||||
|
virtual void identify(const struct mCore*) = 0;
|
||||||
virtual void save(struct Configuration*) const = 0;
|
virtual void save(struct Configuration*) const = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue