MBC3 RTC save format
Back to main page
the RTC data is appended after the sav file, 44 or 48 bytes. you can detect its presence by the save data being 44 or 48 bytes bigger than the cart's ram size, or 44 or 48 bytes bigger than a multiple of 8192.
if the data is 44 bytes, the timestamp is 32 bits. if the data is 48 bytes, the timestamp is 64 bits.
old VBA (from 2005) saves the 44 bytes version, and can load both the 44 and 48 bytes version.
VBA-M saves the 48 bytes version, and can *only* load the 48 bytes version.
one should load both types, and always save the 48 bytes version, and handle the timestamp internally as 64 bits. when loading the 44 bytes version, the high dword of the timestamp is 0.
the data consists entirely of little endian (intel order) dwords. this means the lowest byte is first. as the registers are bytes, it's in the first byte of the field, the other bytes should always be 0.
time is the internal "hidden" version. latched time is what you're reading from the registers.
the unix timestamp is UTC seconds since 1970-01-01 00:00, a very common standard on internet. again, the lowest byte goes first.
An implementation that is unable to save the current time as unix timestamp (for example embedded/hardware) should save the 64 bits value $7fffffff7fffffff, or equivalently, the byte values "ff ff ff 7f ff ff ff 7f" (spanning the 8 bytes in position 40-47).
The reason for this is that VBA-M will ignore a timestamp in the future (will then not advance time). while VBA-M loads the timestamp as 64 bits, VBA only loads the first 4 bytes as 32 bits. the above value will be seen as "in the future" for both 32 bits and 64 bits. BGB supports 64 bits timestamps as well as ignoring future timestamps since version 1.5.3.
offset size desc
0 4 time seconds
4 4 time minutes
8 4 time hours
12 4 time days
16 4 time days high
20 4 latched time seconds
24 4 latched time minutes
28 4 latched time hours
32 4 latched time days
36 4 latched time days high
40 8 unix timestamp when saving (64 bits little endian)