diff --git a/desmume/src/windows/main.cpp b/desmume/src/windows/main.cpp index 3134c8558..9a2383f8d 100644 --- a/desmume/src/windows/main.cpp +++ b/desmume/src/windows/main.cpp @@ -667,10 +667,14 @@ void ToDSScreenRelativeCoords(s32& x, s32& y, int whichScreen) // END Rotation definitions //-----window style handling---- +const u32 DISPMETHOD_DDRAW_HW = 1; +const u32 DISPMETHOD_DDRAW_SW = 2; + const u32 DWS_NORMAL = 0; const u32 DWS_ALWAYSONTOP = 1; const u32 DWS_LOCKDOWN = 2; const u32 DWS_FULLSCREEN = 4; +const u32 DWS_DDRAW_SW = 8; static u32 currWindowStyle = DWS_NORMAL; static void SetStyle(u32 dws) @@ -810,6 +814,7 @@ int CreateDDrawBuffers() ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + if(GetStyle()&DWS_DDRAW_SW) ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; ddsd.dwWidth = video.rotatedwidth(); ddsd.dwHeight = video.rotatedheight(); @@ -907,7 +912,7 @@ void UpdateWndRects(HWND hwnd) POINT ptClient; RECT rc; - bool maximized = IsZoomed(hwnd); + bool maximized = IsZoomed(hwnd)!=FALSE; int wndWidth, wndHeight; int defHeight = video.height; @@ -2291,13 +2296,6 @@ class WinDriver : public BaseDriver } }; -std::string GetPrivateProfileStdString(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpDefault) -{ - static char buf[65536]; - GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buf, 65536, IniName); - return buf; -} - static void RefreshMicSettings() { Mic_DeInit_Physical(); @@ -2385,6 +2383,10 @@ int _main() u32 style = DWS_NORMAL; if(GetPrivateProfileBool("Video","Window Always On Top", false, IniName)) style |= DWS_ALWAYSONTOP; if(GetPrivateProfileBool("Video","Window Lockdown", false, IniName)) style |= DWS_LOCKDOWN; + + int dispMethod = GetPrivateProfileInt("Video","Display Method", DISPMETHOD_DDRAW_HW, IniName); + if(dispMethod == DISPMETHOD_DDRAW_SW) + style |= DWS_DDRAW_SW; windowSize = GetPrivateProfileInt("Video","Window Size", 0, IniName); video.rotation = GetPrivateProfileInt("Video","Window Rotate", 0, IniName); @@ -2993,6 +2995,7 @@ void SetRotate(HWND hwnd, int rot, bool user) ddsd.dwSize = sizeof(ddsd); ddsd.dwFlags = DDSD_CAPS | DDSD_HEIGHT | DDSD_WIDTH; ddsd.ddsCaps.dwCaps = DDSCAPS_OFFSCREENPLAIN; + if(GetStyle()&DWS_DDRAW_SW) ddsd.ddsCaps.dwCaps |= DDSCAPS_SYSTEMMEMORY; ddsd.dwWidth = video.rotatedwidth(); ddsd.dwHeight = video.rotatedheight(); @@ -3645,7 +3648,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM //emulation menu MainWindow->checkMenu(IDM_PAUSE, ((paused))); - MainWindow->checkMenu(IDM_EJECTCARD, nds.cardEjected); + MainWindow->checkMenu(IDM_EJECTCARD, nds.cardEjected != FALSE); // LCDs layout MainWindow->checkMenu(ID_LCDS_VERTICAL, ((video.layout==0))); @@ -3737,7 +3740,10 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM MainWindow->checkMenu(IDC_STATEREWINDING, staterewindingenabled == 1 ); - MainWindow->checkMenu(IDC_BACKGROUNDPAUSE, lostFocusPause); + MainWindow->checkMenu(ID_DISPLAYMETHOD_DIRECTDRAWHW, (GetStyle()&DWS_DDRAW_SW)==0); + MainWindow->checkMenu(ID_DISPLAYMETHOD_DIRECTDRAWSW, (GetStyle()&DWS_DDRAW_SW)!=0); + + MainWindow->checkMenu(IDM_EJECTCARD, nds.cardEjected != FALSE); //Save type const int savelist[] = {IDC_SAVETYPE1,IDC_SAVETYPE2,IDC_SAVETYPE3,IDC_SAVETYPE4,IDC_SAVETYPE5,IDC_SAVETYPE6,IDC_SAVETYPE7,IDC_SAVETYPE8}; @@ -4993,6 +4999,24 @@ DOKEYDOWN: case IDC_SAVETYPE7: backup_setManualBackupType(6); return 0; case IDC_SAVETYPE8: backup_setManualBackupType(7); return 0; + case ID_DISPLAYMETHOD_DIRECTDRAWHW: + { + Lock lock (win_backbuffer_sync); + SetStyle(GetStyle()&~DWS_DDRAW_SW); + WritePrivateProfileInt("Video","Display Method", DISPMETHOD_DDRAW_HW, IniName); + backbuffer_invalidate = true; + } + break; + + case ID_DISPLAYMETHOD_DIRECTDRAWSW: + { + Lock lock (win_backbuffer_sync); + SetStyle(GetStyle()|DWS_DDRAW_SW); + WritePrivateProfileInt("Video","Display Method", DISPMETHOD_DDRAW_SW, IniName); + backbuffer_invalidate = true; + } + break; + case IDM_EJECTCARD: NDS_ToggleCardEject(); return 0; diff --git a/desmume/src/windows/resource.h b/desmume/src/windows/resource.h index c3ddae773..611caf41f 100644 --- a/desmume/src/windows/resource.h +++ b/desmume/src/windows/resource.h @@ -710,6 +710,9 @@ #define IDC_SAVETYPE8 40067 #define IDM_EJECTCARD 40068 #define IDM_SHOWTOOLBAR 40069 +#define ID_CONFIG_DISPLAYMETHOD 40070 +#define ID_DISPLAYMETHOD_DIRECTDRAWHW 40071 +#define ID_DISPLAYMETHOD_DIRECTDRAWSW 40072 #define IDC_LABEL_UP 50000 #define IDC_LABEL_RIGHT 50001 #define IDC_LABEL_LEFT 50002 @@ -805,7 +808,7 @@ #ifdef APSTUDIO_INVOKED #ifndef APSTUDIO_READONLY_SYMBOLS #define _APS_NEXT_RESOURCE_VALUE 118 -#define _APS_NEXT_COMMAND_VALUE 40070 +#define _APS_NEXT_COMMAND_VALUE 40073 #define _APS_NEXT_CONTROL_VALUE 1022 #define _APS_NEXT_SYMED_VALUE 101 #endif diff --git a/desmume/src/windows/resources.rc b/desmume/src/windows/resources.rc index 6a3e6d13f..47403fc5c 100644 Binary files a/desmume/src/windows/resources.rc and b/desmume/src/windows/resources.rc differ diff --git a/desmume/src/windows/winutil.cpp b/desmume/src/windows/winutil.cpp index 288ab5a3a..b27980968 100644 --- a/desmume/src/windows/winutil.cpp +++ b/desmume/src/windows/winutil.cpp @@ -89,3 +89,10 @@ void DesEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, bool enable) { EnableMenuItem(hMenu, uIDEnableItem, MF_BYCOMMAND | (enable?MF_ENABLED:MF_GRAYED)); } + +std::string GetPrivateProfileStdString(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpDefault) +{ + static char buf[65536]; + GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, buf, 65536, IniName); + return buf; +} \ No newline at end of file diff --git a/desmume/src/windows/winutil.h b/desmume/src/windows/winutil.h index 5c8dd8478..6a3f3c5e9 100644 --- a/desmume/src/windows/winutil.h +++ b/desmume/src/windows/winutil.h @@ -25,11 +25,14 @@ #include #include +#include + extern char IniName[MAX_PATH]; void GetINIPath(); void PreventScreensaver(); void DesEnableMenuItem(HMENU hMenu, UINT uIDEnableItem, bool enable); +std::string GetPrivateProfileStdString(LPCSTR lpAppName,LPCSTR lpKeyName,LPCSTR lpDefault); inline bool operator==(const RECT& lhs, const RECT& rhs) {