mirror of https://github.com/mgba-emu/mgba.git
Reduce the code size of division by zero a bit
This commit is contained in:
parent
2fd9ab1197
commit
ae12dd907c
|
@ -108,28 +108,11 @@ static void _Div(struct ARMCore* cpu, int32_t num, int32_t denom) {
|
||||||
cpu->gprs[1] = result.rem;
|
cpu->gprs[1] = result.rem;
|
||||||
cpu->gprs[3] = abs(result.quot);
|
cpu->gprs[3] = abs(result.quot);
|
||||||
} else {
|
} else {
|
||||||
switch (num) {
|
// If abs(num) > 1, this should hang, but that would be painful to
|
||||||
case 0:
|
// emulate in HLE, and no game will get into a state where it hangs...
|
||||||
cpu->gprs[0] = 1;
|
cpu->gprs[0] = (num < 0) ? -1 : 1;
|
||||||
cpu->gprs[1] = 0;
|
cpu->gprs[1] = num;
|
||||||
cpu->gprs[3] = 1;
|
cpu->gprs[3] = 1;
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
cpu->gprs[0] = 1;
|
|
||||||
cpu->gprs[1] = 1;
|
|
||||||
cpu->gprs[3] = 1;
|
|
||||||
break;
|
|
||||||
case -1:
|
|
||||||
cpu->gprs[0] = -1;
|
|
||||||
cpu->gprs[1] = -1;
|
|
||||||
cpu->gprs[3] = 1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
// Technically this should hang, but that would be painful to emulate in HLE
|
|
||||||
cpu->gprs[0] = 0;
|
|
||||||
cpu->gprs[1] = 0;
|
|
||||||
cpu->gprs[3] = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue