Skip to content

Commit

Permalink
cpu: workaround for GTE + interrupt CPU bug
Browse files Browse the repository at this point in the history
  • Loading branch information
JaCzekanski committed Sep 1, 2019
1 parent bc8f2df commit b2edcf5
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/cpu/instructions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit b2edcf5

Please sign in to comment.