From: kub Date: Mon, 17 Jul 2023 19:16:38 +0000 (+0200) Subject: core, optimize vcounter handling X-Git-Tag: v2.00~187 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46b4c1d322d73783fbc3238941906d167cc16c87;p=picodrive.git core, optimize vcounter handling --- diff --git a/pico/memory.c b/pico/memory.c index 96a00744..818080fd 100644 --- a/pico/memory.c +++ b/pico/memory.c @@ -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++; } diff --git a/pico/pico_cmn.c b/pico/pico_cmn.c index a06573e1..3e5a038e 100644 --- a/pico/pico_cmn.c +++ b/pico/pico_cmn.c @@ -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(); diff --git a/pico/pico_int.h b/pico/pico_int.h index dc35426b..977e5cdb 100644 --- a/pico/pico_int.h +++ b/pico/pico_int.h @@ -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; }