famec hack, CPU debug in CD mode

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@292 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-11-10 15:49:07 +00:00
parent 9caf44b59b
commit b5e5172d04
11 changed files with 279 additions and 66 deletions

View file

@ -7,7 +7,8 @@ typedef unsigned char u8;
static unsigned int pppc, ops=0; static unsigned int pppc, ops=0;
extern unsigned int lastread_a, lastread_d[16], lastwrite_cyc_d[16], lastwrite_mus_d[16]; 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; 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 #undef dprintf
#define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__) #define dprintf(f,...) printf("%05i:%03i: " f "\n",Pico.m.frame_count,Pico.m.scanline,##__VA_ARGS__)
@ -21,13 +22,14 @@ unsigned int old_regs[16], old_sr, ppop, have_illegal = 0, dbg_irq_level = 0;
#define other_is_stopped() (PicoCpuCM68k.state_flags&1) #define other_is_stopped() (PicoCpuCM68k.state_flags&1)
#define other_is_tracing() ((PicoCpuCM68k.state_flags&2)?1:0) #define other_is_tracing() ((PicoCpuCM68k.state_flags&2)?1:0)
#elif defined(EMU_F68K) #elif defined(EMU_F68K)
#define other_get_sr() PicoCpuFM68k.sr #define other_set_sub(s) g_m68kcontext=(s)?&PicoCpuFS68k:&PicoCpuFM68k;
#define other_dar(i) ((unsigned int*)PicoCpuFM68k.dreg)[i] #define other_get_sr() g_m68kcontext->sr
#define other_osp PicoCpuFM68k.asp #define other_dar(i) ((unsigned int*)g_m68kcontext->dreg)[i]
#define other_get_irq() PicoCpuFM68k.interrupts[0] #define other_osp g_m68kcontext->asp
#define other_set_irq(irq) PicoCpuFM68k.interrupts[0]=irq #define other_get_irq() g_m68kcontext->interrupts[0]
#define other_is_stopped() ((PicoCpuFM68k.execinfo&FM68K_HALTED)?1:0) #define other_set_irq(irq) g_m68kcontext->interrupts[0]=irq
#define other_is_tracing() ((PicoCpuFM68k.execinfo&FM68K_EMULATE_TRACE)?1:0) #define other_is_stopped() ((g_m68kcontext->execinfo&FM68K_HALTED)?1:0)
#define other_is_tracing() ((g_m68kcontext->execinfo&FM68K_EMULATE_TRACE)?1:0)
#else #else
#error other core missing, don't compile this file #error other core missing, don't compile this file
#endif #endif
@ -44,7 +46,7 @@ static int otherRun(void)
} }
//static //static
void dumpPCandExit() void dumpPCandExit(int is_sub)
{ {
char buff[128]; char buff[128];
int i; int i;
@ -56,19 +58,21 @@ 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("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("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("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); exit(1);
} }
int CM_compareRun(int cyc) int CM_compareRun(int cyc, int is_sub)
{ {
char *str; char *str;
int cyc_done=0, cyc_other, cyc_musashi, err=0; int cyc_done=0, cyc_other, cyc_musashi, *irq_level, err=0;
unsigned int i, mu_sr; unsigned int i, pc, mu_sr;
m68ki_cpu_p=is_sub?&PicoCpuMS68k:&PicoCpuMM68k;
other_set_sub(is_sub);
lrp_cyc = lrp_mus = 0; 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 if (have_illegal && m68k_read_disassembler_16(m68ki_cpu.pc) != 0x4e73) // not rte
{ {
@ -87,7 +91,7 @@ int CM_compareRun(int cyc)
//PicoCpuCM68k.srh|=0x20; //PicoCpuCM68k.srh|=0x20;
} }
pppc = SekPc; pppc = is_sub ? SekPcS68k : SekPc;
ppop = m68k_read_disassembler_16(pppc); ppop = m68k_read_disassembler_16(pppc);
memcpy(old_regs, &other_dar(0), 4*16); memcpy(old_regs, &other_dar(0), 4*16);
old_sr = other_get_sr(); old_sr = other_get_sr();
@ -102,11 +106,12 @@ int CM_compareRun(int cyc)
} }
#endif #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); other_set_irq(*irq_level);
m68k_set_irq(dbg_irq_level); m68k_set_irq(*irq_level);
dbg_irq_level=0; *irq_level=0;
} }
cyc_other=otherRun(); cyc_other=otherRun();
@ -136,9 +141,10 @@ int CM_compareRun(int cyc)
} }
// compare PC // compare PC
pc = is_sub ? SekPcS68k : SekPc;
m68ki_cpu.pc&=~1; m68ki_cpu.pc&=~1;
if (SekPc != m68ki_cpu.pc) { if (pc != m68ki_cpu.pc) {
dprintf("PC: %06x vs %06x", SekPc, m68ki_cpu.pc); dprintf("PC: %06x vs %06x", pc, m68ki_cpu.pc);
err=1; err=1;
} }
@ -188,7 +194,7 @@ int CM_compareRun(int cyc)
err=1; err=1;
} }
if(err) dumpPCandExit(); if(err) dumpPCandExit(is_sub);
#if 0 #if 0
if (PicoCpuCM68k.a[7] < 0x00ff0000 || PicoCpuCM68k.a[7] >= 0x01000000) if (PicoCpuCM68k.a[7] < 0x00ff0000 || PicoCpuCM68k.a[7] >= 0x01000000)

