How to save my game in a memory card?
-
- Curious PSXDEV User
- Posts: 10
- Joined: May 24, 2014
- I am a: Indie Programer and Designer
- PlayStation Model: SCPH-101
- Location: Brazil
How to save my game in a memory card?
What is the code to save my game in memory card? Tanks.
Cristiano Hoffmann dos Santos
-
Administrator Verified
- Admin / PSXDEV
- Posts: 2691
- Joined: Dec 31, 2012
- I am a: Shadow
- PlayStation Model: H2000/5502
In the Sony examples for the Psy-Q SDK. Tanks Yue for your question.
Development Console: SCPH-5502 with 8MB RAM, MM3 Modchip, PAL 60 Colour Modification (for NTSC), PSIO Switch Board, DB-9 breakout headers for both RGB and Serial output and an Xplorer with CAETLA 0.34.
PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.
PlayStation Development PC: Windows 98 SE, Pentium 3 at 400MHz, 128MB SDRAM, DTL-H2000, DTL-H2010, DTL-H201A, DTL-S2020 (with 4GB SCSI-2 HDD), 21" Sony G420, CD-R burner, 3.25" and 5.25" Floppy Diskette Drives, ZIP 100 Diskette Drive and an IBM Model M keyboard.
-
Shendo Verified
- C Programming Expert
- Posts: 250
- Joined: Mar 21, 2012
- I am a: Programmer
- Motto: Never settle
- PlayStation Model: SCPH-7502
- Discord: ShendoXT
- Location: Croatia, EU
There are several ways:
In your main add this:
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:
And then you can write your data:
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).
- Using filesystem BIOS routines,
- Using Memory Card specific BIOS routines.
- Low level access to SIO registers (only for advanced users).
In your main add this:
Code: Select all
InitCARD(1);
StartCARD();
bu_init();
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);
Code: Select all
f = open("bu00:BEmysave", O_WRONLY);
write(f,&SomeArry[0], 8192);
close(f);
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).
Dev console: SCPH-7502, FreePSXBoot, CH340 serial cable.
-
- Curious PSXDEV User
- Posts: 10
- Joined: May 24, 2014
- I am a: Indie Programer and Designer
- PlayStation Model: SCPH-101
- Location: Brazil
Who is online
Users browsing this forum: No registered users and 3 guests