Skip to content

Commit

Permalink
adjustments
Browse files Browse the repository at this point in the history
  • Loading branch information
bucanero committed Jul 25, 2023
1 parent 37fcfdf commit 96fe0de
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 95 deletions.
Binary file added data/tag_pack.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed data/tag_pce.png
Binary file not shown.
2 changes: 1 addition & 1 deletion include/menu.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ enum texture_index
cat_warning_png_index,
tag_lock_png_index,
tag_own_png_index,
tag_pce_png_index,
tag_pack_png_index,
tag_ps1_png_index,
tag_ps2_png_index,
tag_psp_png_index,
Expand Down
8 changes: 4 additions & 4 deletions include/saves.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
#define USB_PATH "mass:/"
#define USER_PATH_USB "PS2/SAVEDATA/"

#define PS2_SAVES_PATH_USB "PS3/EXPORT/PS2SD/"
#define PSP_SAVES_PATH_USB "APOLLO/SAVEDATA/"
#define PS1_SAVES_PATH_USB "PS1/SAVEDATA/"
#define PS2_SAVES_PATH_USB "PS2/SAVEDATA/"

#define PS1_SAVES_PATH_HDD APOLLO_PATH "PS1/"
#define PSP_SAVES_PATH_HDD USB_PATH USER_PATH_USB
Expand Down Expand Up @@ -109,7 +109,7 @@ enum cmd_code_enum
#define SAVE_FLAG_PS1 8
#define SAVE_FLAG_PS2 16
#define SAVE_FLAG_PSP 32
#define SAVE_FLAG_ISO 64
#define SAVE_FLAG_PACKED 64
#define SAVE_FLAG_LOCKED 128
#define SAVE_FLAG_ONLINE 256

Expand Down Expand Up @@ -152,7 +152,7 @@ enum char_flag_enum
CHAR_TAG_TRANSFER,
CHAR_TAG_ZIP,
CHAR_RES_CR,
CHAR_TAG_PCE,
CHAR_TAG_PACK,
CHAR_TAG_WARNING,
CHAR_BTN_X,
CHAR_BTN_S,
Expand Down
31 changes: 16 additions & 15 deletions source/exec_cmd.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static void downloadSave(const save_entry_t* entry, const char* file, int dst)
{
char path[256];

_set_dest_path(path, dst, PSP_SAVES_PATH_USB);
_set_dest_path(path, dst, PS2_SAVES_PATH_USB);
if (dst == STORAGE_MC0)
snprintf(path, sizeof(path), PSP_SAVES_PATH_HDD);

Expand Down Expand Up @@ -130,7 +130,7 @@ static void copySave(const save_entry_t* save, int dev)
char* copy_path;
char exp_path[256];

_set_dest_path(exp_path, dev, PSP_SAVES_PATH_USB);
_set_dest_path(exp_path, dev, PS2_SAVES_PATH_USB);
if (strncmp(save->path, exp_path, strlen(exp_path)) == 0)
{
show_message("Copy operation cancelled!\nSame source and destination.");
Expand All @@ -156,17 +156,18 @@ static void copySave(const save_entry_t* save, int dev)
show_message("Files successfully copied to:\n%s", exp_path);
}

static int _copy_save_psp(const save_entry_t* save)
static int _copy_save_memcard(const save_entry_t* save, int dev)
{
char copy_path[256];

snprintf(copy_path, sizeof(copy_path), PSP_SAVES_PATH_HDD "%s/", save->dir_name);
_set_dest_path(copy_path, dev, save->dir_name);
strcat(copy_path, "/");

LOG("Copying <%s> to %s...", save->path, copy_path);
return (copy_directory(save->path, save->path, copy_path) == SUCCESS);
}

static void copySaveHDD(const save_entry_t* save)
static void copySaveMC(const save_entry_t* save, int dev)
{
//source save is already on HDD
if (save->flags & SAVE_FLAG_MEMCARD)
Expand All @@ -176,16 +177,16 @@ static void copySaveHDD(const save_entry_t* save)
}

init_loading_screen("Copying save game...");
int ret = _copy_save_psp(save);
int ret = _copy_save_memcard(save, dev);
stop_loading_screen();

if (ret)
show_message("Files successfully copied to:\n%s%s", PSP_SAVES_PATH_HDD, save->dir_name);
show_message("Files successfully copied to:\nmc%d:/%s", dev, save->dir_name);
else
show_message("Error! Can't copy Save-game folder:\n%s%s", PSP_SAVES_PATH_HDD, save->dir_name);
show_message("Error! Can't copy Save-game folder:\n%s", save->path);
}

