high framerate fps

This commit is contained in:
CrazyRedMachine 2024-06-01 20:22:39 +02:00
parent ef648b0883
commit 6d3ade4c76
3 changed files with 33 additions and 19 deletions

View File

@ -124,8 +124,6 @@
<keysound_offset __type="s8">0</keysound_offset> <keysound_offset __type="s8">0</keysound_offset>
<!-- Adjust pop-kun and beam brightness (won't affect long popkuns) --> <!-- Adjust pop-kun and beam brightness (won't affect long popkuns) -->
<beam_brightness __type="s8">0</beam_brightness> <beam_brightness __type="s8">0</beam_brightness>
<!-- Disable the builtin frame limiter (faster/smoother animations at 120fps+) -->
<fps_uncap __type="bool">0</fps_uncap>
<!-- 1000Hz polling thread priority (for enhanced_polling only, might cause crashes on some systems if set too high) <!-- 1000Hz polling thread priority (for enhanced_polling only, might cause crashes on some systems if set too high)
values THREAD_PRIORITY_LOWEST -2 values THREAD_PRIORITY_LOWEST -2
THREAD_PRIORITY_BELOW_NORMAL -1 THREAD_PRIORITY_BELOW_NORMAL -1
@ -135,6 +133,12 @@
THREAD_PRIORITY_TIME_CRITICAL 15 --> THREAD_PRIORITY_TIME_CRITICAL 15 -->
<enhanced_polling_priority __type="s8">1</enhanced_polling_priority> <enhanced_polling_priority __type="s8">1</enhanced_polling_priority>
<!-- Framerate -->
<!-- Disable the builtin frame limiter (faster/smoother animations at 120fps+) -->
<fps_uncap __type="bool">0</fps_uncap>
<!-- Reference fps value for high_framerate animation speed (0: auto) -->
<high_framerate_fps __type="u16">0</high_framerate_fps>
<!-- Song db patches (requires patch_db) --> <!-- Song db patches (requires patch_db) -->
<!-- Auto select patch file from data_mods folder based on music limit, or datecode otherwise (will detect datecode from ea3-config or force_datecode option) --> <!-- Auto select patch file from data_mods folder based on music limit, or datecode otherwise (will detect datecode from ea3-config or force_datecode option) -->
<patch_xml_auto __type="bool">1</patch_xml_auto> <patch_xml_auto __type="bool">1</patch_xml_auto>

View File

@ -66,6 +66,7 @@ struct popnhax_config {
bool exclude_omni; bool exclude_omni;
bool partial_entries; bool partial_entries;
bool high_framerate; bool high_framerate;
uint16_t high_framerate_fps;
}; };
#endif #endif

View File

@ -212,6 +212,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, ignore_music_l
"/popnhax/ignore_music_limit") "/popnhax/ignore_music_limit")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, high_framerate, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, high_framerate,
"/popnhax/high_framerate") "/popnhax/high_framerate")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, high_framerate_fps,
"/popnhax/high_framerate_fps")
PSMAP_END PSMAP_END
enum BufferIndexes { enum BufferIndexes {
@ -7439,32 +7441,39 @@ static bool get_music_limit_from_file(const char *filepath, uint32_t *limit){
return true; return true;
} }
static bool patch_afp_framerate() static bool patch_afp_framerate(uint16_t fps)
{ {
DWORD framerate = fps;
if ( framerate == 0 )
{
DEVMODE lpDevMode; DEVMODE lpDevMode;
memset(&lpDevMode, 0, sizeof(DEVMODE)); memset(&lpDevMode, 0, sizeof(DEVMODE));
lpDevMode.dmSize = sizeof(DEVMODE); lpDevMode.dmSize = sizeof(DEVMODE);
lpDevMode.dmDriverExtra = 0; lpDevMode.dmDriverExtra = 0;
if ( EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &lpDevMode) != 0 ) if ( EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &lpDevMode) == 0 )
{ {
DWORD framerate = lpDevMode.dmDisplayFrequency; LOG("popnhax: high_framerate: could not retrieve display mode\n");
float new_value = 1./framerate; return false;
}
framerate = lpDevMode.dmDisplayFrequency;
} else {
LOG("popnhax: high_framerate: force %ldHz\n", framerate);
}
float new_value = 1./framerate;
char *as_hex = (char*)&new_value; char *as_hex = (char*)&new_value;
if ( !find_and_patch_hex(g_game_dll_fn, "\x82\x9D\x88\x3C", 4, 0, as_hex, 4) ) if ( !find_and_patch_hex(g_game_dll_fn, "\x82\x9D\x88\x3C", 4, 0, as_hex, 4) )
{ {
LOG("popnhax: high_framerate: cannot patch animation speed\n"); LOG("popnhax: high_framerate: cannot patch animation speed for %ldHz\n", framerate);
return false; return false;
} }
LOG("popnhax: high_framerate: patched animation speed for %ldHz\n", framerate); LOG("popnhax: high_framerate: patched animation speed for %ldHz\n", framerate);
return true; return true;
}
LOG("popnhax: high_framerate: could not retrieve display mode\n");
return false;
} }
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) { BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
@ -7848,7 +7857,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
if (config.high_framerate) if (config.high_framerate)
{ {
patch_afp_framerate(); patch_afp_framerate(config.high_framerate_fps);
config.fps_uncap = true; config.fps_uncap = true;
} }