Home | Forums | What's new | Resources | |
backup memory structure |
the_mad_joob - Nov 8, 2010 |
1 | 2 | Next> |
cafe-alpha | Nov 9, 2010 | |||||||||||||
Thank you for detailing the backup data format
Your unknown data seems to be a time stamp. For more informations, I recommend you to read SBL backup library documentation : ST-162-R1-092994.... Also, the backup header format is detailled in SBL's SEGA_BUP.H, and it fits your description :
Code:
About the time stamp: you can specify a date to a backup in a way like this:
Code:
BUP_SetDate converts a date structure to a 32bits value, so the separator above the "checksum" is actually used. I tried with a dummy date value like this: bupDir.date = 0x12345678; And I obtained the following result:
(*) The backup language values are defined as below in SBL's SEGA_BUP.H :
Unfortunately, the BUP_SetDate function is a bios function, so I don't know how the date is converted. However, by seeing some date/value couples, it may be easy to guess BUP_SetDate's algorithm. |
antime | Nov 9, 2010 | |||
The time stamps seem to be a minute count. 16231786 - 16230346 = 1440, 1440 = 60 * 24. 16800586 - 16274986 = 525600, 525600 = 1440 * 365. |
the_mad_joob | Nov 9, 2010 | |||
Nice finds =] A time stamp of course... We still have to know how it's precisely calculated but a minute count seems to be a nice lead. However, i'm then suprised that 1980/0/0 0:0 (0) doesn't return 0x00000000. Good point about the language byte too (didn't notice that one). It may be used by games which support multi-language saves. The first post was edited and now includes up2date discoveries (thx guys). |
cafe-alpha | Nov 9, 2010 | |||||
The first time stamp in my previous post was actually not valid, because month and day need to be counted from 1, and I set them to zero. By testing with the valid "1980/1/1 0:0" date, BUP_SetDate returned zero. It seems you can convert the date with the following formula (However, I don't know if it correctly works for leap year or so) : u = BUP_SetDate(date) * 60 + 315529200 (*) Where u is the unix time. (*) 315529200 is the unix time for "1980/1/1 0:0" Example with your save data : u = 0xF795A4 * 60 + 315529200 = 1289071200 By converting the result above (for example, in this page...), it seems to be dated from "2010/11/06 20:20". |
the_mad_joob | Nov 10, 2010 | |||
First post updated. Thx again for your time cafe-alpha. You're the man once again... So the backup mem is almost naked now =] Why almost ? Because i'm afraid there's one more thing to discover. I found some strange incremental word arrays that don't belong to data areas. I'll tell you more later cause right now my brain is too upside down because of hex editing (a bit of smoking too i must confess =]). P.S. : cafe-alpha, are you french by any chance ? |
cafe-alpha | Nov 10, 2010 | |||||
I am french. Are you... french too ? |
TascoDLX | Nov 10, 2010 | |||||
When you create a file that's large enough to span multiple blocks, the block numbers must be stored. This is important in case the blocks are noncontiguous. |
ExCyber | Nov 10, 2010 | |||||
It seems that there isn't a lot of free space in the header. Is it stored like a linked list (i.e. there's a "next block" field)? |
cafe-alpha | Nov 10, 2010 | |||||
I tried to write/erase some long dummy data on backup RAM, and I could verify that the 2nd, 3rd~ block's header are all set to zero. (and the first block's header is set to 0x80000000) Maybe the "strange incremental word arrays" are remains from deleted backup data ? When deleting backup data, the data themselves are not set to zero, only the first block's header is set to zero. |
TascoDLX | Nov 10, 2010 | |||||||||
It's just a ordinary zero-terminated list. There's no fixed header size -- the header will expand as necessary. Example: a 4-block file starting at block 2 (note, blocks 0 and 1 are the reserved blocks). Immediately following the data size in the file header: 0003 0005 0006 0000 Note, the first block (0002, in this case) is not listed. So, the file data is contained in blocks 0002, 0003, 0005, and 0006, in that order. BTW, the 4-byte block headers do not seem to count towards the data size stored in the file header.
Apparently, no directory data is stored. In order to account for all blocks, the system has to scan for marked block headers to locate each file and scan each file's block list to determine which blocks (and how many) are in use. |
the_mad_joob | Nov 10, 2010 | |||
Well done guys. This seems to be clearer and clearer... That means 512 words may be reserved for block informations in the whole backup memory. That also explains the usage of blocks itself =]. Hey TascoDLX, in your example, i suppose block 4 was skipped because it was already used by another save. You're right, when writing, those arrays must simply be scanned in order to know which is the next available block. I'll add those juicy finds in the first post. Looks like we're done here or what ? Anyway, don't hesitate to post if you know more nasty bytes or find errors in my first post. Thx again =] P.S. to cafe-alpha : Le choix de la vid©o est plus que judicieux =]. |
antime | Nov 10, 2010 | |||||
If you take the 1980/0/0 value and go backwards from 1980/1/1 you get 1963/10/8. I wonder if that's an easter egg - the programmer's birthday or something similar. |
the_mad_joob | Nov 10, 2010 | |||
Who knows what they're able to do... =] |
TascoDLX | Nov 11, 2010 | |||||||||||
Correction to the order of data and the reference year (epoch) in the first post:
Also, for clarity, I'd say:
Something like that.
The value in question, 0x008246A0, corresponds to 1996/3/26 0:00, which pretty much coincides with the passing of Comet Hyakutake.... As far as easter eggs go, that'd be my guess. |
the_mad_joob | Nov 11, 2010 | |||
Thanks, it's good to have u there =] |
cafe-alpha | Nov 11, 2010 | ||||||||
Here is a correction about the header structure:
As described in the BupDir structure, the `datasize' field is a 32 bits value. As Saturn internal backup memory size is smaller than 64KB, the upper 2 bytes are not used, but they may be used when data is saved to a backup memory card.
Nice !!! I just wanted to know what may happen in the case the programmer doesn't set the date field in a backup entry. In the case the result wasn't zero, I wasn't expecting anything other than a value resulting from an unhandled date value. I'm so sad I couldn't even find this by myself >_< |
antime | Nov 12, 2010 | |||||
The comet wasn't discovered until January 1996. That'd be hell of an easter egg... |
1 | 2 | Next> |