Compare commits

..

15 Commits

4 changed files with 77 additions and 311 deletions

View File

@ -99,6 +99,7 @@
<!-- PLEASE USE OFFLINE ONLY -->
<practice_mode __type="bool">0</practice_mode>
<!-- Press 9 on option select screen to go back to song selection (requires quick_retire) -->
<!-- Note: causes issues with sounds on song select -->
<back_to_song_select __type="bool">0</back_to_song_select>

View File

@ -680,31 +680,6 @@ static bool patch_custom_track_format(const char *game_dll_fn) {
return true;
}
void (*real_remove_fake_login)();
void hook_remove_fake_login()
{
//getPlayerDataAddr was just called so eax contains _playerdata_addr
__asm("push ebx\n");
__asm("push ecx\n");
__asm("lea ebx, [eax+0x1A5]\n"); //login status offset
__asm("lea ecx, [eax+0x08]\n"); //friendid offset
__asm("mov ecx, [ecx]\n");
__asm("cmp ecx, 0x61666564\n"); //defa
__asm("jne skip_remove_login\n");
__asm("lea ecx, [eax+0x0C]\n"); //friendid offset
__asm("mov ecx, [ecx]\n");
__asm("cmp ecx, 0x00746C75\n"); //ult
__asm("jne skip_remove_login\n");
//fake login detected, cleanup
__asm("mov dword ptr [ebx], 0x00000000\n");
__asm("skip_remove_login:\n");
__asm("pop ecx\n");
__asm("pop ebx\n");
real_remove_fake_login();
}
static bool patch_favorite_categ(const char *game_dll_fn) {
DWORD dllSize = 0;
@ -747,19 +722,6 @@ static bool patch_favorite_categ(const char *game_dll_fn) {
g_playerdata_ptr_addr = (*(uint32_t *)(data + pattern_offset + 0x25));
}
//and I need to remove the fake "logged in" status on credit end to prevent a crash
{
int64_t pattern_offset = search(data, dllSize, "\x84\xC0\x74\x07\xBB\x01\x00\x00\x00\xEB\x02\x33\xDB", 13, 0);
if (pattern_offset == -1) {
LOG("popnhax: local_favorites: cannot find end of credit check if logged function\n");
return false;
}
uint64_t patch_addr = (int64_t)data + pattern_offset - 0x05;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)hook_remove_fake_login,
(void **)&real_remove_fake_login);
}
//hook result screen to replace 3 functions
{

View File

@ -388,7 +388,6 @@ uint32_t g_hispeed = 0; // multiplier
uint32_t g_soflan_retry_hispeed = 0; //hispeed value that is temporary kept for quick retry on soflan songs
uint32_t g_hispeed_addr = 0;
uint32_t g_target_bpm = 0;
uint32_t g_default_bpm = 0; //used to rearm between credits
uint16_t *g_base_bpm_ptr = 0; //will point to g_low_bpm or g_hi_bpm according to mode
uint16_t g_low_bpm = 0;
uint16_t g_hi_bpm = 0;
@ -489,16 +488,6 @@ void compute_longest_bpm(){
g_longest_bpm = longest_bpm;
}
void (*real_rearm_hispeed)();
void hook_rearm_hispeed()
{
__asm("push eax\n");
__asm("mov eax, %0\n"::"m"(g_default_bpm):);
__asm("mov %0, eax\n":"=m"(g_target_bpm): :);
__asm("pop eax\n");
real_rearm_hispeed();
}
void (*real_set_hispeed)();
void hook_set_hispeed()
{
@ -689,7 +678,7 @@ void retry_soflan_reset()
real_leave_options();
}
bool patch_hispeed_auto(uint8_t mode)
bool patch_hispeed_auto(uint8_t mode, uint16_t default_bpm)
{
DWORD dllSize = 0;
char *data = getDllData(g_game_dll_fn, &dllSize);
@ -700,22 +689,7 @@ bool patch_hispeed_auto(uint8_t mode)
else if (mode == 3)
g_base_bpm_ptr = &g_longest_bpm;
g_target_bpm = g_default_bpm;
/* reset target to default bpm at the end of a credit */
{
int64_t pattern_offset = search(data, dllSize, "\x8B\x10\x8B\xC8\x8B\x42\x28\xFF\xE0\xCC", 10, 0);
if (pattern_offset == -1) {
LOG("WARNING: popnhax: auto hi-speed: cannot find playerdata clean function\n");
return false;
} else {
uint64_t patch_addr = (int64_t)data + pattern_offset;
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)hook_rearm_hispeed,
(void **)&real_rearm_hispeed);
}
}
g_target_bpm = default_bpm;
/* retrieve hi-speed address */
{
int64_t pattern_offset = search(data, dllSize, "\x66\x89\x0C\x07\x0F\xB6\x45\x04", 8, 0);
@ -929,14 +903,11 @@ void quickexit_option_screen_cleanup()
}
}
uint32_t loadnew2dx_func;
uint32_t playgeneralsound_func;
char *g_system2dx_filepath;
uint32_t g_addr_icca;
void (*real_option_screen)();
void quickexit_option_screen()
{
/* r2nk226
/* r2nk226
for record reloading */
if (rec_reload) {
__asm("push eax\n");
@ -981,8 +952,6 @@ reload:
real_option_screen();
}
uint8_t g_srambypass = 0;
void (*real_option_screen_later)();
void backtosongselect_option_screen()
{
@ -1000,60 +969,11 @@ void backtosongselect_option_screen()
g_return_to_song_select = true;
g_return_to_song_select_num9 = true;
/* reload correct .2dx file to get correct generalSounds */
__asm("push eax\n");
__asm("push ecx\n");
__asm("push edx\n");
__asm("push %0\n"::"m"(g_system2dx_filepath));
__asm("call %0\n"::"D"(loadnew2dx_func));
__asm("add esp, 4\n");
/* play exit sound */
__asm("push 0\n");
__asm("push 0x19\n");
__asm("call %0\n"::"D"(playgeneralsound_func));
__asm("add esp, 8\n");
/* set srambypass flag */
__asm("mov %0, 1\n":"=m"(g_srambypass):);
__asm("pop edx\n");
__asm("pop ecx\n");
__asm("pop eax\n");
__asm("exit_back_select:\n");
real_option_screen_later();
}
void (*real_backtosongselect_herewego1)();
void backtosongselect_herewego1()
{
__asm("cmp %0, 1\n"::"m"(g_srambypass));
__asm("jne skip_disable_herewego1\n");
__asm("mov %0, 0\n":"=m"(g_srambypass):);
__asm("xor eax, eax\n");
__asm("skip_disable_herewego1:\n");
real_backtosongselect_herewego1();
}
void (*real_backtosongselect_herewego2)();
void backtosongselect_herewego2()
{
__asm("cmp %0, 1\n"::"m"(g_srambypass));
__asm("jne skip_disable_herewego2\n");
__asm("mov %0, 0\n":"=m"(g_srambypass):);
__asm("xor eax, eax\n");
__asm("skip_disable_herewego2:\n");
real_backtosongselect_herewego2();
}
void (*real_backtosongselect_herewego3)();
void backtosongselect_herewego3()
{
__asm("cmp %0, 1\n"::"m"(g_srambypass));
__asm("jne skip_disable_herewego3\n");
__asm("mov %0, 0\n":"=m"(g_srambypass):);
__asm("xor eax, eax\n");
__asm("skip_disable_herewego3:\n");
real_backtosongselect_herewego3();
}
void (*real_backtosongselect_option_screen_auto_leave)();
void backtosongselect_option_screen_auto_leave()
{
@ -1083,24 +1003,6 @@ void backtosongselect_option_yellow()
g_return_to_song_select = true;
g_return_to_song_select_num9 = true;
/* reload correct .2dx file to get correct generalSounds */
__asm("push eax\n");
__asm("push ecx\n");
__asm("push edx\n");
__asm("push %0\n"::"m"(g_system2dx_filepath));
__asm("call %0\n"::"D"(loadnew2dx_func));
__asm("add esp, 4\n");
/* play exit sound */
__asm("push 0\n");
__asm("push 0x19\n");
__asm("call %0\n"::"D"(playgeneralsound_func));
__asm("add esp, 8\n");
/* set srambypass flag */
__asm("mov %0, 1\n":"=m"(g_srambypass):);
__asm("pop edx\n");
__asm("pop ecx\n");
__asm("pop eax\n");
__asm("exit_back_select_yellow:\n");
real_option_screen_yellow();
}
@ -1197,9 +1099,9 @@ void save_recSPflags() {
recbinArray_writing[1].button = (uint8_t)~recbinArray_writing[0].button;
recbinArray_writing[1].flag = (uint8_t)~recbinArray_writing[0].flag;
uint16_t *button_no = *(uint16_t **)button_addr;
uint16_t *button_no = *(uint16_t **)button_addr;
uint8_t bt00 = *button_no;
uint32_t bt14 = 0;
uint32_t bt14 = 0;
uint32_t bt58 = 0;
uint32_t i = 0;
do
@ -1215,12 +1117,12 @@ void save_recSPflags() {
bt58 |= *button_no << (i*8);
++i;
} while (i < 4);
printf("bt00(%02x) bt14(%08X) bt58(%08X)\n", bt00, bt14, bt58);
recbinArray_writing[1].pad[0] = bt00;
recbinArray_writing[1].timing = bt14;
recbinArray_writing[1].recid = bt58;
recbinArray_writing[1].timing = bt14;
recbinArray_writing[1].recid = bt58;
/* .rec file format
random,timing,gauge,guide_se,speed,(00),(00),bt_0-bt_8
*/
@ -1407,19 +1309,6 @@ void quickexit_result_loop()
}
g_return_to_options = true; //transition screen hook will catch it
/* play sound fx (retry song) */
__asm("push eax\n");
__asm("push ecx\n");
__asm("push edx\n");
__asm("mov eax, 0x1F\n"); //"exit menu" sound fx
__asm("push 0\n");
__asm("call %0\n"::"D"(playsramsound_func));
__asm("add esp, 4\n");
__asm("pop edx\n");
__asm("pop ecx\n");
__asm("pop eax\n");
__asm("jmp call_real_result\n");
__asm("quit_session:\n");
@ -1431,18 +1320,6 @@ void quickexit_result_loop()
__asm("mov ebx, %0\n": :"b"(g_transition_addr));
__asm("mov dword ptr[ebx], 0xFFFFFFFC\n"); //quit session
/* play sound fx (end session) */
__asm("push eax\n");
__asm("push ecx\n");
__asm("push edx\n");
__asm("mov eax, 0x09\n"); //"bring menu" sound fx
__asm("push 0\n");
__asm("call %0\n"::"D"(playsramsound_func));
__asm("add esp, 4\n");
__asm("pop edx\n");
__asm("pop ecx\n");
__asm("pop eax\n");
/* ----------- r2nk226 ----------- */
disp = false; // 8.9 message off
speed = 5;
@ -1903,7 +1780,7 @@ static bool patch_datecode(char *datecode) {
if ( g_datecode_override == NULL )
return false;
}
else
else
g_datecode_override = strdup(datecode);
{
@ -3420,59 +3297,6 @@ static bool patch_quick_retire(bool pfree)
if (config.back_to_song_select)
{
char filepath[64];
if (sprintf(filepath, "/data/sd/system/system%d/system%d.2dx", config.game_version, config.game_version) <= 0){
LOG("popnhax: back to song select: cannot build systemxx.2dx filepath string.\n");
return false;
}
g_system2dx_filepath = strdup(filepath);
if (g_system2dx_filepath == NULL){
LOG("popnhax: back to song select: cannot allocate systemxx.2dx filepath string.\n");
return false;
}
{
// loadnew2dx func
int64_t pattern_offset = search(data, dllSize,
"\x53\x55\x8B\x6C\x24\x0C\x56\x57\x8B\xCD", 10, 0);
if (pattern_offset == -1) {
LOG("popnhax: loadnew2dx_addr was not found.\n");
return false;
}
loadnew2dx_func = (uint32_t)((int64_t)data + pattern_offset);
}
{
// playgeneralsound func
int64_t pattern_offset = search(data, dllSize,
"\x33\xC0\x5B\xC3\xCC\xCC\xCC\xCC\xCC\x55\x8B\xEC\x83\xE4\xF8", 15, 0);
if (pattern_offset == -1) {
LOG("popnhax: playgeneralsound_addr was not found.\n");
return false;
}
playgeneralsound_func = (uint32_t)((int64_t)data + pattern_offset + 9);
}
/* prevent "here we go" sound from playing when going back to song select (3 occurrences) */
{
LPVOID hook[3] = { (LPVOID)backtosongselect_herewego1, (LPVOID)backtosongselect_herewego2, (LPVOID)backtosongselect_herewego3 };
void** real[3] = { (void**)&real_backtosongselect_herewego1, (void**)&real_backtosongselect_herewego2, (void**)&real_backtosongselect_herewego3 };
int64_t pattern_offset = 0;
int i = 0;
do {
pattern_offset = search(data, dllSize-pattern_offset-10, "\x6A\x00\xB8\x17\x00\x00\x00\xE8", 8, pattern_offset+10);
if (pattern_offset == -1) {
LOG("popnhax: cannot find \"here we go\" sound play (occurrence %d).\n",i+1);
} else {
uint64_t patch_addr = (int64_t)data + pattern_offset + 7;
MH_CreateHook((LPVOID)patch_addr, hook[i],real[i]);
i++;
}
} while (i < 3 && pattern_offset != -1);
}
/* go back to song select with numpad 9 on song option screen (before pressing yellow) */
{
int64_t pattern_offset = search(data, dllSize, "\x0A\x00\x00\x83\x78\x34\x00\x75\x3D\xB8", 10, 0); //unilab
@ -4684,7 +4508,7 @@ static bool version_check() {
/* check Part 1: (21-23 , 24-27) */
{
int64_t pattern_offset = search(data, dllSize,
int64_t pattern_offset = search(data, dllSize,
"\x70\x64\x61\x74\x61\x5F\x66\x69\x6C\x65\x6E\x61\x6D\x65", 14, 0); // "pdata_filename"
if (pattern_offset == -1) {
old_db = true;
@ -4742,7 +4566,7 @@ static bool version_check() {
p_version = 7;
}
}
uint32_t *g_chartbase_addr;
g_chartbase_addr = (uint32_t *)((int64_t)data + pre_gchartaddr + shift);
chartbase_addr = *g_chartbase_addr;
@ -4807,14 +4631,14 @@ bool check_recdatafile(uint32_t check_notes) {
uint32_t cg = (check_great << 16) | check_cool;
uint32_t gb = (check_bad << 16) | check_good;
val = recbinArray_loaded[0].judge | (recbinArray_loaded[0].button >> 8) | (recbinArray_loaded[0].flag >> 16) | (recbinArray_loaded[0].pad[0] >> 24);
val = val ^ cg ^ gb ^ 0x672DE ^ recbinArray_loaded[0].timestamp;
#if DEBUG == 1
LOG("popnhax: recbin: cool(%d), great(%d), good(%d), bad(%d)\n",
check_cool, check_great, check_good, check_bad);
LOG("popnhax: recbin:cg is %08X. gb is %08X. val is %08X.\n", cg, gb, val);
uint32_t judge_1 = 0;
uint32_t judge_7 = 0;
uint32_t judge_8 = 0;
@ -4865,7 +4689,7 @@ bool check_recdatafile(uint32_t check_notes) {
LOG("popnhax: recbin: check ok!\n");
#endif
}
return true;
}
@ -4923,7 +4747,7 @@ void recid2str(char* mrecid) {
static bool record_playdata_start() {
const char *filename = NULL;
SearchFile s;
char recid[10];
@ -4970,7 +4794,7 @@ static bool record_playdata_start() {
if (find_recdata) {
char filePath[FILENAME_MAX];
snprintf(filePath, sizeof(filePath), "%s\\rec\\%s", currentDirectory, filename);
recbin = fopen(filePath, "rb");
if (recbin == NULL) {
LOG("popnhax: record: filePath is %s\n", filePath);
@ -4989,7 +4813,7 @@ static bool record_playdata_start() {
LOG("popnhax: record: memory allocation failure.\n");
return false;
}
memset(recbinArray_loaded, 0, size);
fread(recbinArray_loaded, sizeof(struct REC), rec_elements, recbin);
fclose(recbin);
@ -5022,7 +4846,7 @@ static bool record_playdata_start() {
// find_recdata = false
LOG("popnhax: record: matching recmusicid not found.\n");
}
// next step: for recbinArray_writing
if(!recording_memoryset()) {
LOG("popnhax: record: memory allocation failure.\n");
@ -5084,7 +4908,7 @@ void rec_id_check() {
__asm("mov ebp, dword ptr [ebp+0x04]\n");
__asm("cmp word ptr [ebp+0x0C], cx\n");
__asm("jne rec_id_nomatch\n");
// redID matched.
__asm("movzx ecx, byte ptr [ebp+0x04]\n"); // judge
__asm("cmp dword ptr [esp+0x08+0x04], 0x01\n"); // bad_check flag
@ -5097,7 +4921,7 @@ void rec_id_check() {
__asm("jne long_check\n");
__asm("mov ebx, 0x02\n");
__asm("xor ecx, ecx\n");
__asm("long_check:\n");
__asm("mov eax, dword ptr [esi+0x04]\n");
__asm("cmp dword ptr [eax+0x08], 0\n"); // long check
@ -5105,15 +4929,15 @@ void rec_id_check() {
__asm("long_start:\n");
__asm("cmp ecx, 0x07\n"); // bad_check 7 - B
__asm("ja id_match_end\n");
__asm("ja id_match_end\n");
__asm("mov byte ptr [esi+0x60], cl\n"); // save long_judge
__asm("id_match_end:\n");
__asm("cmp cl, 0\n");
__asm("cmp cl, 0\n");
__asm("setne al\n");
__asm("rec_id_nomatch:\n");
__asm("pop ebp\n");
__asm("rec_id_nomatch:\n");
__asm("pop ebp\n");
__asm("pop ecx\n");
}
@ -5165,13 +4989,13 @@ void call_guidese() {
void (*hook_playfirst)();
void play_firststep() {
__asm("push eax\n");
if (g_auto_flag == 0 && p_record) {
if (g_auto_flag == 0 && p_record) {
__asm("push ebp\n");
__asm("push ecx\n");
__asm("push ebx\n");
__asm("mov eax, [%0]\n"::"a"(&recbinArray_loaded));
__asm("mov ebp, eax\n");
__asm("movzx ecx, word ptr [ebp+0x08]\n"); // play_counter
__asm("movzx ecx, word ptr [ebp+0x08]\n"); // play_counter
__asm("cmp edi, 0\n"); // edi = elapsed time
__asm("jne p1_start\n");
__asm("mov word ptr [ebp+0x08], 0\n"); // play_counter reset
@ -5214,7 +5038,7 @@ void play_firststep() {
__asm("movzx ecx, byte ptr [eax+0x04]\n");
__asm("cmp cl, 0x01\n");
__asm("jle countup\n"); // 0.1 -> skip
__asm("cmp cl, 0x0A\n"); // A.B~ -> skip_test
__asm("cmp cl, 0x0A\n"); // A.B~ -> skip_test
__asm("jge countup\n");
__asm("p1_idcheck:\n");
@ -5247,14 +5071,14 @@ void play_secondstep() {
if (p_record) {
__asm("push edi\n");
__asm("cmp ebx, 0x02\n"); // long_end_flag
__asm("jne p2_start\n");
__asm("jne p2_start\n");
//__asm("p2_long_end_flow:\n");
__asm("movzx eax, byte ptr [esi+0x12]\n"); // button
__asm("movzx ecx, byte ptr [esi+0x60]\n"); // saved_judge
__asm("shl ax, 8\n");
__asm("or eax, ecx\n");
__asm("push eax\n"); // send judge
__asm("push eax\n"); // send judge
__asm("call %0\n"::"a"(judge_bar_func));
__asm("add esp, 4\n");
__asm("mov ebx, 0x01\n");
@ -5266,7 +5090,7 @@ void play_secondstep() {
__asm("p2_continue:\n");
__asm("movzx eax, word ptr [eax+0x04]\n"); // judge+button
__asm("push eax\n"); // send judge
__asm("push eax\n"); // send judge
__asm("call %0\n"::"a"(judge_bar_func));
__asm("pop eax\n");
__asm("inc word ptr [edi+0x08]\n"); // play_count
@ -5282,7 +5106,7 @@ void play_secondstep() {
__asm("pop edi\n");
__asm("xor al, al\n");
}
}
}
last_auto_flag_check();
}
@ -5301,7 +5125,7 @@ void play_thirdstep() {
__asm("cmp dword ptr [ebx+0x08], 0\n"); // long check
__asm("mov ebx, 0x01\n");
__asm("jbe id_check\n");
__asm("movzx eax, word ptr [esi+0x18]\n"); // flag
__asm("test al, 0x80\n"); // long_end check
__asm("jne p3_long_end\n");
@ -5312,7 +5136,7 @@ void play_thirdstep() {
__asm("add esp, 4\n");
__asm("cmp ebx, 0x02\n");
__asm("jne p3_return\n");
__asm("inc word ptr [edx+0x08]\n");
__asm("or word ptr [esi+0x18], 2\n");
__asm("mov ebx, dword ptr [edx+0x04]\n");
@ -5333,7 +5157,7 @@ void play_thirdstep() {
__asm("jne p3_end\n");
__asm("inc word ptr [edx+0x08]\n"); // play_counter
__asm("add dword ptr [edx+0x04], 0x10\n");
__asm("p3_end:\n");
__asm("mov eax, ebx\n");
} else if (!p_record) {
@ -5394,7 +5218,7 @@ void record_playdata() {
__asm("mov eax, dword ptr [eax+edi*8+4]\n");
__asm("mov dword ptr [ecx+0x08], eax\n"); // input timing
__asm("test esi, esi\n"); // [esi]=p_note
__asm("jne rec1_recid\n"); //
__asm("jne rec1_recid\n"); //
__asm("mov dword ptr [ecx+0x08], esi\n");
__asm("mov dword ptr [ecx+0x0C], esi\n");
__asm("jmp rec1_countup\n");
@ -5417,7 +5241,7 @@ void record_playdata() {
__asm("rec1_countup:\n");
__asm("inc word ptr [ebp]\n");
__asm("rec1_end:\n");
__asm("pop ebx\n");
__asm("pop ebp\n");
@ -5495,7 +5319,7 @@ bool srandom_set() {
return true;
}
*/
/*
/*
void (*real_noteque_addr)();
void noteque_rewrite() {
if (p_record && s_list != NULL) {
@ -5580,7 +5404,7 @@ void load_recPlayoptions() {
}
g_rechispeed_addr = (uint8_t*)(**player_options_addr +0x2A +option_offset);
*g_rechispeed_addr = recbinArray_loaded[1].judge;
}
bool recdata_save() {
@ -5613,10 +5437,10 @@ bool recdata_save() {
mkdir(folderPath);
LOG("popnhax: make dir. (rec)\n");
}
__asm("mov esi, %0\n"::"S"(recdate));
__asm("call %0\n"::"a"(date_func));
filename = (char*)recid;
char filePath[FILENAME_MAX];
@ -5636,7 +5460,7 @@ bool recdata_save() {
LOG("popnhax: recid =%s\n", recid);
LOG("popnhax: recdate =%s\n", recdate);
#endif
return true;
}
return false;
@ -5645,7 +5469,7 @@ bool recdata_save() {
void prepare_for_play_record() {
stop_recchange = true;
get_recPlayoptions();
if (p_record) {
if (recbinArray_loaded == NULL) {
LOG("popnhax: record: recbin load error. (2)\n");
@ -5729,7 +5553,7 @@ void r_random() {
*g_options_addr = 1;
__asm("push 0\n");
__asm("mov ebx, %0\n"::"b"(*button_addr));
__asm("mov ebx, %0\n"::"b"(*button_addr));
__asm("call %0\n"::"a"(ran_func));
__asm("add esp, 4\n");
@ -5738,7 +5562,7 @@ void r_random() {
v9 = *bt_0; // start No.
// 0:regular 1:mirror 2:random 3:S-random
if (orig_plop == 0) {
if (orig_plop == 0) {
uint32_t bt = *(uint32_t *)button_addr;
uint32_t i = 0;
do
@ -5824,7 +5648,7 @@ void wavheader_rewrite () {
0x2C (2byte) : Compression Code , 0x0002=MS ADPCM
0x2E (2byte) : Number of Channels , 0x0002=stereo
0x30 (4byte) : Sample Rate , 0x0000AC44=44100Hz
0x34 (4byte) : byte/sec
0x34 (4byte) : byte/sec
*/
disp = false;
uint32_t temp = 0;
@ -5846,7 +5670,7 @@ void wavheader_rewrite () {
temp = *(g_2dx_buffer + 0x0D); //0x0D*4=0x34 byte per sec.
temp = (uint32_t)((double)temp*mul);
*(g_2dx_buffer + 0x0D) = temp;
use_sp_flag = true;
}
}
@ -5860,7 +5684,7 @@ void ex_2dx_speed() {
__asm("mov eax, ebp\n");
__asm("mov %0, dword ptr [eax]\n":"=a"(g_2dx_str): :);
__asm("mov %0, edi\n":"=D"(g_2dx_buffer): :);
if(new_speed !=100) {
wavheader_rewrite();
}
@ -5880,8 +5704,8 @@ void chart_rewrite() {
double mul = 0;
double mul_2dx =0;
uint32_t i, size;
struct CHART* chart_temp;
uint32_t i, size;
struct CHART* chart_temp;
size = sizeof(struct CHART) * chart_rows_count;
chart_temp = (struct CHART*)malloc(size);
@ -5898,7 +5722,7 @@ void chart_rewrite() {
mul = (double)(100/((double)new_speed));
mul_2dx = (double)(((double)new_speed)/100);
for (i = 0; i < chart_rows_count; i++) {
for (i = 0; i < chart_rows_count; i++) {
chart_temp[i].timestamp = (uint32_t)((double)chart_temp[i].timestamp*mul);
if (chart_temp[i].duration > 0) {
chart_temp[i].duration = (uint32_t)((double)chart_temp[i].duration*mul);
@ -5914,7 +5738,7 @@ void chart_rewrite() {
LOG("popnhax: BPM change %d -> %d \n", bpm_orig, chart_temp[i].data);
}
}
memcpy((uint32_t*)chartbase_addr, chart_temp, size);
#if DEBUG == 1
@ -5922,11 +5746,11 @@ void chart_rewrite() {
LOG("popnhax: chart_temp_addr is 0x%p\n", chart_temp);
#endif
free(chart_temp);
free(chart_temp);
chart_speed_end:
use_sp_flag = true;
LOG("popnhax: chart speed change done.\n");
LOG("popnhax: chart speed change done.\n");
#if DEBUG == 1
LOG("popnhax: chart mul is %f\n", mul);
@ -6019,7 +5843,7 @@ void r2nk_debug() {
__asm("movzx ecx, %0\n"::"c"(spec));
__asm("cmp ecx, 0x42\n");
__asm("je shift_x\n");
__asm("sub ebp, 0x40\n");
__asm("shift_x:\n");
@ -6372,7 +6196,7 @@ if (use_sp_flag) {
//__asm("mov esi, %0\n"::"a"(*font_color+COLOR_GREEN));
__asm("call %0\n"::"a"(font_rend_func));
__asm("add esp, 0x0C\n");
}
__asm("mov eax, [%0]\n"::"a"(*g_rend_addr));
__asm("mov dword ptr [eax], 2\n");
@ -6409,7 +6233,7 @@ static bool patch_practice_mode()
MH_CreateHook((LPVOID)patch_addr, (LPVOID)new_menu,
(void **)&real_aging_loop);
#if DEBUG == 1
LOG("popnhax: practice_mode: aging_hook addr is 0x%llX\n", patch_addr);
#endif
@ -6457,7 +6281,7 @@ static bool patch_practice_mode()
}
uint64_t patch_addr = (int64_t)data + pattern_offset +0x10;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)ex_2dx_speed,
(void **)&real_2dx_addr);
@ -6475,7 +6299,7 @@ static bool patch_practice_mode()
}
uint64_t patch_addr = (int64_t)data + pattern_offset;
MH_CreateHook((LPVOID)patch_addr, (LPVOID)ex_chart_speed,
(void **)&real_chart_addr);
@ -6611,7 +6435,7 @@ static bool patch_record_mode(bool quickretire)
}
uint64_t patch_addr = (int64_t)data + pattern_offset;
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)hook_musicselect,
(void **)&real_musicselect);
}
@ -6638,7 +6462,7 @@ static bool patch_record_mode(bool quickretire)
LOG("popnhax: noteque_func_addr was not found.\n");
return false;
}
uint64_t patch_addr = (int64_t)data + pattern_offset +3;
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)noteque_rewrite,
@ -6669,7 +6493,7 @@ static bool patch_record_mode(bool quickretire)
}
uint64_t patch_addr = (int64_t)data + pattern_offset -0x14;
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)hook_optionloop_after_pressing_red,
(void **)&real_optionloop_after_pressing_red);
}
@ -6714,7 +6538,7 @@ static bool patch_record_mode(bool quickretire)
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)play_thirdstep,
(void **)&first_auto_flag_check);
// play2_addr (last_auto_flag_check) , p_note
int64_t pattern_offset_p2 = search(data, dllSize,
"\x84\xC0\x74\x53", 4, pattern_offset);
@ -6759,7 +6583,7 @@ static bool patch_record_mode(bool quickretire)
uint32_t *tmp_addr = (uint32_t*)((int64_t)data + pattern_offset -1);
judge_bar_func = (uint32_t)((int64_t)data +pattern_offset + *tmp_addr +3);
uint64_t patch_addr = (int64_t)data + pattern_offset -2;
MH_CreateHook((LPVOID)(patch_addr), (LPVOID)record_playdata,
(void **)&get_judge);
}
@ -6792,7 +6616,7 @@ static bool patch_record_mode(bool quickretire)
// j_win_addr
int64_t pattern_offset = search(data, dllSize,
"\x84\xC0\x74\x18\x8B\x04\xFD", 7, 0);
if (pattern_offset == -1) {
if (pattern_offset == -1) {
LOG("popnhax: j_win_addr was not found.\n");
return false;
}
@ -7557,7 +7381,7 @@ static bool get_music_limit_from_file(const char *filepath, uint32_t *limit){
LPVOID lpBasePtr;
LARGE_INTEGER liFileSize;
hFile = CreateFile(filepath,
hFile = CreateFile(filepath,
GENERIC_READ, // dwDesiredAccess
0, // dwShareMode
NULL, // lpSecurityAttributes
@ -7680,7 +7504,7 @@ static bool patch_afp_framerate(uint16_t fps)
framerate = lpDevMode.dmDisplayFrequency;
} else {
LOG("popnhax: high_framerate: force %ldHz\n", framerate);
LOG("popnhax: high_framerate: force %ldHz\n", framerate);
}
float new_value = 1./framerate;
@ -8095,8 +7919,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv
if (config.hispeed_auto)
{
g_default_bpm = config.hispeed_default_bpm;
patch_hispeed_auto(config.hispeed_auto);
patch_hispeed_auto(config.hispeed_auto, config.hispeed_default_bpm);
}
#if DEBUG == 1

View File

@ -850,29 +850,9 @@ static char *get_subcateg_title(const char* path) {
return categ_name;
}
#define F_OK 0
static bool is_excluded_folder(const char *path)
static bool is_excluded_folder(const char *input_filename)
{
char filename[64];
//try to open "folderpath/_exclude"
size_t len = (size_t)(strchr(path+10, '\\')-(path));
strncpy(filename, path, len);
sprintf(filename+len, "\\_exclude");
if (access(filename, F_OK) == 0)
{
LOG("%s causes folder to be excluded from customs (contents will be treated as regular songs)\n", filename);
return true;
}
if ( path[strlen("data_mods/")] == '_' )
{
filename[strchr(path+10, '\\')-path] = '\0';
LOG("%s starting with _ causes folder to be excluded from customs (contents will be treated as regular songs)\n", filename);
return true;
}
return false;
return (input_filename[strlen("data_mods/")] == '_');
}
void parse_musicdb(const char *input_filename, const char *target, struct popnhax_config *config) {
@ -881,11 +861,9 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha
return;
}
bool excluded = (config->custom_categ && is_excluded_folder(input_filename));
char *subcateg_title = NULL;
subcategory_s *subcateg = NULL;
if (config->custom_categ == 2 && !excluded)
if (config->custom_categ == 2)
{
subcateg_title = get_subcateg_title(input_filename);
subcateg = get_subcateg(subcateg_title); //will return a new one if not found
@ -932,7 +910,7 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha
// Update customs/omni songid list
if ( is_fresh || is_gone || config->partial_entries )
{
if ( idx >= config->custom_categ_min_songid && !excluded && bst_search(g_customs_bst, idx) == NULL )
if ( idx >= config->custom_categ_min_songid && bst_search(g_customs_bst, idx) == NULL )
{
g_customs_bst = bst_insert(g_customs_bst, idx);
//LOG("%d inserted into customs bst\n", idx);
@ -940,6 +918,8 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha
{
add_song_to_subcateg(idx, subcateg);
}
} else {
//LOG("%d already present in customs bst\n", idx);
}
}
@ -999,7 +979,7 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha
if ( config->custom_categ
&& config->custom_exclude_from_version
&& !excluded
&& !is_excluded_folder(input_filename)
&& idx >= config->custom_categ_min_songid
&& ( is_fresh || config->exclude_omni ) )
{
@ -1083,7 +1063,7 @@ void parse_musicdb(const char *input_filename, const char *target, struct popnha
free(config_xml);
if (config->custom_categ == 2 && !excluded)
if (config->custom_categ == 2)
{
free(subcateg_title);
}