diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 3d1d89a01b..422bb53afe 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -247,52 +247,42 @@ error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr } if (!type) + { return CELL_GAME_ERROR_PARAM; - // According to testing (in debug mode) cellGameBootCheck doesn't return an error code, when PARAM.SFO doesn't exist. - psf::registry sfo = psf::load_object(fs::file(vfs::get("/app_home/../PARAM.SFO"))); + } - const std::string& category = psf::get_string(sfo, "CATEGORY"); - - if (category == "DG") + if (Emu.GetCat() == "DG") { *type = CELL_GAME_GAMETYPE_DISC; *attributes = 0; // TODO // TODO: dirName might be a read only string when BootCheck is called on a disc game. (e.g. Ben 10 Ultimate Alien: Cosmic Destruction) - if (!fxm::make("", std::move(sfo))) + if (!fxm::make("", psf::load_object(fs::file(vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO"))))) { return CELL_GAME_ERROR_BUSY; } } - else if (category == "AP" || category == "AV" || category == "HG" || category == "AT" || category == "AM" || category == "SF") - { - *type = CELL_GAME_GAMETYPE_HDD; - *attributes = 0; // TODO - if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID()); - - if (!fxm::make(Emu.GetTitleID(), std::move(sfo))) - { - return CELL_GAME_ERROR_BUSY; - } - } - else if (category == "GD") + else if (Emu.GetCat() == "GD") { *type = CELL_GAME_GAMETYPE_DISC; *attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID()); // ??? - if (!fxm::make("", std::move(sfo))) + if (!fxm::make("", psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO"))))) { return CELL_GAME_ERROR_BUSY; } } else { - // Hack: When there is no (or unknown) CATEGORY returned, instead of throwing an exception - // we assume it's a disk game. - *type = CELL_GAME_GAMETYPE_DISC; - *attributes = 0; - cellGame.error("cellGameBootCheck(): Unknown CATEGORY: %s", category); + *type = CELL_GAME_GAMETYPE_HDD; + *attributes = 0; // TODO + if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID()); + + if (!fxm::make(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO"))))) + { + return CELL_GAME_ERROR_BUSY; + } } return CELL_OK; @@ -312,14 +302,12 @@ error_code cellGamePatchCheck(vm::ptr size, vm::ptr r size->sysSizeKB = 0; } - psf::registry sfo = psf::load_object(fs::file(vfs::get("/app_home/../PARAM.SFO"))); - - if (psf::get_string(sfo, "CATEGORY") != "GD") + if (Emu.GetCat() != "GD") { return CELL_GAME_ERROR_NOTPATCH; } - if (!fxm::make(Emu.GetTitleID(), std::move(sfo))) + if (!fxm::make(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO"))))) { return CELL_GAME_ERROR_BUSY; } @@ -454,7 +442,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr cbGet->sizeKB = CELL_GAMEDATA_SIZEKB_NOTCALC; cbGet->sysSizeKB = 0; - psf::registry sfo = psf::load_object(fs::file(vfs::get("/app_home/../PARAM.SFO"))); + psf::registry sfo = psf::load_object(fs::file(vfs::get(Emu.GetCat() == "DG" ? "/dev_bdvd/PS3_GAME/PARAM.SFO"s : "/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO"))); cbGet->getParam.attribute = CELL_GAMEDATA_ATTR_NORMAL; cbGet->getParam.parentalLevel = psf::get_integer(sfo, "PARENTAL_LEVEL", 0); diff --git a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp index 40d14761c6..2a103a066d 100644 --- a/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNpTrophy.cpp @@ -196,7 +196,7 @@ error_code sceNpTrophyCreateContext(vm::ptr context, vm::cptr ar // TODO: set prio, flags std::string path = vfs::get(argv[0]); + std::string disc; + + if (Emu.GetCat() == "DG" || Emu.GetCat() == "GD") + disc = vfs::get("/dev_bdvd/"); + else if (Emu.GetTitleID().size()) + disc = vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/"); vm::temporary_unlock(ppu); - Emu.CallAfter([path = std::move(path), argv = std::move(argv), envp = std::move(envp), data = std::move(data), disc = vfs::get("/dev_bdvd/"), klic = fxm::get_always()->devKlic]() mutable + Emu.CallAfter([path = std::move(path), argv = std::move(argv), envp = std::move(envp), data = std::move(data), disc = std::move(disc), klic = fxm::get_always()->devKlic]() mutable { sys_process.success("Process finished -> %s", argv[0]); Emu.SetForceBoot(true); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index baaa12585e..bbddb0a815 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -357,26 +357,38 @@ void Emulator::Load(bool add_only) const std::string elf_dir = fs::get_parent_dir(m_path); // Load PARAM.SFO (TODO) - const auto _psf = psf::load_object([&] + const auto _psf = psf::load_object([&]() -> fs::file { if (fs::file sfov{elf_dir + "/sce_sys/param.sfo"}) { return sfov; } - if (Emu.disc.size()) + if (disc.size()) { - return fs::file{Emu.disc + "/PS3_GAME/PARAM.SFO"}; + // Check previously used category before it's overwritten + if (m_cat == "DG") + { + return fs::file{disc + "/PS3_GAME/PARAM.SFO"}; + } + + if (m_cat == "GD") + { + return fs::file{GetHddDir() + "game/" + m_title_id + "/PARAM.SFO"}; + } + + return fs::file{disc + "/PARAM.SFO"}; } - return fs::file(elf_dir + "/../PARAM.SFO"); + return fs::file{elf_dir + "/../PARAM.SFO"}; }()); m_title = psf::get_string(_psf, "TITLE", m_path); m_title_id = psf::get_string(_psf, "TITLE_ID"); - const auto _cat = psf::get_string(_psf, "CATEGORY"); + m_cat = psf::get_string(_psf, "CATEGORY"); LOG_NOTICE(LOADER, "Title: %s", GetTitle()); LOG_NOTICE(LOADER, "Serial: %s", GetTitleID()); + LOG_NOTICE(LOADER, "Category: %s", GetCat()); // Initialize data/cache directory m_cache_path = fs::get_data_dir(m_title_id, m_path); @@ -428,7 +440,7 @@ void Emulator::Load(bool add_only) const std::string hdd0_game = vfs::get("/dev_hdd0/game/"); const std::string hdd0_disc = vfs::get("/dev_hdd0/disc/"); - if (_cat == "DG" && m_path.find(hdd0_game) != -1 && Emu.disc.empty()) + if (m_cat == "DG" && m_path.find(hdd0_game) != -1 && disc.empty()) { // Booting disc game from wrong location LOG_ERROR(LOADER, "Disc game %s found at invalid location /dev_hdd0/game/", m_title_id); @@ -447,7 +459,7 @@ void Emulator::Load(bool add_only) } // Booting disc game - if (_cat == "DG" && bdvd_dir.empty() && Emu.disc.empty()) + if (m_cat == "DG" && bdvd_dir.empty() && disc.empty()) { // Mount /dev_bdvd/ if necessary if (auto pos = elf_dir.rfind("/PS3_GAME/") + 1) @@ -457,7 +469,7 @@ void Emulator::Load(bool add_only) } // Booting patch data - if (_cat == "GD" && bdvd_dir.empty() && Emu.disc.empty()) + if (m_cat == "GD" && bdvd_dir.empty() && disc.empty()) { // Load /dev_bdvd/ from game list if available if (auto node = games[m_title_id]) @@ -471,7 +483,7 @@ void Emulator::Load(bool add_only) } // Check /dev_bdvd/ - if (Emu.disc.empty() && !bdvd_dir.empty() && fs::is_dir(bdvd_dir)) + if (disc.empty() && !bdvd_dir.empty() && fs::is_dir(bdvd_dir)) { fs::file sfb_file; @@ -498,17 +510,21 @@ void Emulator::Load(bool add_only) out << games; fs::file(fs::get_config_dir() + "/games.yml", fs::rewrite).write(out.c_str(), out.size()); } - else if (!Emu.disc.empty()) + else if (m_cat != "DG" && m_cat != "GD") { - bdvd_dir = Emu.disc; - vfs::mount("dev_bdvd", bdvd_dir); - LOG_NOTICE(LOADER, "Disk: %s", vfs::get("/dev_bdvd")); + // Don't need /dev_bdvd } - else if (_cat == "DG" || _cat == "GD") + else if (disc.empty()) { LOG_ERROR(LOADER, "Failed to mount disc directory for the disc game %s", m_title_id); return; } + else + { + bdvd_dir = disc; + vfs::mount("dev_bdvd", bdvd_dir); + LOG_NOTICE(LOADER, "Disk: %s", vfs::get("/dev_bdvd")); + } if (add_only) { @@ -586,7 +602,7 @@ void Emulator::Load(bool add_only) // Check game updates const std::string hdd0_boot = hdd0_game + m_title_id + "/USRDIR/EBOOT.BIN"; - if (_cat == "DG" && fs::is_file(hdd0_boot)) + if (disc.empty() && m_cat == "DG" && fs::is_file(hdd0_boot)) { // Booting game update LOG_SUCCESS(LOADER, "Updates found at /dev_hdd0/game/%s/!", m_title_id); diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 62c42ae05d..a1c707f21e 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -181,6 +181,7 @@ class Emulator final std::string m_cache_path; std::string m_title_id; std::string m_title; + std::string m_cat; bool m_force_boot = false; @@ -234,6 +235,11 @@ public: return m_title; } + const std::string& GetCat() const + { + return m_cat; + } + const std::string& GetCachePath() const { return m_cache_path;