Updated for embedded Visual C++ 4.0
authorSam Lantinga <slouken@libsdl.org>
Tue, 20 Aug 2002 00:20:06 +0000
changeset 453 a6fa62b1be09
parent 452 4c5c10383201
child 454 c4338ecf45f9
Updated for embedded Visual C++ 4.0
Makefile.am
README.WinCE
VisualCE.zip
include/SDL_main.h
src/audio/windx5/SDL_dx5audio.c
src/main/win32/SDL_main.c
src/timer/win32/SDL_systimer.c
src/video/SDL_sysvideo.h
src/video/wincommon/SDL_lowvideo.h
src/video/wincommon/SDL_sysevents.c
src/video/wincommon/SDL_wingl.c
src/video/windib/SDL_dibevents.c
src/video/windib/SDL_dibvideo.c
src/video/windx5/SDL_dx5events.c
src/video/windx5/SDL_dx5video.c
src/video/windx5/SDL_dx5video.h
--- a/Makefile.am	Mon Aug 19 18:33:29 2002 +0000
+++ b/Makefile.am	Tue Aug 20 00:20:06 2002 +0000
@@ -39,6 +39,7 @@
 	Borland.zip	\
         VisualC.html	\
         VisualC.zip	\
+	VisualCE.zip	\
         MPWmake.sea.bin	\
 	CWprojects.sea.bin \
 	PBProjects.tar.gz \
--- a/README.WinCE	Mon Aug 19 18:33:29 2002 +0000
+++ b/README.WinCE	Tue Aug 20 00:20:06 2002 +0000
@@ -1,8 +1,7 @@
+
+Project files for embedded Visual C++ 4.0 can be found in VisualCE.zip
 
 NOTE:
-SDL is NOT SUPPORTED on the WinCE platform!  This is for experimental
-purposes only.
-
 There are several SDL features not available in the WinCE port of SDL.
 
 - DirectX is not yet available
Binary file VisualCE.zip has changed
--- a/include/SDL_main.h	Mon Aug 19 18:33:29 2002 +0000
+++ b/include/SDL_main.h	Tue Aug 20 00:20:06 2002 +0000
@@ -30,9 +30,10 @@
 
 /* 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"
--- a/src/audio/windx5/SDL_dx5audio.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/audio/windx5/SDL_dx5audio.c	Tue Aug 20 00:20:06 2002 +0000
@@ -63,7 +63,7 @@
 
 	/* 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 @@
 		 * 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 @@
 	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 @@
 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) {
--- a/src/main/win32/SDL_main.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/main/win32/SDL_main.c	Tue Aug 20 00:20:06 2002 +0000
@@ -225,6 +225,9 @@
 
 	/* Exit cleanly, calling atexit() functions */
 	exit(0);
+
+	/* Hush little compiler, don't you cry... */
+	return(0);
 }
 
 /* This is where execution begins [windowed apps] */
--- a/src/timer/win32/SDL_systimer.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/timer/win32/SDL_systimer.c	Tue Aug 20 00:20:06 2002 +0000
@@ -33,8 +33,8 @@
 #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)
--- a/src/video/SDL_sysvideo.h	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/SDL_sysvideo.h	Tue Aug 20 00:20:06 2002 +0000
@@ -42,6 +42,7 @@
 #ifndef _WIN32_WCE
 #define HAVE_OPENGL
 #endif
+#define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #endif
 
--- a/src/video/wincommon/SDL_lowvideo.h	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/wincommon/SDL_lowvideo.h	Tue Aug 20 00:20:06 2002 +0000
@@ -53,7 +53,11 @@
 #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;
--- a/src/video/wincommon/SDL_sysevents.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/wincommon/SDL_sysevents.c	Tue Aug 20 00:20:06 2002 +0000
@@ -47,10 +47,15 @@
 
 #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 @@
 	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,
+		/* 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
+	{
+		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	= lpszW;
-    }
-#else
-	class.hIcon		= LoadImage(hInst, name, IMAGE_ICON,
-	                                    0, 0, LR_DEFAULTCOLOR);
-	class.lpszMenuName	= "(none)";
-	class.lpszClassName	= name;
-#endif /* _WIN32_WCE */
+	class.lpszClassName	= SDL_Appname;
 	class.hbrBackground	= NULL;
 	class.hInstance		= hInst;
 	class.style		= style;
