bugfixes, adjusted famec timing

git-svn-id: file:///home/notaz/opt/svn/PicoDrive@283 be3aeb3a-fb24-0410-a615-afba39da0efa
This commit is contained in:
notaz 2007-10-28 20:23:15 +00:00
parent 80db44425a
commit 03e4f2a349
15 changed files with 324 additions and 344 deletions

View file

@ -71,7 +71,7 @@ PICO_INTERNAL int PicoAreaPackCpu(unsigned char *cpu, int is_sub)
*(unsigned int *)(cpu+0x44)=context->sr;
*(unsigned int *)(cpu+0x48)=context->asp;
cpu[0x4c] = context->interrupts[0];
cpu[0x4d] = (context->execinfo & M68K_HALTED) ? 1 : 0;
cpu[0x4d] = (context->execinfo & FM68K_HALTED) ? 1 : 0;
#endif
*(unsigned int *)(cpu+0x40)=pc;
@ -108,8 +108,8 @@ PICO_INTERNAL int PicoAreaUnpackCpu(unsigned char *cpu, int is_sub)
context->sr =*(unsigned int *)(cpu+0x44);
context->asp=*(unsigned int *)(cpu+0x48);
context->interrupts[0] = cpu[0x4c];
context->execinfo &= ~M68K_HALTED;
if (cpu[0x4d]&1) context->execinfo |= M68K_HALTED;
context->execinfo &= ~FM68K_HALTED;
if (cpu[0x4d]&1) context->execinfo |= FM68K_HALTED;
#endif
return 0;
}

View file

@ -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++;
}

View file

