Fixed the modulo operator for negative integers

* this changes the behavior of vanilla modulo operator to use signed
integer division to match how the fixed division operator works.
This commit is contained in:
NovaRain
2024-01-25 10:19:23 +08:00
parent 4f786f3302
commit b8fe8cb4e3
+6 -3
View File
@@ -3305,13 +3305,16 @@ void BugFixes::init() {
SafeWriteBatch<WORD>(0x04DB, { // fild 64bit > fild 32bit
0x46A3A8, 0x46A3F4, // op_mul_
0x46A4E7, 0x46A566, // op_div_
0x46A280, 0x46A2CD, // op_sub_
0x46A280, 0x46A2CD // op_sub_
});
// Fix for vanilla division operator treating negative integers as unsigned
// Fix for vanilla division and modulo operators treating negative integers as unsigned
//if (IniReader::GetConfigInt("Misc", "DivisionOperatorFix", 1)) {
dlogr("Applying division operator fix.", DL_FIX);
SafeWrite32(0x46A51D, 0xFBF79990); // xor edx, edx; div ebx > cdq; idiv ebx
SafeWriteBatch<DWORD>(0x90FBF799, { // xor edx, edx; div ebx > cdq; idiv ebx
0x46A51D, // op_div_
0x46A669 // op_mod_
});
//}
//if (IniReader::GetConfigInt("Misc", "SpecialUnarmedAttacksFix", 1)) {