@@ -606,7 +612,6 @@
 		SDL_SetError("Couldn't register application class");
 		return(-1);
 	}
-	SDL_Appname = name;
 	SDL_Instance = hInst;
 
 #ifdef WM_MOUSELEAVE
--- a/src/video/wincommon/SDL_wingl.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/wincommon/SDL_wingl.c	Tue Aug 20 00:20:06 2002 +0000
@@ -27,7 +27,9 @@
 
 /* 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 @@
 	SwapBuffers(GL_hdc);
 }
 
-#endif /* HAVE_OPENGL */
-
-#ifdef HAVE_OPENGL
-
 void WIN_GL_UnloadLibrary(_THIS)
 {
 	if ( this->gl_config.driver_loaded ) {
--- a/src/video/windib/SDL_dibevents.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/windib/SDL_dibevents.c	Tue Aug 20 00:20:06 2002 +0000
@@ -333,28 +333,9 @@
 
 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 @@
 		}
 		ShowWindow(SDL_Window, SW_HIDE);
 	}
-#endif /* _WIN32_WCE */
-
 	return(0);
 }
 
--- a/src/video/windib/SDL_dibvideo.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/windib/SDL_dibvideo.c	Tue Aug 20 00:20:06 2002 +0000
@@ -53,6 +53,15 @@
 #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 @@
 	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 @@
 			(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 @@
 	/* 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 @@
 	}
 
 	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 @@
 			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 @@
 		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 @@
 		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 @@
 		SetForegroundWindow(SDL_Window);
 	}
 
-#ifdef HAVE_OPENGL
 	/* Set up for OpenGL */
 	if ( flags & SDL_OPENGL ) {
 		if ( WIN_GL_SetupWindow(this) < 0 ) {
@@ -697,7 +689,6 @@
 		}
 		video->flags |= SDL_OPENGL;
 	}
-#endif /* HAVE_OPENGL */
 
 	/* We're live! */
 	return(video);
@@ -760,11 +751,7 @@
 			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 @@
 				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 ) {
--- a/src/video/windx5/SDL_dx5events.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/windx5/SDL_dx5events.c	Tue Aug 20 00:20:06 2002 +0000
@@ -43,6 +43,10 @@
 #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 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 @@
  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 @@
 			}
 		}
 		break;
+#endif /* WM_ACTIVATEAPP */
 
+#ifdef WM_DISPLAYCHANGE
 		case WM_DISPLAYCHANGE: {
 			WORD BitsPerPixel;
 			WORD SizeX, SizeY;
@@ -479,6 +486,7 @@
 			/* 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 @@
 		}
 		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 @@
 			    (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 @@
 	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 @@
 		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);
--- a/src/video/windx5/SDL_dx5video.c	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/windx5/SDL_dx5video.c	Tue Aug 20 00:20:06 2002 +0000
@@ -51,10 +51,23 @@
 #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 @@
 
 	/* 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 @@
 	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 @@
 	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 @@
 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_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 @@
 		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_fullscreen_mode = settings;
 			}
 		}
+#endif /* !NO_CHANGEDISPLAYSETTINGS */
 
 		style = GetWindowLong(SDL_Window, GWL_STYLE);
 		style &= ~(resizestyle|WS_MAXIMIZE);
@@ -1096,7 +1113,9 @@
 					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 @@
 			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 @@
 				style |= resizestyle;
 			}
 		}
+#if WS_MAXIMIZE
 		if (IsZoomed(SDL_Window)) style |= WS_MAXIMIZE;
+#endif
 	}
 	SetWindowLong(SDL_Window, GWL_STYLE, style);
 
@@ -1466,8 +1487,7 @@
 		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 @@
 
 	/* 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);
 		}
--- a/src/video/windx5/SDL_dx5video.h	Mon Aug 19 18:33:29 2002 +0000
+++ b/src/video/windx5/SDL_dx5video.h	Tue Aug 20 00:20:06 2002 +0000
@@ -57,7 +57,7 @@
 
 /* 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);