core, optimize vcounter handling

This commit is contained in:
kub 2023-07-17 21:16:38 +02:00
parent 7021622153
commit 46b4c1d322
3 changed files with 13 additions and 13 deletions

View file

@ -1367,7 +1367,7 @@ static unsigned char z80_md_vdp_read(unsigned short a)
case 0x04: return PicoVideoRead8CtlH(1);
case 0x05: return PicoVideoRead8CtlL(1);
case 0x08:
case 0x0c: return PicoVideoGetV(get_scanline(1));
case 0x0c: return PicoVideoGetV(get_scanline(1), 1);
case 0x09:
case 0x0d: return Pico.m.rotate++;
}

View file

@ -128,8 +128,7 @@ static void do_timing_hacks_start(struct PicoVideo *pv)
// XXX how to handle Z80 bus cycle stealing during DMA correctly?
if ((Pico.t.z80_buscycles -= cycles) < 0)
Pico.t.z80_buscycles = 0;
if (Pico.m.scanline&1)
Pico.t.m68c_aim += 1; // add cycle each other line for 488.5 cycles/line
Pico.t.m68c_aim += Pico.m.scanline&1; // add 1 every 2 lines for 488.5 cycles
}
static int PicoFrameHints(void)
@ -151,15 +150,14 @@ static int PicoFrameHints(void)
// === active display ===
pv->status |= PVS_ACTIVE;
for (y = 0;; y++)
for (y = 0; y < 240; y++)
{
Pico.m.scanline = y;
pv->v_counter = PicoVideoGetV(y);
lines_vis = (pv->reg[1] & 8) ? 240 : 224;
if (y == lines_vis)
if (y == 224 && !(pv->reg[1] & 8))
break;
Pico.m.scanline = y;
pv->v_counter = PicoVideoGetV(y, 0);
PAD_DELAY();
// H-Interrupts:
@ -170,7 +168,7 @@ static int PicoFrameHints(void)
}
// decide if we draw this line
if ((PicoIn.opt & POPT_ALT_RENDERER) && !skip)
if (unlikely(PicoIn.opt & POPT_ALT_RENDERER) && !skip)
{
// find the right moment for frame renderer, when display is no longer blanked
if ((pv->reg[1]&0x40) || y > 100) {
@ -213,6 +211,8 @@ static int PicoFrameHints(void)
lines_vis = (pv->reg[1] & 8) ? 240 : 224;
if (y == lines_vis)
pv->status &= ~PVS_ACTIVE;
Pico.m.scanline = y;
pv->v_counter = PicoVideoGetV(y, 0);
memcpy(PicoIn.padInt, PicoIn.pad, sizeof(PicoIn.padInt));
PAD_DELAY();
@ -267,7 +267,7 @@ static int PicoFrameHints(void)
for (y++; y < lines - 1; y++)
{
Pico.m.scanline = y;
pv->v_counter = PicoVideoGetV(y);
pv->v_counter = PicoVideoGetV(y, 1);
PAD_DELAY();

View file

@ -916,9 +916,9 @@ static __inline void VideoWriteVRAM(u32 a, u16 d)
UpdateSAT(a, d);
}
static __inline u8 PicoVideoGetV(int scanline)
static __inline u8 PicoVideoGetV(int scanline, int maywrap)
{
if (scanline >= Pico.t.vcnt_wrap) scanline -= Pico.t.vcnt_adj;
if (maywrap && scanline >= Pico.t.vcnt_wrap) scanline -= Pico.t.vcnt_adj;
if ((Pico.video.reg[12]&6) == 6) scanline = (scanline<<1) | 1;
return scanline;
}