From 41fd1e349584466c07a4093baff2f9f14b42897f Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 15 Mar 2026 07:55:23 +0800 Subject: [PATCH] Fixed +/- not updating brightness slider when used on the Pref screen (ref. fallout2-ce/fallout2-ce#298) --- sfall/FalloutEngine/VariableOffsets.h | 2 ++ sfall/Modules/Interface.cpp | 39 ++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/sfall/FalloutEngine/VariableOffsets.h b/sfall/FalloutEngine/VariableOffsets.h index 3074f105..f504a06a 100644 --- a/sfall/FalloutEngine/VariableOffsets.h +++ b/sfall/FalloutEngine/VariableOffsets.h @@ -41,6 +41,7 @@ #define FO_VAR_carCurrentArea 0x672E68 #define FO_VAR_carGasAmount 0x672E6C #define FO_VAR_card_old_fid1 0x5709EC +#define FO_VAR_changed 0x6639A8 // used in the Preferences screen #define FO_VAR_character_points 0x518538 #define FO_VAR_cmap 0x51DF34 #define FO_VAR_colorTable 0x6A38D0 @@ -287,6 +288,7 @@ #define FO_VAR_pip_win 0x6644C4 #define FO_VAR_pipboy_message_file 0x664348 #define FO_VAR_pipmesg 0x664338 +#define FO_VAR_prfwin 0x663904 #define FO_VAR_preload_list_index 0x519640 #define FO_VAR_procTableStrs 0x51C758 // table of procId (from define.h) => procName map #define FO_VAR_proto_main_msg_file 0x6647FC diff --git a/sfall/Modules/Interface.cpp b/sfall/Modules/Interface.cpp index e51697b9..2a6d1712 100644 --- a/sfall/Modules/Interface.cpp +++ b/sfall/Modules/Interface.cpp @@ -781,7 +781,7 @@ static void __fastcall wmDetectHotspotHover(long wmMouseX, long wmMouseY) { static __declspec(naked) void wmWorldMap_hack() { __asm { - cmp ds:[FO_VAR_In_WorldMap], 1; // player is moving + cmp dword ptr ds:[FO_VAR_In_WorldMap], 1; // player is moving jne checkHover; mov eax, dword ptr ds:[FO_VAR_wmWorldOffsetY]; // overwritten code retn; @@ -1084,6 +1084,39 @@ skip: } } +static __declspec(naked) void IncDecGamma_hack0() { + __asm { + call GetLoopFlags; + test eax, OPTIONS; + jnz inPref; + mov ebx, 0x3FF00000; // overwritten engine code + retn; +inPref: + pop ebx; + add ebx, 39; // offset to next section (0x492916, 0x4929FA) + jmp ebx; + } +} + +static __declspec(naked) void IncDecGamma_hack1() { + __asm { + call GetLoopFlags; + test eax, OPTIONS; + jnz inPref; + mov eax, ds:[0x6638D4]; // overwritten engine code + retn; +inPref: + mov eax, 17; // Brightness slider + call fo::funcoffs::UpdateThing_; + mov eax, ds:[FO_VAR_prfwin]; + call fo::funcoffs::win_draw_; // redraw the Preferences screen + mov dword ptr ds:[FO_VAR_changed], 1; + pop edx; + add edx, 52; // offset to next section (0x4929BE, 0x492A9E) + jmp edx; + } +} + static __declspec(naked) void display_body_hook() { __asm { mov ebx, [esp + 0x60 - 0x28 + 8]; @@ -1444,6 +1477,10 @@ void Interface::init() { MakeCalls(gdCustomSelect_hack_buttons, {0x44A100, 0x44A151}); MakeCall(0x44A47D, gdCustomSelect_hack_keyretn); + // Fix the +/- keys not updating the brightness slider when used on the Preferences screen + MakeCalls(IncDecGamma_hack0, {0x4928EA, 0x4929CE}); + MakeCalls(IncDecGamma_hack1, {0x492985, 0x492A65}); + LoadGameHook::OnGameInit() += []() { // Needs to be invoked in OnGameInit when screen height is already known and db is initialized. ExpandedBarterPatch();