It is currently Sun Sep 24, 2017 12:25 pm

All times are UTC - 7 hours





Post new topic Reply to topic  [ 3 posts ] 
Author Message
PostPosted: Mon Jul 24, 2017 11:38 am 
Offline

Joined: Sat Jan 09, 2016 5:30 pm
Posts: 10
What is the initial value for battery-backed PRG-RAM? If it is undefined, how would one initialize it without overwriting save data?


Top
 Profile  
 
PostPosted: Mon Jul 24, 2017 11:43 am 
Offline
User avatar

Joined: Sun Jan 22, 2012 12:03 pm
Posts: 5645
Location: Canada
In general it has no reliable startup state. You should treat it as if it is random.

To check to see if it's been initialized, it's usual to write some sort of signature values somewhere and check that. If that signature is not present, assume the RAM is uninitialized and proceed wipe its contents (and write the signature).

You could use a CRC or something similar instead of a signature to check for data integrity, etc.


Sometimes it's also useful to have some sort of manual/debug override that forces it to use whatever's there despite failing a signature/CRC check. e.g. I think Chrono Trigger has a cheat code that can be used to load a corrupted save (can be used for some speedrun exploits).


Top
 Profile  
 
PostPosted: Mon Jul 24, 2017 11:46 am 
Offline

Joined: Sun Apr 13, 2008 11:12 am
Posts: 6182
Location: Seattle
RAMs usually power up with some pattern, plus a few random bits.

To prevent accidentally formatting over valid data, use some kind of validity marker. The more bits you use, the less likely it is to arise randomly. For example, Galaxian puts a copy of the author's name in RAM to detect warm boots, because the odds of that name arising randomly is minuscule.

Also consider protecting the actual save data itself with some kind of checksum.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 7 hours


Who is online

Users browsing this forum: Bing [Bot] and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group