diff --git a/Makefile.am b/Makefile.am index a6b75f95a4d16901123d741116ad53f04fe428bf..fbbccda3028dda130b74e2fcdc9f4b2088f12652 100644 --- a/Makefile.am +++ b/Makefile.am @@ -39,6 +39,7 @@ EXTRA_DIST = \ Borland.zip \ VisualC.html \ VisualC.zip \ + VisualCE.zip \ MPWmake.sea.bin \ CWprojects.sea.bin \ PBProjects.tar.gz \ diff --git a/README.WinCE b/README.WinCE index 944df834bfb65cd3f871ca9c5c491c685e282a9b..7ca50fe690f68aa827e4442f82ab00561268ddd8 100644 --- a/README.WinCE +++ b/README.WinCE @@ -1,8 +1,7 @@ -NOTE: -SDL is NOT SUPPORTED on the WinCE platform! This is for experimental -purposes only. +Project files for embedded Visual C++ 4.0 can be found in VisualCE.zip +NOTE: There are several SDL features not available in the WinCE port of SDL. - DirectX is not yet available diff --git a/VisualCE.zip b/VisualCE.zip new file mode 100644 index 0000000000000000000000000000000000000000..834b4fb60d5828afe608600d36e7bf5023706464 Binary files /dev/null and b/VisualCE.zip differ diff --git a/include/SDL_main.h b/include/SDL_main.h index a20f9ba1e4fd111acd93db05dc85b356b619c6c8..6a7a8944e5023e94a04a0265c9bcd82e49e859e4 100644 --- a/include/SDL_main.h +++ b/include/SDL_main.h @@ -30,9 +30,10 @@ static char rcsid = /* Redefine main() on Win32 and MacOS so that it is called by winmain.c */ -#if defined(WIN32) || (defined(__MWERKS__) && !defined(__BEOS__)) || \ - defined(macintosh) || defined(__APPLE__) || defined(__SYMBIAN32__) || \ - defined(QWS) +#if defined(WIN32) || defined(_WIN32) || \ + (defined(__MWERKS__) && !defined(__BEOS__)) || \ + defined(macintosh) || defined(__APPLE__) || \ + defined(__SYMBIAN32__) || defined(QWS) #ifdef __cplusplus #define C_LINKAGE "C" diff --git a/src/audio/windx5/SDL_dx5audio.c b/src/audio/windx5/SDL_dx5audio.c index 78ddd68c3a1045941a2eb9d50284521afebd70a7..d79468d6dfcee886d5da4ba874d360335fdbdc63 100644 --- a/src/audio/windx5/SDL_dx5audio.c +++ b/src/audio/windx5/SDL_dx5audio.c @@ -63,7 +63,7 @@ static int Audio_Available(void) /* Version check DSOUND.DLL (Is DirectX okay?) */ dsound_ok = 0; - DSoundDLL = LoadLibrary("DSOUND.DLL"); + DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL")); if ( DSoundDLL != NULL ) { /* We just use basic DirectSound, we're okay */ /* Yay! */ @@ -95,7 +95,7 @@ static int Audio_Available(void) * to fall back to the DIB driver. */ if (dsound_ok) { /* DirectSoundCaptureCreate was added in DX5 */ - if (!GetProcAddress(DSoundDLL, "DirectSoundCaptureCreate")) + if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) dsound_ok = 0; } @@ -121,10 +121,10 @@ static int DX5_Load(void) int status; DX5_Unload(); - DSoundDLL = LoadLibrary("DSOUND.DLL"); + DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL")); if ( DSoundDLL != NULL ) { DSoundCreate = (void *)GetProcAddress(DSoundDLL, - "DirectSoundCreate"); + TEXT("DirectSoundCreate")); } if ( DSoundDLL && DSoundCreate ) { status = 0; @@ -189,7 +189,7 @@ AudioBootStrap DSOUND_bootstrap = { static void SetDSerror(const char *function, int code) { static const char *error; - static char errbuf[BUFSIZ]; + static char errbuf[1024]; errbuf[0] = 0; switch (code) { diff --git a/src/main/win32/SDL_main.c b/src/main/win32/SDL_main.c index 8625e382776cbf0d0389cfb44b4ee0c5ae59f010..65db02f6ea8c45d223a28e7cf84de67a19bdbbfc 100644 --- a/src/main/win32/SDL_main.c +++ b/src/main/win32/SDL_main.c @@ -225,6 +225,9 @@ int console_main(int argc, char *argv[]) /* Exit cleanly, calling atexit() functions */ exit(0); + + /* Hush little compiler, don't you cry... */ + return(0); } /* This is where execution begins [windowed apps] */ diff --git a/src/timer/win32/SDL_systimer.c b/src/timer/win32/SDL_systimer.c index 11fa67f7ea997272d04fb8120a6fe00730709994..ed43bcae1c1436a6701905a98771728988b3049f 100644 --- a/src/timer/win32/SDL_systimer.c +++ b/src/timer/win32/SDL_systimer.c @@ -33,8 +33,8 @@ static char rcsid = #include "SDL_error.h" #ifdef _WIN32_WCE -#define USE_GETTICKCOUNT -#define USE_SETTIMER +//#define USE_GETTICKCOUNT +//#define USE_SETTIMER #endif #define TIME_WRAP_VALUE (~(DWORD)0) diff --git a/src/video/SDL_sysvideo.h b/src/video/SDL_sysvideo.h index 8d6fb1488e4a45cd3d1ebca32af0ce759e401a8f..a325ae5d5cb66982cb3fe60fa9885f526b5a4a50 100644 --- a/src/video/SDL_sysvideo.h +++ b/src/video/SDL_sysvideo.h @@ -42,6 +42,7 @@ static char rcsid = #ifndef _WIN32_WCE #define HAVE_OPENGL #endif +#define WIN32_LEAN_AND_MEAN #include <windows.h> #endif diff --git a/src/video/wincommon/SDL_lowvideo.h b/src/video/wincommon/SDL_lowvideo.h index 32021d36c3e2c3aad399715ebae1d25897efe5df..938f301f824e924a3f311910b133d1125aa05f8a 100644 --- a/src/video/wincommon/SDL_lowvideo.h +++ b/src/video/wincommon/SDL_lowvideo.h @@ -53,7 +53,11 @@ static char rcsid = #define DINPUT_FULLSCREEN() DDRAW_FULLSCREEN() /* The main window -- and a function to set it for the audio */ -extern const char *SDL_Appname; +#ifdef _WIN32_WCE +extern LPWSTR SDL_Appname; +#else +extern LPSTR SDL_Appname; +#endif extern HINSTANCE SDL_Instance; extern HWND SDL_Window; extern const char *SDL_windowid; diff --git a/src/video/wincommon/SDL_sysevents.c b/src/video/wincommon/SDL_sysevents.c index dbd8065cc4bb23aa65f3972928f12cab4d4cc780..e200070e94a9cd233cac7e67ce959c2faa169de3 100644 --- a/src/video/wincommon/SDL_sysevents.c +++ b/src/video/wincommon/SDL_sysevents.c @@ -47,10 +47,15 @@ static char rcsid = #ifdef _WIN32_WCE #define NO_GETKEYBOARDSTATE +#define NO_CHANGEDISPLAYSETTINGS #endif /* The window we use for everything... */ -const char *SDL_Appname = NULL; +#ifdef _WIN32_WCE +LPWSTR SDL_Appname = NULL; +#else +LPSTR SDL_Appname = NULL; +#endif HINSTANCE SDL_Instance = NULL; HWND SDL_Window = NULL; RECT SDL_bounds = {0, 0, 0, 0}; @@ -578,21 +583,22 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst) class.hCursor = NULL; #ifdef _WIN32_WCE { - /* WinCE uses the UNICODE version */ - int nLen = strlen(name)+1; - LPWSTR lpszW = alloca(nLen*2); - MultiByteToWideChar(CP_ACP, 0, name, -1, lpszW, nLen); - class.hIcon = LoadImage(hInst, lpszW, IMAGE_ICON, - 0, 0, LR_DEFAULTCOLOR); - class.lpszMenuName = NULL; - class.lpszClassName = lpszW; + /* WinCE uses the UNICODE version */ + int nLen = strlen(name)+1; + SDL_Appname = malloc(nLen*2); + MultiByteToWideChar(CP_ACP, 0, name, -1, SDL_Appname, nLen); } #else - class.hIcon = LoadImage(hInst, name, IMAGE_ICON, - 0, 0, LR_DEFAULTCOLOR); - class.lpszMenuName = "(none)"; - class.lpszClassName = name; + { + int nLen = strlen(name)+1; + SDL_Appname = malloc(nLen); + strcpy(SDL_Appname, name); + } #endif /* _WIN32_WCE */ + class.hIcon = LoadImage(hInst, SDL_Appname, IMAGE_ICON, + 0, 0, LR_DEFAULTCOLOR); + class.lpszMenuName = NULL; + class.lpszClassName = SDL_Appname; class.hbrBackground = NULL; class.hInstance = hInst; class.style = style; @@ -606,7 +612,6 @@ int SDL_RegisterApp(char *name, Uint32 style, void *hInst) SDL_SetError("Couldn't register application class"); return(-1); } - SDL_Appname = name; SDL_Instance = hInst; #ifdef WM_MOUSELEAVE diff --git a/src/video/wincommon/SDL_wingl.c b/src/video/wincommon/SDL_wingl.c index caf8abde86fbe3c77f9b8a20456e7896c470114d..9d067bdfe31c1274fe83903e7d57174ea0bcfb06 100644 --- a/src/video/wincommon/SDL_wingl.c +++ b/src/video/wincommon/SDL_wingl.c @@ -27,7 +27,9 @@ static char rcsid = /* WGL implementation of SDL OpenGL support */ +#ifdef HAVE_OPENGL #include "SDL_opengl.h" +#endif #include "SDL_error.h" #include "SDL_lowvideo.h" #include "SDL_wingl_c.h" @@ -264,10 +266,6 @@ void WIN_GL_SwapBuffers(_THIS) SwapBuffers(GL_hdc); } -#endif /* HAVE_OPENGL */ - -#ifdef HAVE_OPENGL - void WIN_GL_UnloadLibrary(_THIS) { if ( this->gl_config.driver_loaded ) { diff --git a/src/video/windib/SDL_dibevents.c b/src/video/windib/SDL_dibevents.c index 26eb31da0dde5f539eeb68b97669fcf9e8a681c7..8a49ddcedc2237b020e5673e01cddde0f6b265e7 100644 --- a/src/video/windib/SDL_dibevents.c +++ b/src/video/windib/SDL_dibevents.c @@ -333,28 +333,9 @@ static SDL_keysym *TranslateKey(UINT vkey, UINT scancode, SDL_keysym *keysym, in int DIB_CreateWindow(_THIS) { -#ifdef _WIN32_WCE - /* WinCE uses the UNICODE version */ - int nLen; - LPWSTR lpszW; - - if ( SDL_RegisterApp("SDL_app", 0, 0) != 0 ) { - return -1; - } - - nLen = strlen(SDL_Appname) + 1; - lpszW = alloca(nLen * 2); - - MultiByteToWideChar(CP_ACP, 0, "SDL_App", -1, lpszW, nLen); - - SDL_Window = CreateWindow(lpszW, lpszW, WS_VISIBLE, - 0, 0, 0, 0, NULL, NULL, SDL_Instance, NULL); - if ( SDL_Window == NULL ) { - SDL_SetError("Couldn't create window"); - return(-1); - } - ShowWindow(SDL_Window, SW_HIDE); -#else +#ifndef CS_BYTEALIGNCLIENT +#define CS_BYTEALIGNCLIENT 0 +#endif SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); if ( SDL_windowid ) { SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); @@ -376,8 +357,6 @@ int DIB_CreateWindow(_THIS) } ShowWindow(SDL_Window, SW_HIDE); } -#endif /* _WIN32_WCE */ - return(0); } diff --git a/src/video/windib/SDL_dibvideo.c b/src/video/windib/SDL_dibvideo.c index 5238f81347313fcf74e49909038a0f5a40ae0cd1..0ab2670b7a0b97298a50441016dafc84548728c1 100644 --- a/src/video/windib/SDL_dibvideo.c +++ b/src/video/windib/SDL_dibvideo.c @@ -53,6 +53,15 @@ static char rcsid = #define NO_CHANGEDISPLAYSETTINGS #define NO_GAMMA_SUPPORT #endif +#ifndef WS_MAXIMIZE +#define WS_MAXIMIZE 0 +#endif +#ifndef SWP_NOCOPYBITS +#define SWP_NOCOPYBITS 0 +#endif +#ifndef PC_NOCOLLAPSE +#define PC_NOCOLLAPSE 0 +#endif /* Initialization/Query functions */ static int DIB_VideoInit(_THIS, SDL_PixelFormat *vformat); @@ -143,11 +152,11 @@ static SDL_VideoDevice *DIB_CreateDevice(int devindex) device->SetGammaRamp = DIB_SetGammaRamp; device->GetGammaRamp = DIB_GetGammaRamp; #ifdef HAVE_OPENGL - device->GL_LoadLibrary = WIN_GL_LoadLibrary; - device->GL_GetProcAddress = WIN_GL_GetProcAddress; - device->GL_GetAttribute = WIN_GL_GetAttribute; - device->GL_MakeCurrent = WIN_GL_MakeCurrent; - device->GL_SwapBuffers = WIN_GL_SwapBuffers; + device->GL_LoadLibrary = WIN_GL_LoadLibrary; + device->GL_GetProcAddress = WIN_GL_GetProcAddress; + device->GL_GetAttribute = WIN_GL_GetAttribute; + device->GL_MakeCurrent = WIN_GL_MakeCurrent; + device->GL_SwapBuffers = WIN_GL_SwapBuffers; #endif device->SetCaption = WIN_SetWMCaption; device->SetIcon = WIN_SetWMIcon; @@ -440,10 +449,8 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, (WS_POPUP); const DWORD windowstyle = (WS_OVERLAPPED|WS_CAPTION|WS_SYSMENU|WS_MINIMIZEBOX); -#ifndef _WIN32_WCE const DWORD resizestyle = (WS_THICKFRAME|WS_MAXIMIZEBOX); -#endif int binfo_size; BITMAPINFO *binfo; HDC hdc; @@ -455,12 +462,10 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, /* See whether or not we should center the window */ was_visible = IsWindowVisible(SDL_Window); -#ifdef HAVE_OPENGL /* Clean up any GL context that may be hanging around */ if ( current->flags & SDL_OPENGL ) { WIN_GL_ShutDown(this); } -#endif /* HAVE_OPENGL */ /* Recalculate the bitmasks if necessary */ if ( bpp == current->format->BitsPerPixel ) { @@ -542,9 +547,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, } style = GetWindowLong(SDL_Window, GWL_STYLE); -#ifndef _WIN32_WCE style &= ~(resizestyle|WS_MAXIMIZE); -#endif if ( (video->flags & SDL_FULLSCREEN) == SDL_FULLSCREEN ) { style &= ~windowstyle; style |= directstyle; @@ -562,13 +565,11 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, style &= ~directstyle; style |= windowstyle; if ( flags & SDL_RESIZABLE ) { -#ifndef _WIN32_WCE style |= resizestyle; -#endif video->flags |= SDL_RESIZABLE; } } -#ifndef _WIN32_WCE +#if WS_MAXIMIZE if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; #endif } @@ -659,11 +660,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, bounds.top = 0; bounds.right = video->w; bounds.bottom = video->h; -#ifndef _WIN32_WCE - AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE); -#else - AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE,0); -#endif + AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); width = bounds.right-bounds.left; height = bounds.bottom-bounds.top; x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; @@ -671,11 +668,7 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, if ( y < 0 ) { /* Cover up title bar for more client area */ y -= GetSystemMetrics(SM_CYCAPTION)/2; } -#ifndef _WIN32_WCE swp_flags = (SWP_NOCOPYBITS | SWP_FRAMECHANGED | SWP_SHOWWINDOW); -#else - swp_flags = (SWP_FRAMECHANGED | SWP_SHOWWINDOW); -#endif if ( was_visible && !(flags & SDL_FULLSCREEN) ) { swp_flags |= SWP_NOMOVE; } @@ -689,7 +682,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, SetForegroundWindow(SDL_Window); } -#ifdef HAVE_OPENGL /* Set up for OpenGL */ if ( flags & SDL_OPENGL ) { if ( WIN_GL_SetupWindow(this) < 0 ) { @@ -697,7 +689,6 @@ SDL_Surface *DIB_SetVideoMode(_THIS, SDL_Surface *current, } video->flags |= SDL_OPENGL; } -#endif /* HAVE_OPENGL */ /* We're live! */ return(video); @@ -760,11 +751,7 @@ int DIB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors) entries[i].peRed = colors[i].r; entries[i].peGreen = colors[i].g; entries[i].peBlue = colors[i].b; -#ifndef _WIN32_WCE entries[i].peFlags = PC_NOCOLLAPSE; -#else - entries[i].peFlags = 0; -#endif } SetPaletteEntries(screen_pal, firstcolor, ncolors, entries); SelectPalette(hdc, screen_pal, FALSE); @@ -917,11 +904,9 @@ void DIB_VideoQuit(_THIS) ShowWindow(SDL_Window, SW_HIDE); } #endif -#ifdef HAVE_OPENGL if ( this->screen->flags & SDL_OPENGL ) { WIN_GL_ShutDown(this); } -#endif /* HAVE_OPENGL */ this->screen->pixels = NULL; } if ( screen_bmp ) { diff --git a/src/video/windx5/SDL_dx5events.c b/src/video/windx5/SDL_dx5events.c index 7d81ac7ac22d6891f8fd4b10078674ef4d55ec5a..0f49f38f046f46ededf39e1b96dda0ff5047fa8f 100644 --- a/src/video/windx5/SDL_dx5events.c +++ b/src/video/windx5/SDL_dx5events.c @@ -43,6 +43,10 @@ static char rcsid = #define WM_APP 0x8000 #endif +#ifdef _WIN32_WCE +#define NO_GETKEYBOARDSTATE +#endif + /* The keyboard and mouse device input */ #define MAX_INPUTS 16 /* Maximum of 16-1 input devices */ #define INPUT_QSIZE 32 /* Buffer up to 32 input messages */ @@ -67,7 +71,7 @@ static WNDPROC userWindowProc = NULL; static void SetDIerror(char *function, int code) { static char *error; - static char errbuf[BUFSIZ]; + static char errbuf[1024]; errbuf[0] = 0; switch (code) { @@ -449,6 +453,7 @@ LONG DX5_HandleMessage(_THIS, HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { +#ifdef WM_ACTIVATEAPP case WM_ACTIVATEAPP: { int i, active; @@ -467,7 +472,9 @@ LONG } } break; +#endif /* WM_ACTIVATEAPP */ +#ifdef WM_DISPLAYCHANGE case WM_DISPLAYCHANGE: { WORD BitsPerPixel; WORD SizeX, SizeY; @@ -479,6 +486,7 @@ LONG /* We cause this message when we go fullscreen */ } break; +#endif /* WM_DISPLAYCHANGE */ /* The keyboard is handled via DirectInput */ case WM_SYSKEYUP: @@ -489,6 +497,7 @@ LONG } return(0); +#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER) /* Don't allow screen savers or monitor power downs. This is because they quietly clear DirectX surfaces. It would be better to allow the application to @@ -501,11 +510,11 @@ LONG (wParam&0xFFF0)==SC_MONITORPOWER) return(0); } - goto custom_processing; - break; + /* Fall through to default processing */ + +#endif /* SC_SCREENSAVE || SC_MONITORPOWER */ default: { - custom_processing: /* Only post the event if we're watching for it */ if ( SDL_ProcessEvents[SDL_SYSWMEVENT] == SDL_ENABLE ) { SDL_SysWMmsg wmmsg; @@ -759,14 +768,21 @@ static SDL_keysym *TranslateKey(UINT scancode, SDL_keysym *keysym, int pressed) keysym->unicode = 0; if ( pressed && SDL_TranslateUNICODE ) { /* Someday use ToUnicode() */ UINT vkey; +#ifndef NO_GETKEYBOARDSTATE BYTE keystate[256]; BYTE chars[2]; +#endif vkey = MapVirtualKey(scancode, 1); +#ifdef NO_GETKEYBOARDSTATE + /* Uh oh, better hope the vkey is close enough.. */ + keysym->unicode = vkey; +#else GetKeyboardState(keystate); if ( ToAscii(vkey,scancode,keystate,(WORD *)chars,0) == 1 ) { keysym->unicode = chars[0]; } +#endif } return(keysym); } @@ -782,7 +798,9 @@ int DX5_CreateWindow(_THIS) SDL_DIfun[i] = NULL; } - /* Create the SDL window */ +#ifndef CS_BYTEALIGNCLIENT +#define CS_BYTEALIGNCLIENT 0 +#endif SDL_RegisterApp("SDL_app", CS_BYTEALIGNCLIENT, 0); if ( SDL_windowid ) { SDL_Window = (HWND)strtol(SDL_windowid, NULL, 0); diff --git a/src/video/windx5/SDL_dx5video.c b/src/video/windx5/SDL_dx5video.c index 695e2b144b42ee5c21b24c5cf21c909c037eb95c..08526288e49dfbb0339f5d229dd6d25344d16748 100644 --- a/src/video/windx5/SDL_dx5video.c +++ b/src/video/windx5/SDL_dx5video.c @@ -51,10 +51,23 @@ static char rcsid = #include "SDL_dx5yuv_c.h" #include "SDL_wingl_c.h" +#ifdef _WIN32_WCE +#define NO_CHANGEDISPLAYSETTINGS +#endif +#ifndef WS_MAXIMIZE +#define WS_MAXIMIZE 0 +#endif +#ifndef SWP_NOCOPYBITS +#define SWP_NOCOPYBITS 0 +#endif +#ifndef PC_NOCOLLAPSE +#define PC_NOCOLLAPSE 0 +#endif + /* DirectX function pointers for video and events */ HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); -HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); +HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter); /* This is the rect EnumModes2 uses */ struct DX5EnumRect { @@ -443,19 +456,19 @@ static int DX5_Available(void) /* Version check DINPUT.DLL and DDRAW.DLL (Is DirectX okay?) */ dinput_ok = 0; - DInputDLL = LoadLibrary("DINPUT.DLL"); + DInputDLL = LoadLibrary(TEXT("DINPUT.DLL")); if ( DInputDLL != NULL ) { dinput_ok = 1; FreeLibrary(DInputDLL); } ddraw_ok = 0; - DDrawDLL = LoadLibrary("DDRAW.DLL"); + DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL")); if ( DDrawDLL != NULL ) { HRESULT (WINAPI *DDrawCreate)(GUID *,LPDIRECTDRAW *,IUnknown *); LPDIRECTDRAW DDraw; /* Try to create a valid DirectDraw object */ - DDrawCreate = (void *)GetProcAddress(DDrawDLL, "DirectDrawCreate"); + DDrawCreate = (void *)GetProcAddress(DDrawDLL, TEXT("DirectDrawCreate")); if ( (DDrawCreate != NULL) && !FAILED(DDrawCreate(NULL, &DDraw, NULL)) ) { if ( !FAILED(IDirectDraw_SetCooperativeLevel(DDraw, @@ -511,15 +524,15 @@ static int DX5_Load(void) int status; DX5_Unload(); - DDrawDLL = LoadLibrary("DDRAW.DLL"); + DDrawDLL = LoadLibrary(TEXT("DDRAW.DLL")); if ( DDrawDLL != NULL ) { DDrawCreate = (void *)GetProcAddress(DDrawDLL, - "DirectDrawCreate"); + TEXT("DirectDrawCreate")); } - DInputDLL = LoadLibrary("DINPUT.DLL"); + DInputDLL = LoadLibrary(TEXT("DINPUT.DLL")); if ( DInputDLL != NULL ) { DInputCreate = (void *)GetProcAddress(DInputDLL, - "DirectInputCreateA"); + TEXT("DirectInputCreateA")); } if ( DDrawDLL && DDrawCreate && DInputDLL && DInputCreate ) { status = 0; @@ -596,11 +609,11 @@ static SDL_VideoDevice *DX5_CreateDevice(int devindex) device->SetGammaRamp = DX5_SetGammaRamp; device->GetGammaRamp = DX5_GetGammaRamp; #ifdef HAVE_OPENGL - device->GL_LoadLibrary = WIN_GL_LoadLibrary; - device->GL_GetProcAddress = WIN_GL_GetProcAddress; - device->GL_GetAttribute = WIN_GL_GetAttribute; - device->GL_MakeCurrent = WIN_GL_MakeCurrent; - device->GL_SwapBuffers = WIN_GL_SwapBuffers; + device->GL_LoadLibrary = WIN_GL_LoadLibrary; + device->GL_GetProcAddress = WIN_GL_GetProcAddress; + device->GL_GetAttribute = WIN_GL_GetAttribute; + device->GL_MakeCurrent = WIN_GL_MakeCurrent; + device->GL_SwapBuffers = WIN_GL_SwapBuffers; #endif device->SetCaption = WIN_SetWMCaption; device->SetIcon = WIN_SetWMIcon; @@ -670,7 +683,7 @@ static HRESULT WINAPI EnumModes2(DDSURFACEDESC *desc, VOID *udata) void SetDDerror(const char *function, int code) { static char *error; - static char errbuf[BUFSIZ]; + static char errbuf[1024]; errbuf[0] = 0; switch (code) { @@ -994,11 +1007,13 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, SDL_primary = NULL; } +#ifndef NO_CHANGEDISPLAYSETTINGS /* Unset any previous OpenGL fullscreen mode */ if ( (current->flags & (SDL_OPENGL|SDL_FULLSCREEN)) == (SDL_OPENGL|SDL_FULLSCREEN) ) { ChangeDisplaySettings(NULL, 0); } +#endif /* Clean up any GL context that may be hanging around */ if ( current->flags & SDL_OPENGL ) { @@ -1057,6 +1072,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, video->h = height; video->pitch = SDL_CalculatePitch(video); +#ifndef NO_CHANGEDISPLAYSETTINGS /* Set fullscreen mode if appropriate. Ugh, since our list of valid video modes comes from the DirectX driver, we may not actually be able to @@ -1077,6 +1093,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, SDL_fullscreen_mode = settings; } } +#endif /* !NO_CHANGEDISPLAYSETTINGS */ style = GetWindowLong(SDL_Window, GWL_STYLE); style &= ~(resizestyle|WS_MAXIMIZE); @@ -1096,7 +1113,9 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, video->flags |= SDL_RESIZABLE; } } +#if WS_MAXIMIZE if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; +#endif } SetWindowLong(SDL_Window, GWL_STYLE, style); @@ -1110,7 +1129,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, bounds.top = 0; bounds.right = video->w; bounds.bottom = video->h; - AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE); + AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); width = bounds.right-bounds.left; height = bounds.bottom-bounds.top; x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; @@ -1157,7 +1176,9 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, style |= resizestyle; } } +#if WS_MAXIMIZE if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE; +#endif } SetWindowLong(SDL_Window, GWL_STYLE, style); @@ -1466,8 +1487,7 @@ SDL_Surface *DX5_SetVideoMode(_THIS, SDL_Surface *current, bounds.top = 0; bounds.right = video->w; bounds.bottom = video->h; - AdjustWindowRect(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), - FALSE); + AdjustWindowRectEx(&bounds, GetWindowLong(SDL_Window, GWL_STYLE), FALSE, 0); width = bounds.right-bounds.left; height = bounds.bottom-bounds.top; x = (GetSystemMetrics(SM_CXSCREEN)-width)/2; @@ -2235,11 +2255,13 @@ void DX5_VideoQuit(_THIS) /* If we're fullscreen GL, we need to reset the display */ if ( this->screen != NULL ) { +#ifndef NO_CHANGEDISPLAYSETTINGS if ( (this->screen->flags & (SDL_OPENGL|SDL_FULLSCREEN)) == (SDL_OPENGL|SDL_FULLSCREEN) ) { ChangeDisplaySettings(NULL, 0); ShowWindow(SDL_Window, SW_HIDE); } +#endif if ( this->screen->flags & SDL_OPENGL ) { WIN_GL_ShutDown(this); } diff --git a/src/video/windx5/SDL_dx5video.h b/src/video/windx5/SDL_dx5video.h index df32a5ccc7c3243981a87c5709c19a8329acc746..db07b4b9007c91f2c1c5c23ba50f8e2f75125ce0 100644 --- a/src/video/windx5/SDL_dx5video.h +++ b/src/video/windx5/SDL_dx5video.h @@ -57,7 +57,7 @@ struct SDL_PrivateVideoData { /* DirectX function pointers for video and events */ extern HRESULT (WINAPI *DDrawCreate)( GUID FAR *lpGUID, LPDIRECTDRAW FAR *lplpDD, IUnknown FAR *pUnkOuter ); -extern HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUTA *ppDI, LPUNKNOWN punkOuter); +extern HRESULT (WINAPI *DInputCreate)(HINSTANCE hinst, DWORD dwVersion, LPDIRECTINPUT *ppDI, LPUNKNOWN punkOuter); /* DirectDraw error reporting function */ extern void SetDDerror(const char *function, int code);