diff --git a/win32/render.cpp b/win32/render.cpp index b7e64ce2..97c68bb9 100644 --- a/win32/render.cpp +++ b/win32/render.cpp @@ -549,6 +549,34 @@ inline void SetRect(RECT* rect, int width, int height, int scale) rect->bottom = (height - (GUI.HeightExtend?0:15)) * scale; } +#define AVERAGE_565(el0, el1) (((el0) & (el1)) + ((((el0) ^ (el1)) & 0xF7DE) >> 1)) +void RenderMergeHires(void *buffer, int pitch, unsigned int &width, unsigned int &height) +{ + if (width <= 256) + return; + + for (register int y = 0; y < height; y++) + { + register uint16 *input = (uint16 *) ((uint8 *) buffer + y * pitch); + register uint16 *output = input; + register uint16 l, r; + + l = 0; + for (register int x = 0; x < (width >> 1); x++) + { + r = *input++; + *output++ = AVERAGE_565 (l, r); + l = r; + + r = *input++; + *output++ = AVERAGE_565 (l, r); + l = r; + } + } + + return; +} + // No enlargement, just render to the screen void RenderPlain (SSurface Src, SSurface Dst, RECT *rect) @@ -600,14 +628,14 @@ void RenderForced1X( SSurface Src, SSurface Dst, RECT *rect) memcpy (lpDst, lpSrc, Src.Width << 1); else for (H = 0; H < srcHeight; H++, lpDst += dstPitch, lpSrc += srcPitch) - HalfLine16 (lpDst, lpSrc, Src.Width); + HalfLine16 (lpDst, lpSrc, Src.Width >> 1); else if(Src.Width != 512) for (H = 0; H != Src.Height; H+=2, lpDst += dstPitch, lpSrc += srcPitch<<1) memcpy (lpDst, lpSrc, Src.Width << 1); else for (H = 0; H < Src.Height >> 1; H++, lpDst += dstPitch, lpSrc += srcPitch<<1) - HalfLine16 (lpDst, lpSrc, Src.Width); + HalfLine16 (lpDst, lpSrc, Src.Width >> 1); } else if(GUI.ScreenDepth == 32) { @@ -619,14 +647,14 @@ void RenderForced1X( SSurface Src, SSurface Dst, RECT *rect) SingleLine32 (lpDst, lpSrc, Src.Width); else for (H = 0; H < srcHeight; H++, lpDst += dstPitch, lpSrc += srcPitch) - HalfLine32 (lpDst, lpSrc, Src.Width); + HalfLine32 (lpDst, lpSrc, Src.Width >> 1); else if(Src.Width != 512) for (H = 0; H != Src.Height; H+=2, lpDst += dstPitch, lpSrc += srcPitch<<1) SingleLine32 (lpDst, lpSrc, Src.Width); else for (H = 0; H < Src.Height >> 1; H++, lpDst += dstPitch, lpSrc += srcPitch<<1) - HalfLine32 (lpDst, lpSrc, Src.Width); + HalfLine32 (lpDst, lpSrc, Src.Width >> 1); } } diff --git a/win32/render.h b/win32/render.h index 2ad453df..b80cdcd3 100644 --- a/win32/render.h +++ b/win32/render.h @@ -195,8 +195,9 @@ typedef void (*TRenderMethod)( SSurface Src, SSurface Dst, RECT *); void SelectRenderMethod(); void InitLUTsWin32(); +void RenderMergeHires(void *buffer, int pitch, unsigned int &width, unsigned int &height); extern TRenderMethod RenderMethod; extern TRenderMethod RenderMethodHiRes; -#endif \ No newline at end of file +#endif diff --git a/win32/rsrc/resource.h b/win32/rsrc/resource.h index d6603e0d..113860f4 100644 --- a/win32/rsrc/resource.h +++ b/win32/rsrc/resource.h @@ -129,6 +129,8 @@ #define IDC_TRANS 1113 #define IDC_HIRES 1114 #define IDC_CHEAT_CODE 1115 +#define IDC_HIRES2 1115 +#define IDC_HIRESBLEND 1115 #define IDC_FILTERBOX 1116 #define IDC_FILTERBOX2 1117 #define IDC_AUTOFRAME 1118 @@ -397,7 +399,7 @@ #define ID_OPTIONS_EMULATION 40069 #define ID_OPTIONS_SETTINGS 40070 #define ID_DEBUG_TRACE 40071 -#define ID_FRAME_ADVANCE 40074 +#define ID_FRAME_ADVANCE 40074 #define ID_DEBUG_FRAME_ADVANCE 40075 #define ID_DEBUG_SNES_STATUS 40076 #define ID_NETPLAY_SERVER 40077 diff --git a/win32/rsrc/snes9x.rc b/win32/rsrc/snes9x.rc index 7d744f39..9c9fbc4a 100644 --- a/win32/rsrc/snes9x.rc +++ b/win32/rsrc/snes9x.rc @@ -173,13 +173,13 @@ BEGIN CONTROL "Sync By Reset",IDC_SYNCBYRESET,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,10,90,174,15 END -IDD_NEWDISPLAY DIALOGEX 0, 0, 353, 259 +IDD_NEWDISPLAY DIALOGEX 0, 0, 353, 274 STYLE DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_CLIPCHILDREN | WS_CAPTION CAPTION "Display Settings" FONT 8, "MS Sans Serif", 0, 0, 0x1 BEGIN - DEFPUSHBUTTON "OK",IDOK,239,237,50,14 - PUSHBUTTON "Cancel",IDCANCEL,296,237,50,14 + DEFPUSHBUTTON "OK",IDOK,239,251,50,14 + PUSHBUTTON "Cancel",IDCANCEL,296,251,50,14 COMBOBOX IDC_OUTPUTMETHOD,68,17,101,58,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Fullscreen",IDC_FULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,36,48,10 CONTROL "Emulate Fullscreen",IDC_EMUFULLSCREEN,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,47,75,10 @@ -188,40 +188,41 @@ BEGIN COMBOBOX IDC_ASPECTDROP,104,67,63,41,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP CONTROL "Bilinear Filtering",IDC_BILINEAR,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,80,75,8 CONTROL "Show Frame Rate",IDC_SHOWFPS,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,91,73,8 - CONTROL "Automatic",IDC_AUTOFRAME,"Button",BS_AUTORADIOBUTTON,11,126,43,8 - CONTROL "Fixed",IDC_FIXEDSKIP,"Button",BS_AUTORADIOBUTTON,11,143,43,10 - EDITTEXT IDC_MAXSKIP,133,125,35,14,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN_MAX_SKIP_DISP,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,169,127,11,13 - EDITTEXT IDC_SKIPCOUNT,133,142,35,14,ES_AUTOHSCROLL | ES_NUMBER - CONTROL "",IDC_SPIN_MAX_SKIP_DISP_FIXED,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,169,139,11,13 + CONTROL "Automatic",IDC_AUTOFRAME,"Button",BS_AUTORADIOBUTTON,11,140,43,8 + CONTROL "Fixed",IDC_FIXEDSKIP,"Button",BS_AUTORADIOBUTTON,11,157,43,10 + EDITTEXT IDC_MAXSKIP,133,139,35,14,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN_MAX_SKIP_DISP,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,169,141,11,13 + EDITTEXT IDC_SKIPCOUNT,133,156,35,14,ES_AUTOHSCROLL | ES_NUMBER + CONTROL "",IDC_SPIN_MAX_SKIP_DISP_FIXED,"msctls_updown32",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS,169,153,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 "VSync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,300,86,37,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,135,111,10 + CONTROL "Extend Height of SNES Image",IDC_HEIGHT_EXTEND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,147,111,10 CONTROL "Display messages before applying filters",IDC_MESSAGES_IN_IMAGE, - "Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,146,140,10 - GROUPBOX "",IDC_SHADER_GROUP,8,162,338,71,0,WS_EX_TRANSPARENT - EDITTEXT IDC_SHADER_HLSL_FILE,13,184,306,14,ES_AUTOHSCROLL | WS_DISABLED - PUSHBUTTON "...",IDC_SHADER_HLSL_BROWSE,322,184,19,14,WS_DISABLED - GROUPBOX "Frame Skipping:",IDC_STATIC,7,113,167,46,0,WS_EX_TRANSPARENT - GROUPBOX "SNES Image",IDC_STATIC,180,103,166,57,0,WS_EX_TRANSPARENT + "Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,158,140,10 + GROUPBOX "",IDC_SHADER_GROUP,8,176,338,71,0,WS_EX_TRANSPARENT + EDITTEXT IDC_SHADER_HLSL_FILE,13,198,306,14,ES_AUTOHSCROLL | WS_DISABLED + PUSHBUTTON "...",IDC_SHADER_HLSL_BROWSE,322,198,19,14,WS_DISABLED + GROUPBOX "Frame Skipping:",IDC_STATIC,7,127,167,46,0,WS_EX_TRANSPARENT + GROUPBOX "SNES Image",IDC_STATIC,180,103,166,71,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 LTEXT "Hi Res:",IDC_HIRESLABEL,186,36,31,8 - GROUPBOX "General",IDC_STATIC,7,7,167,99,0,WS_EX_TRANSPARENT - LTEXT "Max skipped frames:",IDC_STATIC,62,126,67,8 - LTEXT "Amount skipped:",IDC_STATIC,62,144,67,8 + GROUPBOX "General",IDC_STATIC,7,7,167,113,0,WS_EX_TRANSPARENT + LTEXT "Max skipped frames:",IDC_STATIC,62,140,67,8 + LTEXT "Amount skipped:",IDC_STATIC,62,158,67,8 LTEXT "Output Method",IDC_STATIC,10,19,51,11 - CONTROL "Use Shader",IDC_SHADER_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,162,52,9 - LTEXT "HLSL Effect File",IDC_STATIC,13,173,104,8 - EDITTEXT IDC_SHADER_GLSL_FILE,13,213,306,14,ES_AUTOHSCROLL | WS_DISABLED - PUSHBUTTON "...",IDC_SHADER_GLSL_BROWSE,322,213,19,14,WS_DISABLED - LTEXT "GLSL shader",IDC_STATIC,13,202,104,8 + CONTROL "Use Shader",IDC_SHADER_ENABLED,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,176,52,9 + LTEXT "HLSL Effect File",IDC_STATIC,13,187,104,8 + EDITTEXT IDC_SHADER_GLSL_FILE,13,227,306,14,ES_AUTOHSCROLL | WS_DISABLED + PUSHBUTTON "...",IDC_SHADER_GLSL_BROWSE,322,227,19,14,WS_DISABLED + LTEXT "GLSL shader",IDC_STATIC,13,216,104,8 + CONTROL "Blend Hi-Res Images",IDC_HIRESBLEND,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,187,136,82,10 + CONTROL "VSync",IDC_VSYNC,"Button",BS_AUTOCHECKBOX | WS_TABSTOP,11,102,37,10 END IDD_CHEATER DIALOGEX 0, 0, 262, 218 @@ -603,7 +604,7 @@ BEGIN LEFTMARGIN, 7 RIGHTMARGIN, 346 TOPMARGIN, 7 - BOTTOMMARGIN, 251 + BOTTOMMARGIN, 266 END IDD_CHEATER, DIALOG diff --git a/win32/snes9xw.vcproj b/win32/snes9xw.vcproj index aab13ada..0fd8c850 100644 --- a/win32/snes9xw.vcproj +++ b/win32/snes9xw.vcproj @@ -597,7 +597,7 @@ RandomizedBaseAddress="1" DataExecutionPrevention="0" TargetMachine="17" - Profile="true" + Profile="false" /> Render(Src); + GUI.FlipCounter++; + } } void WinChangeWindowSize(unsigned int newWidth, unsigned int newHeight) @@ -329,9 +334,7 @@ bool8 S9xInitUpdate (void) bool8 S9xContinueUpdate(int Width, int Height) { // called every other frame during interlace - - SSurface Src; - + Src.Width = Width; if(Height%SNES_HEIGHT) Src.Height = Height; @@ -344,10 +347,8 @@ bool8 S9xContinueUpdate(int Width, int Height) Src.Pitch = GFX.Pitch; Src.Surface = (BYTE*)GFX.Screen; - Height = Src.Height; - // avi writing - DoAVIVideoFrame(&Src, Width, Height); + DoAVIVideoFrame(&Src); return true; } @@ -355,8 +356,6 @@ bool8 S9xContinueUpdate(int Width, int Height) // do the actual rendering of a frame bool8 S9xDeinitUpdate (int Width, int Height) { - SSurface Src; - Src.Width = Width; if(Height%SNES_HEIGHT) Src.Height = Height; @@ -372,10 +371,12 @@ bool8 S9xDeinitUpdate (int Width, int Height) const int OrigHeight = Height; Height = Src.Height; - // avi writing - DoAVIVideoFrame(&Src, Width, Height); + if(GUI.BlendHiRes) { + RenderMergeHires(Src.Surface,Src.Pitch,Src.Width,Src.Height); + } - SelectRenderMethod (); + // avi writing + DoAVIVideoFrame(&Src); // Clear some of the old SNES rendered image // when the resolution becomes lower in x or y, @@ -406,9 +407,7 @@ bool8 S9xDeinitUpdate (int Width, int Height) LastHeight = OrigHeight; } - S9xDisplayOutput->Render(Src); - - GUI.FlipCounter++; + WinRefreshDisplay(); return (true); } diff --git a/win32/wsnes9x.cpp b/win32/wsnes9x.cpp index 3a864874..8c492099 100644 --- a/win32/wsnes9x.cpp +++ b/win32/wsnes9x.cpp @@ -6958,7 +6958,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, prevVideoMemory, prevShaderEnabled; + static bool prevStretch, prevAspectRatio, prevHeightExtend, prevAutoDisplayMessages, prevBilinearFilter, prevShaderEnabled; static int prevAspectWidth; static OutputMethod prevOutputMethod; static TCHAR prevHLSLShaderFile[MAX_PATH],prevGLSLShaderFile[MAX_PATH]; @@ -6983,7 +6983,7 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) prevScaleHiRes = GUI.ScaleHiRes; prevPPL = GFX.RealPPL; prevStretch = GUI.Stretch; - prevVideoMemory = GUI.BilinearFilter; + prevBilinearFilter = GUI.BilinearFilter; prevAspectRatio = GUI.AspectRatio; prevAspectWidth = GUI.AspectWidth; prevHeightExtend = GUI.HeightExtend; @@ -7009,6 +7009,8 @@ INT_PTR CALLBACK DlgFunky(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam) if(Settings.SupportHiRes) SendDlgItemMessage(hDlg, IDC_HIRES, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); + if(GUI.BlendHiRes) + SendDlgItemMessage(hDlg, IDC_HIRESBLEND, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); if(GUI.HeightExtend) SendDlgItemMessage(hDlg, IDC_HEIGHT_EXTEND, BM_SETCHECK, (WPARAM)BST_CHECKED, 0); if(Settings.AutoDisplayMessages) @@ -7386,6 +7388,7 @@ updateFilterBox2: fullscreenWanted = (bool)(IsDlgButtonChecked(hDlg, IDC_FULLSCREEN)==BST_CHECKED); GUI.EmulateFullscreen = (bool)(IsDlgButtonChecked(hDlg, IDC_EMUFULLSCREEN)==BST_CHECKED); Settings.DisplayFrameRate = IsDlgButtonChecked(hDlg, IDC_SHOWFPS); + GUI.BlendHiRes = (bool)(IsDlgButtonChecked(hDlg, IDC_HIRESBLEND)==BST_CHECKED); index = ComboBox_GetCurSel(GetDlgItem(hDlg,IDC_RESOLUTION)); @@ -7438,7 +7441,7 @@ updateFilterBox2: GFX.RealPPL = prevPPL; GUI.Stretch = prevStretch; Settings.AutoDisplayMessages = prevAutoDisplayMessages; - GUI.BilinearFilter = prevVideoMemory; + GUI.BilinearFilter = prevBilinearFilter; GUI.AspectRatio = prevAspectRatio; GUI.AspectWidth = prevAspectWidth; GUI.HeightExtend = prevHeightExtend; diff --git a/win32/wsnes9x.h b/win32/wsnes9x.h index c63791dc..3273cea8 100644 --- a/win32/wsnes9x.h +++ b/win32/wsnes9x.h @@ -300,6 +300,7 @@ struct sGUI { dMode FullscreenMode; RenderFilter Scale; RenderFilter ScaleHiRes; + bool BlendHiRes; bool DoubleBuffered; bool FullScreen; bool Stretch;