Skip to content

Commit

Permalink
move PSV to user tools
Browse files Browse the repository at this point in the history
ps1/ps2 convert to PSV
export PSV to ps1/ps2
add ps2 vmc import formats (cbs, xps, max)
  • Loading branch information
bucanero committed Nov 12, 2024
1 parent e17e333 commit 3a6f82c
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 326 deletions.
5 changes: 1 addition & 4 deletions include/saves.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,6 @@ enum cmd_code_enum
CMD_VIEW_RAW_PATCH,
CMD_RESIGN_PSV,
CMD_CONVERT_TO_PSV,
CMD_COPY_DUMMY_PSV,
CMD_IMPORT_DATA_FILE,
CMD_HEX_EDIT_FILE,
CMD_DELETE_VMCSAVE,
Expand All @@ -115,8 +114,7 @@ enum cmd_code_enum
CMD_EXP_FLASH2_USB,
CMD_EXP_PS2_BINENC,
CMD_EXP_PS2_VM2,
CMD_EXP_PSV_MCS,
CMD_EXP_PSV_PSU,
CMD_EXP_SAVE_PSV,
CMD_EXP_VM2_RAW,
CMD_EXP_VMC1SAVE,
CMD_EXP_VMC2SAVE,
Expand Down Expand Up @@ -177,7 +175,6 @@ enum save_type_enum
FILE_TYPE_MAX,
FILE_TYPE_CBS,
FILE_TYPE_XPS,
FILE_TYPE_VM2,
FILE_TYPE_PS2RAW,

// License Files
Expand Down
2 changes: 1 addition & 1 deletion include/settings.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

#define APOLLO_VERSION "2.0.0" //Apollo PS3 version (about menu)
#define APOLLO_VERSION "2.0.2" //Apollo PS3 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
4 changes: 2 additions & 2 deletions sfo.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0" ?>
<sfo>
<value name="APP_VER" type="string">
02.00
02.02
</value>
<value name="ATTRIBUTE" type="integer">
133
Expand Down Expand Up @@ -34,6 +34,6 @@
NP0APOLLO
</value>
<value name="VERSION" type="string">
02.00
02.02
</value>
</sfo>
79 changes: 28 additions & 51 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -782,36 +782,11 @@ static void activateAccount(const char* ex_path)
show_message("Account successfully activated!\nA system reboot might be required");
}

static void copyDummyPSV(const char* psv_file, int dst)
static void exportPSVfile(const char* in_file, int type)
{
char *in, *out;
char out_path[256];

_set_dest_path(out_path, dst, PSV_SAVES_PATH_USB);
if (mkdirs(out_path) != SUCCESS)
{
show_message("Error! Export folder is not available:\n%s", out_path);
return;
}

asprintf(&in, APOLLO_DATA_PATH "%s", psv_file);
asprintf(&out, "%s%s", out_path, psv_file);

init_loading_screen("Copying PSV file...");
copy_file(in, out);
stop_loading_screen();

free(in);
free(out);

show_message("File successfully saved to:\n%s%s", out_path, psv_file);
}

