Skip to content

Commit daf18f2

Browse files
authored
Merge pull request #159 from nicolasnoble/break
Handle break instructions.
2 parents 001deee + 8909e17 commit daf18f2

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

src/core/ix86/iR3000A.cc

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2362,7 +2362,16 @@ void X86DynaRecCPU::recSYSCALL() {
23622362
m_stopRecompile = true;
23632363
}
23642364

2365-
void X86DynaRecCPU::recBREAK() {}
2365+
void X86DynaRecCPU::recBREAK() {
2366+
gen.MOV32ItoM((uint32_t)&m_psxRegs.pc, (uint32_t)m_pc - 4);
2367+
gen.MOV32ItoR(PCSX::ix86::EBP, 0xffffffff);
2368+
gen.MOV32ItoM((uint32_t)&m_arg2, m_inDelaySlot ? 1 : 0);
2369+
gen.MOV32ItoM((uint32_t)&m_arg1, 0x30);
2370+
gen.MOV32ItoM((uint32_t)&m_functionPtr, 0);
2371+
2372+
m_pcInEBP = true;
2373+
m_stopRecompile = true;
2374+
}
23662375

23672376
void X86DynaRecCPU::recMFHI() {
23682377
// Rd = Hi

src/core/psxinterpreter.cc

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,13 @@ void InterpretedCPU::psxMTLO() { _rLo_ = _rRs_; } // Lo = Rs
524524
* Format: OP *
525525
*********************************************************/
526526
void InterpretedCPU::psxBREAK() {
527-
// Break exception - psx rom doens't handles this
527+
PCSX::g_emulator.m_psxCpu->m_psxRegs.pc -= 4;
528+
PCSX::g_emulator.m_psxCpu->psxException(0x30, m_inDelaySlot);
529+
if (m_inDelaySlot) {
530+
auto &delayedLoad = m_delayedLoadInfo[m_currentDelayedLoad];
531+
if (!delayedLoad.pcActive) abort();
532+
delayedLoad.pcActive = false;
533+
}
528534
}
529535

530536
void InterpretedCPU::psxSYSCALL() {

0 commit comments

Comments
 (0)