From b38c0ea6f9d61f529eb6ca0b34c2587232300660 Mon Sep 17 00:00:00 2001 From: kub Date: Wed, 14 Feb 2024 23:36:43 +0100 Subject: [PATCH] core, fix some bugs reported by ASAN --- pico/draw.c | 11 +++++------ pico/videoport.c | 2 +- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index d47240cf..1b4ceb3c 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -2095,17 +2095,16 @@ static void PicoLine(int line, int offs, int sh, int bgc, int off, int on) void PicoDrawSync(int to, int off, int on) { struct PicoEState *est = &Pico.est; - int line, offs = 0; + int line, offs; int sh = (est->Pico->video.reg[0xC] & 8) >> 3; // shadow/hilight? int bgc = est->Pico->video.reg[7] & 0x3f; pprof_start(draw); - if (rendlines != 240) { - offs = 8; - if (to > 223) - to = 223; - } + offs = (240-rendlines) >> 1; + if (to >= rendlines) + to = rendlines-1; + if (est->DrawScanline <= to && (est->rendstatus & (PDRAW_DIRTY_SPRITES|PDRAW_PARSE_SPRITES))) ParseSprites(to + 1, on); diff --git a/pico/videoport.c b/pico/videoport.c index 503e0eb3..73c90edb 100644 --- a/pico/videoport.c +++ b/pico/videoport.c @@ -397,7 +397,7 @@ int PicoVideoFIFOHint(void) // reset slot to start of scanline vf->fifo_slot = 0; // only need to refresh sprite position if we are synced - if (Pico.est.DrawScanline == Pico.m.scanline) + if (Pico.est.DrawScanline == Pico.m.scanline && !(pv->status & SR_VB)) PicoDrawRefreshSprites(); // if CPU is waiting for the bus, advance CPU and FIFO until bus is free -- 2.39.5