mirror of
https://github.com/RaySollium99/picodrive.git
synced 2025-09-05 15:27:46 -04:00
some new cpu debug code
This commit is contained in:
parent
f81107f590
commit
12da51c27a
12 changed files with 224 additions and 54 deletions
|
@ -1 +1 @@
|
|||
Subproject commit 194104e334f7c26015b99c862486a73be0d80162
|
||||
Subproject commit 1f9661c5a2919ba91c0f4b89985e0712871e5762
|
|
@ -19,7 +19,7 @@
|
|||
#define MEMHANDLERS_NEED_CYCLES 1
|
||||
#define MEMHANDLERS_CHANGE_PC 0
|
||||
#define MEMHANDLERS_CHANGE_FLAGS 0
|
||||
#define MEMHANDLERS_CHANGE_CYCLES 0
|
||||
#define MEMHANDLERS_CHANGE_CYCLES 1
|
||||
|
||||
#define MEMHANDLERS_DIRECT_PREFIX "cyclone_"
|
||||
|
||||
|
|
|
@ -136,15 +136,6 @@ void sh2_unpack(SH2 *sh2, const unsigned char *buff)
|
|||
|
||||
static SH2 sh2ref[2];
|
||||
static unsigned int mem_val;
|
||||
static FILE *f;
|
||||
|
||||
enum ctl_byte {
|
||||
CTL_MASTERSLAVE = 0x80,
|
||||
CTL_EA = 0x82,
|
||||
CTL_EAVAL = 0x83,
|
||||
CTL_M68KPC = 0x84,
|
||||
CTL_CYCLES = 0x85,
|
||||
};
|
||||
|
||||
static unsigned int local_read32(SH2 *sh2, u32 a)
|
||||
{
|
||||
|
@ -176,12 +167,6 @@ static unsigned int local_read32(SH2 *sh2, u32 a)
|
|||
return 0;
|
||||
}
|
||||
|
||||
static void write_uint(unsigned char ctl, unsigned int v)
|
||||
{
|
||||
fwrite(&ctl, 1, 1, f);
|
||||
fwrite(&v, sizeof(v), 1, f);
|
||||
}
|
||||
|
||||
void do_sh2_trace(SH2 *current, int cycles)
|
||||
{
|
||||
static int current_slave = -1;
|
||||
|
@ -193,39 +178,36 @@ void do_sh2_trace(SH2 *current, int cycles)
|
|||
u32 val;
|
||||
int i;
|
||||
|
||||
if (f == NULL)
|
||||
f = fopen("tracelog", "wb");
|
||||
|
||||
if (SekPc != current_m68k_pc) {
|
||||
current_m68k_pc = SekPc;
|
||||
write_uint(CTL_M68KPC, current_m68k_pc);
|
||||
tl_write_uint(CTL_M68KPC, current_m68k_pc);
|
||||
}
|
||||
|
||||
if (current->is_slave != current_slave) {
|
||||
current_slave = current->is_slave;
|
||||
v = CTL_MASTERSLAVE | current->is_slave;
|
||||
fwrite(&v, 1, 1, f);
|
||||
tl_write(&v, sizeof(v));
|
||||
}
|
||||
|
||||
for (i = 0; i < offsetof(SH2, read8_map) / 4; i++) {
|
||||
if (i == 17) // ppc
|
||||
continue;
|
||||
if (regs_a[i] != regs_o[i]) {
|
||||
write_uint(i, regs_a[i]);
|
||||
tl_write_uint(CTL_SH2_R + i, regs_a[i]);
|
||||
regs_o[i] = regs_a[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (current->ea != sh2o->ea) {
|
||||
write_uint(CTL_EA, current->ea);
|
||||
tl_write_uint(CTL_EA, current->ea);
|
||||
sh2o->ea = current->ea;
|
||||
}
|
||||
val = local_read32(current, current->ea);
|
||||
if (mem_val != val) {
|
||||
write_uint(CTL_EAVAL, val);
|
||||
tl_write_uint(CTL_EAVAL, val);
|
||||
mem_val = val;
|
||||
}
|
||||
write_uint(CTL_CYCLES, cycles);
|
||||
tl_write_uint(CTL_CYCLES, cycles);
|
||||
}
|
||||
|
||||
static const char *regnames[] = {
|
||||
|
@ -264,17 +246,14 @@ void do_sh2_cmp(SH2 *current)
|
|||
int cycles;
|
||||
int i, ret;
|
||||
|
||||
if (f == NULL) {
|
||||
f = fopen("tracelog", "rb");
|
||||
sh2ref[1].is_slave = 1;
|
||||
}
|
||||
sh2ref[1].is_slave = 1;
|
||||
|
||||
while (1) {
|
||||
ret = fread(&code, 1, 1, f);
|
||||
ret = tl_read(&code, 1);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
if (code == CTL_CYCLES) {
|
||||
fread(&cycles_o, 1, 4, f);
|
||||
tl_read(&cycles_o, 4);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -284,23 +263,27 @@ void do_sh2_cmp(SH2 *current)
|
|||
current_slave = code & 1;
|
||||
break;
|
||||
case CTL_EA:
|
||||
fread(&sh2o->ea, 4, 1, f);
|
||||
tl_read_uint(&sh2o->ea);
|
||||
break;
|
||||
case CTL_EAVAL:
|
||||
fread(¤t_val, 4, 1, f);
|
||||
tl_read_uint(¤t_val);
|
||||
break;
|
||||
case CTL_M68KPC:
|
||||
fread(&val, 4, 1, f);
|
||||
tl_read_uint(&val);
|
||||
if (SekPc != val) {
|
||||
printf("m68k: %08x %08x\n", SekPc, val);
|
||||
bad = 1;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
if (code < offsetof(SH2, read8_map) / 4)
|
||||
fread(regs_o + code, 4, 1, f);
|
||||
else {
|
||||
printf("invalid code: %02x\n", code);
|
||||
if (CTL_SH2_R <= code && code < CTL_SH2_R +
|
||||
offsetof(SH2, read8_map) / 4)
|
||||
{
|
||||
tl_read_uint(regs_o + code - CTL_SH2_R);
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("wrong code: %02x\n", code);
|
||||
goto end;
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue