From 352479001c82fc5c9abbcc1501c6e78ddc691a14 Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 4 Aug 2020 22:24:56 +0200 Subject: [PATCH] vdp, optimisation for 8bit renderers --- pico/draw.c | 9 ++++++++- pico/mode4.c | 18 ++++++++---------- platform/gp2x/emu.c | 2 +- platform/linux/emu.c | 2 +- 4 files changed, 18 insertions(+), 13 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index 43bbea76..ed818546 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1582,7 +1582,10 @@ static void FinalizeLine8bit(int sh, int line, struct PicoEState *est) len = 256; } - if (!sh && (est->rendstatus & PDRAW_SONIC_MODE)) { + if (DrawLineDestBase == HighColBase) { + if (!sh && (est->rendstatus & PDRAW_SONIC_MODE)) + blockcpy_or(pd+8, est->HighCol+8, len, est->SonicPalCount*0x40); + } else if (!sh && (est->rendstatus & PDRAW_SONIC_MODE)) { // select active backup palette blockcpy_or(pd, est->HighCol+8, len, est->SonicPalCount*0x40); } else { @@ -1892,6 +1895,10 @@ void PicoDrawSetOutFormat(pdso_t which, int use_32x_line_mode) void PicoDrawSetOutBufMD(void *dest, int increment) { + if (FinalizeLine == FinalizeLine8bit && increment == 328) { + // kludge for no-copy mode + PicoDrawSetInternalBuf(dest, increment); + } if (dest != NULL) { DrawLineDestBase = dest; DrawLineDestIncrement = increment; diff --git a/pico/mode4.c b/pico/mode4.c index cb1e8e0c..fa4407b5 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -17,7 +17,7 @@ static void (*FinalizeLineM4)(int line); static int skip_next_line; -static int screen_offset; +static int screen_offset, line_offset; static void TileBGM4(int sx, int pal) { @@ -110,8 +110,7 @@ static void draw_sprites(int scanline) if (pv->reg[0] & 8) xoff = 0; - if (!FinalizeLineM4 && !(PicoIn.opt & POPT_DIS_32C_BORDER)) - xoff += 32; + xoff += line_offset; sat = (unsigned char *)PicoMem.vram + ((pv->reg[5] & 0x7e) << 7); if (pv->reg[1] & 2) { @@ -252,8 +251,7 @@ static void DrawDisplayM4(int scanline) if (dx != 8) cells++; // have hscroll, need to draw 1 cell more dx += cellskip << 3; - if (!FinalizeLineM4 && !(PicoIn.opt & POPT_DIS_32C_BORDER)) - dx += 32; + dx += line_offset; // low priority tiles if (!(pv->debug_p & PVD_KILL_B)) @@ -365,18 +363,18 @@ static void FinalizeLine8bitM4(int line) { unsigned char *pd = Pico.est.DrawLineDest; - if (!(PicoIn.opt & POPT_DIS_32C_BORDER)) - pd += 32; - - memcpy(pd, Pico.est.HighCol + 8, 256); + if (HighColBase != DrawLineDestBase) + memcpy(pd + line_offset, Pico.est.HighCol + line_offset + 8, 256); } void PicoDrawSetOutputMode4(pdso_t which) { + line_offset = PicoIn.opt & POPT_DIS_32C_BORDER ? 0 : 32; switch (which) { case PDF_8BIT: FinalizeLineM4 = FinalizeLine8bitM4; break; - case PDF_RGB555: FinalizeLineM4 = FinalizeLineRGB555M4; break; + case PDF_RGB555: FinalizeLineM4 = FinalizeLineRGB555M4; + line_offset = 0 /* done in FinalizeLine */; break; default: FinalizeLineM4 = NULL; PicoDrawSetInternalBuf(Pico.est.Draw2FB, 328); break; } diff --git a/platform/gp2x/emu.c b/platform/gp2x/emu.c index 1deb84da..42e34ee3 100644 --- a/platform/gp2x/emu.c +++ b/platform/gp2x/emu.c @@ -364,7 +364,7 @@ void pemu_finalize_frame(const char *fps, const char *notice) localPalSize = make_local_pal(1); // a hack for VR if (PicoIn.AHW & PAHW_SVP) - memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328); + memset32((int *)(Pico.est.Draw2FB+328*8+328*223), 0xe0e0e0e0, 328/4); // do actual copy vidcpyM2(g_screen_ptr, Pico.est.Draw2FB+328*8, !(Pico.video.reg[12] & 1), !(PicoIn.opt & POPT_DIS_32C_BORDER)); diff --git a/platform/linux/emu.c b/platform/linux/emu.c index 4ef08a79..8c86471d 100644 --- a/platform/linux/emu.c +++ b/platform/linux/emu.c @@ -107,7 +107,7 @@ static void apply_renderer(void) case RT_8BIT_ACC: PicoIn.opt &= ~POPT_ALT_RENDERER; PicoDrawSetOutFormat(PDF_8BIT, 0); - PicoDrawSetOutBuf(Pico.est.Draw2FB + 8, 328); + PicoDrawSetOutBuf(Pico.est.Draw2FB, 328); break; case RT_8BIT_FAST: PicoIn.opt |= POPT_ALT_RENDERER; -- 2.39.5