Skip to content

Commit

Permalink
games: Fix broken input on Killzone: Mercenary at >59 fps
Browse files Browse the repository at this point in the history
* 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 <miso.chvila@gmail.com>
  • Loading branch information
Electry committed Sep 1, 2018
1 parent 98a10e1 commit ddde261
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ target_link_libraries(VitaGrafix
taihen_stub
SceAppMgr_stub
SceDisplay_stub
SceCtrl_stub
kuio_stub
k
gcc
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <br/> PCSE00326 <br/> PCSG00074 | Internal res. <br/> FPS cap | 640x352 <br/> 30 | OFF <br/> OFF | At 60 FPS menu is double speed |
| Hatsune Miku: Project Diva f 2nd | PCSB00554 <br/> PCSE00434 <br/> PCSG00205 <br/> PCSH00088 | Internal res. <br/> FPS cap | 720x408 <br/> 30 | OFF <br/> OFF | At 60 FPS menu is double speed |
| Jak and Daxter Collection | PCSF00247 <br/> PCSF00248 <br/> PCSF00249 <br/> PCSF00250 <br/> PCSA00080 | Framebuffer | 720x408 | 960x544 | All 3 games |
| Killzone: Mercenary | PCSF00243 <br/> PCSF00403 <br/> PCSA00107 <br/> PCSC00045 <br/> PCSD00071 | Internal res. <br/> FPS cap | Dynamic <br/> 30 | OFF <br/> OFF | Input doesn't work when framerate is > 59. <br/> Particles are rendered separately. |
| Killzone: Mercenary | PCSF00243 <br/> PCSF00403 <br/> PCSA00107 <br/> PCSC00045 <br/> PCSD00071 | Internal res. <br/> FPS cap | Dynamic <br/> 30 | OFF <br/> OFF | Particles are rendered separately. |
| LEGO Star Wars: The Force Awakens | PCSB00877 <br/> PCSE00791 | Internal res. | 640x368 | 720x408 | Game crashes when opening pause menu at high resolutions. |
| LittleBigPlanet | PCSF00021 <br/> PCSA00017 <br/> PCSC00013 <br/> PCSD00006 | Internal res. | 720x408 | OFF | Particles cause artifacts at native res. |
| Miracle Girls Festival | PCSG00610 | Internal res. | 720x408 | 960x544 | |
Expand Down
15 changes: 14 additions & 1 deletion games.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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]
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit ddde261

Please sign in to comment.