@ -32,8 +32,7 @@ void PicoWriteRomHW_in1 (u32 a,u32 d);
#endif
#if defined(EMU_C68K) && defined(EMU_M68K)
// cyclone debug mode
#ifdef EMU_CORE_DEBUG
u32 lastread_a, lastread_d[16]={0,}, lastwrite_cyc_d[16]={0,}, lastwrite_mus_d[16]={0,};
int lrp_cyc=0, lrp_mus=0, lwp_cyc=0, lwp_mus=0;
extern unsigned int ppop;
@ -323,7 +322,7 @@ PICO_INTERNAL_ASM u32 PicoRead8(u32 a)
a&=0xffffff;
#if !(defined(EMU_C68K) && defined(EMU_M68K))
#ifndef EMU_CORE_DEBUG
// sram
if(a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) {
d = SRAMRead(a);
@ -342,7 +341,7 @@ end:
#ifdef __debug_io
dprintf("r8 : %06x, %02x @%06x", a&0xffffff, (u8)d, SekPc);
#endif
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) {
lastread_a = a;
lastread_d[lrp_cyc++&15] = (u8)d;
@ -359,7 +358,7 @@ PICO_INTERNAL_ASM u32 PicoRead16(u32 a)
a&=0xfffffe;
#if !(defined(EMU_C68K) && defined(EMU_M68K))
#ifndef EMU_CORE_DEBUG
// sram
if(a >= SRam.start && a <= SRam.end && (Pico.m.sram_reg&5)) {
d = SRAMRead(a);
@ -378,7 +377,7 @@ end:
#ifdef __debug_io
dprintf("r16: %06x, %04x @%06x", a&0xffffff, d, SekPc);
#endif
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) {
lastread_a = a;
lastread_d[lrp_cyc++&15] = d;
@ -412,7 +411,7 @@ end:
#ifdef __debug_io
dprintf("r32: %06x, %08x @%06x", a&0xffffff, d, SekPc);
#endif
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
if(a>=Pico.romsize/*&&(ppop&0x3f)!=0x3a&&(ppop&0x3f)!=0x3b*/) {
lastread_a = a;
lastread_d[lrp_cyc++&15] = d;
@ -431,12 +430,9 @@ PICO_INTERNAL_ASM void PicoWrite8(u32 a,u8 d)
#ifdef __debug_io
dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
#endif
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
//if ((a&0xe0ffff)==0xe0a9ba+0x69c)
//if(a==0x200000||a==0x200001) printf("w8 : %02x [%06x] @ %06x [%i]\n", d, a, SekPc, SekCyclesDoneT());
// dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);
if ((a&0xe00000)==0xe00000) { *(u8 *)(Pico.ram+((a^1)&0xffff))=d; return; } // Ram
log_io(a, 8, 1);
@ -451,7 +447,7 @@ void PicoWrite16(u32 a,u16 d)
#ifdef __debug_io
dprintf("w16: %06x, %04x", a&0xffffff, d);
#endif
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
@ -467,7 +463,7 @@ static void PicoWrite32(u32 a,u32 d)
#ifdef __debug_io
dprintf("w32: %06x, %08x", a&0xffffff, d);
#endif
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
lastwrite_cyc_d[lwp_cyc++&15] = d;
#endif
@ -534,7 +530,7 @@ static unsigned int m68k_read_8 (unsigned int a, int do_fake) {
a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD8(a);
if(a<Pico.romsize) return *(u8 *)(Pico.rom+(a^1)); // Rom
#ifdef EMU_C68K
#ifdef EMU_CORE_DEBUG
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
#endif
if((a&0xe00000)==0xe00000) return *(u8 *)(Pico.ram+((a^1)&0xffff)); // Ram
@ -544,7 +540,7 @@ static unsigned int m68k_read_16(unsigned int a, int do_fake) {
a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD16(a);
if(a<Pico.romsize) return *(u16 *)(Pico.rom+(a&~1)); // Rom
#ifdef EMU_C68K
#ifdef EMU_CORE_DEBUG
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
#endif
if((a&0xe00000)==0xe00000) return *(u16 *)(Pico.ram+(a&0xfffe)); // Ram
@ -554,7 +550,7 @@ static unsigned int m68k_read_32(unsigned int a, int do_fake) {
a&=0xffffff;
if(PicoMCD&1) return m68k_read_pcrelative_CD32(a);
if(a<Pico.romsize) { u16 *pm=(u16 *)(Pico.rom+(a&~1)); return (pm[0]<<16)|pm[1]; }
#ifdef EMU_C68K
#ifdef EMU_CORE_DEBUG
if(do_fake&&((ppop&0x3f)==0x3a||(ppop&0x3f)==0x3b)) return lastread_d[lrp_mus++&15];
#endif
if((a&0xe00000)==0xe00000) { u16 *pm=(u16 *)(Pico.ram+(a&0xfffe)); return (pm[0]<<16)|pm[1]; } // Ram
@ -570,7 +566,7 @@ unsigned int m68k_read_disassembler_8 (unsigned int a) { return m68k_read_8 (a,
unsigned int m68k_read_disassembler_16(unsigned int a) { return m68k_read_16(a, 0); }
unsigned int m68k_read_disassembler_32(unsigned int a) { return m68k_read_32(a, 0); }
#ifdef EMU_C68K
#ifdef EMU_CORE_DEBUG
// ROM only
unsigned int m68k_read_memory_8(unsigned int a)
{
@ -658,10 +654,14 @@ PICO_INTERNAL unsigned char z80_read(unsigned short a)
{
u8 ret = 0;
#ifndef _USE_DRZ80
if (a<0x4000) return Pico.zram[a&0x1fff];
#endif
if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald)
{
if(PicoOpt&1) ret = (u8) YM2612Read();
goto end;
if (PicoOpt&1) ret = (u8) YM2612Read();
return ret;
}
if (a>=0x8000)
@ -672,15 +672,15 @@ PICO_INTERNAL unsigned char z80_read(unsigned short a)
ret = (u8) PicoRead8(addr68k);
elprintf(EL_Z80BNK, "z80->68k r8 [%06x] %02x", addr68k, ret);
goto end;
return ret;
}
#ifdef _USE_DRZ80
// should not be needed || dprintf("z80_read RAM");
if (a<0x4000) { ret = (u8) Pico.zram[a&0x1fff]; goto end; }
if (a<0x4000) return Pico.zram[a&0x1fff];
#endif
elprintf(EL_ANOMALY, "z80 invalid r8 [%06x] %02x", a, ret);
end:
return ret;
}
@ -690,8 +690,9 @@ PICO_INTERNAL_ASM void z80_write(unsigned char data, unsigned short a)
PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data)
#endif
{
//if (a<0x4000)
// dprintf("z80 w8 : %06x, %02x @%04x", a, data, mz80GetRegisterValue(NULL, 0));
#ifndef _USE_DRZ80
if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; }
#endif
if ((a>>13)==2) // 0x4000-0x5fff (Charles MacDonald)
{
@ -723,8 +724,10 @@ PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data)
return;
}
#ifdef _USE_DRZ80
// should not be needed, drZ80 knows how to access RAM itself || dprintf("z80_write RAM @ %08x", lr);
if (a<0x4000) { Pico.zram[a&0x1fff]=data; return; }
#endif
elprintf(EL_ANOMALY, "z80 invalid w8 [%06x] %02x", a, data);
}
@ -732,15 +735,11 @@ PICO_INTERNAL_ASM void z80_write(unsigned int a, unsigned char data)
#ifndef _USE_CZ80
PICO_INTERNAL unsigned short z80_read16(unsigned short a)
{
//dprintf("z80_read16");
return (u16) ( (u16)z80_read(a) | ((u16)z80_read((u16)(a+1))<<8) );
}
PICO_INTERNAL void z80_write16(unsigned short data, unsigned short a)
{
//dprintf("z80_write16");
z80_write((unsigned char) data,a);
z80_write((unsigned char)(data>>8),(u16)(a+1));
}

View file

@ -202,11 +202,9 @@ static __inline void SekRunM68k(int cyc)
{
int cyc_do;
SekCycleAim+=cyc;
//printf("aim: %i, cnt: %i\n", SekCycleAim, SekCycleCnt);
if((cyc_do=SekCycleAim-SekCycleCnt) <= 0) return;
//printf("cyc_do: %i\n", cyc_do);
#if defined(EMU_C68K) && defined(EMU_M68K)
// this means we do run-compare Cyclone vs Musashi
#if defined(EMU_CORE_DEBUG)
// this means we do run-compare
SekCycleCnt+=CM_compareRun(cyc_do);
#elif defined(EMU_C68K)
PicoCpuCM68k.cycles=cyc_do;
@ -215,7 +213,7 @@ static __inline void SekRunM68k(int cyc)
#elif defined(EMU_M68K)
SekCycleCnt+=m68k_execute(cyc_do);
#elif defined(EMU_F68K)
SekCycleCnt+=m68k_emulate(cyc_do);
SekCycleCnt+=fm68k_emulate(cyc_do+1);
#endif
}
@ -223,8 +221,7 @@ static __inline void SekStep(void)
{
// this is required for timing sensitive stuff to work
int realaim=SekCycleAim; SekCycleAim=SekCycleCnt+1;
#if defined(EMU_C68K) && defined(EMU_M68K)
// this means we do run-compare Cyclone vs Musashi
#if defined(EMU_CORE_DEBUG)
SekCycleCnt+=CM_compareRun(1);
#elif defined(EMU_C68K)
PicoCpuCM68k.cycles=1;
@ -233,7 +230,7 @@ static __inline void SekStep(void)
#elif defined(EMU_M68K)
SekCycleCnt+=m68k_execute(1);
#elif defined(EMU_F68K)
SekCycleCnt+=m68k_emulate(1);
SekCycleCnt+=fm68k_emulate(1);
#endif
SekCycleAim=realaim;
}

View file

@ -54,10 +54,20 @@
static int PicoFrameHints(void)
{
struct PicoVideo *pv=&Pico.video;
int lines,y,lines_vis = 224,total_z80 = 0,z80CycleAim = 0,line_sample;
int skip=PicoSkipFrame || (PicoOpt&0x10);
int lines, y, lines_vis = 224, total_z80 = 0, z80CycleAim = 0, line_sample, skip;
int hint; // Hint counter
if ((PicoOpt&0x10) && !PicoSkipFrame) {
// draw a frame just after vblank in alternative render mode
// yes, this will cause 1 frame lag, but this is inaccurate mode anyway.
PicoFrameFull();
#ifdef DRAW_FINISH_FUNC
DRAW_FINISH_FUNC();
#endif
skip = 1;
}
else skip=PicoSkipFrame;
if (Pico.m.pal) {
//cycles_68k = (int) ((double) OSC_PAL / 7 / 50 / 312 + 0.4); // should compile to a constant (488)
//cycles_z80 = (int) ((double) OSC_PAL / 15 / 50 / 312 + 0.4); // 228
@ -140,7 +150,8 @@ static int PicoFrameHints(void)
}
#ifdef DRAW_FINISH_FUNC
DRAW_FINISH_FUNC();
if (!skip)
DRAW_FINISH_FUNC();
#endif
// V-int line (224 or 240)
@ -223,10 +234,6 @@ static int PicoFrameHints(void)
#endif
}
// draw a frame just after vblank in alternative render mode
if (!PicoSkipFrame && (PicoOpt&0x10))
PicoFrameFull();
return 0;
}

View file

@ -48,6 +48,10 @@ extern struct Cyclone PicoCpuCM68k, PicoCpuCS68k;
#define SekPcS68k (PicoCpuCS68k.pc-PicoCpuCS68k.membase)
#define SekSetStop(x) { PicoCpuCM68k.state_flags&=~1; if (x) { PicoCpuCM68k.state_flags|=1; PicoCpuCM68k.cycles=0; } }
#define SekSetStopS68k(x) { PicoCpuCS68k.state_flags&=~1; if (x) { PicoCpuCS68k.state_flags|=1; PicoCpuCS68k.cycles=0; } }
#define SekShouldInterrupt (PicoCpuCM68k.irq > (PicoCpuCM68k.srh&7))
#ifdef EMU_M68K
#define EMU_CORE_DEBUG
#endif
#endif
#ifdef EMU_F68K
@ -62,16 +66,20 @@ M68K_CONTEXT PicoCpuFM68k, PicoCpuFS68k;
#define SekSetCyclesLeft(c) { \
if ((PicoMCD&1) && (PicoOpt & 0x2000)) SekCycleCnt=SekCycleAim-(c); else SekSetCyclesLeftNoMCD(c); \
}
#define SekPc m68k_get_pc(&PicoCpuFM68k)
#define SekPcS68k m68k_get_pc(&PicoCpuFS68k)
#define SekPc fm68k_get_pc(&PicoCpuFM68k)
#define SekPcS68k fm68k_get_pc(&PicoCpuFS68k)
#define SekSetStop(x) { \
PicoCpuFM68k.execinfo &= ~M68K_HALTED; \
if (x) { PicoCpuFM68k.execinfo |= M68K_HALTED; PicoCpuFM68k.io_cycle_counter = 0; } \
PicoCpuFM68k.execinfo &= ~FM68K_HALTED; \
if (x) { PicoCpuFM68k.execinfo |= FM68K_HALTED; PicoCpuFM68k.io_cycle_counter = 0; } \
}
#define SekSetStopS68k(x) { \
PicoCpuFS68k.execinfo &= ~M68K_HALTED; \
if (x) { PicoCpuFS68k.execinfo |= M68K_HALTED; PicoCpuFS68k.io_cycle_counter = 0; } \
PicoCpuFS68k.execinfo &= ~FM68K_HALTED; \
if (x) { PicoCpuFS68k.execinfo |= FM68K_HALTED; PicoCpuFS68k.io_cycle_counter = 0; } \
}
#define SekShouldInterrupt fm68k_would_interrupt()
#ifdef EMU_M68K
#define EMU_CORE_DEBUG
#endif
#endif
#ifdef EMU_M68K
@ -97,6 +105,7 @@ extern m68ki_cpu_core PicoCpuMM68k, PicoCpuMS68k;
if(x) { SET_CYCLES(0); PicoCpuMS68k.stopped=STOP_LEVEL_STOP; } \
else PicoCpuMS68k.stopped=0; \
}
#define SekShouldInterrupt (CPU_INT_LEVEL > FLAG_INT_MASK)
#endif
#endif
@ -128,8 +137,7 @@ extern int SekCycleAimS68k;
}
#define SekCyclesDoneS68k() (SekCycleAimS68k-SekCyclesLeftS68k)
// debug cyclone
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
#undef SekSetCyclesLeftNoMCD
#undef SekSetCyclesLeft
#undef SekCyclesBurn
@ -304,6 +312,9 @@ PICO_INTERNAL int PicoCdLoadState(void *file);
// Cart.c
PICO_INTERNAL void PicoCartDetect(void);
// Debug.c
int CM_compareRun(int cyc);
// Draw.c
PICO_INTERNAL int PicoLine(int scan);
PICO_INTERNAL void PicoFrameStart(void);

