From b061bc166c023265a484e243eeff58735eab8bbb Mon Sep 17 00:00:00 2001 From: kub Date: Tue, 7 Apr 2020 20:47:38 +0200 Subject: [PATCH] vdp rendering, sprite caching optimization --- pico/draw.c | 12 ++++++++---- pico/draw_arm.S | 2 +- pico/pico.h | 5 +++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index 68af73e2..82bb3462 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1601,7 +1601,6 @@ static int DrawDisplay(int sh) int win=0, edge=0, hvwind=0, lflags; int maxw, maxcells; - est->rendstatus &= ~(PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES); est->rendstatus &= ~(PDRAW_SHHI_DONE|PDRAW_PLANE_HI_PRIO); if (pvid->reg[12]&1) { @@ -1713,6 +1712,7 @@ PICO_INTERNAL void PicoFrameStart(void) { int offs = 8, lines = 224; int dirty = ((Pico.est.rendstatus & PDRAW_SONIC_MODE) || Pico.m.dirtyPal); + int sprep = Pico.est.rendstatus & (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES); // prepare to do this frame Pico.est.rendstatus = 0; @@ -1732,6 +1732,8 @@ PICO_INTERNAL void PicoFrameStart(void) lines, (Pico.video.reg[12] & 1) ? 0 : 1); rendstatus_old = Pico.est.rendstatus; } + if (sprep) + Pico.est.rendstatus |= PDRAW_PARSE_SPRITES; Pico.est.HighCol = HighColBase + offs * HighColIncrement; Pico.est.DrawLineDest = (char *)DrawLineDestBase + offs * DrawLineDestIncrement; @@ -1804,6 +1806,7 @@ static void PicoLine(int line, int offs, int sh, int bgc) void PicoDrawSync(int to, int blank_last_line) { + struct PicoEState *est = &Pico.est; int line, offs = 0; int sh = (Pico.video.reg[0xC] & 8) >> 3; // shadow/hilight? int bgc = Pico.video.reg[7]; @@ -1815,10 +1818,11 @@ void PicoDrawSync(int to, int blank_last_line) if (to > 223) to = 223; } - if (Pico.est.DrawScanline <= to - blank_last_line) + if (est->DrawScanline <= to - blank_last_line && (est->rendstatus & + (PDRAW_SPRITES_MOVED|PDRAW_DIRTY_SPRITES|PDRAW_PARSE_SPRITES))) PrepareSprites(to - blank_last_line + 1); - for (line = Pico.est.DrawScanline; line < to; line++) + for (line = est->DrawScanline; line < to; line++) PicoLine(line, offs, sh, bgc); // last line @@ -1829,7 +1833,7 @@ void PicoDrawSync(int to, int blank_last_line) else PicoLine(line, offs, sh, bgc); line++; } - Pico.est.DrawScanline = line; + est->DrawScanline = line; pprof_end(draw); } diff --git a/pico/draw_arm.S b/pico/draw_arm.S index 2ae6dba6..9b5a4e32 100644 --- a/pico/draw_arm.S +++ b/pico/draw_arm.S @@ -14,7 +14,7 @@ .equ PDRAW_SPRITES_MOVED, (1<<0) .equ PDRAW_WND_DIFF_PRIO, (1<<1) -.equ PDRAW_ACC_SPRITES, (1<<2) +.equ PDRAW_PARSE_SPRITES, (1<<2) .equ PDRAW_DIRTY_SPRITES, (1<<4) .equ PDRAW_PLANE_HI_PRIO, (1<<6) .equ PDRAW_SHHI_DONE, (1<<7) diff --git a/pico/pico.h b/pico/pico.h index 1a60ce34..efc30e5f 100644 --- a/pico/pico.h +++ b/pico/pico.h @@ -196,10 +196,11 @@ void vidConvCpyRGB565(void *to, void *from, int pixels); #endif void PicoDoHighPal555(int sh, int line, struct PicoEState *est); // internals -#define PDRAW_SPRITES_MOVED (1<<0) // (asm) +#define PDRAW_SPRITES_MOVED (1<<0) // SAT address modified #define PDRAW_WND_DIFF_PRIO (1<<1) // not all window tiles use same priority +#define PDRAW_PARSE_SPRITES (1<<2) // SAT needs parsing #define PDRAW_INTERLACE (1<<3) -#define PDRAW_DIRTY_SPRITES (1<<4) // (asm) +#define PDRAW_DIRTY_SPRITES (1<<4) // SAT modified #define PDRAW_SONIC_MODE (1<<5) // mid-frame palette changes for 8bit renderer #define PDRAW_PLANE_HI_PRIO (1<<6) // have layer with all hi prio tiles (mk3) #define PDRAW_SHHI_DONE (1<<7) // layer sh/hi already processed -- 2.39.5