win32: Allow disabling of NTSC Filter Scanlines.

This commit is contained in:
Brandon Wright 2018-06-16 16:35:56 -05:00
parent 5fd4265440
commit c28a86dfd0
6 changed files with 34 additions and 15 deletions

View File

@ -2918,19 +2918,23 @@ void RenderBlarggNTSCRgb( SSurface Src, SSurface Dst, RECT *rect)
void RenderBlarggNTSC( SSurface Src, SSurface Dst, RECT *rect)
{
SetRect(rect, 256, 239, 2);
rect->right = SNES_NTSC_OUT_WIDTH(256);
SetRect(rect, 256, 239, 2);
rect->right = SNES_NTSC_OUT_WIDTH(256);
const unsigned int srcRowPixels = Src.Pitch/2;
const unsigned int srcRowPixels = Src.Pitch/2;
if(Src.Width == 512)
snes_ntsc_blit_hires( ntsc, (unsigned short *)Src.Surface, srcRowPixels, 0,Src.Width, Src.Height, Dst.Surface, Dst.Pitch );
else
snes_ntsc_blit( ntsc, (unsigned short *)Src.Surface, srcRowPixels, 0,Src.Width, Src.Height, Dst.Surface, Dst.Pitch );
if(Src.Width == 512)
snes_ntsc_blit_hires( ntsc, (unsigned short *)Src.Surface, srcRowPixels, 0,Src.Width, Src.Height, Dst.Surface, Dst.Pitch );
else
snes_ntsc_blit( ntsc, (unsigned short *)Src.Surface, srcRowPixels, 0,Src.Width, Src.Height, Dst.Surface, Dst.Pitch );
//Blargg's filter produces half-height output, so we have to double the height again (unless we have double height hi-res)
//Blargg's filter produces half-height output, so we have to double the height again (unless we have double height hi-res)
if(Src.Height <= SNES_HEIGHT_EXTENDED)
{
int mask = 0;
if (GUI.NTSCScanlines)
mask = 0x18E3;
int last_blargg_line = rect->bottom / 2;
memset(Dst.Surface + last_blargg_line * Dst.Pitch, 0, Dst.Pitch);
for(int y = last_blargg_line; --y >= 0; )
@ -2945,7 +2949,7 @@ void RenderBlarggNTSC( SSurface Src, SSurface Dst, RECT *rect)
unsigned mixed = prev + next + ((prev ^ next) & 0x0821);
/* darken by 12% */
*(unsigned short*)out = prev;
*(unsigned short*)(out + Dst.Pitch) = (mixed >> 1) - (mixed >> 4 & 0x18E3);
*(unsigned short*)(out + Dst.Pitch) = (mixed >> 1) - (mixed >> 4 & mask);
in += 2;
out += 2;
}

View File

@ -340,6 +340,7 @@
#define IDC_PLAYWARN 1257
#define IDC_REDUCEINPUTLAG 1258
#define IDC_INTEGERSCALING 1259
#define IDC_NTSCSCANLINES 1260
#define IDC_HOTKEY1 2000
#define IDC_HOTKEY2 2001
#define IDC_HOTKEY3 2002

View File

@ -190,9 +190,10 @@ BEGIN
CONTROL "",IDC_SPIN_MAX_SKIP_DISP_FIXED,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,169,158,11,13
COMBOBOX IDC_FILTERBOX,186,17,153,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
COMBOBOX IDC_FILTERBOX2,217,33,122,90,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
LTEXT "Resolution",IDC_CURRMODE,187,71,41,8
COMBOBOX IDC_RESOLUTION,234,69,105,95,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Enable Triple Buffering",IDC_DBLBUFFER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,86,87,10
CONTROL "NTSC Filter Scanlines", IDC_NTSCSCANLINES, "Button", BS_AUTOCHECKBOX | WS_TABSTOP, 186, 47, 85, 10
LTEXT "Resolution",IDC_CURRMODE,187,76,41,8
COMBOBOX IDC_RESOLUTION,234,74,105,95,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP
CONTROL "Enable Triple Buffering",IDC_DBLBUFFER,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,88,87,10
CONTROL "Transparency Effects",IDC_TRANS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,113,153,10
CONTROL "Hi Resolution Support",IDC_HIRES,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,124,85,10
CONTROL "Extend Height of SNES Image",IDC_HEIGHT_EXTEND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,146,111,10
@ -203,8 +204,8 @@ BEGIN
PUSHBUTTON "...",IDC_SHADER_HLSL_BROWSE,322,206,19,14,WS_DISABLED
GROUPBOX "Frame Skipping:",IDC_STATIC,7,132,167,46,0,WS_EX_TRANSPARENT
GROUPBOX "SNES Image",IDC_STATIC,180,103,166,79,0,WS_EX_TRANSPARENT
GROUPBOX "Output Image Processing",IDC_STATIC,179,7,166,46,0,WS_EX_TRANSPARENT
GROUPBOX "Fullscreen Display Settings",IDC_STATIC,179,56,166,44,0,WS_EX_TRANSPARENT
GROUPBOX "Output Image Processing",IDC_STATIC,179,7,166,53,0,WS_EX_TRANSPARENT
GROUPBOX "Fullscreen Display Settings",IDC_STATIC,179,63,166,39,0,WS_EX_TRANSPARENT
LTEXT "Hi Res:",IDC_HIRESLABEL,186,36,31,8
GROUPBOX "General",IDC_STATIC,7,7,167,123,0,WS_EX_TRANSPARENT
LTEXT "Max skipped frames:",IDC_STATIC,62,145,67,8

View File

@ -901,6 +901,7 @@ void WinRegisterConfigItems()
AddUIntC("FilterType", GUI.Scale, 0, filterString);
AddUIntC("FilterHiRes", GUI.ScaleHiRes, 0, filterString2);
AddBoolC("BlendHiRes", GUI.BlendHiRes, true, "true to horizontally blend Hi-Res images (better transparency effect on filters that do not account for this)");
AddBoolC("NTSCScanlines", GUI.NTSCScanlines, true, "true to use scanlines with Blargg's NTSC filters");
AddBoolC("ShaderEnabled", GUI.shaderEnabled, false, "true to use pixel shader (if supported by output method)");
AddStringC("Direct3D:D3DShader", GUI.D3DshaderFileName, MAX_PATH, "", "shader filename for Direct3D mode (HLSL effect file or CG shader");
AddStringC("OpenGL:OGLShader", GUI.OGLshaderFileName, MAX_PATH, "", "shader filename for OpenGL mode (bsnes-style XML shader or CG shader)");

View File

@ -7401,7 +7401,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
// temporary GUI state for restoring after previewing while selecting options
static int prevScale, prevScaleHiRes, prevPPL;
static bool prevStretch, prevAspectRatio, prevHeightExtend, prevAutoDisplayMessages, prevBilinearFilter, prevShaderEnabled, prevBlendHires, prevIntegerScaling;
static bool prevStretch, prevAspectRatio, prevHeightExtend, prevAutoDisplayMessages, prevBilinearFilter, prevShaderEnabled, prevBlendHires, prevIntegerScaling, prevNTSCScanlines;
static int prevAspectWidth;
static OutputMethod prevOutputMethod;
static TCHAR prevD3DShaderFile[MAX_PATH],prevOGLShaderFile[MAX_PATH];
@ -7436,6 +7436,8 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
prevAutoDisplayMessages = Settings.AutoDisplayMessages != 0;
prevShaderEnabled = GUI.shaderEnabled;
prevBlendHires = GUI.BlendHiRes;
prevNTSCScanlines = GUI.NTSCScanlines;
lstrcpy(prevD3DShaderFile, GUI.D3DshaderFileName);
lstrcpy(prevOGLShaderFile, GUI.OGLshaderFileName);
@ -7449,6 +7451,8 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
SendDlgItemMessage(hDlg, IDC_VSYNC, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
if (GUI.ReduceInputLag)
SendDlgItemMessage(hDlg, IDC_REDUCEINPUTLAG, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
if (GUI.NTSCScanlines)
SendDlgItemMessage(hDlg, IDC_NTSCSCANLINES, BM_SETCHECK, (WPARAM)BST_CHECKED, 0);
SendDlgItemMessage(hDlg, IDC_FRAMERATESKIPSLIDER, TBM_SETRANGE, (WPARAM)true, (LPARAM)MAKELONG(0, 9));
if (Settings.SkipFrames != AUTO_FRAMERATE)
SendDlgItemMessage(hDlg, IDC_FRAMERATESKIPSLIDER, TBM_SETPOS, (WPARAM)true, (LPARAM)Settings.SkipFrames);
@ -7671,6 +7675,12 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam)
WinRefreshDisplay();
break;
case IDC_NTSCSCANLINES:
GUI.NTSCScanlines = (bool)(IsDlgButtonChecked(hDlg, IDC_NTSCSCANLINES) == BST_CHECKED);
WinDisplayApplyChanges();
WinRefreshDisplay();
break;
case IDC_HIRESBLEND:
GUI.BlendHiRes = (bool)(IsDlgButtonChecked(hDlg,IDC_HIRESBLEND)==BST_CHECKED);
WinRefreshDisplay();
@ -7962,6 +7972,7 @@ updateFilterBox2:
GUI.HeightExtend = prevHeightExtend;
GUI.shaderEnabled = prevShaderEnabled;
GUI.BlendHiRes = prevBlendHires;
GUI.NTSCScanlines = prevNTSCScanlines;
lstrcpy(GUI.D3DshaderFileName,prevD3DShaderFile);
lstrcpy(GUI.OGLshaderFileName,prevOGLShaderFile);
}

View File

@ -359,6 +359,7 @@ struct sGUI {
HACCEL Accelerators;
bool NeedDepthConvert;
bool DepthConverted;
bool NTSCScanlines;
bool InactivePause;
bool CustomRomOpen;