PSPIdentRandom Homebrew: PSPIdent
Get info about your motherboard, firmware, etc.. take a screenshot to share it easy with other peopl [...]

Chars? floats? Saving games?

Forum rules
Any post not directly related to programming will be moderated.
Do not request people to code something for you.
Avoid posting messages that do not bring anything to the conversation. We want the threads in this subforum to stay focused.

Chars? floats? Saving games?

Postby Zasisem » Wed Oct 12, 2011 11:16 pm

Advertising
How does saving work on PSP? Or any platform? Do they save certain chars? Floats? What kind of information does it save? basically how does saving work? Do they save certain variables or something? Like say you have in a game:

You start with:
Spoiler
Coins: 0
Health: 500
Level: 1


Later in the game your with:
Spoiler
Coins: 1000
Health: 375
Level: 54


I'm guessing the the local variables would be:
Code: Select all
int Coins = 0,
     Health = 500,
     Level = 1;

I sense incorrect statements already.. Lol but I am asking a question. :)
Zasisem
 
Posts: 283
Joined: Mon Sep 27, 2010 3:49 pm

Re: Chars? floats? Saving games?

Postby NightStar3 » Wed Oct 12, 2011 11:25 pm

Advertising
Take a look at some online code samples and look at the psputility_savedata.h file
for more information :P
Follow me on Twitter
User avatar
NightStar3
VIP
 
Posts: 460
Joined: Mon Sep 27, 2010 8:22 pm
Location: 0x13371A4D

Re: Chars? floats? Saving games?

Postby Zasisem » Wed Oct 12, 2011 11:47 pm

NightStar3 wrote:Take a look at some online code samples and look at the psputility_savedata.h file
for more information :P

They don't explain how they can save certain data into "gibirish code" that we cant read then load back again later though... :oops: I'll take a look though
Zasisem
 
Posts: 283
Joined: Mon Sep 27, 2010 3:49 pm

Re: Chars? floats? Saving games?

Postby codestation » Thu Oct 13, 2011 12:17 am

The data that needs to be saved depends entirely of you and how much you want to reconstruct of the game when the user loads the savedata. For example, if you make a 2d side scrolling game like sonic, then you only need to save the rings number, level, score, emeralds, lives and optionally the checkpoint number in the level (of course, if you want to save only the level and drop everything else its fine too).

If you game is simple enough then yu can save simple data types, else you could save the structs, or if you are using objects then you can serialize them to the savedata so you can load the exact state later.

If you are asking how then it can be as simple as:

Code: Select all
typedef struct {
   int level;
   int score;
} savedata;
........
savedata data;
.........
data.level = current_level;
data.score = current_score;
fwrite(&data, sizeof(data), 1, fd); //if you are managing the file yourself
// or just call the savedata_utility and give them the struct pointer
..........


Also you don't need to worry about that "gibirish code/data", just read it in the same way that you are saving it and you will be fine.
Plugin list
Working on: Python (django, sqlalchemy, PyQt, etc) + Lua
Repositories: github, bitbucket, google code
Just feel the code..
opencma/vitamtp for Archlinux
User avatar
codestation
Big Beholder
 
Posts: 1287
Joined: Wed Jan 19, 2011 3:45 pm
Location: /dev/negi

Re: Chars? floats? Saving games?

Postby m0skit0 » Thu Oct 13, 2011 8:22 am

TL;DR: each game/developer has his own way to store information on the savegame. This depends on what you want to save and how you want to save it. Usually, it's binary (to load fast) and with no standard format (not that there's any anyway...).
I wanna lots of mov al,0xb
Image
"just not into this RA stuffz"
User avatar
m0skit0
Guru
 
Posts: 4800
Joined: Mon Sep 27, 2010 6:01 pm


Return to Programming

Who is online

Users browsing this forum: No registered users and 2 guests

Friends

Coding 'n Cracking - Nymphaea - PS3 Forum - darkforestgroup - daxhordes.org - Tgames - coldbird - gopsp.it - pspstation.org - prometheus - hgoel.info - MakeSmartTV - ps vita