GP32 Reading From Smc?


mystic_twin

Still Fresh
Joined
Jul 2, 2003
Messages
30
Hello,

I was just wondering if anyone has any code for reading files from an smc, i want to be able to load audio files for playback.

thank you,

Ian,

Btw, if you also know of any code on how to write to the smc, that would be cool.

Thanks.
 
mystic_twin posted on May 17 2004 at 09:44 PM said:
Hello,

I was just wondering if anyone has any code for reading files from an smc, i want to be able to load audio files for playback.

thank you,

Ian,

Btw, if you also know of any code on how to write to the smc, that would be cool.

Thanks.
which OS/SDK?
 
Last edited by a moderator:
Look up GpFileOpen, GpFileCreate etc in the official SDK documentation, or use fopen in Mirko's SDK, etc (he has a PDF covering all of his SDKs functions - see his thread for a link).
 
Last edited by a moderator:
Yep but remember: before doing any smc operation you have to call GpFatInit()
;) If you miss this, you won't go any futher...

I personally use the devkitadv SDK and I goth the following functions in gpstdio.h:

Code:
ERR_CODE GpFatInit (void);
...
ERR_CODE GpFileOpen (const char * p_file_name, ulong fopen_mode, F_HANDLE *p_handle);
ERR_CODE GpFileRead (F_HANDLE h_file, void * p_buf, ulong buf_size, ulong * p_read_count);
ERR_CODE GpFileWrite (F_HANDLE h_file, const void * p_buf, ulong count);
ERR_CODE GpFileSeek (F_HANDLE h_file, ulong seek_mode, ulong offset, long * p_old_offset);
ERR_CODE GpFileClose (F_HANDLE h_file);
...

With those you can do everything... Just a brief example, in case you need it:

Code:
F_HANDLE *myfile;
char mydata;

GpFatInit();
if( GpFileOpen( "gp:\\gpmm\\test.bin", OPEN_R, &myfile )!=SM_OK )
  return -1;
if( GpFileRead( myfile, &mydata, sizeof(mydata), 1)==SM_OK )
{
....
}
...
GpFileClose( myfile );

Hope you got the idea..

Good luck with your coding ;)

Later
Alessandro
 
I don't understand:

Code:
if( GpFileRead( myfile, &mydata, sizeof(mydata), 1)==SM_OK )

you never seemed to define the size of mydata? Are you intentionally reading in blocks? :blink:
 
That's a yes then:). It seemed odd to me that you are reading in 1 byte chunks, I would've found it more logical if you read a string or int or whatever, so I suspected a special meaning with the 1 byte size. :)
 
Thanks guys, that helps alot.

Cheers for the source code Alessandro. That will be very usefull.

Ian
 
Back
Top