Castle Paradox Forum Index Castle Paradox

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
 Gamelist   Review List   Song List   All Journals   Site Stats   Search Gamelist   IRC Chat Room

Externally Reading the .SAV files

 
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP!
View previous topic :: View next topic  
Author Message
NeoSpade
Of course!




Joined: 23 Sep 2008
Posts: 249
Location: Wales GB

PostPosted: Sat Apr 17, 2010 4:30 am    Post subject: Externally Reading the .SAV files Reply with quote

(First of all hey I'm back after not having a (real) computer for over 3 months ^_^)

Right, so I've recently been thinking of making some interesting programs that revolve around reading the OHRs .SAV files, thing is even though it's just reading them; what is safe to touch in there, what's just garbage, and what is the actual useful stuff.

I've been reading through the wiki article on the .SAV format, but I'm still a bit confused as to what I can externally read for much use.

The tags (2636-2762) are the only part I (vaguely) understand, however; I have no idea how to read whether they are ON or OFF.

Are the Globals (20013-21037) the user define Globals, the Pre-define ones, or both, and again is there anyway I can read of the Globals value or state externally?

I know that the current .SAV format is on its way out, but for now I'd just like to see if I can read this stuff off, any explaination would be greatly appreciated.
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
Bob the Hamster
OHRRPGCE Developer




Joined: 22 Feb 2003
Posts: 2526
Location: Hamster Republic (Southern California Enclave)

PostPosted: Sat Apr 17, 2010 10:39 am    Post subject: Re: Externally Reading the .SAV files Reply with quote

NeoSpade wrote:
(First of all hey I'm back after not having a (real) computer for over 3 months ^_^)


Welcome back!

NeoSpade wrote:

Right, so I've recently been thinking of making some interesting programs that revolve around reading the OHRs .SAV files, thing is even though it's just reading them; what is safe to touch in there, what's just garbage, and what is the actual useful stuff.

I've been reading through the wiki article on the .SAV format, but I'm still a bit confused as to what I can externally read for much use.

The tags (2636-2762) are the only part I (vaguely) understand, however; I have no idea how to read whether they are ON or OFF.


all the data in the SAV file is in 16-bit numbers (so two bytes)

2636 and 2637 is the first 16 bits (0-15)
2638 and 2639 is the next 16 bits (16-31)
2640 and 2641 is the third 16 bits (32-47)
and so-on

I don't know if you are familiar with binary bits, but the least-significant bit is the first one, and the most-significant bit is the last one

1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384

I don't know if I am making sense here or not :)

NeoSpade wrote:

Are the Globals (20013-21037) the user define Globals, the Pre-define ones, or both, and again is there anyway I can read of the Globals value or state externally?


Those are the plotscripting global variables. I am not sure what you mean by pre-defined ones.

NeoSpade wrote:
I know that the current .SAV format is on its way out, but for now I'd just like to see if I can read this stuff off, any explaination would be greatly appreciated.


Yeah, it is all going to go away, hopefully soon. The new format will be based on RELOAD and it will be possible to export it to XML for much easier inspection.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rimudora
Psychopath yandere
Halloween 2006 Creativity Winner
Halloween 2006 Creativity Winner



Joined: 26 May 2005
Posts: 335

PostPosted: Sat Apr 17, 2010 11:05 am    Post subject: Reply with quote

To start off you'd need to get a hex viewer. I used XVI32 for the examples here.



This is what you see right away when you open up the .sav file. (I'm using a Vikings of Midgard save here.) The numbers in each box is a byte, but each INT (the numbers used in the SAV wiki article) is made up of two bytes. So if the wiki article says the integer offset of something is 2636, for example, you'd have to skip ahead to byte 5272, which would bring you here where the tag information is stored.



This part might be a little confusing. The values WITHIN each byte are in the right order (left to right), but you have to read the values in adjacent bytes from right to left. So here at INT 2636, the numbers they're giving you are E0-FD, but you should flip it around and read it as FDE0. If you feed it into a hexadecimal calculator, you see that the decimal value is 74992 and the binary value is:

1111110111100000

If you read this backwards (right to left), it tells you the on/off values of the first 16 tag values. So tags 0-4 are off, tags 5-8 are on, tag 9 is off, and tags 10-15 are on.

I'm sort of an amateur at this, so someone speak up if I'm getting any of this wrong.
Back to top
View user's profile Send private message Send e-mail
TMC
On the Verge of Insanity




Joined: 05 Apr 2003
Posts: 3240
Location: Matakana

PostPosted: Sun Apr 18, 2010 6:28 am    Post subject: Reply with quote

Sephy's walkthrough looks correct.

Global variables are stored in a really messy way. They are split into 4 blocks. The easiest way to load them is to adapt the loadglobalvars function in moresubs.bas. This function loads a specified range of globals, so should be easy to modify to load either all, or a single, global. If you don't understand our FB code very well, I could translate it into psuedo code or something else.
_________________
"It is so great it is insanely great."
Back to top
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic    Castle Paradox Forum Index -> HELP! All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group