int shift = (source[i] >> 19) & 1;
int lm = (source[i] >> 10) & 1;
switch(c2op) {
+#ifndef DRC_DBG
case GTE_MVMVA: {
int v = (source[i] >> 15) & 3;
int cv = (source[i] >> 13) & 3;
c2op_prologue(c2op,reglist);
c2op_call_rgb_func(shift?gteGPL_part_shift:gteGPL_part_noshift,lm,need_ir,need_flags);
break;
-
+#endif
default:
c2op_prologue(c2op,reglist);
- //emit_movimm(source[i],1); // opcode
- //emit_writeword(1,(int)&psxRegs.code);
+#ifdef DRC_DBG
+ emit_movimm(source[i],1); // opcode
+ emit_writeword(1,(int)&psxRegs.code);
+#endif
emit_call((int)(need_flags?gte_handlers[c2op]:gte_handlers_nf[c2op]));
break;
}
static psxRegisters oldregs;
static u32 old_io_addr = (u32)-1;
static u32 old_io_data = 0xbad0c0de;
+ static u32 event_cycles_o[PSXINT_COUNT];
u32 *allregs_p = (void *)&psxRegs;
u32 *allregs_o = (void *)&oldregs;
u32 io_data;
int i;
u8 byte;
-//last_io_addr = 0x5e2c8;
+ //last_io_addr = 0x5e2c8;
if (f == NULL)
f = fopen("tracelog", "wb");
+ // log reg changes
oldregs.code = psxRegs.code; // don't care
for (i = 0; i < offsetof(psxRegisters, intCycle) / 4; i++) {
if (allregs_p[i] != allregs_o[i]) {
allregs_o[i] = allregs_p[i];
}
}
+ // log event changes
+ for (i = 0; i < PSXINT_COUNT; i++) {
+ if (event_cycles[i] != event_cycles_o[i]) {
+ byte = 0xfc;
+ fwrite(&byte, 1, 1, f);
+ fwrite(&i, 1, 1, f);
+ fwrite(&event_cycles[i], 1, 4, f);
+ event_cycles_o[i] = event_cycles[i];
+ }
+ }
+ // log last io
if (old_io_addr != last_io_addr) {
byte = 0xfd;
fwrite(&byte, 1, 1, f);
u32 *allregs_p = (void *)&psxRegs;
u32 *allregs_e = (void *)&rregs;
static u32 ppc, failcount;
- int i, ret, bad = 0;
+ int i, ret, bad = 0, which_event = -1;
+ u32 ev_cycles = 0;
u8 code;
if (f == NULL)
break;
if (code == 0xff)
break;
- if (code == 0xfd) {
- if ((ret = fread(&mem_addr, 1, 4, f)) <= 0)
- break;
+ switch (code) {
+ case 0xfc:
+ which_event = 0;
+ fread(&which_event, 1, 1, f);
+ fread(&ev_cycles, 1, 4, f);
continue;
- }
- if (code == 0xfe) {
- if ((ret = fread(&mem_val, 1, 4, f)) <= 0)
- break;
+ case 0xfd:
+ fread(&mem_addr, 1, 4, f);
+ continue;
+ case 0xfe:
+ fread(&mem_val, 1, 4, f);
continue;
}
- if ((ret = fread(&allregs_e[code], 1, 4, f)) <= 0)
- break;
+ fread(&allregs_e[code], 1, 4, f);
}
if (ret <= 0) {
psxRegs.cycle = rregs.cycle;
psxRegs.CP0.r[9] = rregs.CP0.r[9]; // Count
-//if (psxRegs.cycle == 166172) breakme();
+ //if (psxRegs.cycle == 166172) breakme();
if (memcmp(&psxRegs, &rregs, offsetof(psxRegisters, intCycle)) == 0 &&
mem_val == memcheck_read(mem_addr)
goto end;
}
+ if (which_event >= 0 && event_cycles[which_event] != ev_cycles) {
+ printf("bad ev_cycles #%d: %08x %08x\n", which_event, event_cycles[which_event], ev_cycles);
+ goto end;
+ }
+
if (psxRegs.pc == rregs.pc && bad < 6 && failcount < 32) {
static int last_mcycle;
if (last_mcycle != psxRegs.cycle >> 20) {