n64: speed up first boot of games with RTC

There is no reason to advance ~1.7 billion times from the epoch. We can
just initialize the RTC with the current time.
This commit is contained in:
Giovanni Bajo
2026-09-06 12:34:34 +01:00
committed by Luke Usher
parent 5de16c334d
commit e6130f66e7
+4 -4
View File
@@ -10,7 +10,7 @@ auto Cartridge::RTC::load() -> void {
present = 1;
n64 timestamp = ram.read<Dual>(24);
if(!~timestamp) {
time_t t = (time_t)0;
time_t t = time(0);
struct tm tmm = *localtime(&t);
ram.write<Byte>(16, BCD::encode(tmm.tm_sec));
ram.write<Byte>(17, BCD::encode(tmm.tm_min));
@@ -20,10 +20,10 @@ auto Cartridge::RTC::load() -> void {
ram.write<Byte>(21, BCD::encode(tmm.tm_mon + 1));
ram.write<Byte>(22, BCD::encode(tmm.tm_year % 100));
ram.write<Byte>(23, BCD::encode(tmm.tm_year / 100));
} else {
timestamp = time(0) - timestamp;
advance(timestamp);
}
timestamp = time(0) - timestamp;
advance(timestamp);
}
}