static void copyAllSavesHDD(const save_entry_t* save, int all)
static void copyAllSavesMC(const save_entry_t* save, int dev, int all)
{
int done = 0, err_count = 0;
list_node_t *node;
Expand All @@ -195,20 +196,20 @@ static void copyAllSavesHDD(const save_entry_t* save, int all)

init_progress_bar("Copying all saves...");

LOG("Copying all saves from '%s' to HDD...", save->path);
LOG("Copying all saves from '%s' to mc%d:/...", save->path, dev);
for (node = list_head(list); (item = list_get(node)); node = list_next(node))
{
update_progress_bar(progress++, list_count(list), item->name);
if (!all && !(item->flags & SAVE_FLAG_SELECTED))
continue;

if ((item->flags & SAVE_FLAG_PS1) || item->type == FILE_TYPE_PS2)
(_copy_save_psp(item) ? done++ : err_count++);
(_copy_save_memcard(item, dev) ? done++ : err_count++);
}

end_progress_bar();

show_message("%d/%d Saves copied to Memory Stick\n" PSP_SAVES_PATH_HDD, done, done+err_count);
show_message("%d/%d Saves copied to Memory Card %d", done, done+err_count, dev+1);
}

static void extractArchive(const char* file_path)
Expand Down Expand Up @@ -522,7 +523,7 @@ static void copyAllSavesUSB(const save_entry_t* save, int dev, int all)
save_entry_t *item;
list_t *list = ((void**)save->dir_name)[0];

_set_dest_path(dst_path, dev, PSP_SAVES_PATH_USB);
_set_dest_path(dst_path, dev, PS2_SAVES_PATH_USB);
if (!list || mkdirs(dst_path) != SUCCESS)
{
show_message("Error! Folder is not available:\n%s", dst_path);
Expand Down Expand Up @@ -937,7 +938,7 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)
break;

case CMD_COPY_SAVE_HDD:
copySaveHDD(selected_entry);
copySaveMC(selected_entry, codecmd[1]);
code->activated = 0;
break;

Expand Down Expand Up @@ -980,7 +981,7 @@ void execCodeCommand(code_entry_t* code, const char* codecmd)

case CMD_COPY_SAVES_HDD:
case CMD_COPY_ALL_SAVES_HDD:
copyAllSavesHDD(selected_entry, codecmd[0] == CMD_COPY_ALL_SAVES_HDD);
copyAllSavesMC(selected_entry, codecmd[1], codecmd[0] == CMD_COPY_ALL_SAVES_HDD);
code->activated = 0;
break;

Expand Down
2 changes: 0 additions & 2 deletions source/import_ps2.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
#define CBS_HEADER_MAGIC "CFU\0"
#define XPS_HEADER_MAGIC "SharkPortSave\0\0\0"

#define xps_mode_swap(M) ((M & 0x00FF) << 8) + ((M & 0xFF00) >> 8)

// flag value used for mcSetFileInfo at MC file restoration
#define MC_SFI 0xFEED

