Compare commits

...

5 Commits

Author SHA1 Message Date
d4f47bf9b4 test enhanced_polling_nb_iter 2023-09-03 18:11:51 +02:00
98ba8de780 test enhanced_polling_nb_iter 2023-09-03 18:10:11 +02:00
5eacda584e wip reoptim 2023-09-03 14:24:35 +02:00
2f9d25df05 wip reoptim 2023-09-03 14:23:51 +02:00
848105eb27 iidx_hard_gauge shortcut 2023-09-03 14:08:32 +02:00
3 changed files with 73 additions and 24 deletions

View File

@ -51,12 +51,9 @@
<hispeed_default_bpm __type="u16">0</hispeed_default_bpm> <hispeed_default_bpm __type="u16">0</hispeed_default_bpm>
<!-- Gauge options --> <!-- Gauge options -->
<!-- Turn hard gauge into survival gauge (1: former COURSE gauge (-3.42%), 2: NORMAL gauge decrease rate (-4.99%), 3: IIDX HARD gauge decrease rate (-9%), 4: HARD gauge decrease rate (-19.94%)) --> <!-- IIDX-like hard gauge (start with full gauge, instant fail if gauge drops to 0) -->
<survival_gauge __type="u8">0</survival_gauge> <!-- Gauge details: increment: +0.1% for each cool/great/good (like spicy gauge), decrement: -9% for each bad, or -4.5% if gauge <=30% ) -->
<!-- Survival gauge has IIDX-like decrease rate adjustment (decrease amount halved when gauge is at 33.3% or less) --> <iidx_hard_gauge __type="bool">0</iidx_hard_gauge>
<survival_iidx __type="bool">0</survival_iidx>
<!-- Set survival gauge increase rate to spicy (+01/+01 instead of +02/+01) -->
<survival_spicy __type="bool">0</survival_spicy>
<!-- Result screen display patches --> <!-- Result screen display patches -->
<!-- Display details on result screen by default (no need to press yellow button) --> <!-- Display details on result screen by default (no need to press yellow button) -->
@ -137,4 +134,12 @@
<!-- Dump applied translations and dll runtime data to help debug translation --> <!-- Dump applied translations and dll runtime data to help debug translation -->
<translation_debug __type="bool">0</translation_debug> <translation_debug __type="bool">0</translation_debug>
<!-- HARD Gauge alteration modes -->
<!-- Turn hard gauge into survival gauge (1: former COURSE gauge (-3.42%), 2: NORMAL gauge decrease rate (-4.99%), 3: IIDX HARD gauge decrease rate (-9%), 4: HARD gauge decrease rate (-19.94%)) -->
<survival_gauge __type="u8">0</survival_gauge>
<!-- Survival gauge has IIDX-like decrease rate adjustment (decrease amount halved when gauge is at 30% or less) -->
<survival_iidx __type="bool">0</survival_iidx>
<!-- Set survival gauge increase rate to spicy (+01/+01 instead of +02/+01) -->
<survival_spicy __type="bool">0</survival_spicy>
</popnhax> </popnhax>

View File

