Compare commits

..

2 Commits

Author SHA1 Message Date
dc987c46ac expose base_offset as an option 2024-01-03 14:38:50 +01:00
4706d117a1 auto hispeed soflan retry 2024-01-03 14:11:34 +01:00
3 changed files with 39 additions and 4 deletions

View File

@ -104,6 +104,8 @@
<disable_multiboot __type="bool">0</disable_multiboot>
<!-- Timing and lanes -->
<!-- Base visual offset (value will be added to the base SD (-60) and base HD (-76) values) -->
<base_offset __type="s8">0</base_offset>
<!-- Automatically play keysounds during songs -->
<disable_keysounds __type="bool">0</disable_keysounds>
<!-- Offset the keysounds by x ms (negative is earlier). With disable_keysounds, becomes an audio offset -->

View File

@ -51,6 +51,7 @@ struct popnhax_config {
uint8_t survival_gauge;
bool survival_iidx;
bool survival_spicy;
int8_t base_offset;
};
#endif

View File

@ -31,7 +31,7 @@
#include "SearchFile.h"
#define PROGRAM_VERSION "1.9c_rc2"
#define PROGRAM_VERSION "1.10.dev"
const char *g_game_dll_fn = NULL;
const char *g_config_fn = NULL;
@ -182,6 +182,8 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, hispeed_auto,
"/popnhax/hispeed_auto")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U16, struct popnhax_config, hispeed_default_bpm,
"/popnhax/hispeed_default_bpm")
PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_S8, struct popnhax_config, base_offset,
"/popnhax/base_offset")
PSMAP_END
enum BufferIndexes {
@ -452,13 +454,13 @@ void hook_read_hispeed()
__asm("add cx, 2\n");
__asm __volatile__("mov %0, byte ptr [ecx]\n":"=a"(g_mystery_bpm): :);
if (g_soflan_retry)
if (g_soflan_retry && ( g_mystery_bpm || g_low_bpm != g_hi_bpm ))
{
g_hispeed = g_soflan_retry_hispeed;
__asm("jmp apply_hispeed\n");
}
if ( g_bypass_hispeed || g_target_bpm == 0 ) //bypass for mystery BPM and soflan songs (to avoid hi-speed being locked since target won't change)
if ( g_bypass_hispeed || g_target_bpm == 0 ) //bypass for mystery BPM and soflan songs once hispeed has been manually changed (to avoid hi-speed being locked since target won't change)
{
__asm("jmp leave_read_hispeed\n");
}
@ -570,6 +572,13 @@ void hook_decrease_hispeed()
real_decrease_hispeed();
}
void (*real_leave_options)();
void retry_soflan_reset()
{
g_soflan_retry = false;
real_leave_options();
}
bool patch_hispeed_auto(uint8_t mode, uint16_t default_bpm)
{
DWORD dllSize = 0;
@ -650,6 +659,25 @@ bool patch_hispeed_auto(uint8_t mode, uint16_t default_bpm)
(void **)&real_decrease_hispeed);
}
/* set g_soflan_retry back to false when leaving options */
{
int64_t first_loc = search(data, dllSize, "\x0A\x00\x00\x83\xC0\x04\xBF\x0C\x00\x00\x00\xE8", 12, 0);
if (first_loc == -1) {
LOG("popnhax: auto hi-speed: cannot retrieve option screen loop function\n");
return false;
}
int64_t pattern_offset = search(data, 1000, "\x33\xC9\x51\x50\x8B", 5, first_loc);
if (pattern_offset == -1) {
LOG("popnhax: auto hi-speed: cannot retrieve option screen leave\n");
return false;
}
uint64_t patch_addr = (int64_t)data + pattern_offset;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)retry_soflan_reset,
(void **)&real_leave_options);
}
/* compute longest bpm for mode 3 */
if (mode == 3)
{
@ -5459,8 +5487,12 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
patch_disable_keysound();
}
if (config.base_offset){
patch_add_to_base_offset(config.base_offset);
}
if (config.keysound_offset){
/* must be called _after_ force_hd_timing */
/* must be called _after_ force_hd_timing and base_offset */
patch_keysound_offset(config.keysound_offset);
}