X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=Pico%2FDebug.c;fp=Pico%2F_cyclone_debug.c;h=6962a6aa0104db7c132bca3c005a29efc0cd4fc6;hb=03e4f2a349247334666c87abe3a908df72d23051;hp=854bb74c94a87247b14b5630e1b7c7a15f5b76e2;hpb=80db44425aa5b46185fb9a64520f4b6f5d494ba5;p=picodrive.git diff --git a/Pico/_cyclone_debug.c b/Pico/Debug.c similarity index 52% rename from Pico/_cyclone_debug.c rename to Pico/Debug.c index 854bb74..6962a6a 100644 --- a/Pico/_cyclone_debug.c +++ b/Pico/Debug.c @@ -12,6 +12,37 @@ unsigned int old_regs[16], old_sr, ppop, have_illegal = 0, dbg_irq_level = 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) +#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) +#else +#error other core missing, don't compile this file +#endif + +static int otherRun(void) +{ +#if defined(EMU_C68K) + PicoCpuCM68k.cycles=1; + CycloneRun(&PicoCpuCM68k); + return 1-PicoCpuCM68k.cycles; +#elif defined(EMU_F68K) + return fm68k_emulate(1); +#endif +} + //static void dumpPCandExit() { @@ -22,8 +53,8 @@ void dumpPCandExit() dprintf("PC: %06x: %04x: %s", pppc, ppop, buff); dprintf(" this | prev"); for(i=0; i < 8; i++) - dprintf("d%i=%08x, a%i=%08x | d%i=%08x, a%i=%08x", i, PicoCpuCM68k.d[i], i, PicoCpuCM68k.a[i], i, old_regs[i], i, old_regs[i+8]); - dprintf("SR: %04x | %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpuCM68k), old_sr); + 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); exit(1); @@ -32,7 +63,7 @@ void dumpPCandExit() int CM_compareRun(int cyc) { char *str; - int cyc_done=0, cyc_cyclone, cyc_musashi, err=0; + int cyc_done=0, cyc_other, cyc_musashi, err=0; unsigned int i, mu_sr; lrp_cyc = lrp_mus = 0; @@ -43,7 +74,9 @@ int CM_compareRun(int cyc) { have_illegal = 0; m68ki_cpu.pc += 2; +#ifdef EMU_C68K PicoCpuCM68k.pc=PicoCpuCM68k.checkpc(PicoCpuCM68k.pc + 2); +#endif } // hacks for test_misc2 if (m68ki_cpu.pc == 0x0002e0 && m68k_read_disassembler_16(m68ki_cpu.pc) == 0x4e73) @@ -56,8 +89,8 @@ int CM_compareRun(int cyc) pppc = SekPc; ppop = m68k_read_disassembler_16(pppc); - memcpy(old_regs, PicoCpuCM68k.d, 4*16); - old_sr = CycloneGetSr(&PicoCpuCM68k); + memcpy(old_regs, &other_dar(0), 4*16); + old_sr = other_get_sr(); #if 0 { @@ -71,43 +104,41 @@ int CM_compareRun(int cyc) if (dbg_irq_level) { - PicoCpuCM68k.irq=dbg_irq_level; + other_set_irq(dbg_irq_level); m68k_set_irq(dbg_irq_level); dbg_irq_level=0; } - PicoCpuCM68k.cycles=1; - CycloneRun(&PicoCpuCM68k); - cyc_cyclone=1-PicoCpuCM68k.cycles; + cyc_other=otherRun(); cyc_musashi=m68k_execute(1); - if(cyc_cyclone != cyc_musashi) { - dprintf("cycles: %i vs %i", cyc_cyclone, cyc_musashi); + if (cyc_other != cyc_musashi) { + dprintf("cycles: %i vs %i", cyc_other, cyc_musashi); err=1; } - if(lrp_cyc != lrp_mus) { + if (lrp_cyc != lrp_mus) { dprintf("lrp: %i vs %i", lrp_cyc&15, lrp_mus&15); err=1; } - if(lwp_cyc != lwp_mus) { + if (lwp_cyc != lwp_mus) { dprintf("lwp: %i vs %i", lwp_cyc&15, lwp_mus&15); err=1; } - for(i=0; i < 16; i++) { - if(lastwrite_cyc_d[i] != lastwrite_mus_d[i]) { + for (i=0; i < 16; i++) { + if (lastwrite_cyc_d[i] != lastwrite_mus_d[i]) { dprintf("lastwrite: [%i]= %08x vs %08x", i, lastwrite_cyc_d[i], lastwrite_mus_d[i]); - err=1; + err=1; break; } } // compare PC m68ki_cpu.pc&=~1; - if( SekPc != (m68ki_cpu.pc/*&0xffffff*/) ) { - dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc/*&0xffffff*/); + if ( SekPc != (m68ki_cpu.pc&0xffffff) ) { + dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc&0xffffff); err=1; } @@ -119,41 +150,41 @@ int CM_compareRun(int cyc) #endif // compare regs - for(i=0; i < 16; i++) { - if(PicoCpuCM68k.d[i] != m68ki_cpu.dar[i]) { + for (i=0; i < 16; i++) { + if (other_dar(i) != m68ki_cpu.dar[i]) { str = (i < 8) ? "d" : "a"; - dprintf("reg: %s%i: %08x vs %08x", str, i&7, PicoCpuCM68k.d[i], m68ki_cpu.dar[i]); + dprintf("reg: %s%i: %08x vs %08x", str, i&7, other_dar(i), m68ki_cpu.dar[i]); err=1; } } // SR - if((CycloneGetSr(&PicoCpuCM68k)) != (mu_sr = m68k_get_reg(NULL, M68K_REG_SR))) { - dprintf("SR: %04x vs %04x (??s? 0iii 000x nzvc)", CycloneGetSr(&PicoCpuCM68k), mu_sr); + if (other_get_sr() != (mu_sr = m68k_get_reg(NULL, M68K_REG_SR))) { + dprintf("SR: %04x vs %04x (??s? 0iii 000x nzvc)", other_get_sr(), mu_sr); err=1; } // IRQl - if(PicoCpuCM68k.irq != (m68ki_cpu.int_level>>8)) { - dprintf("IRQ: %i vs %i", PicoCpuCM68k.irq, (m68ki_cpu.int_level>>8)); + if (other_get_irq() != (m68ki_cpu.int_level>>8)) { + dprintf("IRQ: %i vs %i", other_get_irq(), (m68ki_cpu.int_level>>8)); err=1; } // OSP/USP - if(PicoCpuCM68k.osp != m68ki_cpu.sp[((mu_sr>>11)&4)^4]) { - dprintf("OSP: %06x vs %06x", PicoCpuCM68k.osp, m68ki_cpu.sp[((mu_sr>>11)&4)^4]); + if (other_osp != m68ki_cpu.sp[((mu_sr>>11)&4)^4]) { + dprintf("OSP: %06x vs %06x", other_osp, m68ki_cpu.sp[((mu_sr>>11)&4)^4]); err=1; } // stopped - if(((PicoCpuCM68k.state_flags&1) && !m68ki_cpu.stopped) || (!(PicoCpuCM68k.state_flags&1) && m68ki_cpu.stopped)) { - dprintf("stopped: %i vs %i", PicoCpuCM68k.state_flags&1, m68ki_cpu.stopped); + if ((other_is_stopped() && !m68ki_cpu.stopped) || (!other_is_stopped() && m68ki_cpu.stopped)) { + dprintf("stopped: %i vs %i", other_is_stopped(), m68ki_cpu.stopped); err=1; } // tracing - if(((PicoCpuCM68k.state_flags&2) && !m68ki_tracing) || (!(PicoCpuCM68k.state_flags&2) && m68ki_tracing)) { - dprintf("tracing: %i vs %i", PicoCpuCM68k.state_flags&2, m68ki_tracing); + if((other_is_tracing() && !m68ki_tracing) || (!other_is_tracing() && m68ki_tracing)) { + dprintf("tracing: %i vs %i", other_is_tracing(), m68ki_tracing); err=1; } @@ -173,7 +204,7 @@ int CM_compareRun(int cyc) PicoCpuCM68k.a[7] = m68ki_cpu.dar[15] = 0xff8000; #endif - cyc_done += cyc_cyclone; + cyc_done += cyc_other; ops++; }