3 // note: set SPLIT_MOVEL_PD to 0
\r
5 typedef unsigned char u8;
\r
7 static unsigned int pppc, ops=0;
\r
8 extern unsigned int lastread_a, lastread_d[16], lastwrite_cyc_d[16], lastwrite_mus_d[16];
\r
9 extern int lrp_cyc, lrp_mus, lwp_cyc, lwp_mus;
\r
10 unsigned int old_regs[16], old_sr, ppop, have_illegal = 0, dbg_irq_level = 0;
\r
13 #define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
\r
15 #if defined(EMU_C68K)
\r
16 #define other_get_sr() CycloneGetSr(&PicoCpuCM68k)
\r
17 #define other_dar(i) PicoCpuCM68k.d[i]
\r
18 #define other_osp PicoCpuCM68k.osp
\r
19 #define other_get_irq() PicoCpuCM68k.irq
\r
20 #define other_set_irq(irq) PicoCpuCM68k.irq=irq
\r
21 #define other_is_stopped() (PicoCpuCM68k.state_flags&1)
\r
22 #define other_is_tracing() ((PicoCpuCM68k.state_flags&2)?1:0)
\r
23 #elif defined(EMU_F68K)
\r
24 #define other_get_sr() PicoCpuFM68k.sr
\r
25 #define other_dar(i) ((unsigned int*)PicoCpuFM68k.dreg)[i]
\r
26 #define other_osp PicoCpuFM68k.asp
\r
27 #define other_get_irq() PicoCpuFM68k.interrupts[0]
\r
28 #define other_set_irq(irq) PicoCpuFM68k.interrupts[0]=irq
\r
29 #define other_is_stopped() ((PicoCpuFM68k.execinfo&FM68K_HALTED)?1:0)
\r
30 #define other_is_tracing() ((PicoCpuFM68k.execinfo&FM68K_EMULATE_TRACE)?1:0)
\r
32 #error other core missing, don't compile this file
\r
35 static int otherRun(void)
\r
37 #if defined(EMU_C68K)
\r
38 PicoCpuCM68k.cycles=1;
\r
39 CycloneRun(&PicoCpuCM68k);
\r
40 return 1-PicoCpuCM68k.cycles;
\r
41 #elif defined(EMU_F68K)
\r
42 return fm68k_emulate(1);
\r
47 void dumpPCandExit()
\r
52 m68k_disassemble(buff, pppc, M68K_CPU_TYPE_68000);
\r
53 dprintf("PC: %06x: %04x: %s", pppc, ppop, buff);
\r
54 dprintf(" this | prev");
\r
55 for(i=0; i < 8; i++)
\r
56 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]);
\r
57 dprintf("SR: %04x | %04x (??s? 0iii 000x nzvc)", other_get_sr(), old_sr);
\r
58 dprintf("last_read: %08x @ %06x", lastread_d[--lrp_cyc&15], lastread_a);
\r
59 dprintf("ops done: %i", ops);
\r
63 int CM_compareRun(int cyc)
\r
66 int cyc_done=0, cyc_other, cyc_musashi, err=0;
\r
67 unsigned int i, mu_sr;
\r
69 lrp_cyc = lrp_mus = 0;
\r
71 while(cyc > cyc_done)
\r
73 if (have_illegal && m68k_read_disassembler_16(m68ki_cpu.pc) != 0x4e73) // not rte
\r
78 PicoCpuCM68k.pc=PicoCpuCM68k.checkpc(PicoCpuCM68k.pc + 2);
\r
81 // hacks for test_misc2
\r
82 if (m68ki_cpu.pc == 0x0002e0 && m68k_read_disassembler_16(m68ki_cpu.pc) == 0x4e73)
\r
84 // get out of "priviledge violation" loop
\r
86 //m68ki_cpu.s_flag = SFLAG_SET;
\r
87 //PicoCpuCM68k.srh|=0x20;
\r
91 ppop = m68k_read_disassembler_16(pppc);
\r
92 memcpy(old_regs, &other_dar(0), 4*16);
\r
93 old_sr = other_get_sr();
\r
99 m68k_disassemble(buff, pppc, M68K_CPU_TYPE_68000);
\r
100 dprintf("PC: %06x: %04x: %s", pppc, ppop, buff);
\r
101 //dprintf("A7: %08x", PicoCpuCM68k.a[7]);
\r
107 other_set_irq(dbg_irq_level);
\r
108 m68k_set_irq(dbg_irq_level);
\r
112 cyc_other=otherRun();
\r
113 cyc_musashi=m68k_execute(1);
\r
115 if (cyc_other != cyc_musashi) {
\r
116 dprintf("cycles: %i vs %i", cyc_other, cyc_musashi);
\r
120 if (lrp_cyc != lrp_mus) {
\r
121 dprintf("lrp: %i vs %i", lrp_cyc&15, lrp_mus&15);
\r
125 if (lwp_cyc != lwp_mus) {
\r
126 dprintf("lwp: %i vs %i", lwp_cyc&15, lwp_mus&15);
\r
130 for (i=0; i < 16; i++) {
\r
131 if (lastwrite_cyc_d[i] != lastwrite_mus_d[i]) {
\r
132 dprintf("lastwrite: [%i]= %08x vs %08x", i, lastwrite_cyc_d[i], lastwrite_mus_d[i]);
\r
140 if (SekPc != m68ki_cpu.pc) {
\r
141 dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc);
\r
146 if( SekPc > Pico.romsize || SekPc < 0x200 ) {
\r
147 dprintf("PC out of bounds: %06x", SekPc);
\r
153 for (i=0; i < 16; i++) {
\r
154 if (other_dar(i) != m68ki_cpu.dar[i]) {
\r
155 str = (i < 8) ? "d" : "a";
\r
156 dprintf("reg: %s%i: %08x vs %08x", str, i&7, other_dar(i), m68ki_cpu.dar[i]);
\r
162 if (other_get_sr() != (mu_sr = m68k_get_reg(NULL, M68K_REG_SR))) {
\r
163 dprintf("SR: %04x vs %04x (??s? 0iii 000x nzvc)", other_get_sr(), mu_sr);
\r
168 if (other_get_irq() != (m68ki_cpu.int_level>>8)) {
\r
169 dprintf("IRQ: %i vs %i", other_get_irq(), (m68ki_cpu.int_level>>8));
\r
174 if (other_osp != m68ki_cpu.sp[((mu_sr>>11)&4)^4]) {
\r
175 dprintf("OSP: %06x vs %06x", other_osp, m68ki_cpu.sp[((mu_sr>>11)&4)^4]);
\r
180 if ((other_is_stopped() && !m68ki_cpu.stopped) || (!other_is_stopped() && m68ki_cpu.stopped)) {
\r
181 dprintf("stopped: %i vs %i", other_is_stopped(), m68ki_cpu.stopped);
\r
186 if((other_is_tracing() && !m68ki_tracing) || (!other_is_tracing() && m68ki_tracing)) {
\r
187 dprintf("tracing: %i vs %i", other_is_tracing(), m68ki_tracing);
\r
191 if(err) dumpPCandExit();
\r
194 if (PicoCpuCM68k.a[7] < 0x00ff0000 || PicoCpuCM68k.a[7] >= 0x01000000)
\r
196 PicoCpuCM68k.a[7] = m68ki_cpu.dar[15] = 0xff8000;
\r
200 m68k_set_reg(M68K_REG_SR, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000)); // broken
\r
201 CycloneSetSr(&PicoCpuCM68k, ((mu_sr-1)&~0x2000)|(mu_sr&0x2000));
\r
202 PicoCpuCM68k.stopped = m68ki_cpu.stopped = 0;
\r
203 if(SekPc > 0x400 && (PicoCpuCM68k.a[7] < 0xff0000 || PicoCpuCM68k.a[7] > 0xffffff))
\r
204 PicoCpuCM68k.a[7] = m68ki_cpu.dar[15] = 0xff8000;
\r
207 cyc_done += cyc_other;
\r