From 2f9733794027b308f80751394fd311043b0e44e9 Mon Sep 17 00:00:00 2001 From: bucanero Date: Mon, 23 Dec 2024 11:59:41 -0300 Subject: [PATCH] add offline db Update CHANGELOG.md --- CHANGELOG.md | 13 +++++++++++++ include/saves.h | 8 +++++--- include/settings.h | 2 +- source/exec_cmd.c | 2 +- source/http.c | 17 +++++++++++------ source/main.c | 18 ++++++++++++++++++ source/saves.c | 8 +++++--- 7 files changed, 54 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9d3cc11..5115e29 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,19 @@ All notable changes to the `apollo-ps2` project will be documented in this file. ## [Unreleased]() +## [v1.0.2](https://github.com/bucanero/apollo-ps2/releases/tag/v1.0.2) - 2024-12-24 + +### Added + +* Support additional PS2 save formats when importing to PS2 VMCs + - Import to VMC - New supported formats: `.MAX`, `.CBS`, `.XPS`, `.SPS` +* Add support to load an offline save database (from `cdfs:/`, `mass:/`) + - Note: requires `mass` drive to be available to unzip save files + +### Fixed + +* Solve issue when exporting PS1 saves from memory cards + ## [v1.0.0](https://github.com/bucanero/apollo-ps2/releases/tag/v1.0.0) - 2024-12-07 ### Added diff --git a/include/saves.h b/include/saves.h index 904c321..0092b78 100644 --- a/include/saves.h +++ b/include/saves.h @@ -2,8 +2,12 @@ #include #define LOG dbglogger_log -#define APOLLO_PATH "ms0:/APOLLO/" +#define APOLLO_PATH "APOLLO/" +#ifdef APOLLO_ENABLE_LOGGING +#define APOLLO_APP_PATH "host:/APOLLO/" +#else #define APOLLO_APP_PATH "mass:/APOLLO/" +#endif #define APOLLO_USER_PATH USB_PATH "PS2/EXPORT/" #define APOLLO_DATA_PATH APOLLO_APP_PATH "DATA/" #define APOLLO_LOCAL_CACHE APOLLO_APP_PATH "CACHE/" @@ -22,8 +26,6 @@ #define PS1_SAVES_PATH_HDD APOLLO_PATH "PS1/" #define PSP_SAVES_PATH_HDD USB_PATH USER_PATH_USB -#define PS1_IMP_PATH_USB "PS1/SAVEDATA/" - #define EXPORT_PATH "APOLLO/EXPORT/" #define IMP_PS1VMC_PATH_USB "PS1/VMC/" diff --git a/include/settings.h b/include/settings.h index 60463fe..558608a 100644 --- a/include/settings.h +++ b/include/settings.h @@ -1,4 +1,4 @@ -#define APOLLO_VERSION "1.0.0" //Apollo PS2 version (about menu) +#define APOLLO_VERSION "1.0.2" //Apollo PS2 version (about menu) #define MENU_TITLE_OFF 30 //Offset of menu title text from menu mini icon #define MENU_ICON_OFF 35 //X Offset to start printing menu mini icon diff --git a/source/exec_cmd.c b/source/exec_cmd.c index 2f1a1f6..a646b7e 100644 --- a/source/exec_cmd.c +++ b/source/exec_cmd.c @@ -44,7 +44,7 @@ static void downloadSave(const save_entry_t* entry, const char* file, int dst) { char path[256]; - _set_dest_path(path, dst, PS2_SAVES_PATH_USB); + _set_dest_path(path, dst, (entry->flags & SAVE_FLAG_PS1) ? PS1_SAVES_PATH_USB : PS2_SAVES_PATH_USB); if (dst == STORAGE_MC0) snprintf(path, sizeof(path), PSP_SAVES_PATH_HDD); diff --git a/source/http.c b/source/http.c index 606e1e2..c867a0c 100644 --- a/source/http.c +++ b/source/http.c @@ -1,7 +1,7 @@ #include #include #include -#include +//#include //#include //#include @@ -154,22 +154,21 @@ static int update_progress(void *p, int64_t dltotal, int64_t dlnow, int64_t ulto int http_download(const char* url, const char* filename, const char* local_dst, int show_progress) { -#if 0 char full_url[1024]; - CURL *curl; - CURLcode res; +// CURL *curl; +// CURLcode res; FILE* fd; if (network_up() != HTTP_SUCCESS) return HTTP_FAILED; - +/* curl = curl_easy_init(); if(!curl) { LOG("ERROR: CURL INIT"); return HTTP_FAILED; } - +*/ fd = fopen(local_dst, "wb"); if (!fd) { LOG("fopen Error: File path '%s'", local_dst); @@ -180,6 +179,12 @@ int http_download(const char* url, const char* filename, const char* local_dst, snprintf(full_url, sizeof(full_url), "%s%s", url, filename); LOG("URL: %s >> %s", full_url, local_dst); + if (file_exists(full_url) != SUCCESS) + return HTTP_FAILED; + + return (copy_file(full_url, local_dst) == SUCCESS); + +#if 0 curl_easy_setopt(curl, CURLOPT_URL, full_url); // Set user agent string curl_easy_setopt(curl, CURLOPT_USERAGENT, HTTP_USER_AGENT); diff --git a/source/main.c b/source/main.c index 3696812..568c42c 100644 --- a/source/main.c +++ b/source/main.c @@ -344,6 +344,24 @@ void update_vmc_path(char* path) void update_db_path(char* path) { + if (file_exists("cdfs:/" APOLLO_PATH "PS2/games.txt") == SUCCESS) + { + strcpy(path, "cdfs:/" APOLLO_PATH); + return; + } + + if (file_exists("mass:/" APOLLO_PATH "PS2/games.txt") == SUCCESS) + { + strcpy(path, "mass:/" APOLLO_PATH); + return; + } + + if (file_exists("host:/" APOLLO_PATH "PS2/games.txt") == SUCCESS) + { + strcpy(path, "host:/" APOLLO_PATH); + return; + } + strcpy(path, apollo_config.save_db); } diff --git a/source/saves.c b/source/saves.c index 5eebff7..0a4dc02 100644 --- a/source/saves.c +++ b/source/saves.c @@ -697,9 +697,11 @@ int ReadOnlineSaves(save_entry_t * game) asprintf(&item->file, "%.12s", content); item->options_count = 1; - item->options = _createMcOptions(3, "Download to Memory Card", CMD_DOWNLOAD_USB); - asprintf(&item->options->name[2], "Download to Mass Storage (mass:/)"); - asprintf(&item->options->value[2], "%c%c", CMD_DOWNLOAD_USB, STORAGE_MASS); + item->options = _createMcOptions(2, "Download to Mass Storage", CMD_DOWNLOAD_USB); + memcpy(item->options->name[0] + 26, "mass:", 5); + memcpy(item->options->name[1] + 26, "host:", 5); + item->options->value[0][1] = STORAGE_MASS; + item->options->value[1][1] = STORAGE_HOST; list_append(game->codes, item); LOG("[%s%s] %s", game->path, item->file, item->name + 1);