From c180662e07d428ca4c2c9a39fdb152d4fcacc6dd Mon Sep 17 00:00:00 2001 From: kub Date: Sun, 3 Dec 2023 17:46:59 +0100 Subject: [PATCH] sms, improve changing of video mode --- pico/draw.c | 2 +- pico/mode4.c | 27 +++++++++++++++------------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/pico/draw.c b/pico/draw.c index f6a710c5..66b4fca5 100644 --- a/pico/draw.c +++ b/pico/draw.c @@ -1943,7 +1943,7 @@ PICO_INTERNAL void PicoFrameStart(void) if (est->rendstatus != rendstatus_old || lines != rendlines) { rendlines = lines; - // mode_change() might reset rendstatus_old by calling SetColorFormat + // mode_change() might reset rendstatus_old by calling SetOutFormat int rendstatus = est->rendstatus; emu_video_mode_change(loffs, lines, coffs, columns); rendstatus_old = rendstatus; diff --git a/pico/mode4.c b/pico/mode4.c index b56cf442..78108ec0 100644 --- a/pico/mode4.c +++ b/pico/mode4.c @@ -728,11 +728,12 @@ static void FinalizeLine8bitSMS(int line); void PicoFrameStartSMS(void) { + struct PicoEState *est = &Pico.est; int lines = 192, columns = 256, loffs, coffs; skip_next_line = 0; loffs = screen_offset = 24; // 192 lines is really 224 with top/bottom bars - Pico.est.rendstatus = PDRAW_32_COLS; + est->rendstatus = PDRAW_32_COLS; // if mode changes make palette dirty since some modes switch to a fixed one if (mode != ((Pico.video.reg[0]&0x06) | (Pico.video.reg[1]&0x18))) { @@ -753,14 +754,14 @@ void PicoFrameStartSMS(void) } else { if ((mode & 4) && (Pico.video.reg[0] & 0x20)) { // SMS mode 4 with 1st column blanked - Pico.est.rendstatus |= PDRAW_SMS_BLANK_1; + est->rendstatus |= PDRAW_SMS_BLANK_1; columns = 248; } switch (mode) { // SMS2 only 224/240 line modes, e.g. Micro Machines case 0x06|0x08: - Pico.est.rendstatus |= PDRAW_30_ROWS; + est->rendstatus |= PDRAW_30_ROWS; loffs = screen_offset = 0; lines = 240; break; @@ -776,32 +777,34 @@ void PicoFrameStartSMS(void) coffs = (FinalizeLineSMS == NULL && columns == 248 ? 8 : 0); if (FinalizeLineSMS != NULL && (PicoIn.opt & POPT_EN_SOFTSCALE)) { // softscaling always generates 320px, but no scaling in 8bit fast - Pico.est.rendstatus |= PDRAW_SOFTSCALE; + est->rendstatus |= PDRAW_SOFTSCALE; coffs = 0; columns = 320; } else if (!(PicoIn.opt & POPT_DIS_32C_BORDER)) { - Pico.est.rendstatus |= PDRAW_BORDER_32; + est->rendstatus |= PDRAW_BORDER_32; line_offset -= coffs; coffs = (320-columns) / 2; if (FinalizeLineSMS == NULL) line_offset += coffs; // ... else centering done in FinalizeLine } - if (Pico.est.rendstatus != rendstatus_old || lines != rendlines) { + if (est->rendstatus != rendstatus_old || lines != rendlines) { + // mode_change() might reset rendstatus_old by calling SetOutFormat + int rendstatus = est->rendstatus; emu_video_mode_change(loffs, lines, coffs, columns); - rendstatus_old = Pico.est.rendstatus; + rendstatus_old = rendstatus; rendlines = lines; sprites = 0; } - Pico.est.HighCol = HighColBase + screen_offset * HighColIncrement; - Pico.est.DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement; + est->HighCol = HighColBase + screen_offset * HighColIncrement; + est->DrawLineDest = (char *)DrawLineDestBase + screen_offset * DrawLineDestIncrement; if (FinalizeLineSMS == FinalizeLine8bitSMS) { - Pico.m.dirtyPal = (Pico.m.dirtyPal || Pico.est.SonicPalCount ? 2 : 0); - memcpy(Pico.est.SonicPal, PicoMem.cram, 0x40*2); + Pico.m.dirtyPal = (Pico.m.dirtyPal || est->SonicPalCount ? 2 : 0); + memcpy(est->SonicPal, PicoMem.cram, 0x40*2); } - Pico.est.SonicPalCount = 0; + est->SonicPalCount = 0; } void PicoParseSATSMS(int line) -- 2.39.5