GB, GBA Serialize: Attempt to fix MSVC build
Vicki Pfau vi@endrift.com
Tue, 09 Feb 2021 00:28:42 -0800
5 files changed,
26 insertions(+),
26 deletions(-)
M
include/mgba/internal/gb/serialize.h
→
include/mgba/internal/gb/serialize.h
@@ -13,8 +13,8 @@
#include <mgba/core/core.h> #include <mgba/internal/gb/gb.h> -extern const uint32_t GB_SAVESTATE_MAGIC; -extern const uint32_t GB_SAVESTATE_VERSION; +extern MGBA_EXPORT const uint32_t GBSavestateMagic; +extern MGBA_EXPORT const uint32_t GBSavestateVersion; mLOG_DECLARE_CATEGORY(GB_STATE);
M
include/mgba/internal/gba/serialize.h
→
include/mgba/internal/gba/serialize.h
@@ -14,8 +14,8 @@ #include <mgba/core/core.h>
#include <mgba/internal/gba/gba.h> #include <mgba/internal/gb/serialize.h> -extern const uint32_t GBA_SAVESTATE_MAGIC; -extern const uint32_t GBA_SAVESTATE_VERSION; +extern MGBA_EXPORT const uint32_t GBASavestateMagic; +extern MGBA_EXPORT const uint32_t GBASavestateVersion; mLOG_DECLARE_CATEGORY(GBA_STATE);
M
src/gb/serialize.c
→
src/gb/serialize.c
@@ -13,11 +13,11 @@ #include <mgba-util/memory.h>
mLOG_DEFINE_CATEGORY(GB_STATE, "GB Savestate", "gb.serialize"); -const uint32_t GB_SAVESTATE_MAGIC = 0x00400000; -const uint32_t GB_SAVESTATE_VERSION = 0x00000002; +MGBA_EXPORT const uint32_t GBSavestateMagic = 0x00400000; +MGBA_EXPORT const uint32_t GBSavestateVersion = 0x00000002; void GBSerialize(struct GB* gb, struct GBSerializedState* state) { - STORE_32LE(GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION, 0, &state->versionMagic); + STORE_32LE(GBSavestateMagic + GBSavestateVersion, 0, &state->versionMagic); STORE_32LE(gb->romCrc32, 0, &state->romCrc32); STORE_32LE(gb->timing.masterCycles, 0, &state->masterCycles); STORE_64LE(gb->timing.globalCycles, 0, &state->globalCycles);@@ -76,20 +76,20 @@ uint32_t ucheck;
int16_t check16; uint16_t ucheck16; LOAD_32LE(ucheck, 0, &state->versionMagic); - if (ucheck > GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION) { - mLOG(GB_STATE, WARN, "Invalid or too new savestate: expected %08X, got %08X", GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION, ucheck); + if (ucheck > GBSavestateMagic + GBSavestateVersion) { + mLOG(GB_STATE, WARN, "Invalid or too new savestate: expected %08X, got %08X", GBSavestateMagic + GBSavestateVersion, ucheck); error = true; - } else if (ucheck < GB_SAVESTATE_MAGIC) { - mLOG(GB_STATE, WARN, "Invalid savestate: expected %08X, got %08X", GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION, ucheck); + } else if (ucheck < GBSavestateMagic) { + mLOG(GB_STATE, WARN, "Invalid savestate: expected %08X, got %08X", GBSavestateMagic + GBSavestateVersion, ucheck); error = true; - } else if (ucheck < GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION) { - mLOG(GB_STATE, WARN, "Old savestate: expected %08X, got %08X, continuing anyway", GB_SAVESTATE_MAGIC + GB_SAVESTATE_VERSION, ucheck); + } else if (ucheck < GBSavestateMagic + GBSavestateVersion) { + mLOG(GB_STATE, WARN, "Old savestate: expected %08X, got %08X, continuing anyway", GBSavestateMagic + GBSavestateVersion, ucheck); } - bool canSgb = ucheck >= GB_SAVESTATE_MAGIC + 2; + bool canSgb = ucheck >= GBSavestateMagic + 2; if (gb->memory.rom && memcmp(state->title, ((struct GBCartridge*) &gb->memory.rom[0x100])->titleLong, sizeof(state->title))) { LOAD_32LE(ucheck, 0, &state->versionMagic); - if (ucheck > GB_SAVESTATE_MAGIC + 2 || memcmp(state->title, ((struct GBCartridge*) gb->memory.rom)->titleLong, sizeof(state->title))) { + if (ucheck > GBSavestateMagic + 2 || memcmp(state->title, ((struct GBCartridge*) gb->memory.rom)->titleLong, sizeof(state->title))) { // There was a bug in previous versions where the memory address being compared was wrong mLOG(GB_STATE, WARN, "Savestate is for a different game"); error = true;
M
src/gba/serialize.c
→
src/gba/serialize.c
@@ -14,8 +14,8 @@ #include <mgba-util/vfs.h>
#include <fcntl.h> -const uint32_t GBA_SAVESTATE_MAGIC = 0x01000000; -const uint32_t GBA_SAVESTATE_VERSION = 0x00000004; +MGBA_EXPORT const uint32_t GBASavestateMagic = 0x01000000; +MGBA_EXPORT const uint32_t GBASavestateVersion = 0x00000004; mLOG_DEFINE_CATEGORY(GBA_STATE, "GBA Savestate", "gba.serialize");@@ -25,7 +25,7 @@ struct mStateExtdata* extdata;
}; void GBASerialize(struct GBA* gba, struct GBASerializedState* state) { - STORE_32(GBA_SAVESTATE_MAGIC + GBA_SAVESTATE_VERSION, 0, &state->versionMagic); + STORE_32(GBASavestateMagic + GBASavestateVersion, 0, &state->versionMagic); STORE_32(gba->biosChecksum, 0, &state->biosChecksum); STORE_32(gba->romCrc32, 0, &state->romCrc32); STORE_32(gba->timing.masterCycles, 0, &state->masterCycles);@@ -87,14 +87,14 @@ bool error = false;
int32_t check; uint32_t ucheck; LOAD_32(ucheck, 0, &state->versionMagic); - if (ucheck > GBA_SAVESTATE_MAGIC + GBA_SAVESTATE_VERSION) { - mLOG(GBA_STATE, WARN, "Invalid or too new savestate: expected %08X, got %08X", GBA_SAVESTATE_MAGIC + GBA_SAVESTATE_VERSION, ucheck); + if (ucheck > GBASavestateMagic + GBASavestateVersion) { + mLOG(GBA_STATE, WARN, "Invalid or too new savestate: expected %08X, got %08X", GBASavestateMagic + GBASavestateVersion, ucheck); error = true; - } else if (ucheck < GBA_SAVESTATE_MAGIC) { - mLOG(GBA_STATE, WARN, "Invalid savestate: expected %08X, got %08X", GBA_SAVESTATE_MAGIC + GBA_SAVESTATE_VERSION, ucheck); + } else if (ucheck < GBASavestateMagic) { + mLOG(GBA_STATE, WARN, "Invalid savestate: expected %08X, got %08X", GBASavestateMagic + GBASavestateVersion, ucheck); error = true; - } else if (ucheck < GBA_SAVESTATE_MAGIC + GBA_SAVESTATE_VERSION) { - mLOG(GBA_STATE, WARN, "Old savestate: expected %08X, got %08X, continuing anyway", GBA_SAVESTATE_MAGIC + GBA_SAVESTATE_VERSION, ucheck); + } else if (ucheck < GBASavestateMagic + GBASavestateVersion) { + mLOG(GBA_STATE, WARN, "Old savestate: expected %08X, got %08X, continuing anyway", GBASavestateMagic + GBASavestateVersion, ucheck); } LOAD_32(ucheck, 0, &state->biosChecksum); if (ucheck != gba->biosChecksum) {
M
src/platform/qt/SaveConverter.cpp
→
src/platform/qt/SaveConverter.cpp
@@ -266,7 +266,7 @@ state = mCoreExtractState(core, vf, nullptr);
core->deinit(core); if (state) { LOAD_32LE(magic, 0, state); - if (magic - GBA_SAVESTATE_MAGIC <= GBA_SAVESTATE_VERSION) { + if (magic - GBASavestateMagic <= GBASavestateVersion) { platform = mPLATFORM_GBA; } mappedMemoryFree(state, core->stateSize(core));@@ -281,7 +281,7 @@ state = mCoreExtractState(core, vf, nullptr);
core->deinit(core); if (state) { LOAD_32LE(magic, 0, state); - if (magic - GB_SAVESTATE_MAGIC <= GB_SAVESTATE_VERSION) { + if (magic - GBSavestateMagic <= GBSavestateVersion) { platform = mPLATFORM_GB; } mappedMemoryFree(state, core->stateSize(core));