don't use under-stack space in EnemyDamageSync

This commit is contained in:
Martin Michelsen
2025-10-17 21:08:39 -07:00
parent 46c2260d0f
commit a7f2ecefe5
3 changed files with 28 additions and 111 deletions
@@ -53,12 +53,13 @@ handle_6xE4_start: # (G_6xE4* cmd @ [esp + 4]) -> void
xor edx, edx
cmp ecx, edx
cmovl ecx, edx
mov [esp - 4], ecx
fild st0, dword [esp - 4] # current_hp = static_cast<float>(max<int32_t>(cmd->max_hp - st.total_damage, 0))
push ecx
fild st0, dword [esp] # current_hp = static_cast<float>(max<int32_t>(cmd->max_hp - st.total_damage, 0))
fld st0, dword [ebx + 0x0C]
fmulp st1, st0
fistp dword [esp - 4], st0
mov ecx, dword [esp - 4] # adjusted_hit_amount = static_cast<int16_t>(current_hp * cmd->factor)
fistp dword [esp], st0
mov ecx, dword [esp] # adjusted_hit_amount = static_cast<int16_t>(current_hp * cmd->factor)
add esp, 4
xor edx, edx
inc edx
cmp ecx, edx
@@ -202,11 +203,12 @@ on_add_or_subtract_hp_skip_negate_amount:
# esp is 0x18 down from where it is in caller's context
mov edx, 100
sub edx, [esp + 0x24] # edx = (100 - special_amount)
mov [esp - 4], edx
fild st0, dword [esp - 4] # current_hp_factor = static_cast<float>(100 - special_amount)
fmul st0, dword [esp + 0x50] # *= weapon_reduction_factor
mov dword [esp - 4], 0x42C80000 # 100.0f
fdiv st0, dword [esp - 4]
push edx
fild st0, dword [esp] # current_hp_factor = static_cast<float>(100 - special_amount)
fmul st0, dword [esp + 0x54] # *= weapon_reduction_factor
mov dword [esp], 0x42C80000 # 100.0f
fdiv st0, dword [esp]
add esp, 4
fstp dword [esp + 0x0C], st0 # cmd.factor = ((100 - special_amount) * weapon_reduction_factor) / 100
on_add_or_subtract_hp_not_proportional: