From 1f3b1e1c99e92dd1193abe1c48b6334c0ef6d806 Mon Sep 17 00:00:00 2001 From: Eladash Date: Thu, 16 Sep 2021 02:34:20 +0300 Subject: [PATCH] Implement Emulator::GetFakeCat() I still have nightmares about that cat. --- rpcs3/Emu/Cell/Modules/cellGame.cpp | 6 ++++-- rpcs3/Emu/Cell/Modules/sceNp.cpp | 2 +- rpcs3/Emu/System.cpp | 16 ++++++++++++++++ rpcs3/Emu/System.h | 2 ++ rpcs3/rpcs3qt/kernel_explorer.cpp | 2 +- 5 files changed, 24 insertions(+), 4 deletions(-) diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index ac37014161..10c17b4b9c 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -472,7 +472,9 @@ error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr std::string dir; psf::registry sfo; - if (Emu.GetCat() == "DG") + const std::string& cat = Emu.GetFakeCat(); + + if (cat == "DG") { *type = CELL_GAME_GAMETYPE_DISC; *attributes = 0; // TODO @@ -480,7 +482,7 @@ error_code cellGameBootCheck(vm::ptr type, vm::ptr attributes, vm::ptr sfo = psf::load_object(fs::file(vfs::get("/dev_bdvd/PS3_GAME/PARAM.SFO"))); } - else if (Emu.GetCat() == "GD") + else if (cat == "GD") { *type = CELL_GAME_GAMETYPE_DISC; *attributes = CELL_GAME_ATTRIBUTE_PATCH; // TODO diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index 704eeefc29..95a7bd3a4a 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -458,7 +458,7 @@ error_code npDrmIsAvailable(vm::cptr k_licensee_addr, vm::cptr drm_pat sceNp.notice("npDrmIsAvailable(): KLicense key %s", std::bit_cast>(k_licensee)); } - if (Emu.GetCat() == "PE") + if (Emu.GetFakeCat() == "PE") { std::memcpy(&k_licensee, NP_PSP_KEY_2, sizeof(k_licensee)); sceNp.success("npDrmIsAvailable(): PSP remaster KLicense key applied."); diff --git a/rpcs3/Emu/System.cpp b/rpcs3/Emu/System.cpp index 033bb298e5..0e1461216c 100644 --- a/rpcs3/Emu/System.cpp +++ b/rpcs3/Emu/System.cpp @@ -1906,4 +1906,20 @@ bool Emulator::IsPathInsideDir(std::string_view path, std::string_view dir) cons return (GetCallbacks().resolve_path(path) + '/').starts_with(GetCallbacks().resolve_path(dir) + '/'); }; +const std::string& Emulator::GetFakeCat() const +{ + if (m_cat == "DG") + { + const std::string mount_point = vfs::get("/dev_bdvd"); + + if (mount_point.empty() || !IsPathInsideDir(m_path, mount_point)) + { + static const std::string s_hg = "HG"; + return s_hg; + } + } + + return m_cat; +}; + Emulator Emu; diff --git a/rpcs3/Emu/System.h b/rpcs3/Emu/System.h index 37e9712dc1..c59b38fb24 100644 --- a/rpcs3/Emu/System.h +++ b/rpcs3/Emu/System.h @@ -189,6 +189,8 @@ public: return m_cat; } + const std::string& GetFakeCat() const; + const std::string& GetDir() const { return m_dir; diff --git a/rpcs3/rpcs3qt/kernel_explorer.cpp b/rpcs3/rpcs3qt/kernel_explorer.cpp index d16ae720e4..7efd940c85 100644 --- a/rpcs3/rpcs3qt/kernel_explorer.cpp +++ b/rpcs3/rpcs3qt/kernel_explorer.cpp @@ -312,7 +312,7 @@ void kernel_explorer::update() root->setText(0, qstr(fmt::format("Process 0x%08x: Total Memory Usage: 0x%x/0x%x (%0.2f/%0.2f MB)", process_getpid(), total_memory_usage, dct->size, 1. * total_memory_usage / (1024 * 1024) , 1. * dct->size / (1024 * 1024)))); - add_solid_node(find_node(root, additional_nodes::process_info), qstr(fmt::format("Process Info, Sdk Version: 0x%08x, PPC SEG: %#x, SFO Category: %s", g_ps3_process_info.sdk_ver, g_ps3_process_info.ppc_seg, Emu.GetCat()))); + add_solid_node(find_node(root, additional_nodes::process_info), qstr(fmt::format("Process Info, Sdk Version: 0x%08x, PPC SEG: %#x, SFO Category: %s (Fake: %s)", g_ps3_process_info.sdk_ver, g_ps3_process_info.ppc_seg, Emu.GetCat(), Emu.GetFakeCat()))); auto display_program_segments = [this](QTreeWidgetItem* tree, const ppu_module& m) {