From 64dc30d92249815d5c33d4747e9d230f134b2bec Mon Sep 17 00:00:00 2001 From: NovaRain Date: Sun, 26 Feb 2023 23:29:17 +0800 Subject: [PATCH] Removed CreditsAtBottom from ddraw.ini * sfall built-in credits will be shown at the beginning when from the main menu and at the end during the ending. --- artifacts/ddraw.ini | 3 -- artifacts/scripting/sfall function notes.md | 4 +- sfall/Modules/Credits.cpp | 45 ++++++++++++++------- 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index 83d7d0f0..c03c86d2 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -696,9 +696,6 @@ SkipLoadingGameSettings=0 ;The formula for the duration in ticks is: 10 * (value - 3 * EN) KnockoutTime=35 -;Set to 1 to display sfall built-in credits at the bottom of credits.txt contents instead of at the top -CreditsAtBottom=0 - ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX ; Critical modding options - the following options should be changed with caution ;XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX diff --git a/artifacts/scripting/sfall function notes.md b/artifacts/scripting/sfall function notes.md index cbb2ecec..9f73d140 100644 --- a/artifacts/scripting/sfall function notes.md +++ b/artifacts/scripting/sfall function notes.md @@ -983,7 +983,7 @@ sfall_funcX metarule functions `int sfall_func2("get_stat_min", int stat, bool who)`\ `int sfall_func2("get_stat_max", int stat, bool who)` - Returns the maximum or minimum set value of the specified stat (see `set_stat_min` and `set_stat_max` functions) -- `who`: 0 (false) or omitting the argument - returns the value of the player, 1 (true) - returns the value set for other critters +- `who`: 0 (False) or omitting the argument - returns the value of the player, 1 (True) - returns the value set for other critters ---- #### interface_art_draw @@ -1061,7 +1061,7 @@ sfall_funcX metarule functions ---- #### obj_is_openable `bool sfall_func1("obj_is_openable", object obj)` -- Returns True if the object is openable (i.e. has an opening/closing animation) +- Returns True if the object is openable (i.e. has an opening/closing animation), False otherwise **** diff --git a/sfall/Modules/Credits.cpp b/sfall/Modules/Credits.cpp index a719ee3f..03210fbd 100644 --- a/sfall/Modules/Credits.cpp +++ b/sfall/Modules/Credits.cpp @@ -27,7 +27,7 @@ namespace sfall { -static DWORD InCredits = 0; +static bool InCredits = false; static DWORD CreditsLine = 0; static const char* ExtraLines[] = { @@ -84,15 +84,6 @@ static const char* ExtraLines[] = { static DWORD ExtraLineCount = sizeof(ExtraLines) / 4; //static const char* creditsFile = "credits.txt"; -static void __declspec(naked) ShowCreditsHook() { - InCredits = 1; - CreditsLine = 0; - //__asm mov eax, creditsFile; - __asm call fo::funcoffs::credits_; - InCredits = 0; - __asm retn; -} - static DWORD __fastcall CreditsNextLine(char* buf, DWORD* font, DWORD* colour) { if (!InCredits || CreditsLine >= ExtraLineCount) return 0; const char* line = ExtraLines[CreditsLine++]; @@ -159,13 +150,37 @@ morelines: } } -void Credits::init() { - HookCalls(ShowCreditsHook, {0x480C49, 0x43F881}); - if (IniReader::GetConfigInt("Misc", "CreditsAtBottom", 0)) { - HookCall(0x42CB49, CreditsNextLineHook_Bottom); +static void __stdcall SetCreditsPosition(DWORD addr) { + void* func; + if (addr == (0x43F881 + 5)) { // called from endgame_movie_ + func = CreditsNextLineHook_Bottom; } else { - HookCall(0x42CB49, CreditsNextLineHook_Top); + func = CreditsNextLineHook_Top; + } + HookCall(0x42CB49, func); +} + +static void __declspec(naked) ShowCreditsHook() { + __asm { + push eax; + push edx; + push ebx; + push [esp + 12]; // return address + call SetCreditsPosition; + pop ebx; + pop edx; + pop eax; + mov InCredits, 1; + mov CreditsLine, 0; + //mov eax, creditsFile; + call fo::funcoffs::credits_; + mov InCredits, 0; + retn; } } +void Credits::init() { + HookCalls(ShowCreditsHook, {0x480C49, 0x43F881}); +} + }