out = data_reg & ctrl_reg;\r
\r
// pull-ups: should be 0x7f, but Decap Attack has a bug where it temp.\r
- // disables output before doing TH-low read, so don't emulate it for TH.\r
+ // disables output before doing TH-low read, so emulate RC filter for TH.\r
// Decap Attack reportedly doesn't work on Nomad but works on must\r
// other MD revisions (different pull-up strength?).\r
u32 mask = 0x3f;\r
return 0;\r
}\r
\r
- if ((a & 0x4000) == 0x0000)\r
+ if ((a & 0x4000) == 0x0000) {\r
+ SekCyclesBurnRun(1);\r
d = PicoMem.zram[a & 0x1fff];\r
- else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff\r
+ } else if ((a & 0x6000) == 0x4000) // 0x4000-0x5fff\r
d = ym2612_read_local_68k(); \r
else\r
elprintf(EL_UIO|EL_ANOMALY, "68k bad read [%06x] @%06x", a, SekPc);\r
}\r
\r
if ((a & 0x4000) == 0x0000) { // z80 RAM\r
+ SekCyclesBurnRun(1);\r
PicoMem.zram[a & 0x1fff] = (u8)d;\r
return;\r
}\r
\r
static unsigned char z80_md_vdp_read(unsigned short a)\r
{\r
- z80_subCLeft(2);\r
+ if ((a & 0xff00) == 0x7f00) {\r
+ z80_subCLeft(3);\r
+ Pico.t.z80_buscycles += 7;\r
\r
- if ((a & 0x00f0) == 0x0000) {\r
switch (a & 0x0d)\r
{\r
case 0x00: return PicoVideoRead8DataH(1);\r
PsndReset(); // pal must be known here\r
\r
// create an empty "dma" to cause 68k exec start at random frame location\r
- Pico.t.m68c_line_start = Pico.t.m68c_cnt;\r
+ Pico.t.m68c_line_start = Pico.t.m68c_aim;\r
PicoVideoFIFOWrite(rand() & 0x1fff, 0, 0, PVS_CPURD);\r
\r
SekFinishIdleDet();\r
while ((cyc_do = Pico.t.m68c_aim - Pico.t.m68c_cnt) > 0) {
// the Z80 CPU is stealing some bus cycles from the 68K main CPU when
- // accessing the 68K RAM or ROM. Account for these by shortening the time
+ // accessing the main bus. Account for these by shortening the time
// the 68K CPU runs.
- int z80_buscyc = Pico.t.z80_buscycles;
+ int z80_buscyc = Pico.t.z80_buscycles >> (~Pico.m.scanline & 1);
if (z80_buscyc <= cyc_do)
SekExecM68k(cyc_do - z80_buscyc);
else
static __inline void SekRunM68k(int cyc)
{
+ // refresh slowdown handling, 2 cycles every 128 - make this 1 every 64
+ // NB must be quite accurate, so handle fractions as well (c/f OutRunners)
+ static int refresh;
+ Pico.t.m68c_cnt += (cyc + refresh) >> 6;
+ refresh = (cyc + refresh) & 0x3f;
Pico.t.m68c_aim += cyc;
- Pico.t.m68c_cnt += cyc >> 6; // refresh slowdowns
SekSyncM68k();
}
PicoVideoFIFOSync(CYCLES_M68K_LINE);
// need rather tight Z80 sync for emulation of main bus cycle stealing
- if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80) && (Pico.m.scanline&1))
- PicoSyncZ80(Pico.t.m68c_aim);
+ if (Pico.m.scanline&1) {
+ if (Pico.m.z80Run && !Pico.m.z80_reset && (PicoIn.opt&POPT_EN_Z80))
+ PicoSyncZ80(Pico.t.m68c_aim);
+ }
}
static void do_timing_hacks_start(struct PicoVideo *pv)