static void exportPSVfile(const char* in_file, int dst, const char* path)
{
char out_path[256];

_set_dest_path(out_path, dst, path);
snprintf(out_path, sizeof(out_path), "%s%s", selected_entry->path, (type == FILE_TYPE_MCS) ? PS1_IMP_PATH_USB : PS2_IMP_PATH_USB);
if (mkdirs(out_path) != SUCCESS)
{
show_message("Error! Export folder is not available:\n%s", out_path);
Expand All @@ -820,7 +795,7 @@ static void exportPSVfile(const char* in_file, int dst, const char* path)

init_loading_screen("Exporting PSV file...");

if (selected_entry->flags & SAVE_FLAG_PS1)
if (type == FILE_TYPE_MCS)
ps1_psv2mcs(in_file, out_path);
else
ps2_psv2psu(in_file, out_path);
Expand All @@ -829,11 +804,11 @@ static void exportPSVfile(const char* in_file, int dst, const char* path)
show_message("File successfully saved to:\n%s", out_path);
}

static void convertSavePSV(const save_entry_t* save, int dst)
static void convertSavePSV(const char* save_path, int type)
{
char out_path[256];

_set_dest_path(out_path, dst, PSV_SAVES_PATH_USB);
snprintf(out_path, sizeof(out_path), "%s%s", selected_entry->path, PSV_SAVES_PATH_USB);
if (mkdirs(out_path) != SUCCESS)
{
show_message("Error! Export folder is not available:\n%s", out_path);
Expand All @@ -842,30 +817,30 @@ static void convertSavePSV(const save_entry_t* save, int dst)

init_loading_screen("Converting Save to PSV file...");

switch (save->type)
switch (type)
{
case FILE_TYPE_MCS:
ps1_mcs2psv(save->path, out_path);
ps1_mcs2psv(save_path, out_path);
break;

case FILE_TYPE_PSX:
ps1_psx2psv(save->path, out_path);
ps1_psx2psv(save_path, out_path);
break;

case FILE_TYPE_MAX:
ps2_max2psv(save->path, out_path);
ps2_max2psv(save_path, out_path);
break;

case FILE_TYPE_PSU:
ps2_psu2psv(save->path, out_path);
ps2_psu2psv(save_path, out_path);
break;

case FILE_TYPE_CBS:
ps2_cbs2psv(save->path, out_path);
ps2_cbs2psv(save_path, out_path);
break;

case FILE_TYPE_XPS:
ps2_xps2psv(save->path, out_path);
ps2_xps2psv(save_path, out_path);
break;

default:
Expand Down Expand Up @@ -1634,6 +1609,18 @@ static void import_save2vmc(const char* src, int type)
ret = vmc_import_psu(src);
break;

case FILE_TYPE_CBS:
ret = (ps2_cbs2psv(src, NULL) && vmc_import_psv(APOLLO_TMP_PATH "tmp.psv"));
break;

case FILE_TYPE_XPS:
ret = (ps2_xps2psv(src, NULL) && vmc_import_psv(APOLLO_TMP_PATH "tmp.psv"));
break;

case FILE_TYPE_MAX:
ret = (ps2_max2psv(src, NULL) && vmc_import_psv(APOLLO_TMP_PATH "tmp.psv"));
break;

default:
break;
}
Expand Down Expand Up @@ -1750,7 +1737,7 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)
break;

case CMD_RESIGN_PSV:
resignPSVfile(selected_entry->path);
resignPSVfile(code->file);
code->activated = 0;
break;

Expand All @@ -1770,12 +1757,7 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)
break;

case CMD_CONVERT_TO_PSV:
convertSavePSV(selected_entry, codecmd[1]);
code->activated = 0;
break;

case CMD_COPY_DUMMY_PSV:
copyDummyPSV(code->file, codecmd[1]);
convertSavePSV(code->file, codecmd[1]);
code->activated = 0;
break;

Expand All @@ -1784,13 +1766,8 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)
code->activated = 0;
break;

case CMD_EXP_PSV_MCS:
exportPSVfile(selected_entry->path, codecmd[1], PS1_IMP_PATH_USB);
code->activated = 0;
break;

case CMD_EXP_PSV_PSU:
exportPSVfile(selected_entry->path, codecmd[1], PS2_IMP_PATH_USB);
case CMD_EXP_SAVE_PSV:
exportPSVfile(code->file, codecmd[1]);
code->activated = 0;
break;

Expand Down
2 changes: 1 addition & 1 deletion source/menu_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ static void doPatchMenu(void)
list_node_t* node;

for (node = list_head(selected_entry->codes); (code = list_get(node)); node = list_next(node))
if (wildcard_match_icase(code->name, "*(REQUIRED)*"))
if (wildcard_match_icase(code->name, "*(REQUIRED)*") && code->options_count == 0)
code->activated = 1;
}
/*
Expand Down
6 changes: 6 additions & 0 deletions source/psv_resign.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ void get_psv_filename(char* psvName, const char* path, const char* dirName)
char tmpName[13];
const char *ch = &dirName[12];

if (!path)
{
strcpy(psvName, "/dev_hdd0/tmp/apollo/tmp.psv");
return;
}

memcpy(tmpName, dirName, 12);
tmpName[12] = 0;

Expand Down
Loading

0 comments on commit 3a6f82c

Please sign in to comment.