mirror of
https://github.com/CrazyRedMachine/popnhax.git
synced 2024-11-23 22:00:57 +01:00
fix autohispeed
This commit is contained in:
parent
ccf3a4c8f8
commit
2535fba8d6
@ -4311,6 +4311,7 @@ uint16_t *g_base_bpm_ptr = 0; //will point to g_low_bpm or g_hi_bpm according to
|
||||
uint16_t g_low_bpm = 0;
|
||||
uint16_t g_hi_bpm = 0;
|
||||
uint16_t g_longest_bpm = 0;
|
||||
uint16_t g_low_bpm_ebp_offset = 0;
|
||||
unsigned char *g_chart_addr = 0;
|
||||
|
||||
typedef struct chart_chunk_s {
|
||||
@ -4453,9 +4454,14 @@ void hook_read_hispeed()
|
||||
__asm("push ecx\n");
|
||||
__asm("push edx\n");
|
||||
|
||||
__asm("mov %0, word ptr [ebp+0xA1A]\n":"=a"(g_low_bpm): :);
|
||||
__asm("mov %0, word ptr [ebp+0xA1C]\n":"=a"(g_hi_bpm): :);
|
||||
__asm("mov %0, byte ptr [ebp+0xA1E]\n":"=a"(g_mystery_bpm): :);
|
||||
__asm("mov ecx, ebp\n");
|
||||
__asm("add cx, word ptr [%0]\n"::"a"(&g_low_bpm_ebp_offset));
|
||||
|
||||
__asm __volatile__("mov %0, word ptr [ecx]\n":"=a"(g_low_bpm): :);
|
||||
__asm("add cx, 2\n");
|
||||
__asm __volatile__("mov %0, word ptr [ecx]\n":"=a"(g_hi_bpm): :);
|
||||
__asm("add cx, 2\n");
|
||||
__asm __volatile__("mov %0, byte ptr [ecx]\n":"=a"(g_mystery_bpm): :);
|
||||
|
||||
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)
|
||||
{
|
||||
@ -4590,13 +4596,28 @@ bool patch_hispeed_auto(uint8_t mode, uint16_t default_bpm)
|
||||
}
|
||||
/* write new hispeed according to target bpm */
|
||||
{
|
||||
int64_t pattern_offset = search(data, dllSize, "\x98\x50\x66\x8B\x85", 5, 0);
|
||||
/* improve compatibility with newer games */
|
||||
int64_t pattern_offset = search(data, dllSize, "\xEB\x57\x8B\xBC\x24\x50\x01\x00\x00\x66\x8B\x85", 12, 0);
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: auto hi-speed: cannot find chart BPM address offset\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset + 0x1C;
|
||||
g_low_bpm_ebp_offset = *((uint16_t *)(patch_addr));
|
||||
|
||||
if (g_low_bpm_ebp_offset != 0x0A1A && g_low_bpm_ebp_offset != 0x0A1E)
|
||||
{
|
||||
LOG("popnhax: auto hi-speed: WARNING: unexpected BPM address offset (%hu), might not work\n", g_low_bpm_ebp_offset);
|
||||
}
|
||||
|
||||
pattern_offset = search(data, dllSize, "\x98\x50\x66\x8B\x85", 5, 0);
|
||||
if (pattern_offset == -1) {
|
||||
LOG("popnhax: auto hi-speed: cannot find hi-speed apply address\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x07;
|
||||
patch_addr = (int64_t)data + pattern_offset - 0x07;
|
||||
|
||||
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)hook_read_hispeed,
|
||||
(void **)&real_read_hispeed);
|
||||
|
Loading…
Reference in New Issue
Block a user