Moved DeathScreenFontPatch code to Interface.cpp

Added a note about DeathScreenFontPatch in ddraw.ini.

Some code edits in BugFixes.cpp and DamageMod.cpp.
This commit is contained in:
NovaRain
2020-08-21 12:36:41 +08:00
parent dfb7779e87
commit aa132d9951
5 changed files with 70 additions and 73 deletions
+1
View File
@@ -698,6 +698,7 @@ NumbersInDialogue=0
WorldMapFontPatch=0
;Set to 1 to use Fallout's normal text font for death screen subtitles
;Requires changing the color of subtitles in death.pal palette (color index 220) to display the text correctly
DeathScreenFontPatch=0
;Set to 1 to keep the selected attack mode when moving the weapon between active item slots
+19 -19
View File
@@ -1172,21 +1172,6 @@ static void __declspec(naked) action_explode_hack1() {
}
}
static void __declspec(naked) barter_attempt_transaction_hack() {
__asm {
cmp dword ptr [eax + protoId], PID_ACTIVE_GEIGER_COUNTER
je found
cmp dword ptr [eax + protoId], PID_ACTIVE_STEALTH_BOY
je found
mov eax, 0x474D34
jmp eax
found:
call fo::funcoffs::item_m_turn_off_
mov eax, 0x474D17
jmp eax // Is there any other activated items among the ones being sold?
}
}
static void __declspec(naked) barter_attempt_transaction_hook_weight() {
__asm {
call fo::funcoffs::item_total_weight_;
@@ -1198,10 +1183,25 @@ skip:
}
}
static void __declspec(naked) barter_attempt_transaction_hack() {
__asm {
mov edx, [eax + protoId];
cmp edx, PID_ACTIVE_GEIGER_COUNTER;
je found;
cmp edx, PID_ACTIVE_STEALTH_BOY;
je found;
mov eax, 0x474D34; // Can't sell
jmp eax;
found:
push 0x474D17; // Is there any other activated items among the ones being sold?
jmp fo::funcoffs::item_m_turn_off_;
}
}
static void __declspec(naked) item_m_turn_off_hook() {
__asm {
and byte ptr [eax+0x25], 0xDF // Rest flag of used items
jmp fo::funcoffs::queue_remove_this_
and byte ptr [eax + 0x25], ~0x20; // Unset flag of used items
jmp fo::funcoffs::queue_remove_this_;
}
}
@@ -3089,8 +3089,8 @@ void BugFixes::init()
// Fix for being unable to sell used geiger counters or stealth boys
if (GetConfigInt("Misc", "CanSellUsedGeiger", 1)) {
dlog("Applying fix for being unable to sell used geiger counters or stealth boys.", DL_INIT);
SafeWriteBatch<BYTE>(0xBA, {0x478115, 0x478138}); // mov eax, 1 > mov edx, 1
MakeJump(0x474D22, barter_attempt_transaction_hack);
SafeWriteBatch<BYTE>(0xBA, {0x478115, 0x478138}); // item_queued_ (will return the found item)
MakeJump(0x474D22, barter_attempt_transaction_hack, 1);
HookCall(0x4798B1, item_m_turn_off_hook);
dlogr(" Done", DL_INIT);
}
+30 -35
View File
@@ -282,26 +282,26 @@ void DamageMod::DamageYAAM(fo::ComputeAttackResult &ctd, DWORD &accumulatedDamag
}
////////////////////////////////////////////////////////////////////////////////
// Display melee damage w/o perk bonus
static __declspec(naked) void MeleeDmgDisplayPrintFix_hook() {
__asm {
mov ecx, eax; // Store pointer to critter
call fo::funcoffs::stat_level_; // Get Melee Damage
mov ecx, eax; // Store value
xchg ecx, eax; // Store Melee Damage value
mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage
mov eax, dword ptr ds:[FO_VAR_obj_dude]; // Get pointer to PC
call fo::funcoffs::perk_level_; // Get rank of Bonus HtH Damage
shl eax, 1; // Multiply by 2
push eax;
sub ecx, eax; // Subtract from Melee Damage
mov edx, STAT_melee_dmg;
mov eax, dword ptr ds:[FO_VAR_obj_dude];
call fo::funcoffs::stat_get_base_;
pop edx;
sub ecx, edx; // Subtract from Melee Damage
cmp ecx, eax;
mov eax, ds:[FO_VAR_obj_dude]; // Get pointer to PC
call fo::funcoffs::stat_get_base_; // Get Melee Damage w/o bonuses
cmp ecx, eax; // HtH Damage vs Base Melee Damage
cmovg eax, ecx; // Move back to eax in preparation of push
retn;
}
}
// Display max melee damage w/o perk bonus
static __declspec(naked) void CommonDmgRngDispFix_hook() {
__asm {
mov ebx, eax; // Store pointer to critter
@@ -310,13 +310,11 @@ static __declspec(naked) void CommonDmgRngDispFix_hook() {
mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage
call fo::funcoffs::perk_level_; // Get rank of Bonus HtH Damage
shl eax, 1; // Multiply by 2
push eax;
sub ebx, eax; // Subtract from Melee Damage
mov edx, STAT_melee_dmg;
mov eax, dword ptr ds:[FO_VAR_obj_dude];
call fo::funcoffs::stat_get_base_;
pop edx;
sub ebx, edx; // Subtract from Melee Damage
cmp ebx, eax;
mov eax, ds:[FO_VAR_stack];
call fo::funcoffs::stat_get_base_; // Get Melee Damage w/o bonuses
cmp ebx, eax; // HtH Damage vs Base Melee Damage
cmovg eax, ebx; // Move back to eax in preparation of push
retn;
}
@@ -324,16 +322,16 @@ static __declspec(naked) void CommonDmgRngDispFix_hook() {
static __declspec(naked) void HtHDamageFix1a_hack() {
__asm {
xor edx, edx;
cmp ecx, dword ptr ds:[FO_VAR_obj_dude]; // Is the critter == PC?
jnz skip; // Skip if no
je fix; // Skip if no
mov edx, 1; // Min_Damage = 1
retn;
fix:
mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage
mov eax, ecx; // pointer to PC
call fo::funcoffs::perk_level_; // Return Rank_of_Bonus_HtH_Damage_perk
shl eax, 1; // Rank_of_Bonus_HtH_Damage_perk *= 2
mov edx, eax; // Min_Damage = Rank_of_Bonus_HtH_Damage_perk
skip:
add edx, 1; // Min_Damage += 1
lea edx, [eax + 1]; // Min_Damage = 1 + Rank_of_Bonus_HtH_Damage_perk
retn;
}
}
@@ -342,7 +340,9 @@ static __declspec(naked) void HtHDamageFix1b_hook() {
__asm {
call fo::funcoffs::stat_level_; // Get Total_Melee_Damage
cmp ecx, dword ptr ds:[FO_VAR_obj_dude]; // Is the critter == PC?
jnz end; // Skip to exit if no
je fix; // Skip to exit if no
retn;
fix:
push eax;
mov edx, PERK_bonus_hth_damage; // perk_level_ argument: PERK_bonus_hth_damage
mov eax, ecx; // pointer to PC
@@ -350,7 +350,6 @@ static __declspec(naked) void HtHDamageFix1b_hook() {
shl eax, 1; // Rank_of_Bonus_HtH_Damage_perk *= 2
add dword ptr [esp + 0x24 - 0x20 + 8], eax; // Min_Damage += Rank_of_Bonus_HtH_Damage_perk
pop eax;
end:
retn;
}
}
@@ -360,7 +359,7 @@ static void __declspec(naked) DisplayBonusRangedDmg_hook() {
mov edx, PERK_bonus_ranged_damage;
mov eax, dword ptr ds:[FO_VAR_stack];
call fo::funcoffs::perk_level_;
shl eax, 1;
shl eax, 1; // Multiply by 2
add dword ptr [esp + 4 * 4], eax; // min_dmg + perk bonus
add dword ptr [esp + 4 * 5], eax; // max_dmg + perk bonus
jmp fo::funcoffs::sprintf_;
@@ -372,14 +371,14 @@ static void __declspec(naked) DisplayBonusHtHDmg1_hook() {
mov edx, PERK_bonus_hth_damage;
mov eax, dword ptr ds:[FO_VAR_stack];
call fo::funcoffs::perk_level_;
shl eax, 1;
shl eax, 1; // Multiply by 2
add dword ptr [esp + 4 * 4], eax; // min_dmg + perk bonus
jmp fo::funcoffs::sprintf_;
}
}
static void __declspec(naked) DisplayBonusHtHDmg2_hack() {
static const DWORD DisplayBonusHtHDmg2Exit = 0x472569;
static const DWORD DisplayBonusHtHDmg2Exit = 0x47254E;
__asm {
mov ecx, eax;
call fo::funcoffs::stat_level_;
@@ -388,16 +387,8 @@ static void __declspec(naked) DisplayBonusHtHDmg2_hack() {
mov edx, PERK_bonus_hth_damage;
mov eax, ecx;
call fo::funcoffs::perk_level_;
shl eax, 1;
add eax, 1;
push eax; // min dmg + bonus
mov ecx, dword ptr [esp + 0x98 + 0x4];
push ecx; // message
push 0x509EDC; // '%s %d-%d'
lea eax, [esp + 0x0C + 0x4];
push eax; // buf
call fo::funcoffs::sprintf_;
add esp, 0x10 + 0x4;
shl eax, 1; // Multiply by 2
inc eax; // min dmg (1 + bonus)
jmp DisplayBonusHtHDmg2Exit;
}
}
@@ -421,7 +412,7 @@ void DamageMod::init() {
int DisplayBonusDmg = GetConfigInt("Misc", "DisplayBonusDamage", 0);
if (BonusHtHDmgFix) {
dlog("Applying Bonus HtH Damage Perk fix.", DL_INIT);
if (!DisplayBonusDmg) { // Subtract damage from perk bonus (vanilla displaying)
if (DisplayBonusDmg == 0) { // Subtract damage from perk bonus (vanilla displaying)
HookCalls(MeleeDmgDisplayPrintFix_hook, {
0x435C0C, // DisplayFix (ListDrvdStats_)
0x439921 // PrintFix (Save_as_ASCII_)
@@ -442,6 +433,10 @@ void DamageMod::init() {
if (BonusHtHDmgFix) {
HookCall(0x472309, DisplayBonusHtHDmg1_hook); // display_stats_
MakeJump(0x472546, DisplayBonusHtHDmg2_hack); // display_stats_
SafeWrite32(0x472558, 0x509EDC); // fmt: '%s %d-%d'
SafeWrite8(0x472552, 0x98 + 4);
SafeWrite8(0x47255F, 0x0C + 4);
SafeWrite8(0x472568, 0x10 + 4);
}
dlogr(" Done", DL_INIT);
}
+20
View File
@@ -718,6 +718,14 @@ static void __declspec(naked) wmInterfaceRefreshCarFuel_hack() {
}
}
static void __declspec(naked) main_death_scene_hook() {
__asm {
mov eax, 101;
call fo::funcoffs::text_font_;
jmp fo::funcoffs::debug_printf_;
}
}
static void WorldMapInterfacePatch() {
BlockCall(0x4C2380); // Remove disabling palette animations (can be used as a place to call a hack function in wmInterfaceInit_)
@@ -885,6 +893,18 @@ void Interface::init() {
if (hrpVersionValid) IFACE_BAR_MODE = *(BYTE*)HRPAddress(0x1006EB0C) != 0;
HookCall(0x44C018, gmouse_handle_event_hook); // replaces hack function from HRP
};
// Set the normal font for death screen subtitles
if (GetConfigInt("Misc", "DeathScreenFontPatch", 0)) {
dlog("Applying death screen font patch.", DL_INIT);
HookCall(0x4812DF, main_death_scene_hook);
dlogr(" Done", DL_INIT);
}
// Corrects the height of the black background for death screen subtitles
if (hrpIsEnabled == false) SafeWrite32(0x48134D, -602 - (640 * 2)); // main_death_scene_ (shift y-offset 2px up, w/o HRP)
if (hrpIsEnabled == false || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_
if (hrpVersionValid) SafeWrite8(HRPAddress(0x10011738), 10);
}
void Interface::exit() {
-19
View File
@@ -361,14 +361,6 @@ static void __declspec(naked) map_check_state_hook() {
}
}
static void __declspec(naked) main_death_scene_hook() {
__asm {
mov eax, 101;
call fo::funcoffs::text_font_;
jmp fo::funcoffs::debug_printf_;
}
}
static void AdditionalWeaponAnimsPatch() {
if (GetConfigInt("Misc", "AdditionalWeaponAnims", 0)) {
dlog("Applying additional weapon animations patch.", DL_INIT);
@@ -812,17 +804,6 @@ void MiscPatches::init() {
HookCall(0x48A954, obj_move_to_tile_hook);
HookCall(0x483726, map_check_state_hook);
// Set the normal font for death screen subtitles
if (GetConfigInt("Misc", "DeathScreenFontPatch", 0)) {
dlog("Applying death screen font patch.", DL_INIT);
HookCall(0x4812DF, main_death_scene_hook);
dlogr(" Done", DL_INIT);
}
// Corrects the height of the black background for death screen subtitles
if (hrpIsEnabled == false) SafeWrite32(0x48134D, -602 - (640 * 2)); // main_death_scene_ (shift y-offset 2px up, w/o HRP)
if (hrpIsEnabled == false || hrpVersionValid) SafeWrite8(0x481345, 4); // main_death_scene_
if (hrpVersionValid) SafeWrite8(HRPAddress(0x10011738), 10);
F1EngineBehaviorPatch();
DialogueFix();
AdditionalWeaponAnimsPatch();