X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FDebug.c;h=45ba08b336b50cb47dc8af6b3a9de46f12ff70f1;hb=e5fa9817777032758511868c8aaa9ff780786c3f;hp=6962a6aa0104db7c132bca3c005a29efc0cd4fc6;hpb=03e4f2a349247334666c87abe3a908df72d23051;p=picodrive.git diff --git a/Pico/Debug.c b/Pico/Debug.c index 6962a6a..45ba08b 100644 --- a/Pico/Debug.c +++ b/Pico/Debug.c @@ -1,33 +1,35 @@ #include "PicoInt.h" -// note: set SPLIT_MOVEL_PD to 0 - typedef unsigned char u8; static unsigned int pppc, ops=0; extern unsigned int lastread_a, lastread_d[16], lastwrite_cyc_d[16], lastwrite_mus_d[16]; extern int lrp_cyc, lrp_mus, lwp_cyc, lwp_mus; -unsigned int old_regs[16], old_sr, ppop, have_illegal = 0, dbg_irq_level = 0; +unsigned int old_regs[16], old_sr, ppop, have_illegal = 0; +int dbg_irq_level = 0, dbg_irq_level_sub = 0; #undef dprintf #define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) #if defined(EMU_C68K) -#define other_get_sr() CycloneGetSr(&PicoCpuCM68k) -#define other_dar(i) PicoCpuCM68k.d[i] -#define other_osp PicoCpuCM68k.osp -#define other_get_irq() PicoCpuCM68k.irq -#define other_set_irq(irq) PicoCpuCM68k.irq=irq -#define other_is_stopped() (PicoCpuCM68k.state_flags&1) -#define other_is_tracing() ((PicoCpuCM68k.state_flags&2)?1:0) +static struct Cyclone *currentC68k = NULL; +#define other_set_sub(s) currentC68k=(s)?&PicoCpuCS68k:&PicoCpuCM68k; +#define other_get_sr() CycloneGetSr(currentC68k) +#define other_dar(i) currentC68k->d[i] +#define other_osp currentC68k->osp +#define other_get_irq() currentC68k->irq +#define other_set_irq(i) currentC68k->irq=i +#define other_is_stopped() (currentC68k->state_flags&1) +#define other_is_tracing() ((currentC68k->state_flags&2)?1:0) #elif defined(EMU_F68K) -#define other_get_sr() PicoCpuFM68k.sr -#define other_dar(i) ((unsigned int*)PicoCpuFM68k.dreg)[i] -#define other_osp PicoCpuFM68k.asp -#define other_get_irq() PicoCpuFM68k.interrupts[0] -#define other_set_irq(irq) PicoCpuFM68k.interrupts[0]=irq -#define other_is_stopped() ((PicoCpuFM68k.execinfo&FM68K_HALTED)?1:0) -#define other_is_tracing() ((PicoCpuFM68k.execinfo&FM68K_EMULATE_TRACE)?1:0) +#define other_set_sub(s) g_m68kcontext=(s)?&PicoCpuFS68k:&PicoCpuFM68k; +#define other_get_sr() g_m68kcontext->sr +#define other_dar(i) ((unsigned int*)g_m68kcontext->dreg)[i] +#define other_osp g_m68kcontext->asp +#define other_get_irq() g_m68kcontext->interrupts[0] +#define other_set_irq(irq) g_m68kcontext->interrupts[0]=irq +#define other_is_stopped() ((g_m68kcontext->execinfo&FM68K_HALTED)?1:0) +#define other_is_tracing() ((g_m68kcontext->execinfo&FM68K_EMULATE_TRACE)?1:0) #else #error other core missing, don't compile this file #endif @@ -35,16 +37,16 @@ unsigned int old_regs[16], old_sr, ppop, have_illegal = 0, dbg_irq_level = 0; static int otherRun(void) { #if defined(EMU_C68K) - PicoCpuCM68k.cycles=1; - CycloneRun(&PicoCpuCM68k); - return 1-PicoCpuCM68k.cycles; + currentC68k->cycles=1; + CycloneRun(currentC68k); + return 1-currentC68k->cycles; #elif defined(EMU_F68K) - return fm68k_emulate(1); + return fm68k_emulate(1, 0); #endif } //static -void dumpPCandExit() +void dumpPCandExit(int is_sub) { char buff[128]; int i; @@ -56,26 +58,28 @@ void dumpPCandExit() dprintf("d%i=%08x, a%i=%08x | d%i=%08x, a%i=%08x", i, other_dar(i), i, other_dar(i+8), i, old_regs[i], i, old_regs[i+8]); dprintf("SR: %04x | %04x (??s? 0iii 000x nzvc)", other_get_sr(), old_sr); dprintf("last_read: %08x @ %06x", lastread_d[--lrp_cyc&15], lastread_a); - dprintf("ops done: %i", ops); + dprintf("ops done: %i, is_sub: %i", ops, is_sub); exit(1); } -int CM_compareRun(int cyc) +int CM_compareRun(int cyc, int is_sub) { char *str; - int cyc_done=0, cyc_other, cyc_musashi, err=0; - unsigned int i, mu_sr; + int cyc_done=0, cyc_other, cyc_musashi, *irq_level, err=0; + unsigned int i, pc, mu_sr; + m68ki_cpu_p=is_sub?&PicoCpuMS68k:&PicoCpuMM68k; + other_set_sub(is_sub); lrp_cyc = lrp_mus = 0; - while(cyc > cyc_done) + while (cyc_done < cyc) { if (have_illegal && m68k_read_disassembler_16(m68ki_cpu.pc) != 0x4e73) // not rte { have_illegal = 0; m68ki_cpu.pc += 2; #ifdef EMU_C68K - PicoCpuCM68k.pc=PicoCpuCM68k.checkpc(PicoCpuCM68k.pc + 2); + currentC68k->pc=currentC68k->checkpc(currentC68k->pc + 2); #endif } // hacks for test_misc2 @@ -84,10 +88,10 @@ int CM_compareRun(int cyc) // get out of "priviledge violation" loop have_illegal = 1; //m68ki_cpu.s_flag = SFLAG_SET; - //PicoCpuCM68k.srh|=0x20; + //currentC68k->srh|=0x20; } - pppc = SekPc; + pppc = is_sub ? SekPcS68k : SekPc; ppop = m68k_read_disassembler_16(pppc); memcpy(old_regs, &other_dar(0), 4*16); old_sr = other_get_sr(); @@ -98,18 +102,22 @@ int CM_compareRun(int cyc) dprintf("---"); m68k_disassemble(buff, pppc, M68K_CPU_TYPE_68000); dprintf("PC: %06x: %04x: %s", pppc, ppop, buff); - //dprintf("A7: %08x", PicoCpuCM68k.a[7]); + //dprintf("A7: %08x", currentC68k->a[7]); } #endif - if (dbg_irq_level) + irq_level = is_sub ? &dbg_irq_level_sub : &dbg_irq_level; + if (*irq_level) { - other_set_irq(dbg_irq_level); - m68k_set_irq(dbg_irq_level); - dbg_irq_level=0; + other_set_irq(*irq_level); + m68k_set_irq(*irq_level); + *irq_level=0; } cyc_other=otherRun(); + // Musashi takes irq even if it hasn't got cycles left, let othercpu do it too + if (other_get_irq() && other_get_irq() > ((other_get_sr()>>8)&7)) + cyc_other+=otherRun(); cyc_musashi=m68k_execute(1); if (cyc_other != cyc_musashi) { @@ -136,9 +144,10 @@ int CM_compareRun(int cyc) } // compare PC + pc = is_sub ? SekPcS68k : SekPc; m68ki_cpu.pc&=~1; - if ( SekPc != (m68ki_cpu.pc&0xffffff) ) { - dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc&0xffffff); + if (pc != m68ki_cpu.pc) { + dprintf("PC: %06x vs %06x", pc, m68ki_cpu.pc); err=1; } @@ -188,20 +197,20 @@ int CM_compareRun(int cyc) err=1; } - if(err) dumpPCandExit(); + if(err) dumpPCandExit(is_sub); #if 0 - if (PicoCpuCM68k.a[7] < 0x00ff0000 || PicoCpuCM68k.a[7] >= 0x01000000) + if (m68ki_cpu.dar[15] < 0x00ff0000 || m68ki_cpu.dar[15] >= 0x01000000) { - PicoCpuCM68k.a[7] = m68ki_cpu.dar[15] = 0xff8000; + other_dar(15) = m68ki_cpu.dar[15] = 0xff8000; } #endif #if 0 m68k_set_reg(M68K_REG_SR, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); // broken - CycloneSetSr(&PicoCpuCM68k, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); - PicoCpuCM68k.stopped = m68ki_cpu.stopped = 0; - if(SekPc > 0x400 && (PicoCpuCM68k.a[7] < 0xff0000 || PicoCpuCM68k.a[7] > 0xffffff)) - PicoCpuCM68k.a[7] = m68ki_cpu.dar[15] = 0xff8000; + CycloneSetSr(currentC68k, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); + currentC68k->stopped = m68ki_cpu.stopped = 0; + if(SekPc > 0x400 && (currentC68k->a[7] < 0xff0000 || currentC68k->a[7] > 0xffffff)) + currentC68k->a[7] = m68ki_cpu.dar[15] = 0xff8000; #endif cyc_done += cyc_other;