#ifndef __SCEUTILITY_H__
#define __SCEUTILITY_H__

#define PSP_SYSTEMPARAM_ID_STRING_NICKNAME      1
#define PSP_SYSTEMPARAM_ID_INT_ADHOC_CHANNEL    2
#define PSP_SYSTEMPARAM_ID_INT_WLAN_POWERSAVE   3
#define PSP_SYSTEMPARAM_ID_INT_DATE_FORMAT      4
#define PSP_SYSTEMPARAM_ID_INT_TIME_FORMAT      5
#define PSP_SYSTEMPARAM_ID_INT_TIMEZONE         6
#define PSP_SYSTEMPARAM_ID_INT_DAYLIGHTSAVINGS  7
#define PSP_SYSTEMPARAM_ID_INT_LANGUAGE         8
#define PSP_SYSTEMPARAM_ID_INT_UNKNOWN          9
#define PSP_SYSTEMPARAM_RETVAL_OK       0
#define PSP_SYSTEMPARAM_RETVAL_FAIL     0x80110103

typedef enum PspUtilitySavedataMode
{
	PSP_UTILITY_SAVEDATA_AUTOLOAD = 0,
	PSP_UTILITY_SAVEDATA_AUTOSAVE,
	PSP_UTILITY_SAVEDATA_LOAD,
	PSP_UTILITY_SAVEDATA_SAVE,
	PSP_UTILITY_SAVEDATA_LISTLOAD,
	PSP_UTILITY_SAVEDATA_LISTSAVE,
	PSP_UTILITY_SAVEDATA_LISTDELETE,
	PSP_UTILITY_SAVEDATADELETE,

} PspUtilitySavedataMode;

typedef struct PspUtilitySavedataSFOParam
{
	char title [0x80];
	char savedataTitle [0x80];
	char detail [0x400];
	unsigned char parentalLevel;
	unsigned char unknown [3];
} PspUtilitySavedataSFOParam;

typedef struct PspUtilitySavedataFileData
{
	void * buf;
	SceSize bufSize;
	SceSize size;
	int unknown;
} PspUtilitySavedataFileData;

typedef struct PspUtilitySavedataListSaveNewData
{
	PspUtilitySavedataFileData icon0;
	char * title;
} PspUtilitySavedataListSaveNewData;

typedef enum
{
	PSP_UTILITY_SAVEDATA_FOCUS_UNKNOWN = 0,
	PSP_UTILITY_SAVEDATA_FOCUS_FIRSTLIST,	// First in list
	PSP_UTILITY_SAVEDATA_FOCUS_LASTLIST,	// Last in list
	PSP_UTILITY_SAVEDATA_FOCUS_LATEST,	// Most recent date
	PSP_UTILITY_SAVEDATA_FOCUS_OLDEST,	// Oldest date
	PSP_UTILITY_SAVEDATA_FOCUS_UNKNOWN2,
	PSP_UTILITY_SAVEDATA_FOCUS_UNKNOWN3,
	PSP_UTILITY_SAVEDATA_FOCUS_FIRSTEMPTY, // First empty slot
	PSP_UTILITY_SAVEDATA_FOCUS_LASTEMPTY,	//Last empty slot

} PspUtilitySavedataFocus;

typedef struct PspUtilityDialogCommon
{
	unsigned int size;
	int language;
	int buttonSwap;
	int graphicsThread;
	int accessThread;
	int fontThread;
	int soundThread;
	int result;
	int reserved [4];
} PspUtilityDialogCommon;

typedef struct SceUtilitySavedataParam
{
	PspUtilityDialogCommon base;
	PspUtilitySavedataMode mode;
	int unknown1;
	int overwrite;
	char gameName [13];
	char reserved [3];
	char saveName [20];
	char(* saveNameList )[20];
	char fileName [13];
	char reserved1 [3];
	void * dataBuf;
	SceSize dataBufSize;
	SceSize dataSize;
	PspUtilitySavedataSFOParam sfoParam;
	PspUtilitySavedataFileData icon0FileData;
	PspUtilitySavedataFileData icon1FileData;
	PspUtilitySavedataFileData pic1FileData;
	PspUtilitySavedataFileData snd0FileData;
	PspUtilitySavedataListSaveNewData * newData;
	PspUtilitySavedataFocus focus;
	int unknown2 [4];
} SceUtilitySavedataParam;

int (* sceUtilityGetSystemParamInt) (int id, int *value) = (void *) (BASE_OFFSET + 0xe6ed0);
int (* sceUtilityGetSystemParamString) (int id, char *str, int len) = (void *) (BASE_OFFSET + 0xe6ed8);
int (* sceUtilitySavedataGetStatus) (void) = (void *) (BASE_OFFSET + 0xe6ec8);
int (* sceUtilitySavedataInitStart) (SceUtilitySavedataParam *params) = (void *) (BASE_OFFSET + 0xe6eb0);
int (* sceUtilitySavedataShutdownStart) (void) = (void *) (BASE_OFFSET + 0xe6eb8);
void (* sceUtilitySavedataUpdate) (int unknown) = (void *) (BASE_OFFSET + 0xe6ec0);

#endif
