Increment state version, narrow direction in state too

This commit is contained in:
CasualPokePlayer 2025-04-06 21:08:50 -07:00 committed by Vicki Pfau
parent 3ae429fd91
commit 57d1552582
3 changed files with 12 additions and 10 deletions

View File

@ -165,8 +165,10 @@ mLOG_DECLARE_CATEGORY(GBA_STATE);
* | 0x00288 - 0x0028B: DMA next count * | 0x00288 - 0x0028B: DMA next count
* | 0x0028C - 0x0028F: DMA next event * | 0x0028C - 0x0028F: DMA next event
* 0x00290 - 0x002C3: GPIO state * 0x00290 - 0x002C3: GPIO state
* | 0x00290 - 0x00291: Pin state * | 0x00290: Pin state
* | 0x00292 - 0x00293: Direction state * | 0x00291: Write latch
* | 0x00292: Direction state
* | 0x00293: Reserved
* | 0x00294 - 0x002B6: RTC state (see hardware.h for format) * | 0x00294 - 0x002B6: RTC state (see hardware.h for format)
* | 0x002B7 - 0x002B7: GPIO devices * | 0x002B7 - 0x002B7: GPIO devices
* | bit 0: Has RTC values * | bit 0: Has RTC values
@ -378,7 +380,8 @@ struct GBASerializedState {
struct { struct {
uint8_t pinState; uint8_t pinState;
uint8_t writeLatch; uint8_t writeLatch;
uint16_t pinDirection; uint8_t pinDirection;
uint8_t reserved0;
int32_t rtcBytesRemaining; int32_t rtcBytesRemaining;
int32_t rtcTransferStep; int32_t rtcTransferStep;
int32_t rtcBitsRead; int32_t rtcBitsRead;
@ -386,7 +389,7 @@ struct GBASerializedState {
int32_t rtcCommandActive; int32_t rtcCommandActive;
RTCCommandData rtcCommand; RTCCommandData rtcCommand;
uint8_t rtcControl; uint8_t rtcControl;
uint8_t reserved[3]; uint8_t reserved1[3];
uint8_t time[7]; uint8_t time[7];
uint8_t devices; uint8_t devices;
uint16_t gyroSample; uint16_t gyroSample;

View File

@ -485,7 +485,7 @@ void GBAHardwareSerialize(const struct GBACartridgeHardware* hw, struct GBASeria
flags1 = GBASerializedHWFlags1SetReadWrite(flags1, hw->readWrite); flags1 = GBASerializedHWFlags1SetReadWrite(flags1, hw->readWrite);
state->hw.writeLatch = hw->writeLatch; state->hw.writeLatch = hw->writeLatch;
state->hw.pinState = hw->pinState; state->hw.pinState = hw->pinState;
STORE_16(hw->direction, 0, &state->hw.pinDirection); state->hw.pinDirection = hw->direction;
state->hw.devices = hw->devices; state->hw.devices = hw->devices;
STORE_32(hw->rtc.bytesRemaining, 0, &state->hw.rtcBytesRemaining); STORE_32(hw->rtc.bytesRemaining, 0, &state->hw.rtcBytesRemaining);
@ -521,10 +521,9 @@ void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, const struct GBASer
GBASerializedHWFlags1 flags1; GBASerializedHWFlags1 flags1;
LOAD_16(flags1, 0, &state->hw.flags1); LOAD_16(flags1, 0, &state->hw.flags1);
hw->readWrite = GBASerializedHWFlags1GetReadWrite(flags1); hw->readWrite = GBASerializedHWFlags1GetReadWrite(flags1);
hw->writeLatch = state->hw.writeLatch; hw->writeLatch = state->hw.writeLatch & 0xF;
hw->pinState = state->hw.pinState; hw->pinState = state->hw.pinState & 0xF;
LOAD_16(hw->direction, 0, &state->hw.pinDirection); hw->direction = state->hw.pinDirection & 0xF;
hw->direction &= 0xF;
hw->devices = state->hw.devices; hw->devices = state->hw.devices;
if ((hw->devices & HW_GPIO) && hw->gpioBase) { if ((hw->devices & HW_GPIO) && hw->gpioBase) {

View File

@ -15,7 +15,7 @@
#include <fcntl.h> #include <fcntl.h>
MGBA_EXPORT const uint32_t GBASavestateMagic = 0x01000000; MGBA_EXPORT const uint32_t GBASavestateMagic = 0x01000000;
MGBA_EXPORT const uint32_t GBASavestateVersion = 0x00000007; MGBA_EXPORT const uint32_t GBASavestateVersion = 0x00000008;
mLOG_DEFINE_CATEGORY(GBA_STATE, "GBA Savestate", "gba.serialize"); mLOG_DEFINE_CATEGORY(GBA_STATE, "GBA Savestate", "gba.serialize");