diff --git a/amxmodx/amxexecn.asm b/amxmodx/amxexecn.asm index 207a7e35..5ce6cc20 100755 --- a/amxmodx/amxexecn.asm +++ b/amxmodx/amxexecn.asm @@ -1473,11 +1473,23 @@ OP_FLOAT_ROUND: mov [ebp], eax fldcw [ebp] ;calculate - push 0 + sub esp,4 fld dword [edi+ecx+4] + test edx,edx + jz .correct + jmp .skip_correct + .correct: + fadd st0 + fadd dword [g_round_nearest] + fistp dword [esp] + pop eax + sar eax,1 + jmp .done + .skip_correct: frndint fistp dword [esp] pop eax + .done: pop edx ;restore bits pop ebp @@ -1593,6 +1605,8 @@ Start_DATA lodb_and DD 0ffh, 0ffffh, 0, 0ffffffffh +g_round_nearest DD 0.5 + GLOBAL g_flags g_flags: DD -1 @@ -1740,10 +1754,10 @@ _amx_opcodelist DD OP_INVALID DD OP_SYSREQ_D DD OP_SYMTAG DD OP_BREAK - DD OP_FLOAT_MUL - DD OP_FLOAT_DIV - DD OP_FLOAT_ADD - DD OP_FLOAT_SUB - DD OP_FLOAT_TO - DD OP_FLOAT_ROUND - DD OP_FLOAT_CMP \ No newline at end of file + DD OP_FLOAT_MUL + DD OP_FLOAT_DIV + DD OP_FLOAT_ADD + DD OP_FLOAT_SUB + DD OP_FLOAT_TO + DD OP_FLOAT_ROUND + DD OP_FLOAT_CMP diff --git a/amxmodx/amxjitsn.asm b/amxmodx/amxjitsn.asm index 15cbbae1..d9844cc2 100755 --- a/amxmodx/amxjitsn.asm +++ b/amxmodx/amxjitsn.asm @@ -1962,11 +1962,23 @@ OP_FLOAT_ROUND: mov [ebp], eax fldcw [ebp] ;calculate - push 0 + sub esp,4 fld dword [esi+4] + test edx,edx + jz .correct + jmp .skip_correct + .correct: + fadd st0 + fadd dword [g_round_nearest] + fistp dword [esp] + pop eax + sar eax,1 + jmp .done + .skip_correct: frndint fistp dword [esp] pop eax + .done: pop edx ;restore bits pop ebp @@ -2422,6 +2434,10 @@ g_flagsjit: DD -1 DD 0 DD 1 + +global g_round_nearest +g_round_nearest: + DD 0.5 global amx_opcodelist_jit, _amx_opcodelist_jit