Skip to content

Commit 1490431

Browse files
Add RTC last latch to savestates
1 parent 348bf75 commit 1490431

2 files changed

Lines changed: 7 additions & 2 deletions

File tree

include/mgba/internal/gba/serialize.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,8 @@ mLOG_DECLARE_CATEGORY(GBA_STATE);
258258
* 0x00380 - 0x0038F: Audio FIFO B samples
259259
* 0x00390 - 0x003CF: Audio rendered samples
260260
* 0x003D0 - 0x003D3: Memory bus value
261-
* 0x003D4 - 0x003FF: Reserved (leave zero)
261+
* 0x003D4 - 0x003DB: RTC last latch
262+
* 0x003DC - 0x003FF: Reserved (leave zero)
262263
* 0x00400 - 0x007FF: I/O memory
263264
* 0x00800 - 0x00BFF: Palette
264265
* 0x00C00 - 0x00FFF: OAM
@@ -474,7 +475,9 @@ struct GBASerializedState {
474475

475476
uint32_t bus;
476477

477-
uint32_t reserved[11];
478+
int64_t rtcLastLatch;
479+
480+
uint32_t reserved[9];
478481

479482
uint16_t io[GBA_SIZE_IO >> 1];
480483
uint16_t pram[GBA_SIZE_PALETTE_RAM >> 1];

src/gba/cart/gpio.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,7 @@ void GBAHardwareSerialize(const struct GBACartridgeHardware* hw, struct GBASeria
791791
STORE_32(hw->rtc.command, 0, &state->hw.rtcCommand);
792792
STORE_32(hw->rtc.control, 0, &state->hw.rtcControl);
793793
memcpy(state->hw.time, hw->rtc.time, sizeof(state->hw.time));
794+
STORE_64((int64_t)hw->rtc.lastLatch, 0, &state->rtcLastLatch);
794795

795796
STORE_16(hw->gyroSample, 0, &state->hw.gyroSample);
796797
flags1 = GBASerializedHWFlags1SetGyroEdge(flags1, hw->gyroEdge);
@@ -844,6 +845,7 @@ void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, const struct GBASer
844845
LOAD_32(hw->rtc.command, 0, &state->hw.rtcCommand);
845846
LOAD_32(hw->rtc.control, 0, &state->hw.rtcControl);
846847
memcpy(hw->rtc.time, state->hw.time, sizeof(hw->rtc.time));
848+
LOAD_64(hw->rtc.lastLatch, 0, &state->rtcLastLatch);
847849
GBAHardwareRTCSanitize(hw);
848850

849851
LOAD_16(hw->gyroSample, 0, &state->hw.gyroSample);

0 commit comments

Comments
 (0)