View file

@ -104,6 +104,7 @@ PICO_INTERNAL int SekInit()
PicoCpuCM68k.IrqCallback=SekIntAck;
PicoCpuCM68k.ResetCallback=SekResetAck;
PicoCpuCM68k.UnrecognizedCallback=SekUnrecognizedOpcode;
PicoCpuCM68k.flags=4; // Z set
#endif
#ifdef EMU_M68K
{
@ -122,7 +123,7 @@ PICO_INTERNAL int SekInit()
void *oldcontext = g_m68kcontext;
g_m68kcontext = &PicoCpuFM68k;
memset(&PicoCpuFM68k, 0, sizeof(PicoCpuFM68k));
m68k_init();
fm68k_init();
PicoCpuFM68k.iack_handler = SekIntAckF68K;
g_m68kcontext = oldcontext;
}
@ -141,7 +142,6 @@ PICO_INTERNAL int SekReset()
PicoCpuCM68k.state_flags=0;
PicoCpuCM68k.osp=0;
PicoCpuCM68k.srh =0x27; // Supervisor mode
PicoCpuCM68k.flags=4; // Z set
PicoCpuCM68k.irq=0;
PicoCpuCM68k.a[7]=PicoCpuCM68k.read32(0); // Stack Pointer
PicoCpuCM68k.membase=0;
@ -156,7 +156,7 @@ PICO_INTERNAL int SekReset()
#ifdef EMU_F68K
{
g_m68kcontext = &PicoCpuFM68k;
m68k_reset();
fm68k_reset();
}
#endif
@ -166,7 +166,7 @@ PICO_INTERNAL int SekReset()
PICO_INTERNAL int SekInterrupt(int irq)
{
#if defined(EMU_C68K) && defined(EMU_M68K)
#ifdef EMU_CORE_DEBUG
{
extern unsigned int dbg_irq_level;
dbg_irq_level=irq;
@ -195,9 +195,9 @@ PICO_INTERNAL int SekInterrupt(int irq)
PICO_INTERNAL void SekState(int *data)
{
#ifdef EMU_C68K
memcpy32(data,PicoCpuCM68k.d,0x44/4);
memcpy32(data,(int *)PicoCpuCM68k.d,0x44/4);
#elif defined(EMU_M68K)
memcpy32(data, PicoCpuMM68k.dar, 0x40/4);
memcpy32(data, (int *)PicoCpuMM68k.dar, 0x40/4);
data[0x10] = PicoCpuMM68k.pc;
#elif defined(EMU_F68K)
memcpy32(data, (int *)PicoCpuFM68k.dreg, 0x40/4);

View file

@ -129,7 +129,7 @@ static void DmaSlow(int len)
pd=(u16 *)(prg_ram+(source&0x1fffe));
pdend=(u16 *)(prg_ram+0x20000);
} else {
elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow FIXME: unsupported src");
elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow[%i] %06x->%04x: FIXME: unsupported src", Pico.video.type, source, a);
return;
}
} else {
@ -137,7 +137,7 @@ static void DmaSlow(int len)
pd=(u16 *)(Pico.rom+(source&~1));
pdend=(u16 *)(Pico.rom+Pico.romsize);
} else {
elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow: invalid dma src");
elprintf(EL_VDPDMA|EL_ANOMALY, "DmaSlow[%i] %06x->%04x: invalid src", Pico.video.type, source, a);
return;
}
}
@ -374,29 +374,24 @@ PICO_INTERNAL_ASM void PicoVideoWrite(unsigned int a,unsigned short d)
//if(num==01) dprintf("set_blank: %i @ %06x [%i|%i]", !((d&0x40)>>6), SekPc, Pico.m.scanline, SekCyclesDone());
//if(num==10) dprintf("hint_set: %i @ %06x [%i|%i]", (unsigned char)d, SekPc, Pico.m.scanline, SekCyclesDone());
pvid->reg[num]=(unsigned char)d;
#if !(defined(EMU_C68K) && defined(EMU_M68K)) // not debugging Cyclone
#ifndef EMU_CORE_DEBUG
// update IRQ level (Lemmings, Wiz 'n' Liz intro, ... )
// may break if done improperly:
// International Superstar Soccer Deluxe (crash), Street Racer (logos), Burning Force (gfx),
// Fatal Rewind (hang), Sesame Street Counting Cafe
if(num < 2) {
#ifdef EMU_C68K
// hack: make sure we do not touch the irq line if Cyclone is just about to take the IRQ
if (PicoCpuCM68k.irq <= (PicoCpuCM68k.srh&7)) {
#endif
int lines, pints;
// Fatal Rewind (crash), Sesame Street Counting Cafe
if (num < 2)
{
if (!SekShouldInterrupt) // hack
{
int lines, pints, irq=0;
lines = (pvid->reg[1] & 0x20) | (pvid->reg[0] & 0x10);
pints = (pvid->pending_ints&lines);
if(pints & 0x20) SekInterrupt(6);
else if(pints & 0x10) SekInterrupt(4);
else SekInterrupt(0);
#ifdef EMU_C68K
// adjust cycles for Cyclone so it would take the int "in time"
if(PicoCpuCM68k.irq) {
SekEndRun(24);
}
if(pints & 0x20) irq = 6;
else if(pints & 0x10) irq = 4;
SekInterrupt(irq); // update line
if (irq) SekEndRun(24); // make it delayed
}
#endif
}
else
#endif

View file

@ -97,7 +97,7 @@ static __inline void SekRunM68k(int cyc)
SekCycleCnt+=m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext=&PicoCpuFM68k;
SekCycleCnt+=m68k_emulate(cyc_do);
SekCycleCnt+=fm68k_emulate(cyc_do);
#endif
}
@ -115,7 +115,7 @@ static __inline void SekRunS68k(int cyc)
SekCycleCntS68k+=m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext=&PicoCpuFS68k;
SekCycleCntS68k+=m68k_emulate(cyc_do);
SekCycleCntS68k+=fm68k_emulate(cyc_do);
#endif
}
@ -148,7 +148,7 @@ static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
SekCycleCnt += m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext = &PicoCpuFM68k;
SekCycleCnt += m68k_emulate(cyc_do);
SekCycleCnt += fm68k_emulate(cyc_do);
#endif
}
if ((cyc_do = SekCycleAimS68k-SekCycleCntS68k-cycn_s68k) > 0) {
@ -161,7 +161,7 @@ static __inline void SekRunPS(int cyc_m68k, int cyc_s68k)
SekCycleCntS68k += m68k_execute(cyc_do);
#elif defined(EMU_F68K)
g_m68kcontext = &PicoCpuFS68k;
SekCycleCntS68k += m68k_emulate(cyc_do);
SekCycleCntS68k += fm68k_emulate(cyc_do);
#endif
}
}

