mirror of
https://github.com/libretro/mgba.git
synced 2024-11-28 02:30:21 +00:00
GBA: Better const correctness for serialization
This commit is contained in:
parent
826569fdf7
commit
6835ac8a81
@ -424,7 +424,7 @@ uint8_t GBAHardwareTiltRead(struct GBACartridgeHardware* hw, uint32_t address) {
|
||||
|
||||
// == 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 @@ void GBAHardwareSerialize(struct GBACartridgeHardware* hw, struct GBASerializedS
|
||||
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;
|
||||
|
@ -149,7 +149,7 @@ void GBAHardwareTiltWrite(struct GBACartridgeHardware* gpio, uint32_t address, u
|
||||
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
|
||||
|
@ -675,7 +675,7 @@ void GBAIOSerialize(struct GBA* gba, struct GBASerializedState* state) {
|
||||
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]) {
|
||||
|
@ -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
|
||||
|
@ -1461,12 +1461,12 @@ void GBAMemoryServiceDMA(struct GBA* gba, int number, struct GBADMA* info) {
|
||||
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);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -55,7 +55,7 @@ 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) {
|
||||
if (state->versionMagic != GBA_SAVESTATE_MAGIC) {
|
||||
GBALog(gba, GBA_LOG_WARN, "Invalid or too new savestate");
|
||||
return;
|
||||
|
@ -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);
|
||||
|
@ -235,7 +235,7 @@ static void GBAVideoDummyRendererGetPixels(struct GBAVideoRenderer* renderer, un
|
||||
}
|
||||
|
||||
|
||||
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 @@ void GBAVideoSerialize(struct GBAVideo* video, struct GBASerializedState* state)
|
||||
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) {
|
||||
|
@ -201,7 +201,7 @@ int32_t GBAVideoProcessEvents(struct GBAVideo* video, int32_t cycles);
|
||||
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
|
||||
|
Loading…
Reference in New Issue
Block a user