Skip to content

Commit

Permalink
Changed DebugWindowFont to a toggle option
Browse files Browse the repository at this point in the history
(because other fonts are not practical for displaying debug ouput)
Minor edits/simplification to ASM code in DebugEditor.cpp.
  • Loading branch information
NovaRain committed May 14, 2024
1 parent 39dbe4f commit bc05a00
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 22 deletions.
14 changes: 7 additions & 7 deletions artifacts/ddraw.ini
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ ActionPointsBar=0

;Set to 1 to use the expanded barter/trade interface with 4 item slots per table instead of 3
;Requires the hi-res patch/mode and new BARTER_E.frm and TRADE_E.frm files in art\intrface\ (included in sfall.dat)
;The resolution of the hi-res patch must be set to at least 640x528
;The screen resolution must be set to at least 640x528
;The only supported version of the hi-res patch is v4.1.8
ExpandBarter=0

Expand All @@ -127,7 +127,7 @@ ExpandInventory=0
;Set to 2 to skip correcting the position of entrance markers on town maps
;You can use resized FRMs in 700x682 for town maps in the expanded world map interface
;Requires the hi-res patch/mode and a new WORLDMAP.frm file in art\intrface\ (included in sfall.dat)
;The resolution of the hi-res patch must be set to at least 890x720
;The screen resolution must be set to at least 890x720
ExpandWorldMap=0

;Set to 1 to draw a dotted line while traveling on the world map (similar to Fallout 1)
Expand Down Expand Up @@ -698,7 +698,7 @@ NumbersInDialogue=0
;Set to 1 to use Fallout's normal text font instead of DOS-like font on the world map
WorldMapFontPatch=0

;Set to 1 to use Fallout's normal text font for death screen subtitles
;Set to 1 to use Fallout's normal text font instead of DOS-like font for death screen subtitles
;Requires changing the color of subtitles in death.pal palette to white color (index 220) to display the text correctly
DeathScreenFontPatch=0

Expand Down Expand Up @@ -873,13 +873,13 @@ SkipCompatModeCheck=0
;-------
DebugMode=0

;Font to use in internal debug window (DebugMode 1 or 3): 0 to use default DOS font, 101 is a smaller Fallout font
;Changes the font used for debug output in the internal debug window (DebugMode 1 or 3)
;Set to 1 to use Fallout's normal text font instead of DOS-like font
DebugWindowFont=0

;Width of internal debug window in range [300, 1920]
;Changes the width of the internal debug window (valid range: 300..1920; default is 300)
DebugWindowWidth=300

;Internal debug window height in range [192, 1080]
;Changes the height of the internal debug window (valid range: 192..1080; default is 192)
DebugWindowHeight=192

;Set to 1 to hide error messages in debug output when a null value is passed to the function as an object
Expand Down
29 changes: 14 additions & 15 deletions sfall/Modules/DebugEditor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -440,12 +440,10 @@ static long debugWndFont = 0;
// Before something is printed in the window: remembers current font, replace it with debugWndFont.
static void __declspec(naked) win_debug_text_height_hook() {
__asm {
pushadc;
call fo::funcoffs::text_curr_;
mov debugWndFontOld, eax;
mov eax, debugWndFont;
mov debugWndFontOld, eax;
mov eax, debugWndFont;
call fo::funcoffs::text_font_;
popadc;
call dword ptr ds:[FO_VAR_text_height];
retn;
}
Expand All @@ -454,23 +452,22 @@ static void __declspec(naked) win_debug_text_height_hook() {
// After something is printed in the window: restores current font.
static void __declspec(naked) win_debug_win_draw_hook() {
__asm {
pushadc;
mov eax, debugWndFontOld;
push eax; // winID
mov eax, debugWndFontOld;
call fo::funcoffs::text_font_;
popadc;
jmp fo::funcoffs::win_draw_;
pop eax;
jmp fo::funcoffs::win_draw_;
}
}


static long debugWndWidth;
constexpr DWORD win_debug_pitch_calc_hack__back = 0x4DC542;
static void __declspec(naked) win_debug_pitch_calc_hack() {
static const DWORD win_debug_pitch_calc_hack_back = 0x4DC542;
__asm {
mov eax, debugWndWidth;
mul esi;
mov ebp, eax;
jmp win_debug_pitch_calc_hack__back;
mov eax, debugWndWidth;
imul esi;
mov ebp, eax;
jmp win_debug_pitch_calc_hack_back;
}
}

Expand Down Expand Up @@ -514,7 +511,9 @@ static void DebugModePatch() {
MakeCall(0x4DC32C, win_debug_text_height_hook, 1);
HookCall(0x4DC649, win_debug_win_draw_hook);

debugWndFont = IniReader::GetIntDefaultConfig("Debugging", "DebugWindowFont", 0);
if (IniReader::GetIntDefaultConfig("Debugging", "DebugWindowFont", 0)) {
debugWndFont = 101;
}

constexpr int defaultWidth = 300;
long wdWidth = clamp(IniReader::GetIntDefaultConfig("Debugging", "DebugWindowWidth", defaultWidth), defaultWidth, 1920);
Expand Down

0 comments on commit bc05a00

Please sign in to comment.