From ca5d43177075ac037a05040bd239348b240b1c86 Mon Sep 17 00:00:00 2001 From: SimoneN64 Date: Tue, 6 Jun 2023 10:59:36 +0200 Subject: [PATCH] initial RTC implementation --- src/backend/core/mmio/PIF.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/src/backend/core/mmio/PIF.cpp b/src/backend/core/mmio/PIF.cpp index 3042c5bb..5e2f4f6a 100644 --- a/src/backend/core/mmio/PIF.cpp +++ b/src/backend/core/mmio/PIF.cpp @@ -212,18 +212,15 @@ void PIF::ProcessCommands(Mem &mem) { break; case 2: { auto now = std::time(nullptr); - tm gmtm{}; - if(gmtime_s(&gmtm, &now)) { - Util::panic("Could not retrieve time!"); - } - res[0] = BCD_ENCODE(gmtm.tm_sec); - res[1] = BCD_ENCODE(gmtm.tm_min); - res[2] = BCD_ENCODE(gmtm.tm_hour) + 0x80; - res[3] = BCD_ENCODE(gmtm.tm_mday); - res[4] = BCD_ENCODE(gmtm.tm_wday); - res[5] = BCD_ENCODE(gmtm.tm_mon); - res[6] = BCD_ENCODE(gmtm.tm_year); - res[7] = (gmtm.tm_year - 1900) >= 100 ? 1 : 0; + auto* gmtm = gmtime(&now); + res[0] = BCD_ENCODE(gmtm->tm_sec); + res[1] = BCD_ENCODE(gmtm->tm_min); + res[2] = BCD_ENCODE(gmtm->tm_hour) + 0x80; + res[3] = BCD_ENCODE(gmtm->tm_mday); + res[4] = BCD_ENCODE(gmtm->tm_wday); + res[5] = BCD_ENCODE(gmtm->tm_mon); + res[6] = BCD_ENCODE(gmtm->tm_year); + res[7] = (gmtm->tm_year - 1900) >= 100 ? 1 : 0; } break; default: Util::panic("Invalid read RTC block {}", cmd[CMD_START]); }