GP32 How to load and save ?...


RTj

Member
Joined
Mar 17, 2003
Messages
104
Age
53
Hi all!
:D

I've got some code running well on the GP32 now but I need to load and save to the GP32 SMC. :huh:

I have my screen in a buffer and i'd like to SAVE that screen buffer to a file on the SMC (say as file1.???).
[basically saving a snapshot of the screen]
First problem is how do I save the data? What file format am i using? (or worse still do i need to create a file format??) :huh: :(

I'd like to compress the file (on save) if possible.

I'd also like to give the user a way to load the files they've saved.

I'm not too concerned with a file requester at the moment, just loading and saving to 'banks' since i'm sure people would hate having to put in filenames with a virtual keyboard! ;)

Any help would be greatly appreciated.
 
Use big fat long passwords that are very compressed, because the first time that I saw some file saving/loading code I never want to look at it again ;) It is much easier to store the data for a pic in your brain IMHO (well, mabye it is harder, but I have never tried :p ) , but if you really want it, there is some examle on CHN's (DevKitAdv GP32 patch) page.
 
yeah i know whatcha mean... :blink:
its not something i'm looking forward to... :(
I'm sure it'll probably mean code thats PAGES and PAGES in length
(knowing my luck!) :angry:

But i gotta load and save images... gotta be done...
 
My first thought would just be to take the actual surface of the screen (GPDRAWSURFACE type? ..or whatever) and write it directly to a file like you would with any other struct (fwrite if you are using devkitadv which has a wrapper for this over the SDK functions). Later, you can just load it right back into another screen buffer and flip it to active.

I can't think of any reason why that wouldn't work as you would expect it to. It wouldn't be compressed at all.. size wise you are looking at 76kb or so per screen.

Quick & dirty but easy to implement in just a couple lines of code :)
 
@makenai : well, i did think of that but wasn't sure if it'd be that easy! :blink:

I'm still an amateur and quite probably out of my depth here. :(
What commands would i use? And what information do the commands need??? :huh:

Any help would be great.

Thanks for the replies guys.... :)
 
Just take a look at the TGA format, really simple to use and a save function does not have to be more than like 20-30 lines.
(loading is just as simple, since the format does not have to be compressed, but for 8bit TGA's you could add RLE compression, not a very good compression
but it's good enough and lossless)

//mithris
 
yeah but how would i go about loading and saving ???
I'm not too clued up on this kinda thing.

Is there maybe a command to dump a screen to SMC as a BMP file or something ???

I have a screen called bgscreen. This is where the image is that i'd like to save to the SMC.
And this is also the screen i'd like to load the image into...

Thanks for the reply Mithris. :)
 
Well, depending on the mode you have a 240x320 pixel buffer with either 8bit data or 16bit data, afaik TGA file format does not support 16bit, but it's easy
to extend it to 32bit and then save the image, what you do is you enter the needed values in the tga header (check www.wotsit.org for details)
and allocate a buffer big enough 320x240x(1 or 4 depending on mode) + 18(TGA header size) copy the header into the buffer, and also copy the image data there.
Then use GpFileOpen() (I'm not sure about that function name, it should be mentioned in gpstdlib.h or smth)
And then use GpFileWrite() (Same as above, i'm not sure about the name, but something similar) to save your buffer to the file..
and then you're done, you can transfer the TGA image to the PC and view it.

--
mithris
 
@ mithris : thanks for the reply mate.
I can see where your coming from, i know the basics behind it now but i just dont know how to put it into practice... <_<

I think the commands are GpFileCreate then GpFileWrite, not sure, with a GpFatInit beforehand.
Oh, and i'm using 16bit mode... maybe I could use BMP format???

But i've no idea how to use the commands, the API docs arent written for us non-programmers... :(

How do i copy the header to the buffer? And how do i get the buffer into the file ??? :huh:
And is the buffer for the data and header the same as the buffer with my image in it ??? :huh:

Sorry to be a pest... :(
 
Back
Top