There are several ways:
- Using filesystem BIOS routines,
- Using Memory Card specific BIOS routines.
- Low level access to SIO registers (only for advanced users).
Since you are beginner I recommend slower but easier filesystem access.
In your main add this:
Code: Select all
InitCARD(1);
StartCARD();
bu_init();
And then you can access bu00 and bu10 devices for 1st and 2nd Memory Card respectively.
Do note that your array size needs to be multiple of 8 KB (eg. 16, 24, 32, etc).
To create a save you can use this code:
Code: Select all
int f;
f = open("bu00:BEmysave", O_CREAT | 1 << 16);
close(f);
And then you can write your data:
Code: Select all
f = open("bu00:BEmysave", O_WRONLY);
write(f,&SomeArry[0], 8192);
close(f);
This is just a basic code. You will also need to check if there is free space on the card
and if the file opened correctly (maybe there is no card conneceted?).
Use normal file routines for that.
Once you get better at it then use Memory Card specific routines.
With those you can check if the card is connected, formatted, you can list all file and save names, etc.
And unlike file access those routines are not blocking, meaning your game can do something else
while reading/writing data (show loading bar for example).