Skip to content

Commit

Permalink
delete PSP saves
Browse files Browse the repository at this point in the history
- improve sorting by type / by title-id
- details for online DB games
  • Loading branch information
bucanero committed Aug 2, 2024
1 parent cdc2c0a commit a22e06e
Show file tree
Hide file tree
Showing 9 changed files with 84 additions and 99 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ find_package(OpenSSL REQUIRED)

set(VITA_APP_NAME "Apollo Save Tool")
set(VITA_TITLEID "NP0APOLLO")
set(VITA_VERSION "01.40")
set(VITA_VERSION "01.42")

option(APOLLO_ENABLE_LOGGING "enables debug logging over udp multicast" OFF)

Expand Down
17 changes: 1 addition & 16 deletions include/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,21 +21,6 @@ int mkdirs(const char* dir);
int copy_file(const char* input, const char* output);
int copy_directory(const char* startdir, const char* inputdir, const char* outputdir);
int clean_directory(const char* inputdir);

//----------------------------------------
//CONSOLE ID UTILS
//----------------------------------------

int ss_aim_get_device_id(uint8_t *idps);
int ss_aim_get_open_psid(uint8_t *psid);
int sys_ss_get_open_psid(uint64_t psid[2]);
int is_ps3hen(void);

//----------------------------------------
//POWER UTILS
//----------------------------------------

int sys_shutdown();
int sys_reboot();
uint32_t file_crc32(const char* input);

#endif
2 changes: 1 addition & 1 deletion include/saves.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ enum cmd_code_enum
CMD_EXP_FINGERPRINT,
CMD_HEX_EDIT_FILE,
CMD_IMPORT_DATA_FILE,
CMD_DELETE_VMCSAVE,
CMD_DELETE_SAVE,

// Bulk commands
CMD_RESIGN_SAVES,
Expand Down
2 changes: 1 addition & 1 deletion include/settings.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#define APOLLO_VERSION "1.4.0" //Apollo Vita version (about menu)
#define APOLLO_VERSION "1.4.2" //Apollo Vita version (about menu)

#define MENU_TITLE_OFF 30 //Offset of menu title text from menu mini icon
#define MENU_ICON_OFF 70 //X Offset to start printing menu mini icon
Expand Down
64 changes: 0 additions & 64 deletions source/common.c
Original file line number Diff line number Diff line change
Expand Up @@ -214,67 +214,3 @@ int clean_directory(const char* inputdir)

return SUCCESS;
}
/*
//----------------------------------------
//POWER UTILS
//----------------------------------------
int sys_shutdown()
{
unlink_secure("/dev_hdd0/tmp/turnoff");
lv2syscall4(379,0x1100,0,0,0);
return_to_user_prog(int);
}
int sys_reboot()
{
unlink_secure("/dev_hdd0/tmp/turnoff");
lv2syscall4(379,0x1200,0,0,0);
return_to_user_prog(int);
}
//----------------------------------------
//CONSOLE ID UTILS
//----------------------------------------
#define SYS_SS_APPLIANCE_INFO_MANAGER 867
#define SYS_SS_GET_OPEN_PSID 872
#define AIM_GET_DEVICE_ID 0x19003
#define AIM_GET_OPEN_PSID 0x19005
#define SYSCALL8_OPCODE_IS_HEN 0x1337
int sys_ss_get_open_psid(uint64_t psid[2])
{
lv2syscall1(SYS_SS_GET_OPEN_PSID, (uint64_t) psid);
return_to_user_prog(int);
}
int sys_ss_appliance_info_manager(u32 packet_id, u64 arg)
{
lv2syscall2(SYS_SS_APPLIANCE_INFO_MANAGER, (uint64_t)packet_id, (uint64_t)arg);
return_to_user_prog(int);
}
int ss_aim_get_device_id(uint8_t *idps)
{
return sys_ss_appliance_info_manager(AIM_GET_DEVICE_ID, (uint64_t)idps);
}
int ss_aim_get_open_psid(uint8_t *psid)
{
return sys_ss_appliance_info_manager(AIM_GET_OPEN_PSID, (uint64_t)psid);
}
int sys8_get_hen(void)
{
lv2syscall1(8, SYSCALL8_OPCODE_IS_HEN);
return_to_user_prog(int);
}
int is_ps3hen(void)
{
return (sys8_get_hen() == 0x1337);
}
*/
27 changes: 20 additions & 7 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -572,15 +572,27 @@ static void exportVmcSave(const save_entry_t* save, int type, int dst_id)
show_message("Error exporting save:\n%s", save->path);
}

static void deleteVmcSave(const save_entry_t* save)
static int deleteSave(const save_entry_t* save)
{
int ret = 0;

if (!show_dialog(DIALOG_TYPE_YESNO, "Do you want to delete %s?", save->dir_name))
return;
return 0;

if (save->flags & SAVE_FLAG_PSP)
{
clean_directory(save->path);
ret = (remove(save->path) == SUCCESS);
}
else if (save->flags & SAVE_FLAG_PS1)
ret = formatSave(save->blocks);

if ((save->flags & SAVE_FLAG_PS1) && formatSave(save->blocks))
if (ret)
show_message("Save successfully deleted:\n%s", save->dir_name);
else
show_message("Error! Couldn't delete save:\n%s", save->dir_name);

return ret;
}

