Open ZXGuesser opened 1 year ago
Thanks! I had seen this on Stardot, but posting here is a helpful reminder to look at it.
I'm wondering whether the RTCY2KAdjust
option is still needed. The previous code in RTCInit()
is:
CMOSRAM[9] = BCD(static_cast<unsigned char>(CurTime->tm_year - (RTCY2KAdjust ? 20 : 0)));
tm_year
contains the number of years since 1900, so 100 for the year 2000, which is larger than the maximum two-digit BCD number (99). So it seems that RTCY2KAdjust
is intended to map years 2000-2019 to 1980-1999. But this obviously will overflow the BCD range from 2020 onwards.
As the MOS only looks for the last two digits of the year (info here), it seems we could just use the year modulo 100 and remove the RTCY2KAdjust
option. Years will always be displayed as 19xx, unless using a patched MOS, though.
My suggestion for dealing with the "configuring RTC to return suitable years for specific things" issue would be to simply store and reload the offset from SysTime as part of the preferences (defaulting to zero offset so a new profile gets the current system time). That way the realtime clock still behaves in a predictable way but can be set to whatever date and time a user wants and persists when the emulated beeb is "off" just as a real machine.
Originally posted on Stardot but for some reason I never opened a bug here 🤦♂️