Expand Down
11 changes: 5 additions & 6 deletions source/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ static int LoadTextures_Menu()
load_menu_texture(logo_text, png);
load_menu_texture(tag_lock, png);
load_menu_texture(tag_own, png);
load_menu_texture(tag_pce, png);
load_menu_texture(tag_pack, png);
load_menu_texture(tag_ps1, png);
load_menu_texture(tag_ps2, png);
load_menu_texture(tag_psp, png);
Expand Down Expand Up @@ -378,11 +378,10 @@ void update_db_path(char* path)
static void registerSpecialChars(void)
{
// Register save tags
RegisterSpecialCharacter(CHAR_TAG_PS1, 2, 1.5, &menu_textures[tag_ps1_png_index]);
RegisterSpecialCharacter(CHAR_TAG_PS2, 2, 1.5, &menu_textures[tag_ps2_png_index]);
RegisterSpecialCharacter(CHAR_TAG_PSP, 2, 1.5, &menu_textures[tag_psp_png_index]);
// RegisterSpecialCharacter(CHAR_TAG_PSV, 2, 1.5, &menu_textures[tag_psv_png_index]);
RegisterSpecialCharacter(CHAR_TAG_PCE, 2, 1.5, &menu_textures[tag_pce_png_index]);
RegisterSpecialCharacter(CHAR_TAG_PS1, 0, 1.5, &menu_textures[tag_ps1_png_index]);
RegisterSpecialCharacter(CHAR_TAG_PS2, 0, 1.5, &menu_textures[tag_ps2_png_index]);
RegisterSpecialCharacter(CHAR_TAG_PSP, 0, 1.5, &menu_textures[tag_psp_png_index]);
RegisterSpecialCharacter(CHAR_TAG_PACK, 0, 0.8, &menu_textures[tag_pack_png_index]);
RegisterSpecialCharacter(CHAR_TAG_LOCKED, 0, 1.3, &menu_textures[tag_lock_png_index]);
RegisterSpecialCharacter(CHAR_TAG_OWNER, 0, 1.3, &menu_textures[tag_own_png_index]);
RegisterSpecialCharacter(CHAR_TAG_WARNING, 0, 1.3, &menu_textures[tag_warning_png_index]);
Expand Down
13 changes: 7 additions & 6 deletions source/menu_cheats.c
Original file line number Diff line number Diff line change
Expand Up @@ -342,25 +342,26 @@ void DrawGameList(int selIndex, list_t * games, u8 alpha)
{
char * nBuffer = strdup(item->name);
int game_name_width = 0;
while ((game_name_width = WidthFromStr(nBuffer)) > 0 && (MENU_ICON_OFF + (MENU_TITLE_OFF * 1) + game_name_width) > ((SCREEN_WIDTH - 30) - (MENU_ICON_OFF * 5)))
while ((game_name_width = WidthFromStr(nBuffer)) > 0 && (MENU_ICON_OFF + (MENU_TITLE_OFF * 1) + game_name_width) > ((SCREEN_WIDTH - 50) - (MENU_ICON_OFF * 5)))
nBuffer[strlen(nBuffer) - 1] = '\0';
DrawString(MENU_ICON_OFF + (MENU_TITLE_OFF * 1), game_y, nBuffer);
free(nBuffer);
}
if (item->title_id)
DrawString((SCREEN_WIDTH - 20) - (MENU_ICON_OFF * 5), game_y, item->title_id);
DrawString((SCREEN_WIDTH - 40) - (MENU_ICON_OFF * 5), game_y, item->title_id);

if (item->flags & SAVE_FLAG_SELECTED)
DrawString(MENU_ICON_OFF + MENU_TITLE_OFF - 30, game_y, UTF8_CHAR_STAR);
DrawFormatString(MENU_ICON_OFF + MENU_TITLE_OFF - 30, game_y, "%c", CHAR_TAG_OWNER);

tmp[0] = ' ';
tmp[1] = ' ';
if (item->flags & SAVE_FLAG_PS2) tmp[0] = CHAR_TAG_PS2;
if (item->flags & SAVE_FLAG_PSP) tmp[0] = CHAR_TAG_PSP;
if (item->flags & SAVE_FLAG_PS1) tmp[0] = CHAR_TAG_PS1;
// if (item->flags & SAVE_FLAG_PSV) tmp[0] = CHAR_TAG_PSV;
tmp[1] = (item->flags & SAVE_FLAG_LOCKED) ? CHAR_TAG_LOCKED : ' ';
if (item->flags & SAVE_FLAG_LOCKED) tmp[1] = CHAR_TAG_LOCKED;
if (item->flags & SAVE_FLAG_PACKED) tmp[1] = CHAR_TAG_PACK;

DrawString(SCREEN_WIDTH - (MENU_ICON_OFF * 2), game_y, tmp);
DrawString(SCREEN_WIDTH - 20 - (MENU_ICON_OFF * 2), game_y, tmp);
skip_draw:
node = list_next(node);
}
Expand Down
69 changes: 8 additions & 61 deletions source/saves.c
Original file line number Diff line number Diff line change
Expand Up @@ -489,12 +489,12 @@ list_t * ReadBackupList(const char* userPath)
item->path = strdup(menu_options[3].options[apollo_config.storage]);
item->type = FILE_TYPE_ZIP;
list_append(list, item);

