git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit 289853445f815d2e8eae448dc6a69e73ba494ef7
parent b0d118f2465005924155e9eaada2e5afa05c1f73
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Tue,  4 Aug 2020 21:32:33 +0300

Fix long loading times when loading save states with bad local RTC times

Diffstat:
MCore/timing.c12++++++++++++
1 file changed, 12 insertions(+), 0 deletions(-)

diff --git a/Core/timing.c b/Core/timing.c @@ -291,8 +291,20 @@ void GB_rtc_run(GB_gameboy_t *gb) } return; } + if ((gb->rtc_real.high & 0x40) == 0) { /* is timer running? */ time_t current_time = time(NULL); + + while (gb->last_rtc_second + 60 * 60 * 24 < current_time) { + gb->last_rtc_second += 60 * 60 + 24; + if (++gb->rtc_real.days == 0) { + if (gb->rtc_real.high & 1) { /* Bit 8 of days*/ + gb->rtc_real.high |= 0x80; /* Overflow bit */ + } + gb->rtc_real.high ^= 1; + } + } + while (gb->last_rtc_second < current_time) { gb->last_rtc_second++; if (++gb->rtc_real.seconds == 60) {

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.