Skip to content

Commit 70e427a

Browse files
committed
EnableLevelSelect: add hook to allow SHIFT/LS to enable bunki option
Bunki option only shows for the ending levels
1 parent 712240d commit 70e427a

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

src/hooks_misc.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -778,6 +778,19 @@ GameDefaultConfigOverride GameDefaultConfigOverride::instance;
778778

779779
class EnableLevelSelect : public Hook
780780
{
781+
inline static SafetyHookMid midhook = {};
782+
static void destination(SafetyHookContext& ctx)
783+
{
784+
// Game checked SwitchNow(0x10) which checks for X/horn press
785+
// but because of how we force level-select to show, that will display sumo sign-in screen instead...
786+
// we'll add an extra SwitchNow(0x100) check here to check for LS press as well
787+
788+
if (Game::SwitchNow(0x100))
789+
ctx.eax = 1;
790+
if (GetAsyncKeyState(VK_SHIFT))
791+
ctx.eax = 1;
792+
}
793+
781794
public:
782795
std::string_view description() override
783796
{
@@ -793,9 +806,11 @@ class EnableLevelSelect : public Hook
793806
{
794807
// Change the param for "GetMenuForId" call from 0 to 0x1B
795808
constexpr int SumoFrontEnd__eventStep1_GetMenuForIdCall_Param = 0x45756 + 1;
809+
constexpr int SumoLevelSelect__update_SwitchNowResult_Addr = 0xE7838;
796810
Memory::VP::Patch(Module::exe_ptr(SumoFrontEnd__eventStep1_GetMenuForIdCall_Param), uint8_t(0x1B));
797811

798-
return true;
812+
midhook = safetyhook::create_mid(Module::exe_ptr(SumoLevelSelect__update_SwitchNowResult_Addr), destination);
813+
return !!midhook;
799814
}
800815

801816
static EnableLevelSelect instance;

0 commit comments

Comments
 (0)