Reduce the code size of division by zero a bit

This commit is contained in:
Jeffrey Pfau 2014-07-05 13:55:36 -07:00
parent 2fd9ab1197
commit ae12dd907c
1 changed files with 5 additions and 22 deletions

View File

@ -108,28 +108,11 @@ static void _Div(struct ARMCore* cpu, int32_t num, int32_t denom) {
cpu->gprs[1] = result.rem;
cpu->gprs[3] = abs(result.quot);
} else {
switch (num) {
case 0:
cpu->gprs[0] = 1;
cpu->gprs[1] = 0;
// If abs(num) > 1, this should hang, but that would be painful to
// emulate in HLE, and no game will get into a state where it hangs...
cpu->gprs[0] = (num < 0) ? -1 : 1;
cpu->gprs[1] = num;
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;
}
}
}