initial RTC implementation
This commit is contained in:
@@ -212,18 +212,15 @@ void PIF::ProcessCommands(Mem &mem) {
|
|||||||
break;
|
break;
|
||||||
case 2: {
|
case 2: {
|
||||||
auto now = std::time(nullptr);
|
auto now = std::time(nullptr);
|
||||||
tm gmtm{};
|
auto* gmtm = gmtime(&now);
|
||||||
if(gmtime_s(&gmtm, &now)) {
|
res[0] = BCD_ENCODE(gmtm->tm_sec);
|
||||||
Util::panic("Could not retrieve time!");
|
res[1] = BCD_ENCODE(gmtm->tm_min);
|
||||||
}
|
res[2] = BCD_ENCODE(gmtm->tm_hour) + 0x80;
|
||||||
res[0] = BCD_ENCODE(gmtm.tm_sec);
|
res[3] = BCD_ENCODE(gmtm->tm_mday);
|
||||||
res[1] = BCD_ENCODE(gmtm.tm_min);
|
res[4] = BCD_ENCODE(gmtm->tm_wday);
|
||||||
res[2] = BCD_ENCODE(gmtm.tm_hour) + 0x80;
|
res[5] = BCD_ENCODE(gmtm->tm_mon);
|
||||||
res[3] = BCD_ENCODE(gmtm.tm_mday);
|
res[6] = BCD_ENCODE(gmtm->tm_year);
|
||||||
res[4] = BCD_ENCODE(gmtm.tm_wday);
|
res[7] = (gmtm->tm_year - 1900) >= 100 ? 1 : 0;
|
||||||
res[5] = BCD_ENCODE(gmtm.tm_mon);
|
|
||||||
res[6] = BCD_ENCODE(gmtm.tm_year);
|
|
||||||
res[7] = (gmtm.tm_year - 1900) >= 100 ? 1 : 0;
|
|
||||||
} break;
|
} break;
|
||||||
default: Util::panic("Invalid read RTC block {}", cmd[CMD_START]);
|
default: Util::panic("Invalid read RTC block {}", cmd[CMD_START]);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user