So I did a patch to the pspsdk checked out to revision 1400 and added a sample and a new include:
Code: Select all
--- ./pspsdk/sdk/samples/Makefile.am	Mon Nov  7 15:50:37 2005
+++ ./pspsdk/sdk/samples/Makefile.am	Mon Nov  7 15:17:31 2005
***************
*** 43,49 ****
  	usb/storage \
  	utility/netconf \
  	utility/msgdialog \
! 	utility/systemparam \
  	me/basic \
  	wlan
  
--- 43,50 ----
  	usb/storage \
  	utility/netconf \
  	utility/msgdialog \
! 	utility/systemparam \
! 	utility/savedata
  	me/basic \
  	wlan
  
--- ./pspsdk/sdk/samples/utility/savedata/Makefile.sample	Thu Jan  1 01:00:00 1970
+++ ./pspsdk/sdk/samples/utility/savedata/Makefile.sample	Mon Nov  7 15:14:42 2005
***************
*** 0 ****
--- 1,12 ----
+ PSPSDK = $(shell psp-config --pspsdk-path)
+ PSPLIBSDIR = $(PSPSDK)/..
+ TARGET = savedatasample
+ OBJS = main.o
+ LIBS = -lpspdebug -lpsputility -lm
+ 
+ 
+ CFLAGS = -O2 -G0 -Wall
+ CXXFLAGS = $(CFLAGS) -fno-exceptions -fno-rtti
+ ASFLAGS = $(CFLAGS)
+ 
+ include $(PSPSDK)/lib/build.mak
--- ./pspsdk/sdk/samples/utility/savedata/main.c	Thu Jan  1 01:00:00 1970
+++ ./pspsdk/sdk/samples/utility/savedata/main.c	Mon Nov  7 15:13:45 2005
***************
*** 0 ****
--- 1,192 ----
+ /*
+  * PSP Software Development Kit - http://www.pspdev.org
+  * -----------------------------------------------------------------------
+  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
+  *
+  * main.c - Sample to desmonstrate how to use savedata utility
+  *
+  * Copyright (c) 2005 weltall (weltall@consoleworld.org)
+  * Based on work by Shine
+  *
+  * $Id:$
+  */
+ #include <pspkernel.h>
+ #include <pspdisplay.h>
+ #include <pspctrl.h>
+ #include <stdio.h>
+ #include <string.h>
+ #include <stdlib.h>
+ #include <pspmoduleinfo.h>
+ #include <pspiofilemgr.h>
+ #include <pspdebug.h>
+ #include <psputility.h>
+ 
+ /* Define the module info section */
+ PSP_MODULE_INFO("Savedata Sample", 0, 1, 0);
+ 
+ /* Define printf, just to make typing easier */
+ #define printf  pspDebugScreenPrintf
+ 
+ //this is for the save under the folder ULJS00015-000 with a DATA.BIN file inside it, the game is tales of eternia (J)
+ char* gameName = "ULJS00015";
+ char* saveName = "-000";
+ char* dataName = "DATA.BIN";
+ 
+ //define for buffer lenght
+ 
+ #define DATABUFFLEN   0x100000
+ #define READICON0LEN  0x100000
+ #define READICON1LEN  0x100000
+ #define READPIC1LEN   0x100000
+ 
+ /* Exit callback */
+ int exit_callback(int arg1, int arg2, void *common)
+ {
+     sceKernelExitGame();
+     return 0;
+ }
+ 
+ /* Callback thread */
+ int CallbackThread(SceSize args, void *argp)
+ {
+     int cbid;
+     cbid = sceKernelCreateCallback("Exit Callback", exit_callback, NULL);
+     sceKernelRegisterExitCallback(cbid);
+     sceKernelSleepThreadCB();
+ 
+     return 0;
+ }
+ 
+ /* Sets up the callback thread and returns its thread id */
+ int SetupCallbacks(void)
+ {
+     int thid = 0;
+     thid = sceKernelCreateThread("update_thread", CallbackThread, 0x11, 0xFA0, 0, 0);
+     if (thid >= 0)
+ 	sceKernelStartThread(thid, 0, 0);
+     return thid;
+ }
+ 
+ /* Utility Savedata functions */
+ 
+ /* based Shine's function, args: SceUtilitySavedataParam* savedata pass the save data structure
+ 				           mode: pass the mode parameter 0 = load 1 = save */
+ 
+ void initSavedata(SceUtilitySavedataParam* savedata, int mode) {
+ 	memset(savedata, 0, sizeof(SceUtilitySavedataParam)); //zeroes out the struct
+ 	savedata->size = sizeof(SceUtilitySavedataParam);     //size of the structure
+ 	savedata->unknown3 = 0x11;  // ?
+ 	savedata->unknown4 = 0x13;
+ 	savedata->unknown5 = 0x12;
+ 	savedata->unknown6 = 0x10;
+ 	savedata->unknown13 = 1;
+ 	savedata->mode = mode;  //mode: 0 = load, 1 = save
+ 	strcpy(savedata->gameNameAsciiZ, gameName); //first part of the save name, game identifier name
+ 	strcpy(savedata->saveNameAsciiZ, saveName); //second part of the save name, save identifier name
+ 	strcpy(savedata->dataDotBinAsciiZ, dataName); //name of the data file
+ 
+ 	//alllocates buffers to store various part of the savedata
+ 	savedata->dataBuf = malloc(DATABUFFLEN);
+ 	savedata->sizeOfDataBuf = DATABUFFLEN;	
+ 
+ 	savedata->readIcon0Buf = malloc(READICON0LEN);
+ 	savedata->sizeOfReadIcon0Buf = READICON0LEN;
+ 
+ 	savedata->readIcon1Buf = malloc(READICON1LEN);
+ 	savedata->sizeOfReadIcon1Buf = READICON1LEN;
+ 
+ 	savedata->readPic1Buf = malloc(READPIC1LEN);
+ 	savedata->sizeOfReadPic1Buf = READPIC1LEN;
+ }
+ 
+ void WorkSaveData(int mode)
+ {
+     SceUtilitySavedataParam savedata;
+ 	initSavedata(&savedata, mode);
+ 
+ 	//opens files to write or read savedata
+ 	int fd_data = sceIoOpen("ms0:/dataBuf", PSP_O_TRUNC | PSP_O_CREAT | PSP_O_WRONLY,0777);
+ 	int fd_sfo = sceIoOpen("ms0:/sfodata", PSP_O_TRUNC | PSP_O_CREAT | PSP_O_WRONLY,0777);
+ 
+ 	if(mode == 1) //if we are in mode 1 (writing savedata), reads files and put their contents on the savedata structure
+ 	{
+ 				sceIoRead(fd_data,savedata.dataBuf, DATABUFFLEN);
+ 				sceIoRead(fd_sfo,&savedata.paramsSfoTitle, 0x80);
+ 				sceIoRead(fd_sfo,&savedata.paramsSfoSavedataTitle, 0x80);
+ 				sceIoRead(fd_sfo,&savedata.paramsSfoDetail, 0x400);
+ 				sceIoClose(fd_data);
+ 				sceIoClose(fd_sfo);
+ 	}
+ 
+ 	int result = sceUtilitySavedataInitStart(&savedata); //calls the save data utility
+ 	
+ 	printf("sceUtilitySavedataInitStart result: %i\n", result); //writes on screen sceUtilitySavedataInitStart result
+ 
+ 	if (result) //if an error happened write it to screen
+ 	{
+ 		printf("sceUtilitySavedataInitStart failed: %i\n", result);
+ 	}
+ 
+ 
+ 	while (1) //wait for sceUtilitySavedataInitStart to completes
+ 	{
+ 		result = sceUtilitySavedataGetStatus(); //get status of sceUtilitySavedata
+ 		if (result == 3) break; //if 3 it has completed let's go out
+ 		sceUtilitySavedataUpdate(1); //update sceUtilitySavedata
+ 		sceDisplayWaitVblankStart(); //wait some time
+ 	}
+ 
+ 	result = sceUtilitySavedataShutdownStart(); //shutdown the Savedata Utility
+ 
+ 	printf("sceUtilitySavedataShutdownStart result: %i", result); //writes on screen sceUtilitySavedataShutdownStart result
+ 
+ 	if (result) //if an error happened write it to screen
+ 	{
+ 		printf("sceUtilitySavedataShutdownStart failed: %i", result);
+ 	}
+ 
+ 	while (1) //wait for sceUtilitySavedataShutdownStart to completes
+ 	{
+ 		result = sceUtilitySavedataGetStatus(); //get status of sceUtilitySavedata
+ 		if (result == 4) break; //if 3 it has shutdown let's go out
+ 		sceUtilitySavedataUpdate(1); //update sceUtilitySavedata
+ 		sceDisplayWaitVblankStart(); //wait some time
+ 	}
+ 
+ 	if(mode == 0) //if we was reading savedata then write it to a file in the ms0 root
+ 	{
+ 				sceIoWrite(fd_data,savedata.dataBuf, DATABUFFLEN);
+ 				sceIoWrite(fd_sfo,&savedata.paramsSfoTitle, 0x80);
+ 				sceIoWrite(fd_sfo,&savedata.paramsSfoSavedataTitle, 0x80);
+ 				sceIoWrite(fd_sfo,&savedata.paramsSfoDetail, 0x400);
+ 				sceIoClose(fd_data);
+ 				sceIoClose(fd_sfo);
+ 	}
+ 
+ }
+ 
+ /* main routine */
+ int main(int argc, char *argv[])
+ {
+ 	SetupCallbacks();
+ 	pspDebugScreenInit();
+ 	printf("sceUtilitySavedata sample\n\nPress O to load savedata, and put it into ms0:/\nPress X to save savedata, from files put into ms0:/\n");
+ 	while(1)
+ 	{
+ 		SceCtrlData pad;
+ 		sceCtrlReadBufferPositive(&pad, 1);
+ 		if(pad.Buttons & PSP_CTRL_CIRCLE)
+ 		{
+ 			WorkSaveData(0);
+ 		}
+ 		if(pad.Buttons & PSP_CTRL_CROSS)
+ 		{
+ 			WorkSaveData(1);
+ 		}
+ 		if(pad.Buttons & PSP_CTRL_TRIANGLE)
+ 			break;
+ 	}
+ 
+     sceKernelExitGame();
+     return 0;
+ }
--- ./pspsdk/sdk/utility/Makefile.am	Mon Nov  7 15:50:25 2005
+++ ./pspsdk/sdk/utility/Makefile.am	Mon Nov  7 15:18:06 2005
***************
*** 17,23 ****
                                 psputility_sysparam.h \
                                 psputility_netconf.h \
                                 psputility_netparam.h \
