Skip to content

Commit

Permalink
fix psp iso not able to boot after download
Browse files Browse the repository at this point in the history
  • Loading branch information
cy33hc committed Sep 21, 2021
1 parent 9783c09 commit f254b2f
Show file tree
Hide file tree
Showing 7 changed files with 39 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ include("${VITASDK}/share/vita.cmake" REQUIRED)

set(VITA_APP_NAME "Launcher")
set(VITA_TITLEID "SMLA00001")
set(VITA_VERSION "03.30")
set(VITA_VERSION "03.40")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fpermissive")

Expand Down
2 changes: 1 addition & 1 deletion src/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
#define PSP_EBOOT_PATH "ux0:pspemu/PSP/GAME"
#define CONFIG_PSPEMU_PATH "pspemu_location"
#define DEFAULT_PSPEMU_PATH "ux0:pspemu"
#define PSP_ISO_CACHE_PATH "ux0:pspemu/ISO/_cache"
#define PSP_ISO_CACHE_PATH "ux0:pspemu/ISO"
#define PSP_EBOOT_CACHE_PATH "ux0:pspemu/PSP/GAME/_cache"

#define CONFIG_VIEW_MODE "view_mode"
Expand Down
5 changes: 5 additions & 0 deletions src/fs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ namespace FS {
int err = sceIoRemove(file.c_str());
}

void RmDir(const std::string& path)
{
sceIoRmdir(path.c_str());
}

int64_t GetSize(const std::string& path)
{
SceIoStat stat;
Expand Down
33 changes: 29 additions & 4 deletions src/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ namespace GAME {
{
game_index++;
int index = files[j].find_last_of(".");
if (index != std::string::npos && IsRomExtension(files[j].substr(index), psp_iso_extensions) && files[j].find_first_of("_cache/") != 0)
if (index != std::string::npos && IsRomExtension(files[j].substr(index), psp_iso_extensions) && files[j].find_first_of("cache_") != 0)
{
Game game;
try
Expand Down Expand Up @@ -648,7 +648,8 @@ namespace GAME {
{
if (game->type == TYPE_PSP_ISO)
{
sprintf(rom_path_temp, "%s%s", PSP_ISO_CACHE_PATH, rom_path.substr(rom_path.find_last_of("/")).c_str());
rom_path = std::string(PSP_ISO_CACHE_PATH) + "/cache_" + rom_path.substr(rom_path.find_last_of("/")+1);
sprintf(rom_path_temp, "%s", rom_path.c_str());
}
else
{
Expand Down Expand Up @@ -1767,7 +1768,7 @@ namespace GAME {
else if (game->type == TYPE_PSP_ISO)
{
std::string game_path = std::string(game->rom_path);
game->cache_state = FS::FileExists(std::string(PSP_ISO_CACHE_PATH) + game_path.substr(game_path.find_last_of("/")));
game->cache_state = FS::FileExists(std::string(PSP_ISO_CACHE_PATH) + "/cache_" + game_path.substr(game_path.find_last_of("/")+1));
return game->cache_state;
}
else if (game->type == TYPE_EBOOT)
Expand Down Expand Up @@ -1867,7 +1868,7 @@ namespace GAME {
{
FS::MkDirs(PSP_ISO_CACHE_PATH);
}
std::string output_file = std::string(PSP_ISO_CACHE_PATH) + path.substr(path.find_last_of("/"));
std::string output_file = std::string(PSP_ISO_CACHE_PATH) + "/cache_" + path.substr(path.find_last_of("/")+1);
path = path.substr(5);
if (ftpclient->Size(path.c_str(), &bytes_to_download, FtpClient::image) > 0)
{
Expand Down Expand Up @@ -2006,4 +2007,28 @@ namespace GAME {
bytes_transfered = xfered;
return 1;
}

void MigratePSPCache()
{
std::string old_cache_path = std::string(PSP_ISO_PATH) + "/_cache";
if (FS::FolderExists(old_cache_path))
{
std::vector<std::string> files = GetRomFiles(old_cache_path);
for (int i=0; i<files.size(); i++)
{
std::string old_path = old_cache_path + "/" + files[i];
std::string new_path = std::string(PSP_ISO_CACHE_PATH) + "/cache_" + files[i];
if (!FS::FileExists(new_path))
{
FS::Rename(old_path, new_path);
}
else
{
FS::Rm(old_path);
}
}

FS::RmDir(old_cache_path);
}
}
}
1 change: 1 addition & 0 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ namespace GAME {
int DownloadGameThread(SceSize args, Game **game);
void StartGetCacheStateThread();
int GetCacheStateThread(SceSize args, void *argp);
void MigratePSPCache();
std::vector<std::string> GetFilesFromCueFile(char *path);
static int DownloadGameCallback(int64_t xfered, void* arg);
static int LoadScePaf();
Expand Down
2 changes: 1 addition & 1 deletion src/launcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2606,7 +2606,7 @@ namespace Windows {
it!=new_files.end(); )
{
int index = it->find_last_of(".");
if (index != std::string::npos && GAME::IsRomExtension(it->substr(index), psp_iso_extensions) && it->find_first_of("_cache/") != 0)
if (index != std::string::npos && GAME::IsRomExtension(it->substr(index), psp_iso_extensions) && it->find_first_of("cache_") != 0)
{
games_on_filesystem.push_back(rom_path_prefix + "/" + *it);
}
Expand Down
1 change: 1 addition & 0 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ int main(int, char **)
GAME::Init();
GAME::StartScanGamesThread();
GAME::StartGetCacheStateThread();
GAME::MigratePSPCache();

GUI::RenderLoop();

Expand Down

0 comments on commit f254b2f

Please sign in to comment.