Skip to content

Commit 4516bf7

Browse files
committed
Added splash screen fallback to Mash's HRP (4.1.8 only)
Condensed some code in HRP\init.cpp.
1 parent 82567d1 commit 4516bf7

File tree

2 files changed

+75
-16
lines changed

2 files changed

+75
-16
lines changed

sfall/HRP/Init.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -305,25 +305,24 @@ void Setting::init(const char* exeFileName, std::string &cmdline) {
305305
sf::SafeWrite32(0x482E30, FO_VAR_mapEntranceTileNum); // map_load_file_ (_tile_center_tile to _mapEntranceTileNum)
306306

307307
if (SCR_WIDTH != 640 || SCR_HEIGHT != 480) {
308-
// Set the resolution for GNW95_init_mode_ex_
309-
sf::SafeWrite32(0x4CAD6B, SCR_WIDTH); // 640
310-
sf::SafeWrite32(0x4CAD66, SCR_HEIGHT); // 480
308+
// Set the resolution
309+
sf::SafeWriteBatch<DWORD>(SCR_WIDTH, {
310+
0x4CAD6B, // GNW95_init_mode_ex_
311+
// for the overlapping temporary black window when loading/starting the game
312+
0x480D84, // main_load_new_
313+
0x480B04, // gnw_main_
314+
0x47C6E5, 0x47C703 // LoadGame_
315+
});
316+
sf::SafeWriteBatch<DWORD>(SCR_HEIGHT, {
317+
0x4CAD66, // GNW95_init_mode_ex_
318+
// for the overlapping temporary black window when loading/starting the game
319+
0x480D6C, // main_load_new_
320+
0x480AFA, // gnw_main_
321+
0x47C6E0, 0x47C70D // LoadGame_
322+
});
311323
// initWindow_ "Error initializing video mode ..."
312324
sf::SafeWrite32(0x4B9245, (DWORD)&SCR_WIDTH);
313325
sf::SafeWrite32(0x4B923F, (DWORD)&SCR_HEIGHT);
314-
315-
// Set the resolution for the overlapping temporary black window when loading/starting the game
316-
// main_load_new_
317-
sf::SafeWrite32(0x480D6C, SCR_HEIGHT);
318-
sf::SafeWrite32(0x480D84, SCR_WIDTH);
319-
// gnw_main_
320-
sf::SafeWrite32(0x480AFA, SCR_HEIGHT);
321-
sf::SafeWrite32(0x480B04, SCR_WIDTH);
322-
// LoadGame_
323-
sf::SafeWrite32(0x47C6E0, SCR_HEIGHT);
324-
sf::SafeWrite32(0x47C6E5, SCR_WIDTH);
325-
sf::SafeWrite32(0x47C703, SCR_WIDTH);
326-
sf::SafeWrite32(0x47C70D, SCR_HEIGHT);
327326
}
328327
if (sf::isDebug) sf::SafeWrite8(0x480AF6, fo::WinFlags::Hidden); // gnw_main_
329328

sfall/Modules/LoadOrder.cpp

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -585,6 +585,8 @@ __declspec(naked) void LoadOrder::art_get_name_hack() {
585585
}
586586
}
587587

588+
////////////////////////////////////////////////////////////////////////////////
589+
588590
static __declspec(naked) void game_splash_screen_hook() {
589591
__asm {
590592
call fo::funcoffs::db_fopen_;
@@ -610,6 +612,58 @@ static __declspec(naked) void game_splash_screen_hook() {
610612
}
611613
}
612614

615+
static DWORD hrpLoadRIX_func;
616+
static DWORD hrpLoadBMP_func;
617+
618+
static __declspec(naked) void game_splash_screen_hook_rix_HRP() {
619+
static DWORD retAddr;
620+
__asm {
621+
pop retAddr;
622+
call hrpLoadRIX_func;
623+
test al, al
624+
jnz end;
625+
add esp, 24;
626+
mov eax, [esp + 0x114 - 0x108]; // splash value
627+
push eax;
628+
push 0x5023E8; // "art\splash\"
629+
push 0x502404; // "%ssplash%d.rix"
630+
lea edx, [esp + 0x120 - 0x80]; // fullname
631+
push edx;
632+
call fo::funcoffs::sprintf_;
633+
lea eax, [esp + 0x124 - 0x80];
634+
push eax;
635+
push esi; // IMAGE8 data
636+
call hrpLoadRIX_func;
637+
end:
638+
jmp retAddr;
639+
}
640+
}
641+
642+
static __declspec(naked) void game_splash_screen_hook_bmp_HRP() {
643+
static const char* splashFmt = "%ssplash%d.bmp";
644+
static DWORD retAddr;
645+
__asm {
646+
pop retAddr;
647+
call hrpLoadBMP_func;
648+
test al, al
649+
jnz end;
650+
add esp, 24;
651+
mov eax, [esp + 0x114 - 0x108]; // splash value
652+
push eax;
653+
push 0x5023E8; // "art\splash\"
654+
push splashFmt;
655+
lea edx, [esp + 0x120 - 0x80]; // fullname
656+
push edx;
657+
call fo::funcoffs::sprintf_;
658+
lea eax, [esp + 0x124 - 0x80];
659+
push eax;
660+
push esi; // IMAGE8 data
661+
call hrpLoadBMP_func;
662+
end:
663+
jmp retAddr;
664+
}
665+
}
666+
613667
static fo::DbFile* __fastcall LoadFont(const char* font, const char* mode) {
614668
char file[128];
615669
const char* lang;
@@ -711,6 +765,12 @@ void LoadOrder::init() {
711765

712766
// Load splash screens from the default path if not found in the art\<language>\splash\ directory
713767
HookCall(0x44444E, game_splash_screen_hook);
768+
if (HRP::Setting::VersionIsValid) { // for HRP 4.1.8
769+
hrpLoadRIX_func = HRP::Setting::GetAddress(0x1001A530);
770+
hrpLoadBMP_func = HRP::Setting::GetAddress(0x1001A610);
771+
HookCall(HRP::Setting::GetAddress(0x1001B0F6), game_splash_screen_hook_rix_HRP);
772+
HookCall(HRP::Setting::GetAddress(0x1001B0C5), game_splash_screen_hook_bmp_HRP);
773+
}
714774

715775
// Load fonts based on the game language
716776
HookCalls(load_font_hook, {

0 commit comments

Comments
 (0)