!                                psputility_msgdialog.h
  
  lib_LIBRARIES = libpsputility.a
  libpsputility_a_SOURCES = sceUtility.S
--- 17,24 ----
                                 psputility_sysparam.h \
                                 psputility_netconf.h \
                                 psputility_netparam.h \
!                                psputility_msgdialog.h \
! 							   psputility_savedata.h
  
  lib_LIBRARIES = libpsputility.a
  libpsputility_a_SOURCES = sceUtility.S
--- ./pspsdk/sdk/utility/psputility.h	Mon Nov  7 15:50:25 2005
+++ ./pspsdk/sdk/utility/psputility.h	Mon Nov  7 13:24:14 2005
***************
*** 15,20 ****
  #include <psputility_sysparam.h>
  #include <psputility_netconf.h>
  #include <psputility_netparam.h>
! #include <psputility_msgdialog.h>
  
  #endif
--- 15,21 ----
  #include <psputility_sysparam.h>
  #include <psputility_netconf.h>
  #include <psputility_netparam.h>
! #include <psputility_msgdialog.h>
! #include <psputility_savedata.h>
  
  #endif
--- ./pspsdk/sdk/utility/psputility_savedata.h	Thu Jan  1 01:00:00 1970
+++ .pspsdk/sdk/utility/psputility_savedata.h	Mon Nov  7 15:47:51 2005
***************
*** 0 ****
--- 1,149 ----
+ /*
+  * PSP Software Development Kit - http://www.pspdev.org
+  * -----------------------------------------------------------------------
+  * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
+  *
+  *  psputility_savedata.h - Definitions and Functions for savedata part of
+  *							pspUtility library
+  *
+  * Copyright (c) 2005    Shine
+  *                       weltall <weltall@consoleworld.org>
+  *
+  * $Id: $
+  */
+ #ifndef __PSPUTILITY_SAVEDATA_H__
+ #define __PSPUTILITY_SAVEDATA_H__
+ 
+ #ifdef __cplusplus
+ extern "C" {
+ #endif
+ 
+ #include <psptypes.h>
+ 
+ /** Structure to hold the parameters for the savedatainit function
+   */
+ 
+ typedef struct
+ {
+ 	/** Size of the structure */
+ 	int size;
+ 
+ 	int unknown1;
+ 
+ 	int unknown2;
+ 
+ 	/** unknown3 use 0x11 */
+ 	int unknown3;
+ 
+ 	/** unknown4 use 0x13 */
+ 	int unknown4;
+ 
+ 	/** unknown5 use 0x12 */
+ 	int unknown5;
+ 
+ 	/** unknown6 use 0x10 */
+ 	int unknown6;
+ 	int unknown7;
+ 	int unknown8;
+ 	int unknown9;
+ 	int unknown10;
+ 	int unknown11;
+ 
+ 	/** mode: 0 to load, 1 to save */
+ 	int mode;
+ 	int unknown12;
+ 
+ 	/** unknown13 use 0x10 */
+ 	int unknown13;
+ 
+ 	/** gameNameAsciiZ: name used from the game for saves, equal for all saves */
+ 	char gameNameAsciiZ[16];
+ 
+ 	/** saveNameAsciiZ: name of the particular save, normally a number */
+ 	char saveNameAsciiZ[24];
+ 
+ 	/** dataDotBinAsciiZ: name of the data file of the game for example DATA.BIN */
+ 	char dataDotBinAsciiZ[16];
+ 
+ 	/** pointer to a buffer that will contain data file unencrypted data */
+ 	unsigned char* dataBuf;
+ 
+ 	/** size of allocated space to 	unsigned char* dataBuf; */
+ 	int sizeOfDataBuf;
+ 	int sizeOfData;
+ 
+ 	/** paramsSfoTitle, paramsSfoSavedataTitle, paramsSfoDetail: parts of the unencrypted sfo data, it contains
+ 	    what the VSH and standard load screen shows */
+ 	char paramsSfoTitle[0x80];
+ 	char paramsSfoSavedataTitle[0x80];
+ 	char paramsSfoDetail[0x400];
+ 	unsigned char paramsSfoParentalLevel;
+ 	unsigned char unknown14[3];
+ 	
+ 	/** pointer to a buffer to contain Icon0 */
+ 	unsigned char* readIcon0Buf;
+ 
+ 	/** allocated size of unsigned char* readIcon0Buf */
+ 	int sizeOfReadIcon0Buf;
+ 	int sizeOfReadIcon0;
+ 	int unknown15;
+ 
+ 	/** pointer to a buffer to contain Icon1 */
+ 	unsigned char* readIcon1Buf;
+ 
+ 	/** allocated size of unsigned char* readIcon1Buf */
+ 	int sizeOfReadIcon1Buf;
+ 	int sizeOfReadIcon1;
+ 	int unknown16;
+ 
+ 	/** pointer to a buffer to contain Pic1 */
+ 	unsigned char* readPic1Buf;
+ 
+ 	/** allocated size of unsigned char* readPic1Buf */
+ 	int sizeOfReadPic1Buf;
+ 	int sizeOfReadPic1;
+ 	unsigned char unknown17[0x18];
+ } SceUtilitySavedataParam;
+ 
+ 
+ /**
+  * Saves or Load savedata to/from the passed structure
+  * After having called this continue calling sceUtilitySavedataGetStatus to check if the operation is completed
+  *
+  * @param params - savedata parameters
+  * @returns 0 on success
+  */
+ int sceUtilitySavedataInitStart(SceUtilitySavedataParam *params);
+ 
+ /**
+  * Check the current status of the saving/loading/shutdown process
+  * Continue calling this to check current status of the process
+  * before calling this call also sceUtilitySavedataUpdate
+  * @returns 2 if the process is still being processed.
+  * 3 on save/load success, then you can call sceUtilitySavedataShutdownStart.
+  * 4 on complete shutdown.
+  */
+ int sceUtilitySavedataGetStatus(void);
+ 
+ 
+ /**
+  * Shutdown the savedata utility. after calling this continue calling sceUtilitySavedataGetStatus to check
+  * when it has shutdown
+  *
+  * @return 0 on success
+  *
+  */
+ int sceUtilitySavedataShutdownStart(void);
+ 
+ /**
+  * Refresh status of the savedata function
+  *
+  * @param unknown - unknown, pass 1
+  */
+ void sceUtilitySavedataUpdate(int unknown);
+ 
+ #ifdef __cplusplus
+ }
+ #endif
+ 
+ #endif