From 6a10f43aac440cc9af5e732775e8529c8c6abb96 Mon Sep 17 00:00:00 2001 From: CrazyRedMachine Date: Sat, 25 Feb 2023 13:09:43 +0100 Subject: [PATCH] split hd resolution and hd timing patches --- dist/popnhax/popnhax.xml | 9 ++++-- popnhax/config.h | 3 +- popnhax/dllmain.cc | 69 +++++++++++++++++++++++++--------------- 3 files changed, 51 insertions(+), 30 deletions(-) diff --git a/dist/popnhax/popnhax.xml b/dist/popnhax/popnhax.xml index 52b11d2..4708afa 100644 --- a/dist/popnhax/popnhax.xml +++ b/dist/popnhax/popnhax.xml @@ -6,8 +6,10 @@ 0 0 - - 0 + + 0 + + 0 0 @@ -29,8 +31,9 @@ 1 + - + 0 diff --git a/popnhax/config.h b/popnhax/config.h index dc761d8..71010b0 100644 --- a/popnhax/config.h +++ b/popnhax/config.h @@ -7,7 +7,8 @@ struct popnhax_config { bool hidden_is_offset; bool pfree; bool quick_retire; - uint8_t hd_on_sd; + bool force_hd_timing; + uint8_t force_hd_resolution; bool force_unlocks; bool force_unlock_deco; bool unset_volume; diff --git a/popnhax/dllmain.cc b/popnhax/dllmain.cc index 5e76962..7ce2051 100644 --- a/popnhax/dllmain.cc +++ b/popnhax/dllmain.cc @@ -82,8 +82,10 @@ PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, pfree, "/popnhax/pfree") PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, quick_retire, "/popnhax/quick_retire") -PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, hd_on_sd, - "/popnhax/hd_on_sd") +PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, force_hd_timing, + "/popnhax/force_hd_timing") +PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_U8, struct popnhax_config, force_hd_resolution, + "/popnhax/force_hd_resolution") PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, force_unlocks, "/popnhax/force_unlocks") PSMAP_MEMBER_REQ(PSMAP_PROPERTY_TYPE_BOOL, struct popnhax_config, force_unlock_deco, @@ -1773,39 +1775,50 @@ static bool patch_base_offset(int32_t value) { return res; } - - -static bool patch_hd_on_sd(uint8_t mode) { - if (mode > 2) +static bool patch_hd_timing() { + if (!patch_base_offset(-76)) { - printf("ponhax: HD on SD mode invalid value %d\n",mode); + printf("popnhax: HD timing: cannot set HD offset\n"); return false; } - if (!patch_base_offset(-76)) + printf("popnhax: HD timing forced\n"); + return true; +} + +static bool patch_hd_resolution(uint8_t mode) { + if (mode > 2) { - printf("popnhax: HD on SD: cannot set HD offset\n"); + printf("ponhax: HD resolution invalid value %d\n",mode); return false; } /* set window to 1360*768 */ - if ( mode == 2 ) + if (!patch_hex("\x0F\xB6\xC0\xF7\xD8\x1B\xC0\x25\xD0\x02", 10, -5, "\xB8\x50\x05\x00\x00\xC3\xCC\xCC\xCC", 9) + && !patch_hex("\x84\xc0\x74\x14\x0f\xb6\x05", 7, -5, "\xB8\x50\x05\x00\x00\xC3\xCC\xCC\xCC", 9)) { - if (!patch_hex("\x0F\xB6\xC0\xF7\xD8\x1B\xC0\x25\xD0\x02", 10, -5, "\xB8\x50\x05\x00\x00\xC3\xCC\xCC\xCC", 9) - && !patch_hex("\x84\xc0\x74\x14\x0f\xb6\x05", 7, -5, "\xB8\x50\x05\x00\x00\xC3\xCC\xCC\xCC", 9)) - { - printf("popnhax: HD on SD: cannot find screen width function\n"); - return false; - } - - if (!patch_hex("\x0f\xb6\xc0\xf7\xd8\x1b\xc0\x25\x20\x01", 10, -5, "\xB8\x00\x03\x00\x00\xC3\xCC\xCC\xCC", 9)) - printf("popnhax: HD on SD: cannot find screen height function\n"); - - if (!patch_hex("\x8B\x54\x24\x20\x53\x51\x52\xEB\x0C", 9, -6, "\x90\x90", 2)) - printf("popnhax: HD on SD: cannot find screen aspect ratio function\n"); + printf("popnhax: HD resolution: cannot find screen width function\n"); + return false; } - printf("popnhax: HD on SD mode %d\n",mode); + if (!patch_hex("\x0f\xb6\xc0\xf7\xd8\x1b\xc0\x25\x20\x01", 10, -5, "\xB8\x00\x03\x00\x00\xC3\xCC\xCC\xCC", 9)) + printf("popnhax: HD resolution: cannot find screen height function\n"); + + if (!patch_hex("\x8B\x54\x24\x20\x53\x51\x52\xEB\x0C", 9, -6, "\x90\x90", 2)) + printf("popnhax: HD resolution: cannot find screen aspect ratio function\n"); + + + if ( mode == 1 ) + { + /* move texts (by forcing HD behavior) */ + if (!patch_hex("\x1B\xC9\x83\xE1\x95\x81\xC1\x86", 8, -5, "\xB9\xFF\xFF\xFF\xFF\x90\x90", 7)) + printf("popnhax: HD resolution: cannot move gamecode position\n"); + + if (!patch_hex("\x6a\x01\x6a\x00\x50\x8b\x06\x33\xff", 9, -7, "\xEB", 1)) + printf("popnhax: HD resolution: cannot move credit/network position\n"); + } + + printf("popnhax: HD resolution forced%s\n",(mode==2)?" (centered texts)":""); return true; } @@ -1833,8 +1846,12 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv patch_quick_retire(config.pfree); } - if (config.hd_on_sd) { - patch_hd_on_sd(config.hd_on_sd); + if (config.force_hd_timing) { + patch_hd_timing(); + } + + if (config.force_hd_resolution) { + patch_hd_resolution(config.force_hd_resolution); } if (config.hidden_is_offset){ @@ -1842,7 +1859,7 @@ BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserv } if (config.keysound_offset){ - /* must be called after hd_on_sd */ + /* must be called _after_ force_hd_timing */ patch_keysound_offset(config.keysound_offset); }