Skip to content
Permalink
Browse files

cpu: workaround for GTE + interrupt CPU bug

  • Loading branch information
JaCzekanski committed Sep 1, 2019
1 parent bc8f2df commit b2edcf5b061ae90899bc7aaaf9c6311623da24b6
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/cpu/instructions.cpp
@@ -163,6 +163,18 @@ std::array<PrimaryInstruction, 64> SpecialTable = {{

void exception(CPU *cpu, COP0::CAUSE::Exception cause) {
using Exception = COP0::CAUSE::Exception;

// Hardware quirk:
// If COP2 opcode is executed when interrupt occures
// COP0 set EPC to the same opcode causing it to execute twice
// HACK: Delay interrupts if current opcode is GTE command
if (cause == Exception::interrupt) {
Opcode i(cpu->sys->readMemory32(cpu->exceptionPC));
if ((i.opcode & 0xfe000000) == 0x4a000000) { // COP2 opcode
return;
}
}

cpu->cop0.cause.clearForException();
cpu->cop0.cause.exception = cause;

0 comments on commit b2edcf5

Please sign in to comment.
You can’t perform that action at this time.