GBA: Better const correctness for serialization
Jeffrey Pfau jeffrey@endrift.com
Thu, 05 Mar 2015 20:43:18 -0800
10 files changed,
16 insertions(+),
16 deletions(-)
M
src/gba/hardware.c
→
src/gba/hardware.c
@@ -424,7 +424,7 @@ }
// == Serialization -void GBAHardwareSerialize(struct GBACartridgeHardware* hw, struct GBASerializedState* state) { +void GBAHardwareSerialize(const struct GBACartridgeHardware* hw, struct GBASerializedState* state) { state->hw.readWrite = hw->readWrite; state->hw.pinState = hw->pinState; state->hw.pinDirection = hw->direction;@@ -440,7 +440,7 @@ state->hw.lightSample = hw->lightSample;
state->hw.lightEdge = hw->lightEdge; } -void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, struct GBASerializedState* state) { +void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, const struct GBASerializedState* state) { hw->readWrite = state->hw.readWrite; hw->pinState = state->hw.pinState; hw->direction = state->hw.pinDirection;
M
src/gba/hardware.h
→
src/gba/hardware.h
@@ -149,7 +149,7 @@ void GBAHardwareTiltWrite(struct GBACartridgeHardware* gpio, uint32_t address, uint8_t value);
uint8_t GBAHardwareTiltRead(struct GBACartridgeHardware* gpio, uint32_t address); struct GBASerializedState; -void GBAHardwareSerialize(struct GBACartridgeHardware* gpio, struct GBASerializedState* state); -void GBAHardwareDeserialize(struct GBACartridgeHardware* gpio, struct GBASerializedState* state); +void GBAHardwareSerialize(const struct GBACartridgeHardware* gpio, struct GBASerializedState* state); +void GBAHardwareDeserialize(struct GBACartridgeHardware* gpio, const struct GBASerializedState* state); #endif
M
src/gba/io.c
→
src/gba/io.c
@@ -675,7 +675,7 @@ memcpy(state->timers, gba->timers, sizeof(state->timers));
GBAHardwareSerialize(&gba->memory.hw, state); } -void GBAIODeserialize(struct GBA* gba, struct GBASerializedState* state) { +void GBAIODeserialize(struct GBA* gba, const struct GBASerializedState* state) { int i; for (i = 0; i < REG_MAX; i += 2) { if (_isSpecialRegister[i >> 1]) {
M
src/gba/io.h
→
src/gba/io.h
@@ -161,6 +161,6 @@ uint16_t GBAIORead(struct GBA* gba, uint32_t address);
struct GBASerializedState; void GBAIOSerialize(struct GBA* gba, struct GBASerializedState* state); -void GBAIODeserialize(struct GBA* gba, struct GBASerializedState* state); +void GBAIODeserialize(struct GBA* gba, const struct GBASerializedState* state); #endif
M
src/gba/memory.c
→
src/gba/memory.c
@@ -1461,12 +1461,12 @@ }
cpu->cycles += cycles; } -void GBAMemorySerialize(struct GBAMemory* memory, struct GBASerializedState* state) { +void GBAMemorySerialize(const struct GBAMemory* memory, struct GBASerializedState* state) { memcpy(state->wram, memory->wram, SIZE_WORKING_RAM); memcpy(state->iwram, memory->iwram, SIZE_WORKING_IRAM); } -void GBAMemoryDeserialize(struct GBAMemory* memory, struct GBASerializedState* state) { +void GBAMemoryDeserialize(struct GBAMemory* memory, const struct GBASerializedState* state) { memcpy(memory->wram, state->wram, SIZE_WORKING_RAM); memcpy(memory->iwram, state->iwram, SIZE_WORKING_IRAM); }
M
src/gba/memory.h
→
src/gba/memory.h
@@ -172,7 +172,7 @@ void GBAMemoryUpdateDMAs(struct GBA* gba, int32_t cycles);
int32_t GBAMemoryRunDMAs(struct GBA* gba, int32_t cycles); struct GBASerializedState; -void GBAMemorySerialize(struct GBAMemory* memory, struct GBASerializedState* state); -void GBAMemoryDeserialize(struct GBAMemory* memory, struct GBASerializedState* state); +void GBAMemorySerialize(const struct GBAMemory* memory, struct GBASerializedState* state); +void GBAMemoryDeserialize(struct GBAMemory* memory, const struct GBASerializedState* state); #endif
M
src/gba/serialize.c
→
src/gba/serialize.c
@@ -55,7 +55,7 @@ gba->rr->stateSaved(gba->rr, state);
} } -void GBADeserialize(struct GBA* gba, struct GBASerializedState* state) { +void GBADeserialize(struct GBA* gba, const struct GBASerializedState* state) { if (state->versionMagic != GBA_SAVESTATE_MAGIC) { GBALog(gba, GBA_LOG_WARN, "Invalid or too new savestate"); return;
M
src/gba/serialize.h
→
src/gba/serialize.h
@@ -292,7 +292,7 @@ struct VDir;
struct GBAThread; void GBASerialize(struct GBA* gba, struct GBASerializedState* state); -void GBADeserialize(struct GBA* gba, struct GBASerializedState* state); +void GBADeserialize(struct GBA* gba, const struct GBASerializedState* state); bool GBASaveState(struct GBAThread* thread, struct VDir* dir, int slot, bool screenshot); bool GBALoadState(struct GBAThread* thread, struct VDir* dir, int slot);
M
src/gba/video.c
→
src/gba/video.c
@@ -235,7 +235,7 @@ // Nothing to do
} -void GBAVideoSerialize(struct GBAVideo* video, struct GBASerializedState* state) { +void GBAVideoSerialize(const struct GBAVideo* video, struct GBASerializedState* state) { memcpy(state->vram, video->renderer->vram, SIZE_VRAM); memcpy(state->oam, video->oam.raw, SIZE_OAM); memcpy(state->pram, video->palette, SIZE_PALETTE_RAM);@@ -249,7 +249,7 @@ state->video.nextVcounterIRQ = video->nextVcounterIRQ;
state->video.frameCounter = video->frameCounter; } -void GBAVideoDeserialize(struct GBAVideo* video, struct GBASerializedState* state) { +void GBAVideoDeserialize(struct GBAVideo* video, const struct GBASerializedState* state) { memcpy(video->renderer->vram, state->vram, SIZE_VRAM); int i; for (i = 0; i < SIZE_OAM; i += 2) {
M
src/gba/video.h
→
src/gba/video.h
@@ -201,7 +201,7 @@
void GBAVideoWriteDISPSTAT(struct GBAVideo* video, uint16_t value); struct GBASerializedState; -void GBAVideoSerialize(struct GBAVideo* video, struct GBASerializedState* state); -void GBAVideoDeserialize(struct GBAVideo* video, struct GBASerializedState* state); +void GBAVideoSerialize(const struct GBAVideo* video, struct GBASerializedState* state); +void GBAVideoDeserialize(struct GBAVideo* video, const struct GBASerializedState* state); #endif