View file

@ -7,7 +7,7 @@
// For commercial use, separate licencing terms must be obtained. // For commercial use, separate licencing terms must be obtained.
#define __debug_io //#define __debug_io
#include "PicoInt.h" #include "PicoInt.h"
@ -323,7 +323,7 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a)
#ifndef EMU_CORE_DEBUG #ifndef EMU_CORE_DEBUG
// sram // sram
if(a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { if (a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) {
d = SRAMRead(a); d = SRAMRead(a);
elprintf(EL_SRAMIO, "sram r8 [%06x] %02x @ %06x", a, d, SekPc); elprintf(EL_SRAMIO, "sram r8 [%06x] %02x @ %06x", a, d, SekPc);
goto end; goto end;
@ -341,7 +341,7 @@ end:
dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
#endif #endif
#ifdef EMU_CORE_DEBUG #ifdef EMU_CORE_DEBUG
if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) { if (a>=Pico.romsize) {
lastread_a = a; lastread_a = a;
lastread_d[lrp_cyc++&15] = (u8)d; lastread_d[lrp_cyc++&15] = (u8)d;
} }
@ -359,7 +359,7 @@ PICO_INTERNAL_ASM u32 PicoRead16(u32 a)
#ifndef EMU_CORE_DEBUG #ifndef EMU_CORE_DEBUG
// sram // sram
if(a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) { if (a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) {
d = SRAMRead(a); d = SRAMRead(a);
d |= d<<8; d |= d<<8;
elprintf(EL_SRAMIO, "sram r16 [%06x] %04x @ %06x", a, d, SekPc); elprintf(EL_SRAMIO, "sram r16 [%06x] %04x @ %06x", a, d, SekPc);
@ -377,7 +377,7 @@ end:
dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
#endif #endif
#ifdef EMU_CORE_DEBUG #ifdef EMU_CORE_DEBUG
if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) { if (a>=Pico.romsize) {
lastread_a = a; lastread_a = a;
lastread_d[lrp_cyc++&15] = d; lastread_d[lrp_cyc++&15] = d;
} }
@ -411,7 +411,7 @@ end:
dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
#endif #endif
#ifdef EMU_CORE_DEBUG #ifdef EMU_CORE_DEBUG
if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) { if (a>=Pico.romsize) {
lastread_a = a; lastread_a = a;
lastread_d[lrp_cyc++&15] = d; lastread_d[lrp_cyc++&15] = d;
} }
@ -525,33 +525,36 @@ unsigned int m68k_read_pcrelative_CD16(unsigned int a);
unsigned int m68k_read_pcrelative_CD32(unsigned int a); unsigned int m68k_read_pcrelative_CD32(unsigned int a);
// these are allowed to access RAM // these are allowed to access RAM
static unsigned int m68k_read_8 (unsigned int a, int do_fake) { static unsigned int m68k_read_8 (unsigned int a, int do_fake)
{
a&=0xffffff; a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD8(a); if(a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k) return *(u8 *)(Pico.rom+(a^1)); // Rom
if(a<Pico.romsize) return *(u8 *)(Pico.rom+(a^1)); // Rom
#ifdef EMU_CORE_DEBUG #ifdef EMU_CORE_DEBUG
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15]; if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
#endif #endif
if(PicoMCD&1) return m68k_read_pcrelative_CD8(a);
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
return 0; return 0;
} }
static unsigned int m68k_read_16(unsigned int a, int do_fake) { static unsigned int m68k_read_16(unsigned int a, int do_fake)
{
a&=0xffffff; a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD16(a); if(a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k) return *(u16 *)(Pico.rom+(a&~1)); // Rom
if(a<Pico.romsize) return *(u16 *)(Pico.rom+(a&~1)); // Rom
#ifdef EMU_CORE_DEBUG #ifdef EMU_CORE_DEBUG
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15]; if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
#endif #endif
if(PicoMCD&1) return m68k_read_pcrelative_CD16(a);
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
return 0; return 0;
} }
static unsigned int m68k_read_32(unsigned int a, int do_fake) { static unsigned int m68k_read_32(unsigned int a, int do_fake)
{
a&=0xffffff; a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD32(a); if(a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; }
if(a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; }
#ifdef EMU_CORE_DEBUG #ifdef EMU_CORE_DEBUG
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15]; if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
#endif #endif
if(PicoMCD&1) return m68k_read_pcrelative_CD32(a);
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram
return 0; return 0;
} }
@ -570,7 +573,8 @@ unsigned int m68k_read_disassembler_32(unsigned int a) { return m68k_read_32(a,
unsigned int m68k_read_memory_8(unsigned int a) unsigned int m68k_read_memory_8(unsigned int a)
{ {
u8 d; u8 d;
if(a<Pico.romsize) d = *(u8 *) (Pico.rom+(a^1)); if (a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k)
d = *(u8 *) (Pico.rom+(a^1));
else d = (u8) lastread_d[lrp_mus++&15]; else d = (u8) lastread_d[lrp_mus++&15];
#ifdef __debug_io #ifdef __debug_io
dprintf("r8_mu : %06x, %02x @%06x", a&0xffffff, d, SekPc); dprintf("r8_mu : %06x, %02x @%06x", a&0xffffff, d, SekPc);
@ -580,7 +584,8 @@ unsigned int m68k_read_memory_8(unsigned int a)
unsigned int m68k_read_memory_16(unsigned int a) unsigned int m68k_read_memory_16(unsigned int a)
{ {
u16 d; u16 d;
if(a<Pico.romsize) d = *(u16 *)(Pico.rom+(a&~1)); if (a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k)
d = *(u16 *)(Pico.rom+(a&~1));
else d = (u16) lastread_d[lrp_mus++&15]; else d = (u16) lastread_d[lrp_mus++&15];
#ifdef __debug_io #ifdef __debug_io
dprintf("r16_mu: %06x, %04x @%06x", a&0xffffff, d, SekPc); dprintf("r16_mu: %06x, %04x @%06x", a&0xffffff, d, SekPc);
@ -590,7 +595,9 @@ unsigned int m68k_read_memory_16(unsigned int a)
unsigned int m68k_read_memory_32(unsigned int a) unsigned int m68k_read_memory_32(unsigned int a)
{ {
u32 d; u32 d;
if(a<Pico.romsize) {u16 *pm=(u16 *)(Pico.rom+(a&~1));d=(pm[0]<<16)|pm[1];} if (a<Pico.romsize && m68ki_cpu_p==&PicoCpuMM68k)
{ u16 *pm=(u16 *)(Pico.rom+(a&~1));d=(pm[0]<<16)|pm[1]; }
else if (a <= 0x78) d = m68k_read_32(a, 0);
else d = lastread_d[lrp_mus++&15]; else d = lastread_d[lrp_mus++&15];
#ifdef __debug_io #ifdef __debug_io
dprintf("r32_mu: %06x, %08x @%06x", a&0xffffff, d, SekPc); dprintf("r32_mu: %06x, %08x @%06x", a&0xffffff, d, SekPc);

View file

@ -205,7 +205,7 @@ static __inline void SekRunM68k(int cyc)
if((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return; if((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;
#if defined(EMU_CORE_DEBUG) #if defined(EMU_CORE_DEBUG)
// this means we do run-compare // this means we do run-compare
SekCycleCnt+=CM_compareRun(cyc_do); SekCycleCnt+=CM_compareRun(cyc_do, 0);
#elif defined(EMU_C68K) #elif defined(EMU_C68K)
PicoCpuCM68k.cycles=cyc_do; PicoCpuCM68k.cycles=cyc_do;
CycloneRun(&PicoCpuCM68k); CycloneRun(&PicoCpuCM68k);
@ -222,7 +222,7 @@ static __inline void SekStep(void)
// this is required for timing sensitive stuff to work // this is required for timing sensitive stuff to work
int realaim=SekCycleAim; SekCycleAim=SekCycleCnt+1; int realaim=SekCycleAim; SekCycleAim=SekCycleCnt+1;
#if defined(EMU_CORE_DEBUG) #if defined(EMU_CORE_DEBUG)
SekCycleCnt+=CM_compareRun(1); SekCycleCnt+=CM_compareRun(1, 0);
#elif defined(EMU_C68K) #elif defined(EMU_C68K)
PicoCpuCM68k.cycles=1; PicoCpuCM68k.cycles=1;
CycloneRun(&PicoCpuCM68k); CycloneRun(&PicoCpuCM68k);

View file

@ -313,7 +313,7 @@ PICO_INTERNAL int PicoCdLoadState(void *file);
PICO_INTERNAL void PicoCartDetect(void); PICO_INTERNAL void PicoCartDetect(void);
// Debug.c // Debug.c
int CM_compareRun(int cyc); int CM_compareRun(int cyc, int is_sub);
// Draw.c // Draw.c
PICO_INTERNAL int PicoLine(int scan); PICO_INTERNAL int PicoLine(int scan);

View file

@ -125,6 +125,7 @@ PICO_INTERNAL int SekInit()
memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k)); memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k));
fm68k_init(); fm68k_init();
PicoCpuFM68k.iack_handler = SekIntAckF68K; PicoCpuFM68k.iack_handler = SekIntAckF68K;
PicoCpuFM68k.sr = 0x2704; // Z flag
g_m68kcontext = oldcontext; g_m68kcontext = oldcontext;
} }
#endif #endif
@ -168,7 +169,7 @@ PICO_INTERNAL int SekInterrupt(int irq)
{ {
#ifdef EMU_CORE_DEBUG #ifdef EMU_CORE_DEBUG
{ {
extern unsigned int dbg_irq_level; extern int dbg_irq_level;
dbg_irq_level=irq; dbg_irq_level=irq;
return 0; return 0;
} }

View file

@ -2,7 +2,6 @@
// Loosely based on Gens code. // Loosely based on Gens code.
// (c) Copyright 2007, Grazvydas "notaz" Ignotas // (c) Copyright 2007, Grazvydas "notaz" Ignotas
// A68K no longer supported here
//#define __debug_io //#define __debug_io
@ -24,17 +23,22 @@ typedef unsigned int u32;
//#define __debug_io //#define __debug_io
//#define __debug_io2 //#define __debug_io2
#define rdprintf dprintf //#define rdprintf dprintf
//#define rdprintf(...) #define rdprintf(...)
//#define wrdprintf dprintf //#define wrdprintf dprintf
#define wrdprintf(...) #define wrdprintf(...)
#define plprintf dprintf #define plprintf dprintf
//#define plprintf(...) //#define plprintf(...)
#ifdef EMU_CORE_DEBUG
extern u32 lastread_a, lastread_d[16], lastwrite_cyc_d[16];
extern int lrp_cyc, lwp_cyc;
#undef USE_POLL_DETECT
#endif
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// poller detection // poller detection
//#undef USE_POLL_DETECT
#define POLL_LIMIT 16 #define POLL_LIMIT 16
#define POLL_CYCLES 124 #define POLL_CYCLES 124
// int m68k_poll_addr, m68k_poll_cnt; // int m68k_poll_addr, m68k_poll_cnt;
@ -280,7 +284,6 @@ void s68k_reg_write8(u32 a, u32 d)
{ {
//dprintf("s68k_regs w%2i: [%02x] %02x @ %06x", realsize, a, d, SekPcS68k); //dprintf("s68k_regs w%2i: [%02x] %02x @ %06x", realsize, a, d, SekPcS68k);
// TODO: review against Gens
// Warning: d might have upper bits set // Warning: d might have upper bits set
switch (a) { switch (a) {
case 2: case 2:
@ -413,7 +416,6 @@ static void OtherWrite8End(u32 a, u32 d, int realsize)
// ----------------------------------------------------------------- // -----------------------------------------------------------------
// Read Rom and read Ram // Read Rom and read Ram
//u8 PicoReadM68k8_(u32 a);
#ifdef _ASM_CD_MEMORY_C #ifdef _ASM_CD_MEMORY_C
u32 PicoReadM68k8(u32 a); u32 PicoReadM68k8(u32 a);
#else #else
@ -465,6 +467,12 @@ static u32 PicoReadM68k8(u32 a)
#ifdef __debug_io #ifdef __debug_io
dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc); dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
#endif
#ifdef EMU_CORE_DEBUG
if (a>=Pico.romsize) {
lastread_a = a;
lastread_d[lrp_cyc++&15] = d;
}
#endif #endif
return d; return d;
} }
@ -522,6 +530,12 @@ static u32 PicoReadM68k16(u32 a)
#ifdef __debug_io #ifdef __debug_io
dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc); dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
#endif
#ifdef EMU_CORE_DEBUG
if (a>=Pico.romsize) {
lastread_a = a;
lastread_d[lrp_cyc++&15] = d;
}
#endif #endif
return d; return d;
} }
@ -583,6 +597,12 @@ static u32 PicoReadM68k32(u32 a)
end: end:
#ifdef __debug_io #ifdef __debug_io
dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc); dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
#endif
#ifdef EMU_CORE_DEBUG
if (a>=Pico.romsize) {
lastread_a = a;
lastread_d[lrp_cyc++&15] = d;
}
#endif #endif
return d; return d;
} }
@ -599,9 +619,9 @@ static void PicoWriteM68k8(u32 a,u8 d)
#ifdef __debug_io #ifdef __debug_io
dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
#endif #endif
//if ((a&0xe0ffff)==0xe0a9ba+0x69c) #ifdef EMU_CORE_DEBUG
// dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc); lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
if ((a&0xe00000)==0xe00000) { // Ram if ((a&0xe00000)==0xe00000) { // Ram
*(u8 *)(Pico.ram+((a^1)&0xffff)) = d; *(u8 *)(Pico.ram+((a^1)&0xffff)) = d;
@ -652,7 +672,9 @@ static void PicoWriteM68k16(u32 a,u16 d)
#ifdef __debug_io #ifdef __debug_io
dprintf("w16: %06x, %04x", a&0xffffff, d); dprintf("w16: %06x, %04x", a&0xffffff, d);
#endif #endif
// dprintf("w16: %06x, %04x @%06x", a&0xffffff, d, SekPc); #ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
if ((a&0xe00000)==0xe00000) { // Ram if ((a&0xe00000)==0xe00000) { // Ram
*(u16 *)(Pico.ram+(a&0xfffe))=d; *(u16 *)(Pico.ram+(a&0xfffe))=d;
@ -716,6 +738,9 @@ static void PicoWriteM68k32(u32 a,u32 d)
#ifdef __debug_io #ifdef __debug_io
dprintf("w32: %06x, %08x", a&0xffffff, d); dprintf("w32: %06x, %08x", a&0xffffff, d);
#endif #endif
#ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
if ((a&0xe00000)==0xe00000) if ((a&0xe00000)==0xe00000)
{ {
@ -782,6 +807,9 @@ static u32 PicoReadS68k8(u32 a)
{ {
u32 d=0; u32 d=0;
#ifdef EMU_CORE_DEBUG
u32 ab=a&0xfffffe;
#endif
a&=0xffffff; a&=0xffffff;
// prg RAM // prg RAM
@ -865,6 +893,10 @@ static u32 PicoReadS68k8(u32 a)
#ifdef __debug_io2 #ifdef __debug_io2
dprintf("s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k); dprintf("s68k r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPcS68k);
#endif
#ifdef EMU_CORE_DEBUG
lastread_a = ab;
lastread_d[lrp_cyc++&15] = d;
#endif #endif
return d; return d;
} }
@ -878,6 +910,9 @@ static u32 PicoReadS68k16(u32 a)
{ {
u32 d=0; u32 d=0;
#ifdef EMU_CORE_DEBUG
u32 ab=a&0xfffffe;
#endif
a&=0xfffffe; a&=0xfffffe;
// prg RAM // prg RAM
@ -958,6 +993,10 @@ static u32 PicoReadS68k16(u32 a)
#ifdef __debug_io2 #ifdef __debug_io2
dprintf("s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k); dprintf("s68k r16: %06x, %04x @%06x", a&0xffffff, d, SekPcS68k);
#endif
#ifdef EMU_CORE_DEBUG
lastread_a = ab;
lastread_d[lrp_cyc++&15] = d;
#endif #endif
return d; return d;
} }
@ -971,6 +1010,9 @@ static u32 PicoReadS68k32(u32 a)
{ {
u32 d=0; u32 d=0;
#ifdef EMU_CORE_DEBUG
u32 ab=a&0xfffffe;
#endif
a&=0xfffffe; a&=0xfffffe;
// prg RAM // prg RAM
@ -1061,6 +1103,12 @@ static u32 PicoReadS68k32(u32 a)
#ifdef __debug_io2 #ifdef __debug_io2
dprintf("s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k); dprintf("s68k r32: %06x, %08x @%06x", a&0xffffff, d, SekPcS68k);
#endif
#ifdef EMU_CORE_DEBUG
if (ab > 0x78) { // not vectors and stuff
lastread_a = ab;
lastread_d[lrp_cyc++&15] = d;
}
#endif #endif
return d; return d;
} }
@ -1131,6 +1179,10 @@ static void PicoWriteS68k8(u32 a,u8 d)
a&=0xffffff; a&=0xffffff;
#ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
// prg RAM // prg RAM
if (a < 0x80000) { if (a < 0x80000) {
u8 *pm=(u8 *)(Pico_mcd->prg_ram+(a^1)); u8 *pm=(u8 *)(Pico_mcd->prg_ram+(a^1));
@ -1207,6 +1259,10 @@ static void PicoWriteS68k16(u32 a,u16 d)
a&=0xfffffe; a&=0xfffffe;
#ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
// prg RAM // prg RAM
if (a < 0x80000) { if (a < 0x80000) {
wrdprintf("s68k_prgram w16: [%06x] %04x @%06x", a, d, SekPcS68k); wrdprintf("s68k_prgram w16: [%06x] %04x @%06x", a, d, SekPcS68k);
@ -1293,6 +1349,10 @@ static void PicoWriteS68k32(u32 a,u32 d)
a&=0xfffffe; a&=0xfffffe;
#ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
// prg RAM // prg RAM
if (a < 0x80000) { if (a < 0x80000) {
if (a >= (Pico_mcd->s68k_regs[2]<<8)) { if (a >= (Pico_mcd->s68k_regs[2]<<8)) {
@ -1563,7 +1623,8 @@ void PicoWriteCD32w(unsigned int a, unsigned int d) {
} }
// these are allowed to access RAM // these are allowed to access RAM
unsigned int m68k_read_pcrelative_CD8 (unsigned int a) { unsigned int m68k_read_pcrelative_CD8 (unsigned int a)
{
a&=0xffffff; a&=0xffffff;
if(m68ki_cpu_p == &PicoCpuMS68k) { if(m68ki_cpu_p == &PicoCpuMS68k) {
if (a < 0x80000) return *(u8 *)(Pico_mcd->prg_ram+(a^1)); // PRG Ram if (a < 0x80000) return *(u8 *)(Pico_mcd->prg_ram+(a^1)); // PRG Ram
@ -1589,7 +1650,8 @@ unsigned int m68k_read_pcrelative_CD8 (unsigned int a) {
} }
return 0;//(u8) lastread_d; return 0;//(u8) lastread_d;
} }
unsigned int m68k_read_pcrelative_CD16(unsigned int a) { unsigned int m68k_read_pcrelative_CD16(unsigned int a)
{
a&=0xffffff; a&=0xffffff;
if(m68ki_cpu_p == &PicoCpuMS68k) { if(m68ki_cpu_p == &PicoCpuMS68k) {
if (a < 0x80000) return *(u16 *)(Pico_mcd->prg_ram+(a&~1)); // PRG Ram if (a < 0x80000) return *(u16 *)(Pico_mcd->prg_ram+(a&~1)); // PRG Ram
@ -1615,7 +1677,8 @@ unsigned int m68k_read_pcrelative_CD16(unsigned int a) {
} }
return 0; return 0;
} }
unsigned int m68k_read_pcrelative_CD32(unsigned int a) { unsigned int m68k_read_pcrelative_CD32(unsigned int a)
{
u16 *pm; u16 *pm;
a&=0xffffff; a&=0xffffff;
if(m68ki_cpu_p == &PicoCpuMS68k) { if(m68ki_cpu_p == &PicoCpuMS68k) {

View file

@ -88,7 +88,9 @@ static __inline void SekRunM68k(int cyc)
int cyc_do; int cyc_do;
SekCycleAim+=cyc; SekCycleAim+=cyc;
if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return; if ((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;
#if defined(EMU_C68K) #if defined(EMU_CORE_DEBUG)
SekCycleCnt+=CM_compareRun(cyc_do, 0);
#elif defined(EMU_C68K)
PicoCpuCM68k.cycles=cyc_do; PicoCpuCM68k.cycles=cyc_do;
CycloneRun(&PicoCpuCM68k); CycloneRun(&PicoCpuCM68k);
SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles; SekCycleCnt+=cyc_do-PicoCpuCM68k.cycles;
@ -106,7 +108,9 @@ static __inline void SekRunS68k(int cyc)
int cyc_do; int cyc_do;
SekCycleAimS68k+=cyc; SekCycleAimS68k+=cyc;
if ((cyc_do=SekCycleAimS68k-SekCycleCntS68k) <= 0) return; if ((cyc_do=SekCycleAimS68k-SekCycleCntS68k) <= 0) return;
#if defined(EMU_C68K) #if defined(EMU_CORE_DEBUG)
SekCycleCntS68k+=CM_compareRun(cyc_do, 1);
#elif defined(EMU_C68K)
PicoCpuCS68k.cycles=cyc_do; PicoCpuCS68k.cycles=cyc_do;
CycloneRun(&PicoCpuCS68k); CycloneRun(&PicoCpuCS68k);
SekCycleCntS68k+=cyc_do-PicoCpuCS68k.cycles; SekCycleCntS68k+=cyc_do-PicoCpuCS68k.cycles;

View file

@ -64,9 +64,13 @@ static int SekUnrecognizedOpcodeS68k(void)
#ifdef EMU_M68K #ifdef EMU_M68K
static int SekIntAckMS68k(int level) static int SekIntAckMS68k(int level)
{ {
#ifndef EMU_CORE_DEBUG
int level_new = new_irq_level(level); int level_new = new_irq_level(level);
dprintf("s68kACK %i -> %i", level, level_new); dprintf("s68kACK %i -> %i", level, level_new);
CPU_INT_LEVEL = level_new << 8; CPU_INT_LEVEL = level_new << 8;
#else
CPU_INT_LEVEL = 0;
#endif
return M68K_INT_ACK_AUTOVECTOR; return M68K_INT_ACK_AUTOVECTOR;
} }
#endif #endif
@ -76,7 +80,15 @@ static void SekIntAckFS68k(unsigned level)
{ {
int level_new = new_irq_level(level); int level_new = new_irq_level(level);
dprintf("s68kACK %i -> %i", level, level_new); dprintf("s68kACK %i -> %i", level, level_new);
#ifndef EMU_CORE_DEBUG
PicoCpuFS68k.interrupts[0] = level_new; PicoCpuFS68k.interrupts[0] = level_new;
#else
{
extern int dbg_irq_level_sub;
dbg_irq_level_sub = level_new;
PicoCpuFS68k.interrupts[0] = 0;
}
#endif
} }
#endif #endif
@ -109,6 +121,7 @@ PICO_INTERNAL int SekInitS68k()
memset(&PicoCpuFS68k, 0, sizeof(PicoCpuFS68k)); memset(&PicoCpuFS68k, 0, sizeof(PicoCpuFS68k));
fm68k_init(); fm68k_init();
PicoCpuFS68k.iack_handler = SekIntAckFS68k; PicoCpuFS68k.iack_handler = SekIntAckFS68k;
PicoCpuFS68k.sr = 0x2704; // Z flag
g_m68kcontext = oldcontext; g_m68kcontext = oldcontext;
} }
#endif #endif
@ -161,6 +174,14 @@ PICO_INTERNAL int SekInterruptS68k(int irq)
irqs = Pico_mcd->m.s68k_pend_ints >> 1; irqs = Pico_mcd->m.s68k_pend_ints >> 1;
while ((irqs >>= 1)) real_irq++; while ((irqs >>= 1)) real_irq++;
#ifdef EMU_CORE_DEBUG
{
extern int dbg_irq_level_sub;
dbg_irq_level_sub=real_irq;
elprintf(EL_ANOMALY, "s68k irq %i", real_irq);
return 0;
}
#endif
#ifdef EMU_C68K #ifdef EMU_C68K
PicoCpuCS68k.irq=real_irq; PicoCpuCS68k.irq=real_irq;
#endif #endif

View file

@ -28,6 +28,7 @@
#define USE_CYCLONE_TIMING #define USE_CYCLONE_TIMING
#define USE_CYCLONE_TIMING_DIV #define USE_CYCLONE_TIMING_DIV
#define PICODRIVE_HACK
// Options // // Options //
@ -521,6 +522,10 @@ static u32 flag_I;
static u32 initialised = 0; static u32 initialised = 0;
#ifdef PICODRIVE_HACK
extern M68K_CONTEXT PicoCpuFS68k;
#endif
/* Custom function handler */ /* Custom function handler */
typedef void (*opcode_func)(void); typedef void (*opcode_func)(void);
@ -793,6 +798,9 @@ int fm68k_emulate(s32 cycles)
// won't emulate double fault // won't emulate double fault
// if (m68kcontext.execinfo & M68K_FAULTED) return -1; // if (m68kcontext.execinfo & M68K_FAULTED) return -1;
// Cache PPL
flag_I = M68K_PPL;
if (m68kcontext.execinfo & FM68K_HALTED) if (m68kcontext.execinfo & FM68K_HALTED)
{ {
if (interrupt_chk__() <= 0) if (interrupt_chk__() <= 0)
@ -812,9 +820,6 @@ int fm68k_emulate(s32 cycles)
// Cache SR // Cache SR
SET_SR(m68kcontext.sr) SET_SR(m68kcontext.sr)
// Cache PPL
flag_I = M68K_PPL;
// Fijar PC // Fijar PC
SET_PC(m68kcontext.pc) SET_PC(m68kcontext.pc)
@ -943,8 +948,6 @@ init_jump_table:
#endif #endif
u32 i, j; u32 i, j;
m68kcontext.sr = 0x2704; // Z flag
for(i = 0x0000; i <= 0xFFFF; i += 0x0001) for(i = 0x0000; i <= 0xFFFF; i += 0x0001)
JumpTable[0x0000 + i] = CAST_OP(0x4AFC); JumpTable[0x0000 + i] = CAST_OP(0x4AFC);
for(i = 0x0000; i <= 0x0007; i += 0x0001) for(i = 0x0000; i <= 0x0007; i += 0x0001)

View file

@ -18292,8 +18292,19 @@ OPCODE(0x4AD0)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
RET(8) RET(8)
#endif
} }
// TAS // TAS
@ -18310,8 +18321,20 @@ OPCODE(0x4AD8)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
RET(8) RET(8)
#endif
} }
// TAS // TAS
@ -18328,8 +18351,20 @@ OPCODE(0x4AE0)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(20)
#else
RET(10) RET(10)
#endif
} }
// TAS // TAS
@ -18346,8 +18381,20 @@ OPCODE(0x4AE8)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(22)
#else
RET(12) RET(12)
#endif
} }
// TAS // TAS
@ -18364,8 +18411,20 @@ OPCODE(0x4AF0)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(24)
#else
RET(14) RET(14)
#endif
} }
// TAS // TAS
@ -18381,8 +18440,20 @@ OPCODE(0x4AF8)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(22)
#else
RET(12) RET(12)
#endif
} }
// TAS // TAS
@ -18398,8 +18469,20 @@ OPCODE(0x4AF9)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(26)
#else
RET(16) RET(16)
#endif
} }
// TAS // TAS
@ -18416,8 +18499,20 @@ OPCODE(0x4ADF)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
#ifdef USE_CYCLONE_TIMING
RET(18)
#else
RET(8) RET(8)
#endif
} }
// TAS // TAS
@ -18434,8 +18529,20 @@ OPCODE(0x4AE7)
flag_V = 0; flag_V = 0;
flag_NotZ = res; flag_NotZ = res;
flag_N = res; flag_N = res;
#ifdef PICODRIVE_HACK
if (g_m68kcontext == &PicoCpuFS68k) {
res |= 0x80;
WRITE_BYTE_F(adr, res);
}
#endif
POST_IO POST_IO
RET(10) #ifdef USE_CYCLONE_TIMING
RET(20)
#else
RET(8)
#endif
} }
// ILLEGAL // ILLEGAL

View file

@ -2011,7 +2011,8 @@ void m68ki_exception_interrupt(uint int_level)
FLAG_INT_MASK = int_level<<8; FLAG_INT_MASK = int_level<<8;
/* Get the new PC */ /* Get the new PC */
new_pc = m68ki_read_data_32((vector<<2) + REG_VBR); //new_pc = m68ki_read_data_32((vector<<2) + REG_VBR);
new_pc = m68k_read_immediate_32((vector<<2) + REG_VBR); // notaz hack
/* If vector is uninitialized, call the uninitialized interrupt vector */ /* If vector is uninitialized, call the uninitialized interrupt vector */
if(new_pc == 0) if(new_pc == 0)