Skip to content

Commit d2bbb47

Browse files
Add RTC last latch to savestates
1 parent 039f8e9 commit d2bbb47

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
@@ -256,7 +256,8 @@ mLOG_DECLARE_CATEGORY(GBA_STATE);
256256
* 0x00380 - 0x0038F: Audio FIFO B samples
257257
* 0x00390 - 0x003CF: Audio rendered samples
258258
* 0x003D0 - 0x003D3: Memory bus value
259-
* 0x003D4 - 0x003FF: Reserved (leave zero)
259+
* 0x003D4 - 0x003DB: RTC last latch
260+
* 0x003DC - 0x003FF: Reserved (leave zero)
260261
* 0x00400 - 0x007FF: I/O memory
261262
* 0x00800 - 0x00BFF: Palette
262263
* 0x00C00 - 0x00FFF: OAM
@@ -468,7 +469,9 @@ struct GBASerializedState {
468469

469470
uint32_t bus;
470471

471-
uint32_t reserved[11];
472+
int64_t rtcLastLatch;
473+
474+
uint32_t reserved[9];
472475

473476
uint16_t io[GBA_SIZE_IO >> 1];
474477
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
@@ -784,6 +784,7 @@ void GBAHardwareSerialize(const struct GBACartridgeHardware* hw, struct GBASeria
784784
STORE_32(hw->rtc.command, 0, &state->hw.rtcCommand);
785785
STORE_32(hw->rtc.control, 0, &state->hw.rtcControl);
786786
memcpy(state->hw.time, hw->rtc.time, sizeof(state->hw.time));
787+
STORE_64((int64_t)hw->rtc.lastLatch, 0, &state->rtcLastLatch);
787788

788789
STORE_16(hw->gyroSample, 0, &state->hw.gyroSample);
789790
flags1 = GBASerializedHWFlags1SetGyroEdge(flags1, hw->gyroEdge);
@@ -835,6 +836,7 @@ void GBAHardwareDeserialize(struct GBACartridgeHardware* hw, const struct GBASer
835836
LOAD_32(hw->rtc.command, 0, &state->hw.rtcCommand);
836837
LOAD_32(hw->rtc.control, 0, &state->hw.rtcControl);
837838
memcpy(hw->rtc.time, state->hw.time, sizeof(hw->rtc.time));
839+
LOAD_64(hw->rtc.lastLatch, 0, &state->rtcLastLatch);
838840
GBAHardwareRTCSanitize(hw);
839841

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

0 commit comments

Comments
 (0)