mirror of https://github.com/mgba-emu/mgba.git
GB MBC: Fix RTC access when no save file is loaded
This commit is contained in:
parent
fb8781b493
commit
7940428641
1
CHANGES
1
CHANGES
|
@ -20,6 +20,7 @@ Bugfixes:
|
||||||
- SDL: Attach rumble in SDL frontend
|
- SDL: Attach rumble in SDL frontend
|
||||||
- GBA Hardware: Improve Game Boy Player rumble behavior
|
- GBA Hardware: Improve Game Boy Player rumble behavior
|
||||||
- GB: Initialize audio properly
|
- GB: Initialize audio properly
|
||||||
|
- GB MBC: Fix RTC access when no save file is loaded
|
||||||
Misc:
|
Misc:
|
||||||
- All: Only update version info if needed
|
- All: Only update version info if needed
|
||||||
- FFmpeg: Encoding cleanup
|
- FFmpeg: Encoding cleanup
|
||||||
|
|
|
@ -624,6 +624,9 @@ void _GBHuC3(struct GB* gb, uint16_t address, uint8_t value) {
|
||||||
void GBMBCRTCRead(struct GB* gb) {
|
void GBMBCRTCRead(struct GB* gb) {
|
||||||
struct GBMBCRTCSaveBuffer rtcBuffer;
|
struct GBMBCRTCSaveBuffer rtcBuffer;
|
||||||
struct VFile* vf = gb->sramVf;
|
struct VFile* vf = gb->sramVf;
|
||||||
|
if (!vf) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
ssize_t end = vf->seek(vf, -sizeof(rtcBuffer), SEEK_END);
|
ssize_t end = vf->seek(vf, -sizeof(rtcBuffer), SEEK_END);
|
||||||
switch (end & 0x1FFF) {
|
switch (end & 0x1FFF) {
|
||||||
case 0:
|
case 0:
|
||||||
|
@ -645,6 +648,11 @@ void GBMBCRTCRead(struct GB* gb) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void GBMBCRTCWrite(struct GB* gb) {
|
void GBMBCRTCWrite(struct GB* gb) {
|
||||||
|
struct VFile* vf = gb->sramVf;
|
||||||
|
if (!vf) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
uint8_t rtcRegs[5];
|
uint8_t rtcRegs[5];
|
||||||
memcpy(rtcRegs, gb->memory.rtcRegs, sizeof(rtcRegs));
|
memcpy(rtcRegs, gb->memory.rtcRegs, sizeof(rtcRegs));
|
||||||
time_t rtcLastLatch = gb->memory.rtcLastLatch;
|
time_t rtcLastLatch = gb->memory.rtcLastLatch;
|
||||||
|
@ -663,7 +671,6 @@ void GBMBCRTCWrite(struct GB* gb) {
|
||||||
STORE_32LE(gb->memory.rtcRegs[4], 0, &rtcBuffer.latchedDaysHi);
|
STORE_32LE(gb->memory.rtcRegs[4], 0, &rtcBuffer.latchedDaysHi);
|
||||||
STORE_64LE(rtcLastLatch, 0, &rtcBuffer.unixTime);
|
STORE_64LE(rtcLastLatch, 0, &rtcBuffer.unixTime);
|
||||||
|
|
||||||
struct VFile* vf = gb->sramVf;
|
|
||||||
vf->seek(vf, gb->sramSize, SEEK_SET);
|
vf->seek(vf, gb->sramSize, SEEK_SET);
|
||||||
vf->write(vf, &rtcBuffer, sizeof(rtcBuffer));
|
vf->write(vf, &rtcBuffer, sizeof(rtcBuffer));
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue