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>
<!-- Adjust pop-kun and beam brightness (won't affect long popkuns) -->
<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)
values THREAD_PRIORITY_LOWEST -2
THREAD_PRIORITY_BELOW_NORMAL -1
@ -135,6 +133,12 @@
THREAD_PRIORITY_TIME_CRITICAL 15 -->
<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) -->
<!-- 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>

View File

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

View File

@ -212,6 +212,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, ignore_music_l
"/popnhax/ignore_music_limit")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, high_framerate,
"/popnhax/high_framerate")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, high_framerate_fps,
"/popnhax/high_framerate_fps")
PSMAP_END
enum BufferIndexes {
@ -7439,32 +7441,39 @@ static bool get_music_limit_from_file(const char *filepath, uint32_t *limit){
return true;
}
static bool patch_afp_framerate()
static bool patch_afp_framerate(uint16_t fps)
{
DEVMODE lpDevMode;
memset(&lpDevMode, 0, sizeof(DEVMODE));
lpDevMode.dmSize = sizeof(DEVMODE);
lpDevMode.dmDriverExtra = 0;
DWORD framerate = fps;
if ( EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &lpDevMode) != 0 )
if ( framerate == 0 )
{
DWORD framerate = lpDevMode.dmDisplayFrequency;
float new_value = 1./framerate;
DEVMODE lpDevMode;
memset(&lpDevMode, 0, sizeof(DEVMODE));
lpDevMode.dmSize = sizeof(DEVMODE);
lpDevMode.dmDriverExtra = 0;
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 ( EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &lpDevMode) == 0 )
{
LOG("popnhax: high_framerate: cannot patch animation speed\n");
LOG("popnhax: high_framerate: could not retrieve display mode\n");
return false;
}
LOG("popnhax: high_framerate: patched animation speed for %ldHz\n", framerate);
return true;
framerate = lpDevMode.dmDisplayFrequency;
} else {
LOG("popnhax: high_framerate: force %ldHz\n", framerate);
}
LOG("popnhax: high_framerate: could not retrieve display mode\n");
return false;
float new_value = 1./framerate;
char *as_hex = (char*)&new_value;
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 for %ldHz\n", framerate);
return false;
}
LOG("popnhax: high_framerate: patched animation speed for %ldHz\n", framerate);
return true;
}
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)
{
patch_afp_framerate();
patch_afp_framerate(config.high_framerate_fps);
config.fps_uncap = true;
}