From 9a6022d92348ae5f0987c2f6892ee1fd340214e1 Mon Sep 17 00:00:00 2001 From: NovaRain Date: Thu, 21 Apr 2022 19:53:15 +0800 Subject: [PATCH] Moved FO1 worldmap sfx code to Interface.cpp Removed extra button release sfx for markers on the world map. (to match the exact FO1 behavior) --- sfall/FalloutEngine/FunctionOffsets_def.h | 3 +- sfall/FalloutEngine/Functions_def.h | 2 +- sfall/Modules/Interface.cpp | 34 +++++++++++++ sfall/Modules/MiscPatches.cpp | 61 ----------------------- 4 files changed, 37 insertions(+), 63 deletions(-) diff --git a/sfall/FalloutEngine/FunctionOffsets_def.h b/sfall/FalloutEngine/FunctionOffsets_def.h index ab011c34..d4eb43db 100644 --- a/sfall/FalloutEngine/FunctionOffsets_def.h +++ b/sfall/FalloutEngine/FunctionOffsets_def.h @@ -1562,6 +1562,8 @@ FUNC(gsound_init_, 0x44FC70) FUNC(gsound_internal_background_callback_, 0x451AB0) FUNC(gsound_internal_effect_callback_, 0x451AD0) FUNC(gsound_internal_speech_callback_, 0x451A90) +FUNC(gsound_lrg_butt_press_, 0x451998) +FUNC(gsound_lrg_butt_release_, 0x4519A0) FUNC(gsound_load_sound_, 0x4510DC) FUNC(gsound_load_sound_volume_, 0x45145C) FUNC(gsound_med_butt_press_, 0x451988) @@ -4088,4 +4090,3 @@ FUNC(zcfree_, 0x4E3B84) FUNC(zero_vid_mem_, 0x4CADFC) FUNC(zlibVersion_, 0x4E3B50) FUNC(zupstr_, 0x4EEFF4) - diff --git a/sfall/FalloutEngine/Functions_def.h b/sfall/FalloutEngine/Functions_def.h index e7d9c0db..3d2451fd 100644 --- a/sfall/FalloutEngine/Functions_def.h +++ b/sfall/FalloutEngine/Functions_def.h @@ -191,7 +191,7 @@ WRAP_WATCOM_FUNC0(long, new_obj_id) WRAP_WATCOM_FUNC2(void, obj_bound, fo::GameObject*, object, fo::BoundRect*, boundRect) // Calculates bounding box (rectangle) for a given object WRAP_WATCOM_FUNC1(long, obj_destroy, fo::GameObject*, object) WRAP_WATCOM_FUNC2(long, obj_dist, fo::GameObject*, obj_src, fo::GameObject*, obj_trg) -WRAP_WATCOM_FUNC2(void, obj_drop, fo::GameObject*, dropFrom, fo::GameObject*, objectToDrop) +WRAP_WATCOM_FUNC2(void, obj_drop, fo::GameObject*, source, fo::GameObject*, objectToDrop) WRAP_WATCOM_FUNC2(long, obj_erase_object, fo::GameObject*, object, fo::BoundRect*, boundRect) WRAP_WATCOM_FUNC0(fo::GameObject*, obj_find_first) WRAP_WATCOM_FUNC0(fo::GameObject*, obj_find_next) diff --git a/sfall/Modules/Interface.cpp b/sfall/Modules/Interface.cpp index 20fd21ee..e989a4c3 100644 --- a/sfall/Modules/Interface.cpp +++ b/sfall/Modules/Interface.cpp @@ -800,6 +800,37 @@ static void __declspec(naked) wmInterfaceInit_hook() { } } +static void __declspec(naked) wmWorldMap_hook() { + __asm { + push eax; + mov eax, 0x503E14; // 'ib1p1xx1' + call fo::funcoffs::gsound_play_sfx_file_; + pop eax; + jmp fo::funcoffs::wmPartyInitWalking_; + } +} + +static void __declspec(naked) wmDrawCursorStopped_hack_hotspot() { + __asm { + mov eax, 0x503E34; // 'ib2p1xx1' + call fo::funcoffs::gsound_play_sfx_file_; + mov eax, dword ptr ds:[0x672E90]; // hotspot2_pic + retn; + } +} + +static void __declspec(naked) wmTownMapInit_hack() { + __asm { + mov dword ptr ds:[edi + 0x672DD8], eax; // _wmTownMapButtonId + push eax; + mov edx, fo::funcoffs::gsound_med_butt_press_; + xor ebx, ebx; // no button release sfx + call fo::funcoffs::win_register_button_sound_func_; + pop eax; + retn; + } +} + static void WorldMapInterfacePatch() { if (IniReader::GetConfigInt("Misc", "WorldMapFontPatch", 0)) { dlog("Applying world map font patch.", DL_INIT); @@ -814,6 +845,9 @@ static void WorldMapInterfacePatch() { 0x4C2D4C, // up 0x4C2D8A // down }); + HookCall(0x4C02DA, wmWorldMap_hook); // destination marker + MakeCall(0x4C4257, wmDrawCursorStopped_hack_hotspot); // triangle markers on the world map + MakeCall(0x4C4B94, wmTownMapInit_hack, 1); // triangle markers on the town map // Fix images for up/down buttons SafeWrite32(0x4C2C0A, 199); // index of UPARWOFF.FRM diff --git a/sfall/Modules/MiscPatches.cpp b/sfall/Modules/MiscPatches.cpp index c6c42fb3..bd6ca2ae 100644 --- a/sfall/Modules/MiscPatches.cpp +++ b/sfall/Modules/MiscPatches.cpp @@ -774,66 +774,6 @@ static void UseWalkDistancePatch() { } } -bool wmPressed = false; -void __declspec(naked) clickedWMHotspotSound() { - __asm { - mov eax, 0x503E34 // Ib2p1xx1_1 - call fo::funcoffs::gsound_play_sfx_file_ - mov wmPressed, 1 - mov eax, dword ptr ds : [0x00672E90] - mov edx, 0x4C425C - jmp edx - } -} - -void __declspec(naked) releasedWMHotspotSound() { - __asm { - mov al, wmPressed - cmp al, 1 - jne exit_ - mov eax, 0x503E40 // Ib2lu1x1_1 - call fo::funcoffs::gsound_play_sfx_file_ - mov wmPressed, 0 - exit_: - mov eax, dword ptr ds : [0x00672E88] - mov edx, 0x4C425C - jmp edx - } -} - -void __declspec(naked) moveWMSound() { - __asm { - push eax - mov eax, 0x503E14 - call fo::funcoffs::gsound_play_sfx_file_ - pop eax - call fo::funcoffs::wmPartyInitWalking_ - mov eax, 0x4C02DF - jmp eax - } -} - -static void __declspec(naked) townmapButtonSound() { - __asm { - mov dword ptr ds : [edi + 0x672DD8], eax - mov ebx, 0x451990 // gsound_med_butt_release_ - mov edx, 0x451988 // gsound_med_butt_press_ - call fo::funcoffs::win_register_button_sound_func_ - mov eax, 0x4C4B9A - jmp eax; - } -} - - -// https://github.com/phobos2077/sfall/issues/373 -// See https://www.youtube.com/watch?v=dGZjse7uC_0&t=50m for reference on how it works in FO1. -static void Fallout1WMSoundChanges() { - MakeJump(0x4C02DA, moveWMSound); - MakeJump(0x4C4B94, townmapButtonSound); - MakeJump(0x4C4250, releasedWMHotspotSound); - MakeJump(0x4C4257, clickedWMHotspotSound); -} - static void F1EngineBehaviorPatch() { if (IniReader::GetConfigInt("Misc", "Fallout1Behavior", 0)) { dlog("Applying Fallout 1 engine behavior patch.", DL_INIT); @@ -1087,7 +1027,6 @@ void MiscPatches::init() { if (HRP::Setting::VersionIsValid) SafeWrite8(HRP::Setting::GetAddress(0x10011738), 10); } - Fallout1WMSoundChanges(); F1EngineBehaviorPatch(); DialogueFix(); AdditionalWeaponAnimsPatch();