Skip to content

Instantly share code, notes, and snippets.

@daeken
Last active December 31, 2015 02:49
Show Gist options
  • Save daeken/7923691 to your computer and use it in GitHub Desktop.
Save daeken/7923691 to your computer and use it in GitHub Desktop.
#define debugreg(reg) printf(#reg ": %08x\n", psxRegs.GPR.n.reg)
// interpreter execution
static inline void execI() {
u32 *code = Read_ICache(psxRegs.pc, FALSE);
if(code != NULL && SWAP32(*code) == 0xDEADBEEF) {
printf("===== DEBUG =====\n");
printf("pc: %08x\n", psxRegs.pc);
debugreg(r0);
debugreg(at);
debugreg(v0); debugreg(v1);
debugreg(a0); debugreg(a1); debugreg(a2); debugreg(a3);
debugreg(t0); debugreg(t1); debugreg(t2); debugreg(t3);
debugreg(t4); debugreg(t5); debugreg(t6); debugreg(t7);
debugreg(s0); debugreg(s1); debugreg(s2); debugreg(s3);
debugreg(s4); debugreg(s5); debugreg(s6); debugreg(s7);
debugreg(t8); debugreg(t9);
debugreg(k0); debugreg(k1);
debugreg(gp);
debugreg(sp);
debugreg(s8);
debugreg(ra);
debugreg(lo); debugreg(hi);
printf("\n");
psxRegs.pc += 4;
return;
} else if(code != NULL && SWAP32(*code) == 0xDEADBEEE) {
printf("DEBUG: ");
psxRegs.pc += 4;
char buf[256];
int i = 0;
while(psxMemRead8(psxRegs.pc) != 0) {
if(i < 255)
buf[i++] = psxMemRead8(psxRegs.pc++);
}
buf[i++] = 0;
psxRegs.pc++;
printf(buf, psxRegs.GPR.n.t0, psxRegs.GPR.n.t1, psxRegs.GPR.n.t2, psxRegs.GPR.n.t3);
putchar('\n');
if(psxRegs.pc & 3)
while(++psxRegs.pc & 3);
return;
}
psxRegs.code = ((code == NULL) ? 0 : SWAP32(*code));
debugI();
if (Config.Debug) ProcessDebug();
psxRegs.pc += 4;
psxRegs.cycle += BIAS;
psxBSC[psxRegs.code >> 26]();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment