From ca8ca040ad7fca42c2d36ba5640321c45d561059 Mon Sep 17 00:00:00 2001 From: Brandon Wright Date: Sun, 15 Sep 2019 16:03:06 -0500 Subject: [PATCH] win32: Add RF version of blargg NTSC filter. Also, add the burst phase to the blit function. --- win32/render.cpp | 29 ++++++++++++++++++++++++++--- win32/wsnes9x.h | 1 + 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/win32/render.cpp b/win32/render.cpp index 2a597a84..7c08c31e 100644 --- a/win32/render.cpp +++ b/win32/render.cpp @@ -52,6 +52,7 @@ void RenderSimple3X (SSurface Src, SSurface Dst, RECT *); void RenderSimple4X (SSurface Src, SSurface Dst, RECT *); void RenderTVMode3X (SSurface Src, SSurface Dst, RECT *); void RenderDotMatrix3X (SSurface Src, SSurface Dst, RECT *); +void RenderBlarggNTSCRF(SSurface Src, SSurface Dst, RECT *); void RenderBlarggNTSCComposite(SSurface Src, SSurface Dst, RECT *); void RenderBlarggNTSCSvideo(SSurface Src, SSurface Dst, RECT *); void RenderBlarggNTSCRgb(SSurface Src, SSurface Dst, RECT *); @@ -80,7 +81,13 @@ START_EXTERN_C uint8 snes9x_clear_change_log = 0; END_EXTERN_C -enum BlarggMode { UNINITIALIZED,BLARGGCOMPOSITE,BLARGGSVIDEO,BLARGGRGB }; +enum BlarggMode { + UNINITIALIZED, + BLARGGRF, + BLARGGCOMPOSITE, + BLARGGSVIDEO, + BLARGGRGB +}; snes_ntsc_t *ntsc = NULL; BlarggMode blarggMode = UNINITIALIZED; @@ -138,6 +145,7 @@ TRenderMethod FilterToMethod(RenderFilter filterID) case FILTER_LQ3XBOLD: return RenderLQ3XB; case FILTER_EPX3: return RenderEPX3; case FILTER_3XBRZ: return Render3xBRZ; + case FILTER_BLARGGRF: return RenderBlarggNTSCRF; case FILTER_BLARGGCOMP: return RenderBlarggNTSCComposite; case FILTER_BLARGGSVID: return RenderBlarggNTSCSvideo; case FILTER_BLARGGRGB: return RenderBlarggNTSCRgb; @@ -2696,6 +2704,17 @@ void RenderxBRZ(SSurface Src, SSurface Dst, RECT* rect, int scalingFactor) } /*#################### /XBRZ support ####################*/ +void RenderBlarggNTSCRF( SSurface Src, SSurface Dst, RECT *rect) +{ + if(blarggMode!=BLARGGRF) { + snes_ntsc_setup_t setup = snes_ntsc_composite; + setup.merge_fields = 0; + snes_ntsc_init( ntsc, &setup ); + blarggMode=BLARGGRF; + } + RenderBlarggNTSC(Src,Dst,rect); +} + void RenderBlarggNTSCComposite( SSurface Src, SSurface Dst, RECT *rect) { if(blarggMode!=BLARGGCOMPOSITE) { @@ -2734,6 +2753,8 @@ extern unsigned short snes_ntsc_scanline_mask; void RenderBlarggNTSC(SSurface Src, SSurface Dst, RECT *rect) { + static int burst_phase = 0; + SetRect(rect, 256, 239, 2); rect->right = SNES_NTSC_OUT_WIDTH(256); @@ -2748,8 +2769,10 @@ void RenderBlarggNTSC(SSurface Src, SSurface Dst, RECT *rect) snes_ntsc_scanline_mask = 0x18E3; } + burst_phase = (burst_phase + 1) % 3; + if (Src.Width == 512) - snes_ntsc_blit_hires_scanlines(ntsc, (unsigned short *)Src.Surface, srcRowPixels, 0, Src.Width, Src.Height, Dst.Surface, Dst.Pitch); + snes_ntsc_blit_hires_scanlines(ntsc, (unsigned short *)Src.Surface, srcRowPixels, burst_phase, Src.Width, Src.Height, Dst.Surface, Dst.Pitch); else - snes_ntsc_blit_scanlines(ntsc, (unsigned short *)Src.Surface, srcRowPixels, 0, Src.Width, Src.Height, Dst.Surface, Dst.Pitch); + snes_ntsc_blit_scanlines(ntsc, (unsigned short *)Src.Surface, srcRowPixels, burst_phase, Src.Width, Src.Height, Dst.Surface, Dst.Pitch); } diff --git a/win32/wsnes9x.h b/win32/wsnes9x.h index 1bc10364..cb09e3cf 100644 --- a/win32/wsnes9x.h +++ b/win32/wsnes9x.h @@ -65,6 +65,7 @@ enum RenderFilter{ FILTER_SIMPLE2X, FILTER_SCANLINES, FILTER_TVMODE, + FILTER_BLARGGRF, FILTER_BLARGGCOMP, FILTER_BLARGGSVID, FILTER_BLARGGRGB,