initial RTC implementation
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user