From ddde26194c1bd7e323a9e730f5b1c6171d2ccd0a Mon Sep 17 00:00:00 2001 From: Michal Chvila Date: Tue, 28 Aug 2018 21:26:55 +0200 Subject: [PATCH] games: Fix broken input on Killzone: Mercenary at >59 fps * Should fix menus on PSTV * This isn't perfect as we break the TAI hook chain on sceCtrlReadBuffer functions, which means that user plugins that hook these functions to read input need to be placed before VitaGrafix in tai config.txt (or otherwise they won't register any input). Signed-off-by: Michal Chvila --- CMakeLists.txt | 1 + README.md | 2 +- games.c | 15 ++++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ed098bc..74b01f4 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,6 +30,7 @@ target_link_libraries(VitaGrafix taihen_stub SceAppMgr_stub SceDisplay_stub + SceCtrl_stub kuio_stub k gcc diff --git a/README.md b/README.md index c91d835..a6f4def 100755 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ NOTE: If some options are left out, the plugin will use their default values (fo | Hatsune Miku: Project Diva f | PCSB00419
PCSE00326
PCSG00074 | Internal res.
FPS cap | 640x352
30 | OFF
OFF | At 60 FPS menu is double speed | | Hatsune Miku: Project Diva f 2nd | PCSB00554
PCSE00434
PCSG00205
PCSH00088 | Internal res.
FPS cap | 720x408
30 | OFF
OFF | At 60 FPS menu is double speed | | Jak and Daxter Collection | PCSF00247
PCSF00248
PCSF00249
PCSF00250
PCSA00080 | Framebuffer | 720x408 | 960x544 | All 3 games | -| Killzone: Mercenary | PCSF00243
PCSF00403
PCSA00107
PCSC00045
PCSD00071 | Internal res.
FPS cap | Dynamic
30 | OFF
OFF | Input doesn't work when framerate is > 59.
Particles are rendered separately. | +| Killzone: Mercenary | PCSF00243
PCSF00403
PCSA00107
PCSC00045
PCSD00071 | Internal res.
FPS cap | Dynamic
30 | OFF
OFF | Particles are rendered separately. | | LEGO Star Wars: The Force Awakens | PCSB00877
PCSE00791 | Internal res. | 640x368 | 720x408 | Game crashes when opening pause menu at high resolutions. | | LittleBigPlanet | PCSF00021
PCSA00017
PCSC00013
PCSD00006 | Internal res. | 720x408 | OFF | Particles cause artifacts at native res. | | Miracle Girls Festival | PCSG00610 | Internal res. | 720x408 | 960x544 | | diff --git a/games.c b/games.c index f3a8c81..5cb6e03 100755 --- a/games.c +++ b/games.c @@ -9,6 +9,7 @@ #include "games.h" int sceDisplayWaitVblankStartMulti(unsigned int vcount); +int sceCtrlPeekBufferPositive2(int port, SceCtrlData *pad_data, int count); int sceDisplaySetFrameBuf_withWait(const SceDisplayFrameBuf *pParam, int sync) { int ret = TAI_CONTINUE(int, hooks_ref[0], pParam, sync); @@ -18,6 +19,13 @@ int sceDisplaySetFrameBuf_withWait(const SceDisplayFrameBuf *pParam, int sync) { return ret; } +int sceCtrlReadBufferPositive_peekPatched(int port, SceCtrlData *pad_data, int count) { + return sceCtrlPeekBufferPositive(port, pad_data, count); +} +int sceCtrlReadBufferPositive2_peekPatched(int port, SceCtrlData *pad_data, int count) { + return sceCtrlPeekBufferPositive2(port, pad_data, count); +} + uint8_t patch_game(const char *titleid, tai_module_info_t *eboot_info, VG_Config *config) { if (!strncmp(titleid, "PCSF00243", 9) || // Killzone Mercenary [EUR] [1.12] !strncmp(titleid, "PCSF00403", 9) || // Killzone Mercenary [EUR] [1.12] @@ -50,8 +58,13 @@ uint8_t patch_game(const char *titleid, tai_module_info_t *eboot_info, VG_Config // dword_819706A4 DCD 2 ; DATA XREF: seg000:8104F722 injectData(eboot_info->modid, 0, 0x9706A4, &data32_vblank, sizeof(data32_vblank)); + + if (config->fps == FPS_60) { + hookFunctionImport(0x67E7AB83, sceCtrlReadBufferPositive_peekPatched); + hookFunctionImport(0xC4226A3E, sceCtrlReadBufferPositive2_peekPatched); + } } - + return 1; } else if (!strncmp(titleid, "PCSB00245", 9) || // Persona 4 Golden [EUR]