/*
item = _createSaveEntry(0, CHAR_ICON_NET " Network Tools");
item->path = strdup(MC0_PATH);
item->type = FILE_TYPE_NET;
list_append(list, item);

*/
return list;
}

Expand Down Expand Up @@ -793,13 +793,6 @@ static void read_ps2_savegames(const char* userPath, list_t *list, int flags)
if(item->title_id[4] == '-')
memmove(&item->title_id[4], &item->title_id[5], 6);

if (0) //strcmp((char*) sfo_get_param_value(sfo, "SAVEDATA_FILE_LIST"), "CONFIG.BIN") == 0)
{
snprintf(sfoPath, sizeof(sfoPath), "%s%s/SCEVMC0.VMP", userPath, dir->d_name);
if (file_exists(sfoPath) == SUCCESS)
item->flags ^= (SAVE_FLAG_PS1 | SAVE_FLAG_PS2);
}

LOG("[%s] F(%X) name '%s'", item->title_id, item->flags, item->name);
list_append(list, item);
}
Expand All @@ -809,54 +802,10 @@ static void read_ps2_savegames(const char* userPath, list_t *list, int flags)

static void read_usb_savegames(const char* userPath, list_t *list)
{
DIR *d;
struct dirent *dir;
save_entry_t *item;
char sfoPath[256];

d = opendir(userPath);

if (!d)
return;

while ((dir = readdir(d)) != NULL)
{
if (!S_ISDIR(dir->d_stat.st_mode) || strcmp(dir->d_name, ".") == 0 || strcmp(dir->d_name, "..") == 0)
continue;

snprintf(sfoPath, sizeof(sfoPath), "%s%s/sce_sys/param.sfo", userPath, dir->d_name);
if (file_exists(sfoPath) != SUCCESS)
continue;

LOG("Reading %s...", sfoPath);

sfo_context_t* sfo = sfo_alloc();
if (sfo_read(sfo, sfoPath) < 0) {
LOG("Unable to read from '%s'", sfoPath);
sfo_free(sfo);
continue;
}

char *sfo_data = (char*)(sfo_get_param_value(sfo, "PARAMS") + 0x28);
item = _createSaveEntry(SAVE_FLAG_PSP, sfo_data);
item->type = FILE_TYPE_PSV;
asprintf(&item->path, "%s%s/", userPath, dir->d_name);
asprintf(&item->title_id, "%.9s", sfo_data);

sfo_data = (char*)(sfo_get_param_value(sfo, "PARENT_DIRECTORY") + 1);
item->dir_name = strdup(sfo_data);

// uint64_t* int_data = (uint64_t*) sfo_get_param_value(sfo, "ACCOUNT_ID");
// if (int_data && (apollo_config.account_id == *int_data))
// item->flags |= SAVE_FLAG_OWNER;

sfo_free(sfo);

LOG("[%s] F(%X) name '%s'", item->title_id, item->flags, item->name);
list_append(list, item);
}
char path[256];

closedir(d);
snprintf(path, sizeof(path), "%sPS2/SAVEDATA/", userPath);
read_ps2_savegames(path, list, 0);
}

static int set_psx_import_codes(save_entry_t* item)
Expand Down Expand Up @@ -946,12 +895,10 @@ static void read_psx_savegames(const char* userPath, const char* folder, list_t
fread(data, 1, sizeof(data), fp);
fclose(fp);

item = _createSaveEntry(SAVE_FLAG_PS2, dir->d_name);
item = _createSaveEntry(SAVE_FLAG_PACKED, dir->d_name);
set_psx_import_codes(item);

if (type == FILE_TYPE_PSX || type == FILE_TYPE_MCS)
item->flags = SAVE_FLAG_PS1;

item->flags |= (type == FILE_TYPE_PSX || type == FILE_TYPE_MCS) ? SAVE_FLAG_PS1 : SAVE_FLAG_PS2;
item->type = type;
item->path = strdup(psvPath);
asprintf(&item->title_id, "%.10s", data+2);
Expand Down Expand Up @@ -1010,7 +957,7 @@ list_t * ReadUsbList(const char* userPath)

read_usb_savegames(userPath, list);
read_psx_savegames(userPath, "PS2/SAVEDATA/", list);
read_ps2_savegames(userPath, list, 0);
// read_psx_savegames(userPath, "PS1/SAVEDATA/", list);

return list;
}
Expand Down

0 comments on commit 96fe0de

Please sign in to comment.