@ -6,9 +6,7 @@
struct popnhax_config { struct popnhax_config {
bool practice_mode; bool practice_mode;
bool hidden_is_offset; bool hidden_is_offset;
uint8_t survival_gauge; bool iidx_hard_gauge;
bool survival_iidx;
bool survival_spicy;
bool show_offset; bool show_offset;
bool show_fast_slow; bool show_fast_slow;
bool show_details; bool show_details;
@ -46,8 +44,12 @@ struct popnhax_config {
uint8_t debounce; uint8_t debounce;
bool enhanced_polling_stats; bool enhanced_polling_stats;
int8_t enhanced_polling_priority; int8_t enhanced_polling_priority;
uint32_t enhanced_polling_nb_iter;
uint8_t hispeed_auto; uint8_t hispeed_auto;
uint16_t hispeed_default_bpm; uint16_t hispeed_default_bpm;
uint8_t survival_gauge;
bool survival_iidx;
bool survival_spicy;
}; };
#endif #endif

View File

@ -90,6 +90,8 @@ struct popnhax_config config = {};
PSMAP_BEGIN(config_psmap, static) PSMAP_BEGIN(config_psmap, static)
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, hidden_is_offset, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, hidden_is_offset,
"/popnhax/hidden_is_offset") "/popnhax/hidden_is_offset")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, iidx_hard_gauge,
"/popnhax/iidx_hard_gauge")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, survival_gauge, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, survival_gauge,
"/popnhax/survival_gauge") "/popnhax/survival_gauge")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, survival_iidx, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, survival_iidx,
@ -164,6 +166,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, translation_de
"/popnhax/translation_debug") "/popnhax/translation_debug")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, enhanced_polling, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, enhanced_polling,
"/popnhax/enhanced_polling") "/popnhax/enhanced_polling")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U32, struct popnhax_config, enhanced_polling_nb_iter,
"/popnhax/enhanced_polling_nb_iter")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, debounce, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, debounce,
"/popnhax/debounce") "/popnhax/debounce")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, enhanced_polling_stats, PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, enhanced_polling_stats,
@ -2200,6 +2204,20 @@ static bool patch_add_to_base_offset(int8_t delta) {
bool g_enhanced_poll_ready = false; bool g_enhanced_poll_ready = false;
int (*usbPadRead)(uint32_t*); int (*usbPadRead)(uint32_t*);
#pragma GCC push_options
#pragma GCC optimize ("O0")
static uint32_t __inline wait_a_little(uint32_t nb_iter)
{
uint32_t j=0;
for (uint32_t i=0; i<nb_iter; i++)
{
j++;
}
return timeGetTime();
}
#pragma GCC pop_options
uint32_t g_poll_rate_avg = 0; uint32_t g_poll_rate_avg = 0;
uint32_t g_last_button_state = 0; uint32_t g_last_button_state = 0;
uint8_t g_debounce = 0; uint8_t g_debounce = 0;
@ -2237,14 +2255,16 @@ static unsigned int __stdcall enhanced_polling_stats_proc(void *ctx)
/* ensure at least 1ms has elapsed between polls /* ensure at least 1ms has elapsed between polls
* (beware of SD cab hardware compatibility) * (beware of SD cab hardware compatibility)
*/ */
curr_poll_time = timeGetTime(); curr_poll_time = timeGetTime();
if (curr_poll_time == prev_poll_time) if (curr_poll_time == prev_poll_time)
{ {
curr_poll_time++; do {
Sleep(1); curr_poll_time = wait_a_little(config.enhanced_polling_nb_iter);
} while (curr_poll_time == prev_poll_time);
prev_poll_time = curr_poll_time; }
prev_poll_time = curr_poll_time;
if (count == 0) if (count == 0)
{ {
count_time = curr_poll_time; count_time = curr_poll_time;
@ -4505,7 +4525,8 @@ bool patch_hard_gauge_survival(uint8_t severity)
} }
} }
LOG("popnhax: hard gauge into survival (decrease rate : %s)\n", severity_str[severity]); if (!config.iidx_hard_gauge)
LOG("popnhax: survival_gauge debug: enabled (decrease rate : %s)\n", severity_str[severity]);
return true; return true;
} }
@ -4530,8 +4551,8 @@ void hook_survival_iidx_apply_gauge()
__asm("cmp ecx, 2\n"); __asm("cmp ecx, 2\n");
__asm("jb skip_iidx_apply_gauge\n"); //skip if gauge is not decreasing __asm("jb skip_iidx_apply_gauge\n"); //skip if gauge is not decreasing
__asm("mov ecx, 3\n"); __asm("mov ecx, 3\n");
__asm("cmp ax, 342\n"); __asm("cmp ax, 308\n");
__asm("jge skip_iidx_apply_gauge\n"); //skip if gauge is above 33.3% __asm("jge skip_iidx_apply_gauge\n"); //skip if gauge is above 30%
__asm("mov ecx, 2\n"); __asm("mov ecx, 2\n");
__asm("skip_iidx_apply_gauge:\n"); __asm("skip_iidx_apply_gauge:\n");
@ -4557,7 +4578,7 @@ bool patch_survival_iidx()
(void **)&real_survival_iidx_prepare_gauge); (void **)&real_survival_iidx_prepare_gauge);
} }
/* switch slot depending on gauge value (get halved value when 33.3% or less) */ /* switch slot depending on gauge value (get halved value when 30% or less) */
{ {
int64_t pattern_offset = search(data, dllSize, "\x66\x83\xF8\x01\x75\x5E\x66\xA1", 8, 0); int64_t pattern_offset = search(data, dllSize, "\x66\x83\xF8\x01\x75\x5E\x66\xA1", 8, 0);
if (pattern_offset == -1) { if (pattern_offset == -1) {
@ -4571,7 +4592,9 @@ bool patch_survival_iidx()
(void **)&real_survival_iidx_apply_gauge); (void **)&real_survival_iidx_apply_gauge);
} }
LOG("popnhax: survival gauge has IIDX-like adjustment\n"); if (!config.iidx_hard_gauge)
LOG("popnhax: survival_gauge debug: IIDX-like <=30%% adjustment\n");
return true; return true;
} }
@ -4584,7 +4607,8 @@ bool patch_survival_spicy()
return false; return false;
} }
LOG("popnhax: survival gauge is SPICY\n"); if (!config.iidx_hard_gauge)
LOG("popnhax: survival_gauge debug: spicy gauge\n");
return true; return true;
} }
@ -4780,16 +4804,34 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
patch_hd_resolution(config.force_hd_resolution); patch_hd_resolution(config.force_hd_resolution);
} }
if (config.iidx_hard_gauge){
if (config.survival_gauge || config.survival_spicy || config.survival_iidx)
{
LOG("popnhax: iidx_hard_gauge cannot be used when other survival options are already set\n");
config.iidx_hard_gauge = false;
}
else
{
config.survival_gauge = 3;
config.survival_spicy = true;
config.survival_iidx = true;
}
}
if (config.survival_gauge) { if (config.survival_gauge) {
patch_hard_gauge_survival(config.survival_gauge); bool res = true;
res &= patch_hard_gauge_survival(config.survival_gauge);
if (config.survival_spicy) { if (config.survival_spicy) {
patch_survival_spicy(); res &= patch_survival_spicy();
} }
if (config.survival_iidx) { if (config.survival_iidx) {
patch_survival_iidx(); res &= patch_survival_iidx();
} }
if (config.iidx_hard_gauge && res)
LOG("popnhax: iidx_hard_gauge: HARD gauge is now IIDX-like\n");
} }
if (config.hidden_is_offset){ if (config.hidden_is_offset){