View file

@ -1,4 +1,4 @@
// (c) Copyright 2006 notaz, All rights reserved.
// (c) Copyright 2007 notaz, All rights reserved.
#include "../PicoInt.h"
@ -107,7 +107,7 @@ PICO_INTERNAL int SekInitS68k()
void *oldcontext = g_m68kcontext;
g_m68kcontext = &PicoCpuFS68k;
memset(&PicoCpuFS68k, 0, sizeof(PicoCpuFS68k));
m68k_init();
fm68k_init();
PicoCpuFS68k.iack_handler = SekIntAckFS68k;
g_m68kcontext = oldcontext;
}
@ -146,7 +146,7 @@ PICO_INTERNAL int SekResetS68k()
{
void *oldcontext = g_m68kcontext;
g_m68kcontext = &PicoCpuFS68k;
m68k_reset();
fm68k_reset();
g_m68kcontext = oldcontext;
}
#endif

View file

@ -444,7 +444,6 @@ PICO_INTERNAL void z80_pack(unsigned char *data)
#elif defined(_USE_CZ80)
*(int *)data = 0x00007a43; // "Cz"
memcpy(data+4, &CZ80, (INT32)&CZ80.BasePC - (INT32)&CZ80);
printf("size: %i (%x)\n", (INT32)&CZ80.BasePC - (INT32)&CZ80, (INT32)&CZ80.BasePC - (INT32)&CZ80); // FIXME rm
#endif
}