mirror of https://github.com/bsnes-emu/bsnes.git
51 lines
1.0 KiB
C++
51 lines
1.0 KiB
C++
auto V30MZ::instructionDecimalAdjust(bool negate) -> void {
|
|
wait(9);
|
|
uint8 al = r.al;
|
|
if(r.f.h || ((al & 0x0f) > 0x09)) {
|
|
r.al += negate ? -0x06 : 0x06;
|
|
r.f.h = 1;
|
|
}
|
|
if(r.f.c || (al > 0x99)) {
|
|
r.al += negate ? -0x60 : 0x60;
|
|
r.f.c = 1;
|
|
}
|
|
r.f.s = r.al & 0x80;
|
|
r.f.z = r.al == 0;
|
|
r.f.p = parity(r.al);
|
|
}
|
|
|
|
auto V30MZ::instructionAsciiAdjust(bool negate) -> void {
|
|
wait(8);
|
|
if(r.f.h || ((r.al & 0x0f) > 0x09)) {
|
|
r.al += negate ? -0x06 : 0x06;
|
|
r.ah += negate ? -0x01 : 0x01;
|
|
r.f.h = 1;
|
|
r.f.c = 1;
|
|
} else {
|
|
r.f.h = 0;
|
|
r.f.c = 0;
|
|
}
|
|
r.al &= 0x0f;
|
|
}
|
|
|
|
auto V30MZ::instructionAdjustAfterMultiply() -> void {
|
|
wait(16);
|
|
auto imm = fetch();
|
|
if(imm == 0) return interrupt(0);
|
|
r.ah = r.al / imm;
|
|
r.al %= imm;
|
|
r.f.p = parity(r.al);
|
|
r.f.s = r.ax & 0x8000;
|
|
r.f.z = r.ax == 0;
|
|
}
|
|
|
|
auto V30MZ::instructionAdjustAfterDivide() -> void {
|
|
wait(5);
|
|
auto imm = fetch();
|
|
r.al += r.ah * imm;
|
|
r.ah = 0;
|
|
r.f.p = parity(r.al);
|
|
r.f.s = r.ax & 0x8000;
|
|
r.f.z = r.ax == 0;
|
|
}
|