static void copyKeystone(const save_entry_t* entry, int import)
Expand Down Expand Up @@ -1483,10 +1495,11 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)
code->activated = 0;
break;

case CMD_DELETE_VMCSAVE:
deleteVmcSave(selected_entry);
selected_entry->flags |= SAVE_FLAG_UPDATED;
code->activated = 0;
case CMD_DELETE_SAVE:
if (deleteSave(selected_entry))
selected_entry->flags |= SAVE_FLAG_UPDATED;
else
code->activated = 0;
break;

case CMD_EXP_FINGERPRINT:
Expand Down
2 changes: 1 addition & 1 deletion source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const char * menu_pad_help[TOTAL_MENU_IDS] = { NULL, //Main
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //Trophy list
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //USB list
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //HDD list
"\x10 Select \x13 Back \x11 Refresh", //Online list
"\x10 Select \x13 Back \x12 Details \x11 Refresh", //Online list
"\x10 Select \x13 Back \x11 Refresh", //User backup
"\x10 Select \x13 Back", //Options
"\x13 Back", //About
Expand Down
27 changes: 24 additions & 3 deletions source/menu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,25 @@ static void SetMenu(int id)
break;

case MENU_PATCHES: //Cheat Selection Menu
if (selected_entry->flags & SAVE_FLAG_UPDATED && id == MENU_VMC_SAVES)
if (selected_entry->flags & SAVE_FLAG_UPDATED)
{
switch (id)
{
case MENU_VMC_SAVES:
saveMemoryCard(vmc_saves.path, 0, 0);
ReloadUserSaves(&vmc_saves);
break;

case MENU_USB_SAVES:
ReloadUserSaves(&usb_saves);
break;

case MENU_HDD_SAVES:
ReloadUserSaves(&hdd_saves);
break;
}

selected_entry->flags ^= SAVE_FLAG_UPDATED;
saveMemoryCard(vmc_saves.path, 0, 0);
ReloadUserSaves(&vmc_saves);
}
break;

Expand Down Expand Up @@ -761,6 +775,13 @@ static void doPatchMenu(void)
return;
}

if (selected_centry->codes[0] == CMD_DELETE_SAVE)
{
selected_centry->activated = 0;
SetMenu(last_menu_id[MENU_PATCHES]);
return;
}

if (selected_centry->codes[0] == CMD_VIEW_RAW_PATCH)
{
selected_centry->activated = 0;
Expand Down
40 changes: 35 additions & 5 deletions source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,9 @@ static void add_psp_commands(save_entry_t* item)
{
code_entry_t* cmd;

cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_WARN " Delete Save Game", CMD_DELETE_SAVE);
list_append(item->codes, cmd);

cmd = _createCmdCode(PATCH_NULL, "----- " UTF8_CHAR_STAR " Game Key Backup " UTF8_CHAR_STAR " -----", CMD_CODE_NULL);
list_append(item->codes, cmd);

Expand Down Expand Up @@ -796,7 +799,7 @@ int ReadVmcCodes(save_entry_t * save)
cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_USER " View Save Details", CMD_VIEW_DETAILS);
list_append(save->codes, cmd);

cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_WARN " Delete Save Game", CMD_DELETE_VMCSAVE);
cmd = _createCmdCode(PATCH_COMMAND, CHAR_ICON_WARN " Delete Save Game", CMD_DELETE_SAVE);
list_append(save->codes, cmd);

cmd = _createCmdCode(PATCH_NULL, "----- " UTF8_CHAR_STAR " Save Backup " UTF8_CHAR_STAR " -----", CMD_CODE_NULL);
Expand Down Expand Up @@ -1217,16 +1220,32 @@ int sortSaveList_Compare_TitleID(const void* a, const void* b)
if (!tb)
return (1);

return strcasecmp(ta, tb);
int ret = strcasecmp(ta, tb);

return (ret ? ret : sortSaveList_Compare(a, b));
}

static int parseTypeFlags(int flags)
{
if (flags & SAVE_FLAG_VMC)
return FILE_TYPE_VMC;
else if (flags & SAVE_FLAG_PS1)
return FILE_TYPE_PS1;
else if (flags & SAVE_FLAG_PSP)
return FILE_TYPE_PSP;
else if (flags & SAVE_FLAG_PSV)
return FILE_TYPE_PSV;

return 0;
}

int sortSaveList_Compare_Type(const void* a, const void* b)
{
int ta = ((save_entry_t*) a)->type;
int tb = ((save_entry_t*) b)->type;
int ta = parseTypeFlags(((save_entry_t*) a)->flags);
int tb = parseTypeFlags(((save_entry_t*) b)->flags);

if (ta == tb)
return 0;
return sortSaveList_Compare(a, b);
else if (ta < tb)
return -1;
else
Expand Down Expand Up @@ -1843,6 +1862,17 @@ int get_save_details(const save_entry_t* save, char **details)
return 1;
}

if (save->flags & SAVE_FLAG_ONLINE)
{
asprintf(details, "%s\n----- Online Database -----\n"
"Game: %s\n"
"Title ID: %s\n",
save->path,
save->name,
save->title_id);
return 1;
}

if (save->flags & SAVE_FLAG_PSP || save->flags & SAVE_FLAG_PS1)
{
snprintf(sfoPath, sizeof(sfoPath), "%sPARAM.SFO", save->path);
Expand Down

0 comments on commit a22e06e

Please sign in to comment.