//if ((a&0xe0ffff)==0xe0a9ba+0x69c)\r
// dprintf("w8 : %06x, %02x @%06x", a&0xffffff, d, SekPc);\r
\r
-\r
- if ((a&0xe00000)==0xe00000) {\r
- if((a&0xffff)==0xf62a) dprintf("(f62a) = %02x [%i|%i] @ %x", d, Pico.m.scanline, SekCyclesDone(), SekPc);\r
- u8 *pm=(u8 *)(Pico.ram+((a^1)&0xffff)); pm[0]=d; return; } // Ram\r
+ if ((a&0xe00000)==0xe00000) { *(u8 *)(Pico.ram+((a^1)&0xffff))=d; return; } // Ram\r
\r
a&=0xffffff;\r
OtherWrite8(a,d,8);\r
return;
}
if (a==0xa11100) {
- extern int z80startCycle, z80stopCycle;
//int lineCycles=(488-SekCyclesLeft)&0x1ff;
d&=1; d^=1;
if(!d) {
// this is for a nasty situation where Z80 was enabled and disabled in the same 68k timeslice (Golden Axe III)
if (Pico.m.z80Run) {
- int lineCycles=(488-SekCyclesLeft)&0x1ff;
+ int lineCycles;
z80stopCycle = SekCyclesDone();
- lineCycles=(lineCycles>>1)-(lineCycles>>5);
- z80_run(lineCycles);
+ if (Pico.m.z80Run&2)
+ lineCycles=(488-SekCyclesLeft)&0x1ff;
+ else lineCycles=z80stopCycle-z80startCycle; // z80 was started at current line
+ if (lineCycles > 0 && lineCycles <= 488) {
+ dprintf("zrun: %i/%i cycles", lineCycles, (lineCycles>>1)-(lineCycles>>5));
+ lineCycles=(lineCycles>>1)-(lineCycles>>5);
+ z80_run(lineCycles);
+ }
}
} else {
z80startCycle = SekCyclesDone();
getSamples(y);\r
\r
// Run scanline:\r
- if(Pico.m.dma_bytes) SekCycleCnt+=CheckDMA();\r
+ if (Pico.m.dma_bytes) SekCycleCnt+=CheckDMA();\r
SekRun(cycles_68k);\r
- if((PicoOpt&4) && Pico.m.z80Run) {\r
- Pico.m.z80Run|=2;\r
- z80CycleAim+=cycles_z80;\r
+ if ((PicoOpt&4) && Pico.m.z80Run) {\r
+ if (Pico.m.z80Run & 2) z80CycleAim+=cycles_z80;\r
+ else {\r
+ int cnt = SekCyclesDone() - z80startCycle;\r
+ cnt = (cnt>>1)-(cnt>>5);\r
+ //if (cnt > cycles_z80) printf("FIXME: z80 cycles: %i\n", cnt);\r
+ if (cnt > cycles_z80) cnt = cycles_z80;\r
+ Pico.m.z80Run |= 2;\r
+ z80CycleAim+=cnt;\r
+ }\r
total_z80+=z80_run(z80CycleAim-total_z80);\r
}\r
}\r
extern struct Pico Pico;\r
extern struct PicoSRAM SRam;\r
extern int emustatus;\r
+extern int z80startCycle, z80stopCycle; // in 68k cycles\r
int CheckDMA(void);\r
\r
// cd/Pico.c\r
}
if ((PicoOpt&4) && Pico.m.z80Run) {
- Pico.m.z80Run|=2;
- z80CycleAim+=cycles_z80;
+ if (Pico.m.z80Run & 2) z80CycleAim+=cycles_z80;
+ else {
+ int cnt = SekCyclesDone() - z80startCycle;
+ cnt = (cnt>>1)-(cnt>>5);
+ //if (cnt > cycles_z80) printf("FIXME: z80 cycles: %i\n", cnt);
+ if (cnt > cycles_z80) cnt = cycles_z80;
+ Pico.m.z80Run |= 2;
+ z80CycleAim+=cnt;
+ }
total_z80+=z80_run(z80CycleAim-total_z80);
}
m68ki_set_address_error_trap(); /* auto-disable (see m68kcpu.h) */\r
\r
/* Main loop. Keep going until we run out of clock cycles */\r
- while(GET_CYCLES() > 0)\r
+ while(GET_CYCLES() >= 0)\r
{\r
/* Set tracing accodring to T1. (T0 is done inside instruction) */\r
m68ki_trace_t1(); /* auto-disable (see m68kcpu.h) */\r