diff --git a/Core/Compatibility.cpp b/Core/Compatibility.cpp index c8159cc13c..c2dd325d5f 100644 --- a/Core/Compatibility.cpp +++ b/Core/Compatibility.cpp @@ -169,6 +169,7 @@ void Compatibility::CheckSettings(IniFile &iniFile, const std::string &gameID) { CheckSetting(iniFile, gameID, "DepthCLUTIntoHalves", &flags_.DepthCLUTIntoHalves); CheckSetting(iniFile, gameID, "AccurateSplines", &flags_.AccurateSplines); CheckSetting(iniFile, gameID, "ReadbackShadow", &flags_.ReadbackShadow); + CheckSetting(iniFile, gameID, "ColorPickingDrawSyncReadback", &flags_.ColorPickingDrawSyncReadback); } void Compatibility::CheckVRSettings(IniFile &iniFile, const std::string &gameID) { diff --git a/Core/Compatibility.h b/Core/Compatibility.h index 25c0957792..2063013b52 100644 --- a/Core/Compatibility.h +++ b/Core/Compatibility.h @@ -124,6 +124,7 @@ struct CompatFlags { bool DepthCLUTIntoHalves; bool AccurateSplines; bool ReadbackShadow; + bool ColorPickingDrawSyncReadback; }; struct VRCompat { diff --git a/Core/HLE/ReplaceTables.cpp b/Core/HLE/ReplaceTables.cpp index 601d3db80d..246b74ef10 100644 --- a/Core/HLE/ReplaceTables.cpp +++ b/Core/HLE/ReplaceTables.cpp @@ -985,15 +985,6 @@ static int Hook_soranokiseki_sc_download_frame() { return 0; } -static int Hook_amagoushi_download_frame() { - // Amagoushi no Yakata (ULJS00216) offscreen picking pass renders to 0x04000000 or 0x04080000. - // Flush GPU framebuffer to VRAM before CPU decodes pixels into hit-test table. - gpu->PerformReadbackToMemory(0x04000000, 0x00044000); - gpu->PerformReadbackToMemory(0x04080000, 0x00044000); - NotifyMemInfo(MemBlockFlags::WRITE, 0x04000000, 0x00044000, "amagoushi_download_frame"); - return 0; -} - static int Hook_bokunonatsuyasumi4_download_frame() { const u32 fb_address = currentMIPS->r[MIPS_REG_A3]; if (Memory::IsVRAMAddress(fb_address)) { @@ -1926,7 +1917,6 @@ static const ReplacementTableEntry entries[] = { { "kagaku_no_ensemble_download_frame", &Hook_kagaku_no_ensemble_download_frame, 0, REPFLAG_HOOKENTER, 0x38 }, { "soranokiseki_fc_download_frame", &Hook_soranokiseki_fc_download_frame, 0, REPFLAG_HOOKENTER, 0x180 }, { "soranokiseki_sc_download_frame", &Hook_soranokiseki_sc_download_frame, 0, REPFLAG_HOOKENTER, }, - { "amagoushi_download_frame", &Hook_amagoushi_download_frame, 0, REPFLAG_HOOKENTER }, { "bokunonatsuyasumi4_download_frame", &Hook_bokunonatsuyasumi4_download_frame, 0, REPFLAG_HOOKENTER, 0x8C }, { "danganronpa2_1_download_frame", &Hook_danganronpa2_1_download_frame, 0, REPFLAG_HOOKENTER, 0x68 }, { "danganronpa2_2_download_frame", &Hook_danganronpa2_2_download_frame, 0, REPFLAG_HOOKENTER, 0x94 }, diff --git a/Core/HLE/sceGe.cpp b/Core/HLE/sceGe.cpp index fce3bc8a93..ca41407e59 100644 --- a/Core/HLE/sceGe.cpp +++ b/Core/HLE/sceGe.cpp @@ -467,7 +467,16 @@ static u32 sceGeDrawSync(u32 mode) { else if (!PSP_CoreParameter().compat.flags().DrawSyncInstant) hleEatCycles(1240); gstate_c.textureSyncTimeDomain++; - return hleLogDebug(Log::sceGe, gpu->DrawSync(mode)); + u32 result = gpu->DrawSync(mode); + if (mode == 0 && PSP_CoreParameter().compat.flags().ColorPickingDrawSyncReadback) { + // The game waits for its picking pass here and then reads it from VRAM. It renders to one + // of two buffers, so read back the one the last list drew to. + const u32 fb = 0x04000000 | gstate.getFrameBufRawAddress(); + if (fb == 0x04000000 || fb == 0x04080000) { + gpu->PerformReadbackToMemory(fb, 0x00044000); + } + } + return hleLogDebug(Log::sceGe, result); } static int sceGeContinue() { diff --git a/Core/MIPS/MIPSAnalyst.cpp b/Core/MIPS/MIPSAnalyst.cpp index fb80a052c8..fe736e5dfd 100644 --- a/Core/MIPS/MIPSAnalyst.cpp +++ b/Core/MIPS/MIPSAnalyst.cpp @@ -125,7 +125,6 @@ static const HardHashTableEntry hardcodedHashes[] = { { 0x11624abe9542fb01, 180, "everybodysgolf_copy_portrait", }, // Everybody's Golf (EUR) { 0x1252e902d0b49bfb, 44, "vector_sub_q_2", }, { 0x12df3d33a58d0298, 52, "sceVfpuMatrix3Unit", }, - { 0x12eed64025f5052bULL, 268, "amagoushi_download_frame", }, // Amagoushi no Yakata (ULJS00216) { 0x12feef7b017d3431, 700, "memmove", }, { 0x1322c7e3fe6dff4d, 784, "_free_r", }, { 0x1376c115d5f1d90c, 36, "strlen", }, diff --git a/assets/compat.ini b/assets/compat.ini index 3ecb1364dd..909734d662 100644 --- a/assets/compat.ini +++ b/assets/compat.ini @@ -1475,6 +1475,7 @@ ULES01277 = true # Amagoushi no Yakata series - offscreen solid color ID picking pass (issue #22514) ULJS00216 = true ULJS00230 = true +ULJS00247 = true NPJH50186 = true # The water effect of DiRT 2 and Outrun doesn't work in higher resolutions. @@ -2267,3 +2268,12 @@ NPJG00047 = true ULJS00394 = true ULJS19068 = true NPJH50518 = true + +[ColorPickingDrawSyncReadback] +# In 3D investigation mode, the Amagoushi no Yakata games render a solid color ID picking pass, wait for it +# with sceGeDrawSync(0) and read it from VRAM to find what the cursor is over (#22514). Read back the +# framebuffer the last list drew to at each sceGeDrawSync(0). +ULJS00216 = true +ULJS00230 = true +ULJS00247 = true +NPJH50186 = true