sh2: handle some branch exceptions
[picodrive.git] / cpu / sh2 / mame / sh2pico.c
index a3ad9f4..174d469 100644 (file)
@@ -122,6 +122,18 @@ int sh2_execute_interpreter(SH2 *sh2, int cycles)
                {
                        sh2->ppc = sh2->delay;
                        opcode = RW(sh2, sh2->delay);
+
+                       // TODO: more branch types
+                       if ((opcode >> 13) == 5) { // BRA/BSR
+                               sh2->r[15] -= 4;
+                               WL(sh2, sh2->r[15], sh2->sr);
+                               sh2->r[15] -= 4;
+                               WL(sh2, sh2->r[15], sh2->pc);
+                               sh2->pc = RL(sh2, sh2->vbr + 6 * 4);
+                               sh2->icount -= 5;
+                               opcode = 9; // NOP
+                       }
+
                        sh2->pc -= 2;
                }
                else