Remove /app_home/ dependency

Should also fix exitspawn
This commit is contained in:
Nekotekina 2017-12-25 23:14:57 +03:00
parent a605919729
commit e768bdc80f
5 changed files with 62 additions and 46 deletions

View file

@ -247,52 +247,42 @@ error_code cellGameBootCheck(vm::ptr<u32> type, vm::ptr<u32> attributes, vm::ptr
} }
if (!type) if (!type)
{
return CELL_GAME_ERROR_PARAM; 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 (Emu.GetCat() == "DG")
if (category == "DG")
{ {
*type = CELL_GAME_GAMETYPE_DISC; *type = CELL_GAME_GAMETYPE_DISC;
*attributes = 0; // TODO *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) // 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<content_permission>("", std::move(sfo))) if (!fxm::make<content_permission>("", psf::load_object(fs::file(vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO")))))
{ {
return CELL_GAME_ERROR_BUSY; return CELL_GAME_ERROR_BUSY;
} }
} }
else if (category == "AP" || category == "AV" || category == "HG" || category == "AT" || category == "AM" || category == "SF") else if (Emu.GetCat() == "GD")
{
*type = CELL_GAME_GAMETYPE_HDD;
*attributes = 0; // TODO
if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID());
if (!fxm::make<content_permission>(Emu.GetTitleID(), std::move(sfo)))
{
return CELL_GAME_ERROR_BUSY;
}
}
else if (category == "GD")
{ {
*type = CELL_GAME_GAMETYPE_DISC; *type = CELL_GAME_GAMETYPE_DISC;
*attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO *attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO
if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID()); // ??? if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID()); // ???
if (!fxm::make<content_permission>("", std::move(sfo))) if (!fxm::make<content_permission>("", psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO")))))
{ {
return CELL_GAME_ERROR_BUSY; return CELL_GAME_ERROR_BUSY;
} }
} }
else else
{ {
// Hack: When there is no (or unknown) CATEGORY returned, instead of throwing an exception *type = CELL_GAME_GAMETYPE_HDD;
// we assume it's a disk game. *attributes = 0; // TODO
*type = CELL_GAME_GAMETYPE_DISC; if (dirName) strcpy_trunc(*dirName, Emu.GetTitleID());
*attributes = 0;
cellGame.error("cellGameBootCheck(): Unknown CATEGORY: %s", category); if (!fxm::make<content_permission>(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO")))))
{
return CELL_GAME_ERROR_BUSY;
}
} }
return CELL_OK; return CELL_OK;
@ -312,14 +302,12 @@ error_code cellGamePatchCheck(vm::ptr<CellGameContentSize> size, vm::ptr<void> r
size->sysSizeKB = 0; size->sysSizeKB = 0;
} }
psf::registry sfo = psf::load_object(fs::file(vfs::get("/app_home/../PARAM.SFO"))); if (Emu.GetCat() != "GD")
if (psf::get_string(sfo, "CATEGORY") != "GD")
{ {
return CELL_GAME_ERROR_NOTPATCH; return CELL_GAME_ERROR_NOTPATCH;
} }
if (!fxm::make<content_permission>(Emu.GetTitleID(), std::move(sfo))) if (!fxm::make<content_permission>(Emu.GetTitleID(), psf::load_object(fs::file(vfs::get("/dev_hdd0/game/" + Emu.GetTitleID() + "/PARAM.SFO")))))
{ {
return CELL_GAME_ERROR_BUSY; return CELL_GAME_ERROR_BUSY;
} }
@ -454,7 +442,7 @@ error_code cellGameDataCheckCreate2(ppu_thread& ppu, u32 version, vm::cptr<char>
cbGet->sizeKB = CELL_GAMEDATA_SIZEKB_NOTCALC; cbGet->sizeKB = CELL_GAMEDATA_SIZEKB_NOTCALC;
cbGet->sysSizeKB = 0; 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.attribute = CELL_GAMEDATA_ATTR_NORMAL;
cbGet->getParam.parentalLevel = psf::get_integer(sfo, "PARENTAL_LEVEL", 0); cbGet->getParam.parentalLevel = psf::get_integer(sfo, "PARENTAL_LEVEL", 0);

View file

@ -196,7 +196,7 @@ error_code sceNpTrophyCreateContext(vm::ptr<u32> context, vm::cptr<SceNpCommunic
} }
// open trophy pack file // open trophy pack file
fs::file stream(vfs::get("/app_home/../TROPDIR/" + name + "/TROPHY.TRP")); fs::file stream(vfs::get((Emu.GetCat() == "DG" ? "/dev_bdvd/PS3_GAME/TROPDIR/"s : "/dev_hdd0/game/" + Emu.GetTitleID() + "/TROPDIR/") + name + "/TROPHY.TRP"));
// check if exists and opened // check if exists and opened
if (!stream) if (!stream)

View file

@ -286,10 +286,16 @@ void _sys_process_exit2(ppu_thread& ppu, s32 status, vm::ptr<sys_exit2_param> ar
// TODO: set prio, flags // TODO: set prio, flags
std::string path = vfs::get(argv[0]); 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); 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<LoadedNpdrmKeys_t>()->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<LoadedNpdrmKeys_t>()->devKlic]() mutable
{ {
sys_process.success("Process finished -> %s", argv[0]); sys_process.success("Process finished -> %s", argv[0]);
Emu.SetForceBoot(true); Emu.SetForceBoot(true);

View file

@ -357,26 +357,38 @@ void Emulator::Load(bool add_only)
const std::string elf_dir = fs::get_parent_dir(m_path); const std::string elf_dir = fs::get_parent_dir(m_path);
// Load PARAM.SFO (TODO) // 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"}) if (fs::file sfov{elf_dir + "/sce_sys/param.sfo"})
{ {
return sfov; 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"};
} }
return fs::file(elf_dir + "/../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"};
}()); }());
m_title = psf::get_string(_psf, "TITLE", m_path); m_title = psf::get_string(_psf, "TITLE", m_path);
m_title_id = psf::get_string(_psf, "TITLE_ID"); 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, "Title: %s", GetTitle());
LOG_NOTICE(LOADER, "Serial: %s", GetTitleID()); LOG_NOTICE(LOADER, "Serial: %s", GetTitleID());
LOG_NOTICE(LOADER, "Category: %s", GetCat());
// Initialize data/cache directory // Initialize data/cache directory
m_cache_path = fs::get_data_dir(m_title_id, m_path); 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_game = vfs::get("/dev_hdd0/game/");
const std::string hdd0_disc = vfs::get("/dev_hdd0/disc/"); 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 // Booting disc game from wrong location
LOG_ERROR(LOADER, "Disc game %s found at invalid location /dev_hdd0/game/", m_title_id); 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 // 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 // Mount /dev_bdvd/ if necessary
if (auto pos = elf_dir.rfind("/PS3_GAME/") + 1) if (auto pos = elf_dir.rfind("/PS3_GAME/") + 1)
@ -457,7 +469,7 @@ void Emulator::Load(bool add_only)
} }
// Booting patch data // 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 // Load /dev_bdvd/ from game list if available
if (auto node = games[m_title_id]) if (auto node = games[m_title_id])
@ -471,7 +483,7 @@ void Emulator::Load(bool add_only)
} }
// Check /dev_bdvd/ // 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; fs::file sfb_file;
@ -498,17 +510,21 @@ void Emulator::Load(bool add_only)
out << games; out << games;
fs::file(fs::get_config_dir() + "/games.yml", fs::rewrite).write(out.c_str(), out.size()); 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; // Don't need /dev_bdvd
vfs::mount("dev_bdvd", bdvd_dir);
LOG_NOTICE(LOADER, "Disk: %s", vfs::get("/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); LOG_ERROR(LOADER, "Failed to mount disc directory for the disc game %s", m_title_id);
return; return;
} }
else
{
bdvd_dir = disc;
vfs::mount("dev_bdvd", bdvd_dir);
LOG_NOTICE(LOADER, "Disk: %s", vfs::get("/dev_bdvd"));
}
if (add_only) if (add_only)
{ {
@ -586,7 +602,7 @@ void Emulator::Load(bool add_only)
// Check game updates // Check game updates
const std::string hdd0_boot = hdd0_game + m_title_id + "/USRDIR/EBOOT.BIN"; 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 // Booting game update
LOG_SUCCESS(LOADER, "Updates found at /dev_hdd0/game/%s/!", m_title_id); LOG_SUCCESS(LOADER, "Updates found at /dev_hdd0/game/%s/!", m_title_id);

View file

@ -181,6 +181,7 @@ class Emulator final
std::string m_cache_path; std::string m_cache_path;
std::string m_title_id; std::string m_title_id;
std::string m_title; std::string m_title;
std::string m_cat;
bool m_force_boot = false; bool m_force_boot = false;
@ -234,6 +235,11 @@ public:
return m_title; return m_title;
} }
const std::string& GetCat() const
{
return m_cat;
}
const std::string& GetCachePath() const const std::string& GetCachePath() const
{ {
return m_cache_path; return m_cache_path;