forked from Popn_Tools/popnhax
high_framerate_limiter
This commit is contained in:
parent
6d3ade4c76
commit
13cba126f2
12
dist/popnhax/popnhax.xml
vendored
12
dist/popnhax/popnhax.xml
vendored
@ -19,7 +19,7 @@
|
|||||||
<local_favorites __type="bool">0</local_favorites>
|
<local_favorites __type="bool">0</local_favorites>
|
||||||
|
|
||||||
<!-- Framerate -->
|
<!-- Framerate -->
|
||||||
<!-- Maximize framerate and fix animation speed for a smoother experience (lower visual latency) -->
|
<!-- Fix animation speed at higher framerate for a smoother experience (lower visual latency) -->
|
||||||
<high_framerate __type="bool">0</high_framerate>
|
<high_framerate __type="bool">0</high_framerate>
|
||||||
|
|
||||||
<!-- Classic patches -->
|
<!-- Classic patches -->
|
||||||
@ -134,10 +134,12 @@
|
|||||||
<enhanced_polling_priority __type="s8">1</enhanced_polling_priority>
|
<enhanced_polling_priority __type="s8">1</enhanced_polling_priority>
|
||||||
|
|
||||||
<!-- Framerate -->
|
<!-- Framerate -->
|
||||||
<!-- Disable the builtin frame limiter (faster/smoother animations at 120fps+) -->
|
<!-- Reference fps value for high_framerate animation speed (0: use monitor refreshrate and disable frame limiter) -->
|
||||||
<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>
|
<high_framerate_fps __type="u16">0</high_framerate_fps>
|
||||||
|
<!-- Tune the builtin frame limiter the closest to high_framerate_fps -->
|
||||||
|
<high_framerate_limiter __type="bool">1</high_framerate_limiter>
|
||||||
|
<!-- Disable the builtin frame limiter -->
|
||||||
|
<fps_uncap __type="bool">0</fps_uncap>
|
||||||
|
|
||||||
<!-- 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) -->
|
||||||
@ -154,7 +156,7 @@
|
|||||||
<!-- Custom category options (requires patch_db) -->
|
<!-- Custom category options (requires patch_db) -->
|
||||||
<!-- Also exclude omnimix (song id < 3000) tracks from version/level (requires custom_exclude_from_level or custom_exclude_from_version) -->
|
<!-- Also exclude omnimix (song id < 3000) tracks from version/level (requires custom_exclude_from_level or custom_exclude_from_version) -->
|
||||||
<exclude_omni __type="bool">0</exclude_omni>
|
<exclude_omni __type="bool">0</exclude_omni>
|
||||||
<!-- New chart added to existing song moves the song to custom folder -->
|
<!-- Any new chart added to an existing song moves the song to the customs folder -->
|
||||||
<partial_entries __type="bool">0</partial_entries>
|
<partial_entries __type="bool">0</partial_entries>
|
||||||
<!-- Minimum songid for a song to be seen as "custom" (e.g. use 4000 for real customs only) -->
|
<!-- Minimum songid for a song to be seen as "custom" (e.g. use 4000 for real customs only) -->
|
||||||
<custom_categ_min_songid __type="u16">0</custom_categ_min_songid>
|
<custom_categ_min_songid __type="u16">0</custom_categ_min_songid>
|
||||||
|
@ -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;
|
||||||
|
bool high_framerate_limiter;
|
||||||
uint16_t high_framerate_fps;
|
uint16_t high_framerate_fps;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
|
|
||||||
#include "SearchFile.h"
|
#include "SearchFile.h"
|
||||||
|
|
||||||
#define PROGRAM_VERSION "1.12.dev.pollfix"
|
#define PROGRAM_VERSION "1.12.dev"
|
||||||
|
|
||||||
const char *g_game_dll_fn = NULL;
|
const char *g_game_dll_fn = NULL;
|
||||||
const char *g_config_fn = NULL;
|
const char *g_config_fn = NULL;
|
||||||
@ -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_BOOL, struct popnhax_config, high_framerate_limiter,
|
||||||
|
"/popnhax/high_framerate_limiter")
|
||||||
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, high_framerate_fps,
|
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, high_framerate_fps,
|
||||||
"/popnhax/high_framerate_fps")
|
"/popnhax/high_framerate_fps")
|
||||||
PSMAP_END
|
PSMAP_END
|
||||||
@ -4429,7 +4431,49 @@ static bool patch_hd_resolution(uint8_t mode) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool patch_fps_uncap() {
|
static bool patch_fps_uncap(uint16_t fps) {
|
||||||
|
|
||||||
|
if (fps != 0)
|
||||||
|
{
|
||||||
|
/* TODO: fix in spicetools and remove this */
|
||||||
|
uint8_t count = 0;
|
||||||
|
while (find_and_patch_hex(NULL, "\x55\x31\xC0\x89\xE5\x57\x8B\x4D\x08\x8D\x79\x04\xC7\x01\x00\x00\x00\x00\x83\xE7\xFC\xC7\x41\x24\x00\x00\x00\x00\x29\xF9\x83\xC1\x28\xC1\xE9\x02\xF3\xAB\x8B\x7D\xFC\xC9\xC3", 43, 0, "\x31\xC0\xC3", 3))
|
||||||
|
{
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count)
|
||||||
|
{
|
||||||
|
LOG("popnhax: frame_limiter: patched %u instance(s) of memset(a1, 0, 40) (bad usbPadReadLast io hook)\n", count);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t ft = (1000 + (fps / 2)) / fps; // rounded 1000/fps
|
||||||
|
int8_t delta = 16-ft;
|
||||||
|
int8_t newval = -1*delta-2;
|
||||||
|
|
||||||
|
/* enforce fps rate */
|
||||||
|
if (!find_and_patch_hex(g_game_dll_fn, "\x7E\x07\xB9\x0C\x00\x00\x00\xEB\x09\x85\xC9", 11, -1, "\xFF", 1))
|
||||||
|
{
|
||||||
|
LOG("popnhax: frame_limiter: cannot patch frame limiter\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (!find_and_patch_hex(g_game_dll_fn, "\x7E\x07\xB9\x0C\x00\x00\x00\xEB\x09\x85\xC9", 11, 2, "\x90\x90\x90\x90\x90", 5))
|
||||||
|
{
|
||||||
|
LOG("popnhax: frame_limiter: cannot patch frame limiter\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* adjust sleep time (original code is "add -2", replace with "add newval") */
|
||||||
|
if (!find_and_patch_hex(g_game_dll_fn, "\x6A\x00\x83\xC1\xFE\x51\xFF", 7, 4, (char *)&newval, 1))
|
||||||
|
{
|
||||||
|
LOG("popnhax: frame_limiter: cannot patch frame limiter\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
LOG("popnhax: fps capped to %u fps (%ums frame time, new val %d)\n", fps, ft, newval);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
if (!find_and_patch_hex(g_game_dll_fn, "\x7E\x07\xB9\x0C\x00\x00\x00\xEB\x09\x85\xC9", 11, 0, "\xEB\x1C", 2))
|
if (!find_and_patch_hex(g_game_dll_fn, "\x7E\x07\xB9\x0C\x00\x00\x00\xEB\x09\x85\xC9", 11, 0, "\xEB\x1C", 2))
|
||||||
{
|
{
|
||||||
LOG("popnhax: fps uncap: cannot find frame limiter\n");
|
LOG("popnhax: fps uncap: cannot find frame limiter\n");
|
||||||
@ -7862,7 +7906,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (config.fps_uncap)
|
if (config.fps_uncap)
|
||||||
patch_fps_uncap();
|
patch_fps_uncap(config.high_framerate_limiter ? config.high_framerate_fps : 0);
|
||||||
|
|
||||||
if (config.enhanced_polling)
|
if (config.enhanced_polling)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user