changeset 5131:2c500f37abcf

merged: might need to check main.c in the iOS template to make sure no changes were abandoned.
author Eric Wing <ewing . public |-at-| gmail . com>
date Tue, 01 Feb 2011 00:37:02 -0800
parents 067973aec4d8 (current diff) f2c2f0ecba5f (diff)
children b1b0811a1ccc
files README.RISCOS Xcode-iPhoneOS/SDL/SDLiPhoneOS.xcodeproj/project.pbxproj src/SDL_android.cpp src/SDL_android.h src/joystick/riscos/SDL_sysjoystick.c src/thread/riscos/SDL_syscond.c src/thread/riscos/SDL_sysmutex.c src/thread/riscos/SDL_sysmutex_c.h src/thread/riscos/SDL_syssem.c src/thread/riscos/SDL_systhread.c src/thread/riscos/SDL_systhread_c.h src/timer/SDL_systimer.h src/timer/riscos/SDL_systimer.c src/video/riscos/SDL_riscosASM.S src/video/riscos/SDL_riscosFullScreenVideo.c src/video/riscos/SDL_riscosevents.c src/video/riscos/SDL_riscosevents_c.h src/video/riscos/SDL_riscosmouse.c src/video/riscos/SDL_riscosmouse_c.h src/video/riscos/SDL_riscossprite.c src/video/riscos/SDL_riscostask.c src/video/riscos/SDL_riscostask.h src/video/riscos/SDL_riscosvideo.c src/video/riscos/SDL_riscosvideo.h src/video/riscos/SDL_wimppoll.c src/video/riscos/SDL_wimpvideo.c
diffstat 167 files changed, 3200 insertions(+), 10747 deletions(-) [+]
line wrap: on
line diff
--- a/Android.mk	Mon Jan 31 07:36:12 2011 -0800
+++ b/Android.mk	Tue Feb 01 00:37:02 2011 -0800
@@ -12,30 +12,31 @@
 
 LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
 
-LOCAL_SRC_FILES := src/SDL_android.cpp \
+LOCAL_SRC_FILES := \
 	$(subst $(LOCAL_PATH)/,, \
 	$(wildcard $(LOCAL_PATH)/src/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/audio/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
 	$(LOCAL_PATH)/src/atomic/SDL_atomic.c \
 	$(LOCAL_PATH)/src/atomic/SDL_spinlock.c.arm \
+	$(wildcard $(LOCAL_PATH)/src/core/android/*.cpp) \
 	$(wildcard $(LOCAL_PATH)/src/cpuinfo/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/events/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/file/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/joystick/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/haptic/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/stdlib/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/thread/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/timer/*.c) \
+	$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
 	$(wildcard $(LOCAL_PATH)/src/video/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/power/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/audio/android/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/audio/dummy/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/video/android/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/joystick/android/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/haptic/dummy/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/thread/pthread/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/timer/unix/*.c) \
-	$(wildcard $(LOCAL_PATH)/src/loadso/dlopen/*.c))
+	$(wildcard $(LOCAL_PATH)/src/video/android/*.c))
 
 LOCAL_LDLIBS := -ldl -lGLESv1_CM -llog
 
--- a/README	Mon Jan 31 07:36:12 2011 -0800
+++ b/README	Tue Feb 01 00:37:02 2011 -0800
@@ -3,7 +3,7 @@
 
                                   (SDL)
 
-                                Version 1.2
+                                Version 1.3
 
 ---
 http://www.libsdl.org/
@@ -12,10 +12,9 @@
 level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
 and 2D framebuffer across multiple platforms.
 
-The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
-Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
-The code contains support for AIX, OSF/Tru64, RISC OS, and SymbianOS,
-but these are not officially supported.
+The current version supports Windows, Windows CE, Mac OS X, Linux, FreeBSD,
+NetBSD, OpenBSD, BSD/OS, Solaris, QNX, iOS, and Android. The code contains
+support for other operating systems but those are not officially supported.
 
 SDL is written in C, but works with C++ natively, and has bindings to
 several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/README.Platforms	Tue Feb 01 00:37:02 2011 -0800
@@ -0,0 +1,34 @@
+
+This is a list of the platforms SDL supports, and who maintains them.
+
+Officially supported platforms
+==============================
+(code compiles, and thoroughly tested for release)
+==============================
+Windows XP
+Windows Vista
+Windows 7
+Mac OS X 10.4+
+Linux 2.6+
+iOS 3.2+
+Android 1.6+
+
+Unofficially supported platforms
+================================
+(code compiles, but not thoroughly tested)
+================================
+Windows CE
+FreeBSD
+NetBSD
+OpenBSD
+Solaris
+
+Platforms supported by volunteers
+=================================
+Pandora - maintained by Scott Smith <pickle136@sbcglobal.net>
+
+Platforms that need maintainers
+===============================
+Nintendo DS
+QNX
+Haiku
--- a/README.RISCOS	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,129 +0,0 @@
-Readme for RISC OS port of SDL
-==============================
-
-This document last updated on 2nd Februrary 2006
-
-This is a RISC OS port of the Simple Direct Media Layer (SDL) by Alan Buckley with contributions from Peter Naulls.
-
-Details of the SDL can be found at http://www.libsdl.org.
-
-The source code including the RISC OS version can be obtained from:
-
-http://www.libsdl.org.
-
-Pre built libraries and many games and applications compiled for RISC OS using this library can be downloaded from The Unix Porting Project at http://www.riscos.info/unix/.
-
-This is released under the LGPL see the file COPYING for details.
-
-
-Compiling applications under RISC OS
-====================================
-
-Add -ISDL: for the C compiler flags if you include the files in the SDL directory. e.g. #include "SDL/SDL.h"
-Add -ISDL:SDL for the C compiler flags if you include the files directly. e.g. #include "SDL/SDL.h"
-
-Add -LSDL: -lSDL to the link stage of compilation.
-
-For example, to compile the testbitmap.c sample you could use:
-
-gcc -ISDL:SDL -LSDL: -lSDL testbitmap.c -otestbitmap
-
-
-RISC OS port of SDL runtime information
-=======================================
-
-Runtime requirements
---------------------
-
-This library currently needs a minimum of RISC OS 3.6. The source code for the library (and a lot of the programs built with it) also need long file names.
-
-To use the audio you also need 16 bit sound and to have installed the DigitalRender module by Andreas Dehmel version 0.51 available from his
-web site: http://home.t-online.de/~zarquon
-This is loaded when needed by UnixLib.
-
-Note: As most programs ported from other OSes use high resolution graphics and a memory back buffer a machine with a StrongARM processor and 1 or 2MB of VRAM (or a better machine) is recomended.
-
-
-RISC OS runtime parameters
---------------------------
-
-Several environmental variables have been defined to make porting programs easier (i.e. By setting these variable you do not need to have source code differences between OSes).
-
-They are all defined on an application basis.
-
-The <appname> used below is found as follows:
-1. Use the name of the program unless it is !RunImage
-2. Check the folder specification for the folder !RunImage is run from. If it is a folder name use that name, otherwise if it is an environmental variable of the form <XXX$Dir> use the value of XXX.
-
-The variables are:
-
-SDL$<appname>$TaskName
-
-The name of the task for RISC OS. If omitted then <appname> is used for the task name,
-
-SDL$<appname>$BackBuffer
-
-Set to 1 to use a system memory back buffer for the screen in full screen mode. Some programs on other systems assume their is always a back buffer even though the SDL specification specifies this is not the case. The current RISC OS implementation uses direct writes to the screen if a hardware fullscreen is requested.
-
-Set to 2 to use an ARM code full word copy. This is faster than the standard back buffer, but uses aligned words only so it is possible (but unlikely) for it to corrupt the screen for 8bpp and 16bpp modes.
-
-Set to 3 to use a RISC OS sprite as the back buffer. This is usually the slowest for most SDL applications, however it may be useful in the future as Sprite acceleration is added to various hardware that runs RISC OS.
-
-SDL$<appname>$CloseAction - set the action for the close icon. Again as programs don't match the specification you can set this to 0 to remove the close icon from the main window for applications where this does not affect the program.
-
-
-RISC OS SDL port API notes
-==========================
-
-Current level of implementation
--------------------------------
-
-The following list is an overview of how much of the SDL is implemented. The areas match the main areas of the SDL.
-
-video - Mostly done. Doesn't cover gamma, YUV-overlay or OpenGL.
-Window Manager - Mostly done. SetIcon/IconifyWindow not implemented.
-Events - Mostly done. Resize and some joystick events missing.
-Joystick - Currently assumes a single joystick with 4 buttons.
-Audio - Done
-Threads - Done
-Timers - Done
-
-Thread support can be removed by defining DISABLE_THREADS and recompiling the library.
-
-SDL API notes
--------------
-
-This section contains additional notes on some specific commands.
-
-SDL_SetVideoMode
-  On RISC OS a fullscreen mode directly accesses the screen. This can be modified by the environmental variable (SDL$<appname>$BackBuffer) or by using the SDL_SWSURFACE flag to write to an offscreen buffer that is updated using SDL_UpdateRects.
-  Open GL is not supported so SDL_OPENGL and SDL_OPENGLBLIT flags fail.
-  SDL_RESIZEABLE and SDL_NOFRAME flags are not supported.
-
-SDL_SetColors
-  In a wimp mode the screen colours are not changed for a hardware palette instead the RISC OS sprite colour mapping is used to get the best matching colours.
-
-SDL_CreateCursor
-   Inverted colour is not supported.
-
-SDL_WM_ToggleFullScreen
-   Currently this won't work if the application starts up in Fullscreen mode.
-   Toggling to fullscreen will only work if the monitor is set up to support the exact screen size requested.
-
-SDL_EnableUNICODE
-   Unicode translation used here is only really accurate for 7 bit characters.
-
-SDL_NumJoysticks/JoystickName etc.
-   Hardcoded to expect only 1 joystick with 4 buttons if the Joystick module is loaded.
-
-SDL_GetTicks
-   Timer used has only a centisecond accuracy. This applies to other time related functions.
-   
-SDL_Delay
-   Modified to poll keyboard/mouse during the delay on the event thread.
-
-
-Notes on current implementation
--------------------------------
-
-Keyboard and mouse are polled so if too long a time is spent between a call to SDL_PumpEvents, functions that use it, or SDL_Delay events can be missed.
--- a/VisualC/SDL/SDL_VS2005.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualC/SDL/SDL_VS2005.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -29,7 +29,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -207,7 +207,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -648,10 +648,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\atomic\SDL_spinlock.c"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\audio\SDL_audio.c"
 			>
 		</File>
@@ -1048,6 +1044,10 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\atomic\SDL_spinlock.c"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\stdlib\SDL_stdlib.c"
 			>
 		</File>
@@ -1164,6 +1164,22 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\events\SDL_windowevents.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\events\SDL_windowevents_c.h"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\core\windows\SDL_windows.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\core\windows\SDL_windows.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
 			>
 		</File>
@@ -1244,14 +1260,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\events\SDL_windowevents.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\events\SDL_windowevents_c.h"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\video\SDL_yuv_mmx.c"
 			>
 		</File>
--- a/VisualC/SDL/SDL_VS2008.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualC/SDL/SDL_VS2008.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -30,7 +30,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadfood&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -201,7 +201,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadfood&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -1151,6 +1151,22 @@
 			>
 		</File>
 		<File
+			RelativePath="..\..\src\events\SDL_windowevents.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\events\SDL_windowevents_c.h"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\core\windows\SDL_windows.c"
+			>
+		</File>
+		<File
+			RelativePath="..\..\src\core\windows\SDL_windows.h"
+			>
+		</File>
+		<File
 			RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
 			>
 		</File>
@@ -1231,14 +1247,6 @@
 			>
 		</File>
 		<File
-			RelativePath="..\..\src\events\SDL_windowevents.c"
-			>
-		</File>
-		<File
-			RelativePath="..\..\src\events\SDL_windowevents_c.h"
-			>
-		</File>
-		<File
 			RelativePath="..\..\src\video\SDL_yuv_mmx.c"
 			>
 		</File>
--- a/VisualC/SDL/SDL_VS2010.vcxproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualC/SDL/SDL_VS2010.vcxproj	Tue Feb 01 00:37:02 2011 -0800
@@ -74,14 +74,12 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
-      <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_windows.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
-:SDLCONFIGOKAY
+      <Command>echo Copying SDL_config_windows.h to SDL_config.h...
+copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
-echo #define SDL_REVISION 0 &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
+echo #define SDL_REVISION "hg-0:baadf00d" &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
 :SDLREVISIONOKAY
 </Command>
     </PreBuildEvent>
@@ -154,14 +152,12 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
-      <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_windows.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
-:SDLCONFIGOKAY
+      <Command>echo Copying SDL_config_windows.h to SDL_config.h...
+copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
-echo #define SDL_REVISION 0 &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
+echo #define SDL_REVISION "hg-0:baadf00d" &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
 :SDLREVISIONOKAY
 </Command>
     </PreBuildEvent>
@@ -272,6 +268,7 @@
     <ClInclude Include="..\..\include\SDL_types.h" />
     <ClInclude Include="..\..\include\SDL_version.h" />
     <ClInclude Include="..\..\include\SDL_video.h" />
+    <ClInclude Include="..\..\src\core\windows\SDL_windows.h" />
     <ClInclude Include="..\..\src\events\blank_cursor.h" />
     <ClInclude Include="..\..\src\events\default_cursor.h" />
     <ClInclude Include="..\..\src\audio\windx5\directx.h" />
@@ -345,6 +342,7 @@
     <ClInclude Include="..\..\src\video\windows\wmmsg.h" />
   </ItemGroup>
   <ItemGroup>
+    <ClCompile Include="..\..\src\core\windows\SDL_windows.c" />
     <ClCompile Include="..\..\src\events\SDL_clipboardevents.c" />
     <ClCompile Include="..\..\src\events\SDL_gesture.c" />
     <ClCompile Include="..\..\src\events\SDL_touch.c" />
--- a/VisualC/SDLmain/SDLmain_VS2005.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualC/SDLmain/SDLmain_VS2005.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -29,7 +29,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -164,7 +164,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -299,7 +299,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
--- a/VisualC/SDLmain/SDLmain_VS2008.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualC/SDLmain/SDLmain_VS2008.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -30,7 +30,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -165,7 +165,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
@@ -300,7 +300,7 @@
 			<Tool
 				Name="VCPreBuildEventTool"
 				Description="Making sure basic SDL headers are in place..."
-				CommandLine="if exist &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot; goto SDLCONFIGOKAY&#x0D;&#x0A;echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;:SDLCONFIGOKAY&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION 0 &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
+				CommandLine="echo Copying SDL_config_windows.h to SDL_config.h...&#x0D;&#x0A;copy /Y &quot;$(ProjectDir)\..\..\include\SDL_config_windows.h&quot; &quot;$(ProjectDir)\..\..\include\SDL_config.h&quot;&#x0D;&#x0A;&#x0D;&#x0A;if exist &quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot; goto SDLREVISIONOKAY&#x0D;&#x0A;echo Creating stub SDL_revision.h file...&#x0D;&#x0A;echo #define SDL_REVISION &quot;hg-0:baadf00d&quot; &gt;&quot;$(ProjectDir)\..\..\include\SDL_revision.h&quot;&#x0D;&#x0A;:SDLREVISIONOKAY&#x0D;&#x0A;"
 			/>
 			<Tool
 				Name="VCCustomBuildTool"
--- a/VisualC/SDLmain/SDLmain_VS2010.vcxproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualC/SDLmain/SDLmain_VS2010.vcxproj	Tue Feb 01 00:37:02 2011 -0800
@@ -101,14 +101,12 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
-      <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_windows.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
-:SDLCONFIGOKAY
+      <Command>echo Copying SDL_config_windows.h to SDL_config.h...
+copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
-echo #define SDL_REVISION 0 &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
+echo #define SDL_REVISION "hg-0:baadf00d" &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
 :SDLREVISIONOKAY</Command>
     </PreBuildEvent>
     <ClCompile>
@@ -154,14 +152,12 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release_NoSTDIO|Win32'">
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
-      <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_windows.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
-:SDLCONFIGOKAY
+      <Command>echo Copying SDL_config_windows.h to SDL_config.h...
+copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
-echo #define SDL_REVISION 0 &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
+echo #define SDL_REVISION "hg-0:baadf00d" &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
 :SDLREVISIONOKAY</Command>
     </PreBuildEvent>
     <ClCompile>
@@ -207,14 +203,12 @@
   <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
     <PreBuildEvent>
       <Message>Making sure basic SDL headers are in place...</Message>
-      <Command>if exist "$(ProjectDir)\..\..\include\SDL_config.h" goto SDLCONFIGOKAY
-echo Copying SDL_config_windows.h to SDL_config.h...
-copy "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
-:SDLCONFIGOKAY
+      <Command>echo Copying SDL_config_windows.h to SDL_config.h...
+copy /Y "$(ProjectDir)\..\..\include\SDL_config_windows.h" "$(ProjectDir)\..\..\include\SDL_config.h"
 
 if exist "$(ProjectDir)\..\..\include\SDL_revision.h" goto SDLREVISIONOKAY
 echo Creating stub SDL_revision.h file...
-echo #define SDL_REVISION 0 &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
+echo #define SDL_REVISION "hg-0:baadf00d" &gt;"$(ProjectDir)\..\..\include\SDL_revision.h"
 :SDLREVISIONOKAY</Command>
     </PreBuildEvent>
     <ClCompile>
@@ -261,4 +255,4 @@
   <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
   <ImportGroup Label="ExtensionTargets">
   </ImportGroup>
-</Project>
+</Project>
--- a/VisualCE/SDL.sln	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualCE/SDL.sln	Tue Feb 01 00:37:02 2011 -0800
@@ -1,6 +1,6 @@
 
-Microsoft Visual Studio Solution File, Format Version 9.00
-# Visual Studio 2005
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual Studio 2008
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDL", "SDL\SDL.vcproj", "{C598024D-8030-4F9C-AB76-69BF4CA0645F}"
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "SDLmain", "SDLmain\SDLmain.vcproj", "{5AC88B84-5EAA-4C1E-948D-332DA34227F6}"
--- a/VisualCE/SDL/SDL.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualCE/SDL/SDL.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="9.00"
 	Name="SDL"
 	ProjectGUID="{C598024D-8030-4F9C-AB76-69BF4CA0645F}"
 	RootNamespace="SDL"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -93,6 +94,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="_DllMainCRTStartup"
 				BaseAddress="0x00100000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 				ImportLibrary="$(PlatformName)\$(ConfigurationName)/SDL.lib"
 			/>
 			<Tool
@@ -107,6 +110,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDL.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -195,6 +201,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="_DllMainCRTStartup"
 				BaseAddress="0x00100000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 				ImportLibrary="$(PlatformName)\$(ConfigurationName)/SDL.lib"
 			/>
 			<Tool
@@ -209,6 +217,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDL.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -296,6 +307,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="_DllMainCRTStartup"
 				BaseAddress="0x00100000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 				ImportLibrary="$(PlatformName)\$(ConfigurationName)/SDL.lib"
 			/>
 			<Tool
@@ -310,6 +323,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDL.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -396,6 +412,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="_DllMainCRTStartup"
 				BaseAddress="0x00100000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 				ImportLibrary="$(PlatformName)\$(ConfigurationName)/SDL.lib"
 			/>
 			<Tool
@@ -410,6 +428,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDL.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -500,6 +521,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="_DllMainCRTStartup"
 				BaseAddress="0x00100000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 				ImportLibrary="$(PlatformName)\$(ConfigurationName)/SDL.lib"
 			/>
 			<Tool
@@ -514,6 +537,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDL.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -606,6 +632,8 @@
 				LinkTimeCodeGeneration="1"
 				EntryPointSymbol="_DllMainCRTStartup"
 				BaseAddress="0x00100000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 				ImportLibrary="$(PlatformName)\$(ConfigurationName)/SDL.lib"
 			/>
 			<Tool
@@ -620,6 +648,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDL.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -643,1294 +674,238 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 			>
 			<File
+				RelativePath="..\..\src\libm\e_atan2.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\e_log.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\e_pow.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\e_rem_pio2.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\e_sqrt.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\k_cos.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\k_rem_pio2.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\k_sin.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\s_atan.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\s_copysign.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\s_cos.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\s_fabs.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\s_floor.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\s_scalbn.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\libm\s_sin.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\SDL.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_alphamult.c"
+				>
 			</File>
 			<File
-				RelativePath="..\..\src\events\SDL_active.c"
+				RelativePath="..\..\src\SDL_assert.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\atomic\SDL_atomic.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\audio\SDL_audio.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\audio\SDL_audiocvt.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\audio\SDL_audiodev.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\audio\SDL_audiotypecvt.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_blendfillrect.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_blendline.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_blendpoint.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_blendrect.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_blit.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_blit_0.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_blit_1.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_blit_A.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_blit_auto.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_blit_copy.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_blit_N.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_blit_slow.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_bmp.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_ceddrawrender.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_clipboard.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\events\SDL_clipboardevents.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\SDL_compat.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\cpuinfo\SDL_cpuinfo.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_cursor.c"
+				RelativePath="..\..\src\video\windows\SDL_d3drender.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\audio\windib\SDL_dibaudio.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\src\video\windib\SDL_dibevents.c"
-				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\src\video\windib\SDL_dibvideo.c"
-				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\audio\disk\SDL_diskaudio.c"
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\video\SDL_drawline.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_drawpoint.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_drawrect.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\audio\dummy\SDL_dummyaudio.c"
 				>
 			</File>
 			<File
 				RelativePath="..\..\src\SDL_error.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\events\SDL_events.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\src\events\SDL_expose.c"
-				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\SDL_fatal.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_fillrect.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_gamma.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_gapirender.c"
+				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\gapi\sdl_gapivideo.c"
+				RelativePath="..\..\src\video\windows\SDL_gdirender.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\events\SDL_gesture.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\stdlib\SDL_getenv.c"
 				>
 			</File>
 			<File
+				RelativePath="..\..\src\haptic\SDL_haptic.c"
+				>
+			</File>
+			<File
 				RelativePath="..\..\src\stdlib\SDL_iconv.c"
 				>
 			</File>
@@ -1941,60 +916,6 @@
 			<File
 				RelativePath="..\..\src\events\SDL_keyboard.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\stdlib\SDL_malloc.c"
@@ -2003,183 +924,17 @@
 			<File
 				RelativePath="..\..\src\audio\SDL_mixer.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\src\audio\SDL_mixer_MMX_VC.c"
-				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\events\SDL_mouse.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\video\dummy\SDL_nullevents.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\dummy\SDL_nullmouse.c"
+				RelativePath="..\..\src\video\dummy\SDL_nullrender.c"
 				>
 			</File>
 			<File
@@ -2189,60 +944,10 @@
 			<File
 				RelativePath="..\..\src\video\SDL_pixels.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\power\SDL_power.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\stdlib\SDL_qsort.c"
@@ -2251,292 +956,38 @@
 			<File
 				RelativePath="..\..\src\events\SDL_quit.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\src\events\SDL_resize.c"
+				RelativePath="..\..\src\video\SDL_rect.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_renderer_sw.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_RLEaccel.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\file\SDL_rwops.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_shape.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\atomic\SDL_spinlock.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\stdlib\SDL_stdlib.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_stretch.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\stdlib\SDL_string.c"
@@ -2545,1000 +996,118 @@
 			<File
 				RelativePath="..\..\src\video\SDL_surface.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\src\thread\generic\SDL_syscond.c"
+				RelativePath="..\..\src\haptic\dummy\SDL_syshaptic.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\src\video\wincommon\SDL_sysevents.c"
-				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\joystick\dummy\SDL_sysjoystick.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\src\loadso\win32\SDL_sysloadso.c"
+				RelativePath="..\..\src\loadso\windows\SDL_sysloadso.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\thread\windows\SDL_sysmutex.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\wincommon\SDL_sysmouse.c"
+				RelativePath="..\..\src\power\windows\SDL_syspower.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\src\thread\win32\SDL_sysmutex.c"
+				RelativePath="..\..\src\thread\windows\SDL_syssem.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
-				RelativePath="..\..\src\thread\win32\SDL_syssem.c"
+				RelativePath="..\..\src\thread\windows\SDL_systhread.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
-				RelativePath="..\..\src\thread\win32\SDL_systhread.c"
-				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\timer\wince\SDL_systimer.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\wincommon\SDL_syswm.c"
-				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-			</File>
-			<File
 				RelativePath="..\..\src\thread\SDL_thread.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\timer\SDL_timer.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\events\SDL_touch.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_video.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\audio\SDL_wave.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\events\SDL_windowevents.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\windows\SDL_windows.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsclipboard.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsevents.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsgamma.c"
+				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\wincommon\SDL_wingl.c"
+				RelativePath="..\..\src\video\windows\SDL_windowskeyboard.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsmodes.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsmouse.c"
+				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_yuv.c"
+				RelativePath="..\..\src\video\windows\SDL_windowsopengl.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsshape.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsvideo.c"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowswindow.c"
+				>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_yuv_mmx.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 			<File
 				RelativePath="..\..\src\video\SDL_yuv_sw.c"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\thread\win32\win_ce_semaphore.c"
+				RelativePath="..\..\src\thread\windows\win_ce_semaphore.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 		</Filter>
 		<Filter
@@ -3546,27 +1115,19 @@
 			Filter="h;hpp;hxx;hm;inl"
 			>
 			<File
-				RelativePath="..\..\include\begin_code.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\blank_cursor.h"
+				RelativePath="..\..\src\events\blank_cursor.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\close_code.h"
+				RelativePath="..\..\src\events\default_cursor.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\default_cursor.h"
+				RelativePath="..\..\src\libm\math.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\hermes\HeadMMX.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\hermes\HeadX86.h"
+				RelativePath="..\..\src\libm\math_private.h"
 				>
 			</File>
 			<File
@@ -3574,15 +1135,27 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL.h"
+				RelativePath="..\..\src\events\scancodes_darwin.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\events\scancodes_linux.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_active.h"
+				RelativePath="..\..\src\events\scancodes_windows.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_audio.h"
+				RelativePath="..\..\src\events\scancodes_xfree86.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_alphamult.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\SDL_assert_c.h"
 				>
 			</File>
 			<File
@@ -3602,27 +1175,27 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_byteorder.h"
+				RelativePath="..\..\src\video\SDL_blit_auto.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_config.h"
+				RelativePath="..\..\src\video\SDL_blit_copy.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_config_wince.h"
+				RelativePath="..\..\src\video\SDL_blit_slow.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_copying.h"
+				RelativePath="..\..\src\video\windows\SDL_ceddrawrender.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_cpuinfo.h"
+				RelativePath="..\..\src\events\SDL_clipboardevents_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_cursor_c.h"
+				RelativePath="..\..\src\video\windows\SDL_d3drender.h"
 				>
 			</File>
 			<File
@@ -3630,15 +1203,11 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windib\SDL_dibevents_c.h"
+				RelativePath="..\..\src\audio\disk\SDL_diskaudio.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\windib\SDL_dibvideo.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\audio\disk\SDL_diskaudio.h"
+				RelativePath="..\..\src\video\SDL_draw.h"
 				>
 			</File>
 			<File
@@ -3646,22 +1215,10 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_endian.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_error.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\SDL_error_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_events.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\events\SDL_events_c.h"
 				>
 			</File>
@@ -3670,11 +1227,23 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\gapi\sdl_gapivideo.h"
+				RelativePath="..\..\src\video\windows\SDL_gapirender.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_gapirender_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_getenv.h"
+				RelativePath="..\..\src\video\windows\SDL_gdirender.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\events\SDL_gesture_c.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\SDL_glesfuncs.h"
 				>
 			</File>
 			<File
@@ -3682,7 +1251,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_joystick.h"
+				RelativePath="..\..\src\haptic\SDL_haptic_c.h"
 				>
 			</File>
 			<File
@@ -3690,11 +1259,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_keyboard.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_keysym.h"
+				RelativePath="..\..\src\events\SDL_keyboard_c.h"
 				>
 			</File>
 			<File
@@ -3702,39 +1267,11 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_loadso.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\wincommon\SDL_lowvideo.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_main.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\SDL_memops.h"
+				RelativePath="..\..\src\events\SDL_mouse_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\audio\SDL_mixer_MMX.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\audio\SDL_mixer_MMX_VC.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_mouse.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_mutex.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_name.h"
+				RelativePath="..\..\src\video\windows\SDL_msctf.h"
 				>
 			</File>
 			<File
@@ -3742,7 +1279,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\dummy\SDL_nullmouse_c.h"
+				RelativePath="..\..\src\video\dummy\SDL_nullrender_c.h"
 				>
 			</File>
 			<File
@@ -3750,19 +1287,15 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_opengl.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\video\SDL_pixels_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_platform.h"
+				RelativePath="..\..\src\video\SDL_rect_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_quit.h"
+				RelativePath="..\..\src\video\SDL_renderer_sw.h"
 				>
 			</File>
 			<File
@@ -3770,11 +1303,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_rwops.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\SDL_stretch_c.h"
+				RelativePath="..\..\src\video\SDL_shape_internals.h"
 				>
 			</File>
 			<File
@@ -3782,27 +1311,15 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\thread\generic\SDL_syscond_c.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\events\SDL_sysevents.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\joystick\SDL_sysjoystick.h"
+				RelativePath="..\..\src\haptic\SDL_syshaptic.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\wincommon\SDL_sysmouse_c.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\thread\generic\SDL_sysmutex_c.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\thread\generic\SDL_syssem_c.h"
+				RelativePath="..\..\src\joystick\SDL_sysjoystick.h"
 				>
 			</File>
 			<File
@@ -3810,11 +1327,7 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\thread\generic\SDL_systhread_c.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\thread\win32\SDL_systhread_c.h"
+				RelativePath="..\..\src\thread\windows\SDL_systhread_c.h"
 				>
 			</File>
 			<File
@@ -3826,43 +1339,19 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_syswm.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\wincommon\SDL_syswm_c.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_thread.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\thread\SDL_thread_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_timer.h"
-				>
-			</File>
-			<File
 				RelativePath="..\..\src\timer\SDL_timer_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_types.h"
+				RelativePath="..\..\src\events\SDL_touch_c.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\include\SDL_version.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\include\SDL_video.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\windib\SDL_vkeys.h"
+				RelativePath="..\..\src\video\windows\SDL_vkeys.h"
 				>
 			</File>
 			<File
@@ -3870,7 +1359,51 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\wincommon\SDL_wingl_c.h"
+				RelativePath="..\..\src\events\SDL_windowevents_c.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\core\windows\SDL_windows.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsclipboard.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsevents.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsgamma.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowskeyboard.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsmodes.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsmouse.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsopengl.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsshape.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowsvideo.h"
+				>
+			</File>
+			<File
+				RelativePath="..\..\src\video\windows\SDL_windowswindow.h"
 				>
 			</File>
 			<File
@@ -3878,15 +1411,11 @@
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\video\SDL_yuvfuncs.h"
+				RelativePath="..\..\src\thread\windows\win_ce_semaphore.h"
 				>
 			</File>
 			<File
-				RelativePath="..\..\src\thread\win32\win_ce_semaphore.h"
-				>
-			</File>
-			<File
-				RelativePath="..\..\src\video\wincommon\wmmsg.h"
+				RelativePath="..\..\src\video\windows\wmmsg.h"
 				>
 			</File>
 		</Filter>
--- a/VisualCE/SDLMain/SDLmain.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualCE/SDLMain/SDLmain.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="9.00"
 	Name="SDLmain"
 	ProjectGUID="{5AC88B84-5EAA-4C1E-948D-332DA34227F6}"
 	RootNamespace="SDLmain"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -89,6 +90,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDLmain.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -172,6 +176,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDLmain.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -255,6 +262,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDLmain.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -338,6 +348,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDLmain.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -421,6 +434,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDLmain.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -507,6 +523,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/SDLmain.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -530,62 +549,8 @@
 			Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
 			>
 			<File
-				RelativePath="..\..\src\main\win32\SDL_win32_main.c"
+				RelativePath="..\..\src\main\windows\SDL_windows_main.c"
 				>
-				<FileConfiguration
-					Name="Debug|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Debug|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Smartphone 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Pocket PC 2003 (ARMV4)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
-				<FileConfiguration
-					Name="Release|Windows Mobile 5.0 Pocket PC SDK (ARMV4I)"
-					>
-					<Tool
-						Name="VCCLCompilerTool"
-						AdditionalIncludeDirectories=""
-						UsePrecompiledHeader="0"
-					/>
-				</FileConfiguration>
 			</File>
 		</Filter>
 		<Filter
--- a/VisualCE/loopwave/loopwave.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualCE/loopwave/loopwave.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="9.00"
 	Name="loopwave"
 	ProjectGUID="{6F642636-CB11-4DC7-855E-27FE1744003A}"
 	RootNamespace="loopwave"
 	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -74,6 +75,8 @@
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/loopwave.pdb"
 				SubSystem="0"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -85,6 +88,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -125,7 +131,7 @@
 				Name="VCCLCompilerTool"
 				ExecutionBucket="7"
 				Optimization="0"
-				AdditionalIncludeDirectories="..\..\nclude"
+				AdditionalIncludeDirectories="..\..\include"
 				PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_WINDOWS;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
 				MinimalRebuild="true"
 				RuntimeLibrary="1"
@@ -154,6 +160,8 @@
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/loopwave.pdb"
 				SubSystem="0"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -165,6 +173,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -236,6 +247,8 @@
 				SubSystem="0"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -247,6 +260,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -317,6 +333,8 @@
 				SubSystem="0"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -328,6 +346,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
--- a/VisualCE/testalpha/testalpha.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualCE/testalpha/testalpha.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="9.00"
 	Name="testalpha"
 	ProjectGUID="{DF401CB3-6F70-4485-996B-B7C357CF7EE7}"
 	RootNamespace="testalpha"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -94,6 +95,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -107,6 +110,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testalpha.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -195,6 +201,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -208,6 +216,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testalpha.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -300,6 +311,8 @@
 				LinkTimeCodeGeneration="1"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -313,6 +326,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testalpha.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -400,6 +416,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -413,6 +431,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testalpha.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -500,6 +521,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -513,6 +536,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testalpha.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -600,6 +626,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -613,6 +641,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testalpha.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
--- a/VisualCE/testtimer/testtimer.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualCE/testtimer/testtimer.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -1,11 +1,12 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="9.00"
 	Name="testtimer"
 	ProjectGUID="{D482D7EE-6FF0-4254-9027-C59F8F03AB1F}"
 	RootNamespace="testtimer"
 	Keyword="Win32Proj"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -74,6 +75,8 @@
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/testtimer.pdb"
 				SubSystem="0"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -85,6 +88,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -125,6 +131,7 @@
 				Name="VCCLCompilerTool"
 				ExecutionBucket="7"
 				Optimization="0"
+				AdditionalIncludeDirectories="..\..\include"
 				PreprocessorDefinitions="_DEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;DEBUG;_WINDOWS;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
 				MinimalRebuild="true"
 				RuntimeLibrary="1"
@@ -153,6 +160,8 @@
 				GenerateDebugInformation="true"
 				ProgramDatabaseFile="$(OutDir)/testtimer.pdb"
 				SubSystem="0"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -164,6 +173,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -235,6 +247,8 @@
 				SubSystem="0"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -246,6 +260,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -286,6 +303,7 @@
 				Name="VCCLCompilerTool"
 				ExecutionBucket="7"
 				Optimization="2"
+				AdditionalIncludeDirectories="..\..\include"
 				PreprocessorDefinitions="NDEBUG;_WIN32_WCE=$(CEVER);UNDER_CE;$(PLATFORMDEFINES);WINCE;_WINDOWS;$(ARCHFAM);$(_ARCHFAM_);_UNICODE;UNICODE"
 				RuntimeLibrary="0"
 				UsePrecompiledHeader="0"
@@ -315,6 +333,8 @@
 				SubSystem="0"
 				OptimizeReferences="2"
 				EnableCOMDATFolding="2"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -326,6 +346,9 @@
 				Name="VCBscMakeTool"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
--- a/VisualCE/testwin/testwin.vcproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/VisualCE/testwin/testwin.vcproj	Tue Feb 01 00:37:02 2011 -0800
@@ -1,10 +1,11 @@
 <?xml version="1.0" encoding="windows-1251"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="8,00"
+	Version="9.00"
 	Name="testwin"
 	ProjectGUID="{DC516978-88CB-4F9A-A39A-C351C258613B}"
 	RootNamespace="testwin"
+	TargetFrameworkVersion="131072"
 	>
 	<Platforms>
 		<Platform
@@ -93,6 +94,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -106,6 +109,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testwin.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -194,6 +200,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -207,6 +215,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testwin.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -295,6 +306,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -308,6 +321,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testwin.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -395,6 +411,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -408,6 +426,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testwin.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -495,6 +516,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -508,6 +531,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testwin.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
@@ -595,6 +621,8 @@
 				StackCommitSize="4096"
 				EntryPointSymbol="WinMainCRTStartup"
 				BaseAddress="0x00010000"
+				RandomizedBaseAddress="1"
+				DataExecutionPrevention="0"
 			/>
 			<Tool
 				Name="VCALinkTool"
@@ -608,6 +636,9 @@
 				OutputFile="$(PlatformName)\$(ConfigurationName)/testwin.bsc"
 			/>
 			<Tool
+				Name="VCFxCopTool"
+			/>
+			<Tool
 				Name="VCCodeSignTool"
 			/>
 			<Tool
--- a/Xcode-iPhoneOS/Demos/src/keyboard.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/Xcode-iPhoneOS/Demos/src/keyboard.c	Tue Feb 01 00:37:02 2011 -0800
@@ -34,7 +34,7 @@
 */
 typedef struct
 {
-    SDL_scancode scancode;      /* scancode of the key we want to map */
+    SDL_ScanCode scancode;      /* scancode of the key we want to map */
     int allow_no_mod;           /* is the map valid if the key has no modifiers? */
     SDLMod mod;                 /* what modifiers are allowed for the mapping */
     int index;                  /* what index in the font does the scancode map to */
@@ -103,7 +103,7 @@
 };
 
 /*
-	This function maps an SDL_keysym to an index in the bitmap font.
+	This function maps an SDL_KeySym to an index in the bitmap font.
 	It does so by scanning through the font mapping table one entry
 	at a time.
  
@@ -113,7 +113,7 @@
 	If there is no entry for the key, -1 is returned
 */
 int
-keyToIndex(SDL_keysym key)
+keyToIndex(SDL_KeySym key)
 {
     int i, index = -1;
     for (i = 0; i < TABLE_SIZE; i++) {
@@ -240,7 +240,7 @@
     SDL_Window *window;
     SDL_Event event;            /* last event received */
     SDLMod mod;                 /* key modifiers of last key we pushed */
-    SDL_scancode scancode;      /* scancode of last key we pushed */
+    SDL_ScanCode scancode;      /* scancode of last key we pushed */
 
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
         printf("Error initializing SDL: %s", SDL_GetError());
--- a/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Mon Jan 31 07:36:12 2011 -0800
+++ b/Xcode/SDL/SDL.xcodeproj/project.pbxproj	Tue Feb 01 00:37:02 2011 -0800
@@ -123,6 +123,10 @@
 		00D8DA2A1195093100638393 /* testsdl.c in Sources */ = {isa = PBXBuildFile; fileRef = 00D8DA1A1195093100638393 /* testsdl.c */; };
 		044E5F8511E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		044E5F8611E6051C0076F181 /* SDL_clipboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 044E5F8411E6051C0076F181 /* SDL_clipboard.h */; };
+		0469A10B12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		0469A10C12EE4BF100B846D6 /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */; settings = {ATTRIBUTES = (Public, ); }; };
+		0469A10D12EE4BF100B846D6 /* SDL_blendmode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10912EE4BF100B846D6 /* SDL_blendmode.h */; };
+		0469A10E12EE4BF100B846D6 /* SDL_scalemode.h in Headers */ = {isa = PBXBuildFile; fileRef = 0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */; };
 		04BD000812E6671800899322 /* SDL_diskaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD8812E6671700899322 /* SDL_diskaudio.c */; };
 		04BD000912E6671800899322 /* SDL_diskaudio.h in Headers */ = {isa = PBXBuildFile; fileRef = 04BDFD8912E6671700899322 /* SDL_diskaudio.h */; };
 		04BD001012E6671800899322 /* SDL_dummyaudio.c in Sources */ = {isa = PBXBuildFile; fileRef = 04BDFD9412E6671700899322 /* SDL_dummyaudio.c */; };
@@ -578,7 +582,7 @@
 		04DEA57311E6006A00386CAC /* SDL_input.h in Headers */ = {isa = PBXBuildFile; fileRef = 04DEA56F11E6006A00386CAC /* SDL_input.h */; };
 		04F2AF691104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		04F2AF6A1104AC4500D6DDF7 /* SDL_assert.h in Headers */ = {isa = PBXBuildFile; fileRef = 04F2AF681104AC4500D6DDF7 /* SDL_assert.h */; };
-		453773821207C518002F0F45 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 453773811207C518002F0F45 /* SDL_shape.h */; };
+		453773821207C518002F0F45 /* SDL_shape.h in Headers */ = {isa = PBXBuildFile; fileRef = 453773811207C518002F0F45 /* SDL_shape.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8CB0A77811F6A87F00CBA2DE /* SDL_gesture.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CB0A77611F6A87F00CBA2DE /* SDL_gesture.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		8CB0A77911F6A87F00CBA2DE /* SDL_touch.h in Headers */ = {isa = PBXBuildFile; fileRef = 8CB0A77711F6A87F00CBA2DE /* SDL_touch.h */; settings = {ATTRIBUTES = (Public, ); }; };
 		BECDF6760761BA81005FE872 /* SDL_cpuinfo.h in Headers */ = {isa = PBXBuildFile; fileRef = B2CF8DC405C444E400E5DC7F /* SDL_cpuinfo.h */; };
@@ -711,6 +715,8 @@
 		00D8DA1A1195093100638393 /* testsdl.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = testsdl.c; path = ../../test/automated/testsdl.c; sourceTree = SOURCE_ROOT; };
 		00F5D79E0990CA0D0051C449 /* UniversalBinaryNotes.rtf */ = {isa = PBXFileReference; lastKnownFileType = text.rtf; path = UniversalBinaryNotes.rtf; sourceTree = "<group>"; };
 		044E5F8411E6051C0076F181 /* SDL_clipboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_clipboard.h; path = ../../include/SDL_clipboard.h; sourceTree = SOURCE_ROOT; };
+		0469A10912EE4BF100B846D6 /* SDL_blendmode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_blendmode.h; path = ../../include/SDL_blendmode.h; sourceTree = SOURCE_ROOT; };
+		0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = SDL_scalemode.h; path = ../../include/SDL_scalemode.h; sourceTree = SOURCE_ROOT; };
 		04BDFD7412E6671700899322 /* SDL_atomic.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_atomic.c; sourceTree = "<group>"; };
 		04BDFD7512E6671700899322 /* SDL_spinlock.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_spinlock.c; sourceTree = "<group>"; };
 		04BDFD8812E6671700899322 /* SDL_diskaudio.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; path = SDL_diskaudio.c; sourceTree = "<group>"; };
@@ -1141,14 +1147,13 @@
 		0153844A006D81B07F000001 /* Public Headers */ = {
 			isa = PBXGroup;
 			children = (
-				8CB0A77611F6A87F00CBA2DE /* SDL_gesture.h */,
-				8CB0A77711F6A87F00CBA2DE /* SDL_touch.h */,
 				0C5AF5E501191D2B7F000001 /* begin_code.h */,
 				0C5AF5E601191D2B7F000001 /* close_code.h */,
 				0C5AF5FF01191D2B7F000001 /* SDL.h */,
 				04F2AF681104AC4500D6DDF7 /* SDL_assert.h */,
 				00CFA67A106B44CE00758660 /* SDL_atomic.h */,
 				0C5AF5E801191D2B7F000001 /* SDL_audio.h */,
+				0469A10912EE4BF100B846D6 /* SDL_blendmode.h */,
 				044E5F8411E6051C0076F181 /* SDL_clipboard.h */,
 				00CFA67B106B44CE00758660 /* SDL_compat.h */,
 				00162D3709BD1FA90037C8D0 /* SDL_config.h */,
@@ -1158,6 +1163,7 @@
 				0C5AF5EC01191D2B7F000001 /* SDL_endian.h */,
 				0C5AF5ED01191D2B7F000001 /* SDL_error.h */,
 				0C5AF5EE01191D2B7F000001 /* SDL_events.h */,
+				8CB0A77611F6A87F00CBA2DE /* SDL_gesture.h */,
 				00CFA67C106B44CE00758660 /* SDL_haptic.h */,
 				04DEA56F11E6006A00386CAC /* SDL_input.h */,
 				0C5AF5F001191D2B7F000001 /* SDL_joystick.h */,
@@ -1176,6 +1182,7 @@
 				00CFA67F106B44CE00758660 /* SDL_rect.h */,
 				00A6EBD91078D569001EEA06 /* SDL_revision.h */,
 				0C5AF5F801191D2B7F000001 /* SDL_rwops.h */,
+				0469A10A12EE4BF100B846D6 /* SDL_scalemode.h */,
 				00CFA680106B44CE00758660 /* SDL_scancode.h */,
 				453773811207C518002F0F45 /* SDL_shape.h */,
 				00162D3909BD1FA90037C8D0 /* SDL_stdinc.h */,
@@ -1183,6 +1190,7 @@
 				0C5AF5F901191D2B7F000001 /* SDL_syswm.h */,
 				0C5AF5FA01191D2B7F000001 /* SDL_thread.h */,
 				0C5AF5FB01191D2B7F000001 /* SDL_timer.h */,
+				8CB0A77711F6A87F00CBA2DE /* SDL_touch.h */,
 				0C5AF5FC01191D2B7F000001 /* SDL_types.h */,
 				0C5AF5FD01191D2B7F000001 /* SDL_version.h */,
 				0C5AF5FE01191D2B7F000001 /* SDL_video.h */,
@@ -1952,6 +1960,8 @@
 				04BD020712E6671800899322 /* Xvlib.h in Headers */,
 				04BD020812E6671800899322 /* Xvproto.h in Headers */,
 				04BD021512E6671800899322 /* Xvlibint.h in Headers */,
+				0469A10B12EE4BF100B846D6 /* SDL_blendmode.h in Headers */,
+				0469A10C12EE4BF100B846D6 /* SDL_scalemode.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2080,6 +2090,8 @@
 				04BD041F12E6671800899322 /* Xvlib.h in Headers */,
 				04BD042012E6671800899322 /* Xvproto.h in Headers */,
 				04BD042C12E6671800899322 /* Xvlibint.h in Headers */,
+				0469A10D12EE4BF100B846D6 /* SDL_blendmode.h in Headers */,
+				0469A10E12EE4BF100B846D6 /* SDL_scalemode.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -2280,7 +2292,7 @@
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 			shellPath = /bin/sh;
-			shellScript = "# The underlying scripts require calling hg to get revision info.\n# Since hg may not be in the standard Xcode path, I am sourcing .bashrc\n# But I don't know what to do if people are using other shells.\nif test -f ~/.bash_profile; then source ~/.bash_profile; fi\nif test -f ~/.bashrc; then source ~/.bashrc; fi\nsh ../../build-scripts/updaterev.sh\n";
+			shellScript = "# The official HG installer puts the binary in /usr/local/bin, so add that\n# to Xcode's path and see if the hg executable is found. Otherwise, source\n# the user's bash settings file as a last resort.\nPATH=$PATH:/usr/local/bin\nif ! which -s hg ; then\n    if test -f ~/.bash_profile; then source ~/.bash_profile; fi\nfi\nsh ../../build-scripts/updaterev.sh\n";
 		};
 		0083103E1072EA5700A531F1 /* ShellScript */ = {
 			isa = PBXShellScriptBuildPhase;
--- a/acinclude/libtool.m4	Mon Jan 31 07:36:12 2011 -0800
+++ b/acinclude/libtool.m4	Tue Feb 01 00:37:02 2011 -0800
@@ -3014,7 +3014,7 @@
     lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
     lt_cv_file_magic_cmd='func_win32_libid'
   else
-    lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
     lt_cv_file_magic_cmd='$OBJDUMP -f'
   fi
   lt_cv_deplibs_check_method=pass_all
--- a/build-scripts/ltmain.sh	Mon Jan 31 07:36:12 2011 -0800
+++ b/build-scripts/ltmain.sh	Tue Feb 01 00:37:02 2011 -0800
@@ -2560,7 +2560,7 @@
     ;;
   *ar\ archive*) # could be an import, or static
     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
-       $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+       $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null ; then
       win32_nmres=`eval $NM -f posix -A $1 |
 	$SED -n -e '
 	    1,100{
--- a/configure.in	Mon Jan 31 07:36:12 2011 -0800
+++ b/configure.in	Tue Feb 01 00:37:02 2011 -0800
@@ -301,6 +301,7 @@
     int a;
     void *x, *y, *z;
     __sync_lock_test_and_set(&a, 4);
+    __sync_lock_test_and_set(&x, y);
     __sync_fetch_and_add(&a, 1);
     __sync_bool_compare_and_swap(&a, 5, 10);
     __sync_bool_compare_and_swap(&x, y, z);
@@ -317,6 +318,7 @@
         ],[
         int a;
         __sync_lock_test_and_set(&a, 1);
+        __sync_lock_release(&a);
         ],[
         have_gcc_sync_lock_test_and_set=yes
         ])
@@ -2446,6 +2448,10 @@
         CheckWINDOWS
         CheckWINDOWSGL
         CheckDIRECTX
+
+        # Set up the core platform files
+        SOURCES="$SOURCES $srcdir/src/core/windows/*.c"
+
         # Set up files for the video library
         if test x$enable_video = xyes; then
             AC_DEFINE(SDL_VIDEO_DRIVER_WINDOWS)
@@ -2662,32 +2668,6 @@
             EXTRA_LDFLAGS="$EXTRA_LDFLAGS -Wl,-framework,CoreAudio -Wl,-framework,AudioToolbox -Wl,-framework,AudioUnit"
         fi
         ;;
-    *-riscos)
-        ARCH=riscos
-        CheckOSS
-        CheckPTHREAD
-        # Set up files for the video library
-        if test x$enable_video = xyes; then
-            AC_DEFINE(SDL_VIDEO_DRIVER_RISCOS)
-            SOURCES="$SOURCES $srcdir/src/video/riscos/*.c"
-            SOURCES="$SOURCES $srcdir/src/video/riscos/*.S"
-            have_video=yes
-        fi
-        # Set up files for the joystick library
-        if test x$enable_joystick = xyes; then
-            AC_DEFINE(SDL_JOYSTICK_RISCOS)
-            SOURCES="$SOURCES $srcdir/src/joystick/riscos/*.c"
-            have_joystick=yes
-        fi
-        # Set up files for the timer library
-        if test x$enable_timers = xyes; then
-            AC_DEFINE(SDL_TIMER_RISCOS)
-            SOURCES="$SOURCES $srcdir/src/timer/riscos/*.c"
-            have_timers=yes
-        fi
-        # The RISC OS platform requires special setup.
-        EXTRA_LDFLAGS="$EXTRA_LDFLAGS -ljpeg -ltiff -lpng -lz"
-        ;;
     *)
         AC_MSG_ERROR([
 *** Unsupported host:  Please add to configure.in
@@ -2732,10 +2712,10 @@
 fi
 
 OBJECTS=`echo $SOURCES`
-DEPENDS=`echo $SOURCES`
+DEPENDS=`echo $SOURCES | tr ' ' '\n'`
 for EXT in asm cc m c S; do
     OBJECTS=`echo "$OBJECTS" | sed 's,[[^ ]]*/\([[^ ]]*\)\.'$EXT',$(objects)/\1.lo,g'`
-    DEPENDS=`echo "$DEPENDS" | sed "s,\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT,\\\\
+    DEPENDS=`echo "$DEPENDS" | sed "s,^\\([[^ ]]*\\)/\\([[^ ]]*\\)\\.$EXT\\$,\\\\
 \\$(objects)/\\2.lo: \\1/\\2.$EXT\\\\
 	\\$(LIBTOOL) --mode=compile \\$(CC) \\$(CFLAGS) \\$(EXTRA_CFLAGS) $DEPENDENCY_TRACKING_OPTIONS -c \\$< -o \\$@,g"`
 done
--- a/include/SDL.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL.h	Tue Feb 01 00:37:02 2011 -0800
@@ -116,7 +116,6 @@
 #define SDL_INIT_JOYSTICK       0x00000200
 #define SDL_INIT_HAPTIC         0x00001000
 #define SDL_INIT_NOPARACHUTE    0x00100000      /**< Don't catch fatal signals */
-#define SDL_INIT_EVENTTHREAD    0x01000000      /**< Not supported on all OS's */
 #define SDL_INIT_EVERYTHING     0x0000FFFF
 /*@}*/
 
--- a/include/SDL_assert.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_assert.h	Tue Feb 01 00:37:02 2011 -0800
@@ -50,7 +50,7 @@
 assert can have unique static variables associated with it.
 */
 
-#if defined(_MSC_VER)
+#if defined(_MSC_VER) && !defined(_WIN32_WCE)
 #include <intrin.h>
     #define SDL_TriggerBreakpoint() __debugbreak()
 #elif (defined(__GNUC__) && ((__i386__) || (__x86_64__)))
--- a/include/SDL_atomic.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_atomic.h	Tue Feb 01 00:37:02 2011 -0800
@@ -38,8 +38,16 @@
  *  SDL_AtomicDecRef()
  * 
  * Seriously, here be dragons!
+ * ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  *
- * These operations may, or may not, actually be implemented using
+ * You can find out a little more about lockless programming and the 
+ * subtle issues that can arise here:
+ * http://msdn.microsoft.com/en-us/library/ee418650%28v=vs.85%29.aspx
+ *
+ * There's also lots of good information here:
+ * http://www.1024cores.net/home/lock-free-algorithms
+ *
+ * These operations may or may not actually be implemented using
  * processor specific atomic operations. When possible they are
  * implemented as true processor specific atomic operations. When that
  * is not possible the are implemented using locks that *do* use the
@@ -58,9 +66,9 @@
 
 /* Need to do this here because intrin.h has C++ code in it */
 /* Visual Studio 2005 has a bug where intrin.h conflicts with winnt.h */
-#if defined(_MSC_VER) && (_MSC_VER >= 1500)
+#if defined(_MSC_VER) && (_MSC_VER >= 1500) && !defined(_WIN32_WCE)
 #include <intrin.h>
-#define HAVE_MSC_ATOMICS
+#define HAVE_MSC_ATOMICS 1
 #endif
 
 /* Set up for C function definitions, even when using C++ */
@@ -114,19 +122,32 @@
 
 /*@}*//*SDL AtomicLock*/
 
+
+/* The compiler barrier prevents the compiler from reordering
+   reads and writes to globally visible variables across the call.
+*/
+#ifdef _MSC_VER
+void _ReadWriteBarrier(void);
+#pragma intrinsic(_ReadWriteBarrier)
+#define SDL_CompilerBarrier()   _ReadWriteBarrier()
+#elif defined(__GNUC__)
+#define SDL_CompilerBarrier()   __asm__ __volatile__ ("" : : : "memory")
+#else
+#define SDL_CompilerBarrier()   \
+({ SDL_SpinLock _tmp = 0; SDL_AtomicLock(&_tmp); SDL_AtomicUnlock(&_tmp); })
+#endif
+
 /* Platform specific optimized versions of the atomic functions,
  * you can disable these by defining SDL_DISABLE_ATOMIC_INLINE
  */
 #ifndef SDL_DISABLE_ATOMIC_INLINE
 
-#if defined(HAVE_MSC_ATOMICS)
+#ifdef HAVE_MSC_ATOMICS
 
 #define SDL_AtomicSet(a, v)     _InterlockedExchange((long*)&(a)->value, (v))
-#define SDL_AtomicGet(a)        ((a)->value)
 #define SDL_AtomicAdd(a, v)     _InterlockedExchangeAdd((long*)&(a)->value, (v))
 #define SDL_AtomicCAS(a, oldval, newval) (_InterlockedCompareExchange((long*)&(a)->value, (newval), (oldval)) == (oldval))
-#define SDL_AtomicSetPtr(a, v)  (void)_InterlockedExchangePointer((a), (v))
-#define SDL_AtomicGetPtr(a)     (*(a))
+#define SDL_AtomicSetPtr(a, v)  _InterlockedExchangePointer((a), (v))
 #if _M_IX86
 #define SDL_AtomicCASPtr(a, oldval, newval) (_InterlockedCompareExchange((long*)(a), (long)(newval), (long)(oldval)) == (long)(oldval))
 #else
@@ -136,30 +157,7 @@
 #elif defined(__MACOSX__)
 #include <libkern/OSAtomic.h>
 
-#define SDL_AtomicSet(a, v) \
-({                          \
-    int oldvalue;           \
-                            \
-    do {                    \
-        oldvalue = (a)->value; \
-    } while (!OSAtomicCompareAndSwap32Barrier(oldvalue, v, &(a)->value)); \
-                            \
-    oldvalue;               \
-})
-#define SDL_AtomicGet(a)        ((a)->value)
-#define SDL_AtomicAdd(a, v) \
-({                          \
-    int oldvalue;           \
-                            \
-    do {                    \
-        oldvalue = (a)->value; \
-    } while (!OSAtomicCompareAndSwap32Barrier(oldvalue, oldvalue+v, &(a)->value)); \
-                            \
-    oldvalue;               \
-})
-#define SDL_AtomicCAS(a, oldval, newval) OSAtomicCompareAndSwap32Barrier(oldval, newval, &(a)->value)
-#define SDL_AtomicSetPtr(a, v)  (*(a) = v, OSMemoryBarrier())
-#define SDL_AtomicGetPtr(a)     (*(a))
+#define SDL_AtomicCAS(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((oldval), (newval), &(a)->value)
 #if SIZEOF_VOIDP == 4
 #define SDL_AtomicCASPtr(a, oldval, newval) OSAtomicCompareAndSwap32Barrier((int32_t)(oldval), (int32_t)(newval), (int32_t*)(a))
 #elif SIZEOF_VOIDP == 8
@@ -169,11 +167,9 @@
 #elif defined(HAVE_GCC_ATOMICS)
 
 #define SDL_AtomicSet(a, v)     __sync_lock_test_and_set(&(a)->value, v)
-#define SDL_AtomicGet(a)        ((a)->value)
 #define SDL_AtomicAdd(a, v)     __sync_fetch_and_add(&(a)->value, v)
+#define SDL_AtomicSetPtr(a, v)  __sync_lock_test_and_set(a, v)
 #define SDL_AtomicCAS(a, oldval, newval) __sync_bool_compare_and_swap(&(a)->value, oldval, newval)
-#define SDL_AtomicSetPtr(a, v)  (*(a) = v, __sync_synchronize())
-#define SDL_AtomicGetPtr(a)     (*(a))
 #define SDL_AtomicCASPtr(a, oldval, newval) __sync_bool_compare_and_swap(a, oldval, newval)
 
 #endif
@@ -190,48 +186,6 @@
 #endif
 
 /**
- * \brief Set an atomic variable to a value.
- *
- * \return The previous value of the atomic variable.
- */
-#ifndef SDL_AtomicSet
-extern DECLSPEC int SDLCALL SDL_AtomicSet(SDL_atomic_t *a, int value);
-#endif
-
-/**
- * \brief Get the value of an atomic variable
- */
-#ifndef SDL_AtomicGet
-extern DECLSPEC int SDLCALL SDL_AtomicGet(SDL_atomic_t *a);
-#endif
-
-/**
- * \brief  Add to an atomic variable.
- *
- * \return The previous value of the atomic variable.
- */
-#ifndef SDL_AtomicAdd
-extern DECLSPEC int SDLCALL SDL_AtomicAdd(SDL_atomic_t *a, int value);
-#endif
-
-/**
- * \brief Increment an atomic variable used as a reference count.
- */
-#ifndef SDL_AtomicIncRef
-extern DECLSPEC void SDLCALL SDL_AtomicIncRef(SDL_atomic_t *a);
-#endif
-
-/**
- * \brief Decrement an atomic variable used as a reference count.
- *
- * \return SDL_TRUE if the variable has reached zero after decrementing,
- *         SDL_FALSE otherwise
- */
-#ifndef SDL_AtomicDecRef
-extern DECLSPEC SDL_bool SDLCALL SDL_AtomicDecRef(SDL_atomic_t *a);
-#endif
-
-/**
  * \brief Set an atomic variable to a new value if it is currently an old value.
  *
  * \return SDL_TRUE if the atomic variable was set, SDL_FALSE otherwise.
@@ -239,21 +193,71 @@
  * \note If you don't know what this function is for, you shouldn't use it!
 */
 #ifndef SDL_AtomicCAS
-extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval);
+#define SDL_AtomicCAS SDL_AtomicCAS_
+#endif
+extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCAS_(SDL_atomic_t *a, int oldval, int newval);
+
+/**
+ * \brief Set an atomic variable to a value.
+ *
+ * \return The previous value of the atomic variable.
+ */
+#ifndef SDL_AtomicSet
+static __inline__ int SDL_AtomicSet(SDL_atomic_t *a, int v)
+{
+    int value;
+    do {
+        value = a->value;
+    } while (!SDL_AtomicCAS(a, value, v));
+    return value;
+}
+#endif
+
+/**
+ * \brief Get the value of an atomic variable
+ */
+#ifndef SDL_AtomicGet
+static __inline__ int SDL_AtomicGet(SDL_atomic_t *a)
+{
+    int value = a->value;
+    SDL_CompilerBarrier();
+    return value;
+}
 #endif
 
 /**
- * \brief Set a pointer to a value atomically.
+ * \brief Add to an atomic variable.
+ *
+ * \return The previous value of the atomic variable.
+ *
+ * \note This same style can be used for any number operation
  */
-#ifndef SDL_AtomicSetPtr
-extern DECLSPEC void SDLCALL SDL_AtomicSetPtr(void** a, void* value);
+#ifndef SDL_AtomicAdd
+static __inline__ int SDL_AtomicAdd(SDL_atomic_t *a, int v)
+{
+    int value;
+    do {
+        value = a->value;
+    } while (!SDL_AtomicCAS(a, value, (value + v)));
+    return value;
+}
 #endif
 
 /**
- * \brief Get the value of a pointer atomically.
+ * \brief Increment an atomic variable used as a reference count.
  */
-#ifndef SDL_AtomicGetPtr
-extern DECLSPEC void* SDLCALL SDL_AtomicGetPtr(void** a);
+#ifndef SDL_AtomicIncRef
+#define SDL_AtomicIncRef(a)    SDL_AtomicAdd(a, 1)
+#endif
+
+/**
+ * \brief Decrement an atomic variable used as a reference count.
+ *
+ * \return SDL_TRUE if the variable reached zero after decrementing,
+ *         SDL_FALSE otherwise
+ */
+#ifndef SDL_AtomicDecRef
+#define SDL_AtomicDecRef(a)    (SDL_AtomicAdd(a, -1) == 1)
 #endif
 
 /**
@@ -264,8 +268,38 @@
  * \note If you don't know what this function is for, you shouldn't use it!
 */
 #ifndef SDL_AtomicCASPtr
-extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr(void **a, void *oldval, void *newval);
+#define SDL_AtomicCASPtr SDL_AtomicCASPtr_
 #endif
+extern DECLSPEC SDL_bool SDLCALL SDL_AtomicCASPtr_(void **a, void *oldval, void *newval);
+
+/**
+ * \brief Set a pointer to a value atomically.
+ *
+ * \return The previous value of the pointer.
+ */
+#ifndef SDL_AtomicSetPtr
+static __inline__ void* SDL_AtomicSetPtr(void* *a, void* v)
+{
+    void* value;
+    do {
+        value = *a;
+    } while (!SDL_AtomicCASPtr(a, value, v));
+    return value;
+}
+#endif
+
+/**
+ * \brief Get the value of a pointer atomically.
+ */
+#ifndef SDL_AtomicGetPtr
+static __inline__ void* SDL_AtomicGetPtr(void* *a)
+{
+    void* value = *a;
+    SDL_CompilerBarrier();
+    return value;
+}
+#endif
+
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
--- a/include/SDL_compat.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_compat.h	Tue Feb 01 00:37:02 2011 -0800
@@ -65,7 +65,7 @@
 /*@{*/
 
 /* Platform */
-#ifdef __WINDOWS__
+#ifdef __WIN32__
 #undef __WIN32__
 #define __WIN32__   1
 #endif
@@ -223,6 +223,9 @@
  */
 /*@{*/
 
+#define SDL_keysym		SDL_KeySym
+#define SDL_scancode	SDL_ScanCode
+
 /** 
  *  \name Renamed keys
  *
@@ -341,6 +344,13 @@
 #define SDL_RenderFill(X)  (X) ? SDL_RenderFillRect(X) : SDL_RenderClear()
 #define SDL_KillThread(X)
 
+/* The timeslice and timer resolution are no longer relevant */
+#define SDL_TIMESLICE		10
+#define TIMER_RESOLUTION	10
+
+typedef Uint32 (SDLCALL * SDL_OldTimerCallback) (Uint32 interval);
+extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback);
+
 extern DECLSPEC int SDLCALL SDL_putenv(const char *variable);
 
 /*@}*//*Compatibility*/
--- a/include/SDL_config.h.in	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_config.h.in	Tue Feb 01 00:37:02 2011 -0800
@@ -90,7 +90,7 @@
 #undef HAVE_REALLOC
 #undef HAVE_FREE
 #undef HAVE_ALLOCA
-#ifndef __WINDOWS__ /* Don't use C runtime versions of these on Windows */
+#ifndef __WIN32__ /* Don't use C runtime versions of these on Windows */
 #undef HAVE_GETENV
 #undef HAVE_SETENV
 #undef HAVE_PUTENV
@@ -221,7 +221,6 @@
 #undef SDL_JOYSTICK_IOKIT
 #undef SDL_JOYSTICK_LINUX
 #undef SDL_JOYSTICK_NDS
-#undef SDL_JOYSTICK_RISCOS
 #undef SDL_JOYSTICK_WINMM
 #undef SDL_JOYSTICK_USBHID
 #undef SDL_JOYSTICK_USBHID_MACHINE_JOYSTICK_H
@@ -251,7 +250,6 @@
 #undef SDL_TIMER_BEOS
 #undef SDL_TIMER_DUMMY
 #undef SDL_TIMER_NDS
-#undef SDL_TIMER_RISCOS
 #undef SDL_TIMER_UNIX
 #undef SDL_TIMER_WINDOWS
 #undef SDL_TIMER_WINCE
@@ -265,7 +263,6 @@
 #undef SDL_VIDEO_DRIVER_NDS
 #undef SDL_VIDEO_DRIVER_PHOTON
 #undef SDL_VIDEO_DRIVER_QNXGF
-#undef SDL_VIDEO_DRIVER_RISCOS
 #undef SDL_VIDEO_DRIVER_WINDOWS
 #undef SDL_VIDEO_DRIVER_X11
 #undef SDL_VIDEO_DRIVER_X11_DYNAMIC
--- a/include/SDL_config_macosx.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_config_macosx.h	Tue Feb 01 00:37:02 2011 -0800
@@ -148,13 +148,23 @@
 #define SDL_VIDEO_DRIVER_X11_XV 1
 #define SDL_VIDEO_DRIVER_X11_XSHAPE 1
 
+#ifndef SDL_VIDEO_RENDER_OGL
 #define SDL_VIDEO_RENDER_OGL	1
+#endif
+#ifndef SDL_VIDEO_RENDER_X11
 #define SDL_VIDEO_RENDER_X11	1
+#endif
 
 /* Enable OpenGL support */
+#ifndef SDL_VIDEO_OPENGL
 #define SDL_VIDEO_OPENGL	1
+#endif
+#ifndef SDL_VIDEO_OPENGL_CGL
 #define SDL_VIDEO_OPENGL_CGL	1
+#endif
+#ifndef SDL_VIDEO_OPENGL_GLX
 #define SDL_VIDEO_OPENGL_GLX	1
+#endif
 
 /* Enable system power support */
 #define SDL_POWER_MACOSX 1
--- a/include/SDL_config_windows.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_config_windows.h	Tue Feb 01 00:37:02 2011 -0800
@@ -20,8 +20,8 @@
     slouken@libsdl.org
 */
 
-#ifndef _SDL_config_windows2_h
-#define _SDL_config_windows2_h
+#ifndef _SDL_config_windows_h
+#define _SDL_config_windows_h
 
 #include "SDL_platform.h"
 
@@ -178,15 +178,31 @@
 #define SDL_VIDEO_DRIVER_DUMMY	1
 #define SDL_VIDEO_DRIVER_WINDOWS	1
 
+#ifdef _WIN32_WCE
+#ifndef SDL_VIDEO_RENDER_GAPI
+#define SDL_VIDEO_RENDER_GAPI	1
+#endif
+#else
+#ifndef SDL_VIDEO_RENDER_D3D
 #define SDL_VIDEO_RENDER_D3D	1
+#endif
+#endif
+#ifndef SDL_VIDEO_RENDER_GDI
 #define SDL_VIDEO_RENDER_GDI	1
+#endif
 
 /* Enable OpenGL support */
 #ifndef _WIN32_WCE
+#ifndef SDL_VIDEO_OPENGL
 #define SDL_VIDEO_OPENGL	1
+#endif
+#ifndef SDL_VIDEO_OPENGL_WGL
 #define SDL_VIDEO_OPENGL_WGL	1
+#endif
+#ifndef SDL_VIDEO_RENDER_OGL
 #define SDL_VIDEO_RENDER_OGL	1
 #endif
+#endif
 
 /* Enable system power support */
 #define SDL_POWER_WINDOWS 1
@@ -196,4 +212,4 @@
 #define SDL_ASSEMBLY_ROUTINES	1
 #endif
 
-#endif /* _SDL_config_windows2_h */
+#endif /* _SDL_config_windows_h */
--- a/include/SDL_cpuinfo.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_cpuinfo.h	Tue Feb 01 00:37:02 2011 -0800
@@ -39,12 +39,27 @@
 /* *INDENT-ON* */
 #endif
 
+/* This is a guess for the cacheline size used for padding.
+ * Most x86 processors have a 64 byte cache line.
+ * The 64-bit PowerPC processors have a 128 byte cache line.
+ * We'll use the larger value to be generally safe.
+ */
+#define SDL_CACHELINE_SIZE  128
+
 /**
  *  This function returns the number of CPU cores available.
  */
 extern DECLSPEC int SDLCALL SDL_GetCPUCount(void);
 
 /**
+ *  This function returns the L1 cache line size of the CPU
+ *
+ *  This is useful for determining multi-threaded structure padding
+ *  or SIMD prefetch sizes.
+ */
+extern DECLSPEC int SDLCALL SDL_GetCPUCacheLineSize(void);
+
+/**
  *  This function returns true if the CPU has the RDTSC instruction.
  */
 extern DECLSPEC SDL_bool SDLCALL SDL_HasRDTSC(void);
--- a/include/SDL_events.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_events.h	Tue Feb 01 00:37:02 2011 -0800
@@ -151,7 +151,7 @@
     Uint8 repeat;       /**< Non-zero if this is a key repeat */
     Uint8 padding2;
     Uint8 padding3;
-    SDL_keysym keysym;  /**< The key that was pressed or released */
+    SDL_KeySym keysym;  /**< The key that was pressed or released */
 } SDL_KeyboardEvent;
 
 #define SDL_TEXTEDITINGEVENT_TEXT_SIZE (32)
--- a/include/SDL_haptic.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_haptic.h	Tue Feb 01 00:37:02 2011 -0800
@@ -81,6 +81,10 @@
  *    return 0; // Success
  * }
  * \endcode
+ *
+ * You can also find out more information on my blog:
+ * http://bobbens.dyndns.org/journal/2010/sdl_haptic/
+ *
  * \author Edgar Simo Serra
  */
 
--- a/include/SDL_keyboard.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_keyboard.h	Tue Feb 01 00:37:02 2011 -0800
@@ -45,13 +45,13 @@
 /**
  *  \brief The SDL keysym structure, used in key events.
  */
-typedef struct SDL_keysym
+typedef struct SDL_KeySym
 {
-    SDL_scancode scancode;      /**< SDL physical key code - see ::SDL_scancode for details */
+    SDL_ScanCode scancode;      /**< SDL physical key code - see ::SDL_ScanCode for details */
     SDLKey sym;                 /**< SDL virtual key code - see ::SDLKey for details */
     Uint16 mod;                 /**< current key modifiers */
     Uint32 unicode;             /**< \deprecated use SDL_TextInputEvent instead */
-} SDL_keysym;
+} SDL_KeySym;
 
 /* Function prototypes */
 
@@ -65,7 +65,7 @@
  *  
  *  \param numkeys if non-NULL, receives the length of the returned array.
  *  
- *  \return An array of key states. Indexes into this array are obtained by using ::SDL_scancode values.
+ *  \return An array of key states. Indexes into this array are obtained by using ::SDL_ScanCode values.
  *  
  *  \b Example:
  *  \code
@@ -97,17 +97,17 @@
  *  
  *  \sa SDL_GetKeyName()
  */
-extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_scancode scancode);
+extern DECLSPEC SDLKey SDLCALL SDL_GetKeyFromScancode(SDL_ScanCode scancode);
 
 /**
  *  \brief Get the scancode corresponding to the given key code according to the
  *         current keyboard layout.
  *  
- *  See ::SDL_scancode for details.
+ *  See ::SDL_ScanCode for details.
  *  
  *  \sa SDL_GetScancodeName()
  */
-extern DECLSPEC SDL_scancode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
+extern DECLSPEC SDL_ScanCode SDLCALL SDL_GetScancodeFromKey(SDLKey key);
 
 /**
  *  \brief Get a human-readable name for a scancode.
@@ -117,9 +117,9 @@
  *          copy it.  If the scancode doesn't have a name, this function returns
  *          an empty string ("").
  *
- *  \sa SDL_scancode
+ *  \sa SDL_ScanCode
  */
-extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_scancode
+extern DECLSPEC const char *SDLCALL SDL_GetScancodeName(SDL_ScanCode
                                                         scancode);
 
 /**
--- a/include/SDL_main.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_main.h	Tue Feb 01 00:37:02 2011 -0800
@@ -31,7 +31,7 @@
  *  Redefine main() on some platforms so that it is called by SDL.
  */
 
-#if defined(__WINDOWS__) || \
+#if defined(__WIN32__) || \
     (defined(__MWERKS__) && !defined(__BEOS__)) || \
     defined(__SYMBIAN32__) || defined(__IPHONEOS__) || \
     defined(__ANDROID__)
@@ -66,7 +66,7 @@
 
 
 /* From the SDL library code -- needed for registering the app on Win32 */
-#ifdef __WINDOWS__
+#ifdef __WIN32__
 
 #include "begin_code.h"
 #ifdef __cplusplus
--- a/include/SDL_mutex.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_mutex.h	Tue Feb 01 00:37:02 2011 -0800
@@ -164,6 +164,31 @@
 
 /**
  *  Create a condition variable.
+ *
+ *  Typical use of condition variables:
+ *
+ *  Thread A:
+ *    SDL_LockMutex(lock);
+ *    while ( ! condition ) {
+ *        SDL_CondWait(cond, lock);
+ *    }
+ *    SDL_UnlockMutex(lock);
+ *
+ *  Thread B:
+ *    SDL_LockMutex(lock);
+ *    ...
+ *    condition = true;
+ *    ...
+ *    SDL_CondSignal(cond);
+ *    SDL_UnlockMutex(lock);
+ *
+ *  There is some discussion whether to signal the condition variable
+ *  with the mutex locked or not.  There is some potential performance
+ *  benefit to unlocking first on some platforms, but there are some
+ *  potential race conditions depending on how your code is structured.
+ *
+ *  In general it's safer to signal the condition variable while the
+ *  mutex is locked.
  */
 extern DECLSPEC SDL_cond *SDLCALL SDL_CreateCond(void);
 
@@ -181,6 +206,7 @@
 
 /**
  *  Restart all threads that are waiting on the condition variable.
+ *
  *  \return 0 or -1 on error.
  */
 extern DECLSPEC int SDLCALL SDL_CondBroadcast(SDL_cond * cond);
--- a/include/SDL_opengl.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_opengl.h	Tue Feb 01 00:37:02 2011 -0800
@@ -31,7 +31,7 @@
 
 #include "SDL_config.h"
 
-#ifdef __WINDOWS__
+#ifdef __WIN32__
 #define WIN32_LEAN_AND_MEAN
 #ifndef NOMINMAX
 #define NOMINMAX                /* Don't defined min() and max() */
--- a/include/SDL_platform.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_platform.h	Tue Feb 01 00:37:02 2011 -0800
@@ -125,8 +125,8 @@
 #define __SOLARIS__	1
 #endif
 #if defined(WIN32) || defined(_WIN32)
-#undef __WINDOWS__
-#define __WINDOWS__	1
+#undef __WIN32__
+#define __WIN32__	1
 #endif
 
 #if defined(__NDS__)
--- a/include/SDL_rwops.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_rwops.h	Tue Feb 01 00:37:02 2011 -0800
@@ -83,7 +83,7 @@
     Uint32 type;
     union
     {
-#ifdef __WINDOWS__
+#ifdef __WIN32__
         struct
         {
             SDL_bool append;
--- a/include/SDL_scancode.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_scancode.h	Tue Feb 01 00:37:02 2011 -0800
@@ -35,7 +35,7 @@
  *  \brief The SDL keyboard scancode representation.
  *  
  *  Values of this type are used to represent keyboard keys, among other places
- *  in the \link SDL_keysym::scancode key.keysym.scancode \endlink field of the
+ *  in the \link SDL_KeySym::scancode key.keysym.scancode \endlink field of the
  *  SDL_Event structure.
  *  
  *  The values in this enumeration are based on the USB usage page standard:
@@ -392,7 +392,7 @@
 
     SDL_NUM_SCANCODES = 512 /**< not a key, just marks the number of scancodes 
                                  for array bounds */
-} SDL_scancode;
+} SDL_ScanCode;
 
 #endif /* _SDL_scancode_h */
 
--- a/include/SDL_thread.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_thread.h	Tue Feb 01 00:37:02 2011 -0800
@@ -55,7 +55,7 @@
  */
 typedef int (SDLCALL * SDL_ThreadFunction) (void *data);
 
-#if defined(__WINDOWS__) && !defined(HAVE_LIBC)
+#if defined(__WIN32__) && !defined(HAVE_LIBC)
 /**
  *  \file SDL_thread.h
  *  
--- a/include/SDL_timer.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_timer.h	Tue Feb 01 00:37:02 2011 -0800
@@ -41,104 +41,50 @@
 #endif
 
 /**
- *  This is the OS scheduler timeslice, in milliseconds.
- */
-#define SDL_TIMESLICE		10
-
-/**
- *  This is the maximum resolution of the SDL timer on all platforms.
- */
-#define TIMER_RESOLUTION	10      /**< Experimentally determined */
-
-/**
- *  Get the number of milliseconds since the SDL library initialization.
+ * \brief Get the number of milliseconds since the SDL library initialization.
  *  
- *  Note that this value wraps if the program runs for more than ~49 days.
+ * \note This value wraps if the program runs for more than ~49 days.
  */
 extern DECLSPEC Uint32 SDLCALL SDL_GetTicks(void);
 
 /**
- *  Wait a specified number of milliseconds before returning.
+ * \brief Wait a specified number of milliseconds before returning.
  */
 extern DECLSPEC void SDLCALL SDL_Delay(Uint32 ms);
 
 /**
  *  Function prototype for the timer callback function.
- */
-typedef Uint32(SDLCALL * SDL_TimerCallback) (Uint32 interval);
-
-/**
- *  Set a callback to run after the specified number of milliseconds has
- *  elapsed. The callback function is passed the current timer interval
- *  and returns the next timer interval.  If the returned value is the 
- *  same as the one passed in, the periodic alarm continues, otherwise a
- *  new alarm is scheduled.  If the callback returns 0, the periodic alarm
- *  is cancelled.
- *  
- *  To cancel a currently running timer, call 
- *  \code SDL_SetTimer(0, NULL); \endcode
- *  
- *  The timer callback function may run in a different thread than your
- *  main code, and so shouldn't call any functions from within itself.
- *  
- *  The maximum resolution of this timer is 10 ms, which means that if
- *  you request a 16 ms timer, your callback will run approximately 20 ms
- *  later on an unloaded system.  If you wanted to set a flag signaling
- *  a frame update at 30 frames per second (every 33 ms), you might set a 
- *  timer for 30 ms:
- *  \code
- *    SDL_SetTimer((33/10)*10, flag_update);
- *  \endcode
- *  
- *  If you use this function, you need to pass ::SDL_INIT_TIMER to SDL_Init().
- *  
- *  Under UNIX, you should not use raise or use SIGALRM and this function
- *  in the same program, as it is implemented using setitimer().  You also
- *  should not use this function in multi-threaded applications as signals
- *  to multi-threaded apps have undefined behavior in some implementations.
- *  
- *  \return 0 if successful, or -1 if there was an error.
- */
-extern DECLSPEC int SDLCALL SDL_SetTimer(Uint32 interval,
-                                         SDL_TimerCallback callback);
-
-/**
- *  \name Peter timers
- *  New timer API, supports multiple timers
- *  Written by Stephane Peter <megastep@lokigames.com>
- */
-/*@{*/
-
-/**
- *  Function prototype for the new timer callback function.
  *  
  *  The callback function is passed the current timer interval and returns
  *  the next timer interval.  If the returned value is the same as the one
  *  passed in, the periodic alarm continues, otherwise a new alarm is
  *  scheduled.  If the callback returns 0, the periodic alarm is cancelled.
  */
-typedef Uint32(SDLCALL * SDL_NewTimerCallback) (Uint32 interval, void *param);
+typedef Uint32 (SDLCALL * SDL_TimerCallback) (Uint32 interval, void *param);
 
 /**
- *  Definition of the timer ID type.
+ * Definition of the timer ID type.
  */
-typedef struct _SDL_TimerID *SDL_TimerID;
+typedef int SDL_TimerID;
 
 /**
- *  Add a new timer to the pool of timers already running.
- *  \return A timer ID, or NULL when an error occurs.
+ * \brief Add a new timer to the pool of timers already running.
+ *
+ * \return A timer ID, or NULL when an error occurs.
  */
 extern DECLSPEC SDL_TimerID SDLCALL SDL_AddTimer(Uint32 interval,
-                                                 SDL_NewTimerCallback
-                                                 callback, void *param);
+                                                 SDL_TimerCallback callback,
+                                                 void *param);
 
 /**
- *  Remove one of the multiple timers knowing its ID.
- *  \return A boolean value indicating success or failure.
+ * \brief Remove a timer knowing its ID.
+ *
+ * \return A boolean value indicating success or failure.
+ *
+ * \warning It is not safe to remove a timer multiple times.
  */
 extern DECLSPEC SDL_bool SDLCALL SDL_RemoveTimer(SDL_TimerID t);
 
-/*@}*//*Peter timers*/
 
 /* Ends C function definitions when using C++ */
 #ifdef __cplusplus
--- a/include/SDL_video.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/SDL_video.h	Tue Feb 01 00:37:02 2011 -0800
@@ -278,8 +278,6 @@
  *  \param driver_name Initialize a specific driver by name, or NULL for the 
  *                     default video driver.
  *  
- *  \param flags FIXME: Still needed?
- *  
  *  \return 0 on success, -1 on error
  *  
  *  This function initializes the video subsystem; setting up a connection
@@ -288,8 +286,7 @@
  *  
  *  \sa SDL_VideoQuit()
  */
-extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name,
-                                          Uint32 flags);
+extern DECLSPEC int SDLCALL SDL_VideoInit(const char *driver_name);
 
 /**
  *  \brief Shuts down the video subsystem.
--- a/include/begin_code.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/begin_code.h	Tue Feb 01 00:37:02 2011 -0800
@@ -42,7 +42,7 @@
 #  else
 #   define DECLSPEC	__declspec(export)
 #  endif
-# elif defined(__WINDOWS__)
+# elif defined(__WIN32__)
 #  ifdef __BORLANDC__
 #   ifdef BUILD_SDL
 #    define DECLSPEC
@@ -63,7 +63,7 @@
 
 /* By default SDL uses the C calling convention */
 #ifndef SDLCALL
-#if defined(__WINDOWS__) && !defined(__GNUC__)
+#if defined(__WIN32__) && !defined(__GNUC__)
 #define SDLCALL __cdecl
 #else
 #define SDLCALL
--- a/include/doxyfile	Mon Jan 31 07:36:12 2011 -0800
+++ b/include/doxyfile	Tue Feb 01 00:37:02 2011 -0800
@@ -124,10 +124,7 @@
 # If left blank the directory from which doxygen is run is used as the 
 # path to strip.
 
-STRIP_FROM_PATH        = ../ \
-                         C:/source/svn.libsdl.org/trunk/ \
-                         C:\source\svn.libsdl.org\trunk\ \
-                         ..\
+STRIP_FROM_PATH        =
 
 # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of 
 # the path mentioned in the documentation of a class, which tells 
@@ -572,7 +569,7 @@
 # directories like "/usr/src/myproject". Separate the files or directories 
 # with spaces.
 
-INPUT                  = ..
+INPUT                  = .
 
 # This tag can be used to specify the character encoding of the source files 
 # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is 
@@ -652,10 +649,7 @@
 # against the file with absolute path, so to exclude all test directories 
 # for example use the pattern */test/*
 
-EXCLUDE_PATTERNS       = */.svn/* \
-                         */bin/* \
-                         */lib/* \
-                         */obj/*
+EXCLUDE_PATTERNS       =
 
 # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names 
 # (namespaces, classes, functions, etc.) that should be excluded from the 
@@ -669,9 +663,7 @@
 # directories that contain example code fragments that are included (see 
 # the \include command).
 
-EXAMPLE_PATH           = ../test \
-                         ../Xcode \
-                         ../Xcode-iPhoneOS
+EXAMPLE_PATH           =
 
 # If the value of the EXAMPLE_PATH tag contains directories, you can use the 
 # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp 
--- a/src/SDL.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/SDL.c	Tue Feb 01 00:37:02 2011 -0800
@@ -39,7 +39,7 @@
 extern int SDL_TimerInit(void);
 extern void SDL_TimerQuit(void);
 #endif
-#if defined(__WINDOWS__)
+#if defined(__WIN32__)
 extern int SDL_HelperWindowCreate(void);
 extern int SDL_HelperWindowDestroy(void);
 #endif
@@ -59,7 +59,7 @@
 #if !SDL_VIDEO_DISABLED
     /* Initialize the video/event subsystem */
     if ((flags & SDL_INIT_VIDEO) && !(SDL_initialized & SDL_INIT_VIDEO)) {
-        if (SDL_VideoInit(NULL, (flags & SDL_INIT_EVENTTHREAD)) < 0) {
+        if (SDL_VideoInit(NULL) < 0) {
             return (-1);
         }
         SDL_initialized |= SDL_INIT_VIDEO;
@@ -147,7 +147,7 @@
     /* Clear the error message */
     SDL_ClearError();
 
-#if defined(__WINDOWS__)
+#if defined(__WIN32__)
     if (SDL_HelperWindowCreate() < 0) {
         return -1;
     }
@@ -220,7 +220,7 @@
     fflush(stdout);
 #endif
 
-#if defined(__WINDOWS__)
+#if defined(__WIN32__)
     SDL_HelperWindowDestroy();
 #endif
     SDL_QuitSubSystem(SDL_INIT_EVERYTHING);
@@ -312,7 +312,7 @@
     return "RISC OS";
 #elif __SOLARIS__
     return "Solaris";
-#elif __WINDOWS__
+#elif __WIN32__
 #ifdef _WIN32_WCE
     return "Windows CE";
 #else
@@ -325,12 +325,11 @@
 #endif
 }
 
-#if defined(__WINDOWS__)
+#if defined(__WIN32__)
 
 #if !defined(HAVE_LIBC) || (defined(__WATCOMC__) && defined(BUILD_DLL))
 /* Need to include DllMain() on Watcom C for some reason.. */
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "core/windows/SDL_windows.h"
 
 BOOL APIENTRY
 _DllMainCRTStartup(HANDLE hModule,
@@ -347,6 +346,6 @@
 }
 #endif /* building DLL with Watcom C */
 
-#endif /* __WINDOWS__ */
+#endif /* __WIN32__ */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/SDL_android.cpp	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,258 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_android.h"
-
-extern "C" {
-#include "events/SDL_events_c.h"
-#include "video/android/SDL_androidkeyboard.h"
-#include "video/android/SDL_androidtouch.h"
-#include "video/android/SDL_androidvideo.h"
-
-/* Impelemented in audio/android/SDL_androidaudio.c */
-extern void Android_RunAudioThread();
-} // C
-
-/*******************************************************************************
- This file links the Java side of Android with libsdl
-*******************************************************************************/
-#include <jni.h>
-#include <android/log.h>
-
-
-/*******************************************************************************
-                               Globals
-*******************************************************************************/
-static JNIEnv* mEnv = NULL;
-static JNIEnv* mAudioEnv = NULL;
-
-// Main activity
-static jclass mActivityClass;
-
-// method signatures
-static jmethodID midCreateGLContext;
-static jmethodID midFlipBuffers;
-static jmethodID midAudioInit;
-static jmethodID midAudioWriteShortBuffer;
-static jmethodID midAudioWriteByteBuffer;
-static jmethodID midAudioQuit;
-
-// Accelerometer data storage
-static float fLastAccelerometer[3];
-
-
-/*******************************************************************************
-                 Functions called by JNI
-*******************************************************************************/
-
-// Library init
-extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
-{
-    return JNI_VERSION_1_4;
-}
-
-// Called before SDL_main() to initialize JNI bindings
-extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls)
-{
-    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()");
-
-    mEnv = env;
-    mActivityClass = cls;
-
-    midCreateGLContext = mEnv->GetStaticMethodID(mActivityClass,
-                                "createGLContext","()V");
-    midFlipBuffers = mEnv->GetStaticMethodID(mActivityClass,
-                                "flipBuffers","()V");
-    midAudioInit = mEnv->GetStaticMethodID(mActivityClass, 
-                                "audioInit", "(IZZI)Ljava/lang/Object;");
-    midAudioWriteShortBuffer = mEnv->GetStaticMethodID(mActivityClass,
-                                "audioWriteShortBuffer", "([S)V");
-    midAudioWriteByteBuffer = mEnv->GetStaticMethodID(mActivityClass,
-                                "audioWriteByteBuffer", "([B)V");
-    midAudioQuit = mEnv->GetStaticMethodID(mActivityClass,
-                                "audioQuit", "()V");
-
-    if(!midCreateGLContext || !midFlipBuffers || !midAudioInit ||
-       !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) {
-        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
-    }
-}
-
-// Resize
-extern "C" void Java_org_libsdl_app_SDLActivity_onNativeResize(
-                                    JNIEnv* env, jclass jcls,
-                                    jint width, jint height, jint format)
-{
-    Android_SetScreenResolution(width, height, format);
-}
-
-// Keydown
-extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyDown(
-                                    JNIEnv* env, jclass jcls, jint keycode)
-{
-    Android_OnKeyDown(keycode);
-}
-
-// Keyup
-extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(
-                                    JNIEnv* env, jclass jcls, jint keycode)
-{
-    Android_OnKeyUp(keycode);
-}
-
-// Touch
-extern "C" void Java_org_libsdl_app_SDLActivity_onNativeTouch(
-                                    JNIEnv* env, jclass jcls,
-                                    jint action, jfloat x, jfloat y, jfloat p)
-{
-    Android_OnTouch(action, x, y, p);
-}
-
-// Accelerometer
-extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
-                                    JNIEnv* env, jclass jcls,
-                                    jfloat x, jfloat y, jfloat z)
-{
-    fLastAccelerometer[0] = x;
-    fLastAccelerometer[1] = y;
-    fLastAccelerometer[2] = z;   
-}
-
-// Quit
-extern "C" void Java_org_libsdl_app_SDLActivity_nativeQuit(
-                                    JNIEnv* env, jclass cls)
-{    
-    // Inject a SDL_QUIT event
-    SDL_SendQuit();
-}
-
-extern "C" void Java_org_libsdl_app_SDLActivity_nativeRunAudioThread(
-                                    JNIEnv* env, jclass cls)
-{
-    /* This is the audio thread, with a different environment */
-    mAudioEnv = env;
-
-    Android_RunAudioThread();
-}
-
-
-/*******************************************************************************
-             Functions called by SDL into Java
-*******************************************************************************/
-extern "C" void Android_JNI_CreateContext()
-{
-    mEnv->CallStaticVoidMethod(mActivityClass, midCreateGLContext); 
-}
-
-extern "C" void Android_JNI_SwapWindow()
-{
-    mEnv->CallStaticVoidMethod(mActivityClass, midFlipBuffers); 
-}
-
-extern "C" void Android_JNI_SetActivityTitle(const char *title)
-{
-    jmethodID mid;
-
-    mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
-    if (mid) {
-        mEnv->CallStaticVoidMethod(mActivityClass, mid, mEnv->NewStringUTF(title));
-    }
-}
-
-extern "C" void Android_JNI_GetAccelerometerValues(float values[3])
-{
-    int i;
-    for (i = 0; i < 3; ++i) {
-        values[i] = fLastAccelerometer[i];
-    }
-}
-
-//
-// Audio support
-//
-static jboolean audioBuffer16Bit = JNI_FALSE;
-static jboolean audioBufferStereo = JNI_FALSE;
-static jobject audioBuffer = NULL;
-static void* audioBufferPinned = NULL;
-
-extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames)
-{
-    int audioBufferFrames;
-
-    __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
-    audioBuffer16Bit = is16Bit;
-    audioBufferStereo = channelCount > 1;
-
-    audioBuffer = mEnv->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
-
-    if (audioBuffer == NULL) {
-        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: didn't get back a good audio buffer!");
-        return 0;
-    }
-    audioBuffer = mEnv->NewGlobalRef(audioBuffer);
-
-    jboolean isCopy = JNI_FALSE;
-    if (audioBuffer16Bit) {
-        audioBufferPinned = mEnv->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
-        audioBufferFrames = mEnv->GetArrayLength((jshortArray)audioBuffer);
-    } else {
-        audioBufferPinned = mEnv->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
-        audioBufferFrames = mEnv->GetArrayLength((jbyteArray)audioBuffer);
-    }
-    if (audioBufferStereo) {
-        audioBufferFrames /= 2;
-    }
-
-    return audioBufferFrames;
-}
-
-extern "C" void * Android_JNI_GetAudioBuffer()
-{
-    return audioBufferPinned;
-}
-
-extern "C" void Android_JNI_WriteAudioBuffer()
-{
-    if (audioBuffer16Bit) {
-        mAudioEnv->ReleaseShortArrayElements((jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
-        mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
-    } else {
-        mAudioEnv->ReleaseByteArrayElements((jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT);
-        mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
-    }
-
-    /* JNI_COMMIT means the changes are committed to the VM but the buffer remains pinned */
-}
-
-extern "C" void Android_JNI_CloseAudioDevice()
-{
-    mEnv->CallStaticVoidMethod(mActivityClass, midAudioQuit); 
-
-    if (audioBuffer) {
-        mEnv->DeleteGlobalRef(audioBuffer);
-        audioBuffer = NULL;
-        audioBufferPinned = NULL;
-    }
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/SDL_android.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,50 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* Set up for C function definitions, even when using C++ */
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-extern "C" {
-/* *INDENT-ON* */
-#endif
-
-/* Interface from the SDL library into the Android Java activity */
-extern void Android_JNI_CreateContext();
-extern void Android_JNI_SwapWindow();
-extern void Android_JNI_SetActivityTitle(const char *title);
-extern void Android_JNI_GetAccelerometerValues(float values[3]);
-
-// Audio support
-extern int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames);
-extern void* Android_JNI_GetAudioBuffer();
-extern void Android_JNI_WriteAudioBuffer();
-extern void Android_JNI_CloseAudioDevice();
-
-/* Ends C function definitions when using C++ */
-#ifdef __cplusplus
-/* *INDENT-OFF* */
-}
-/* *INDENT-ON* */
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/SDL_assert.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/SDL_assert.c	Tue Feb 01 00:37:02 2011 -0800
@@ -26,9 +26,12 @@
 #include "SDL_assert_c.h"
 #include "video/SDL_sysvideo.h"
 
-#ifdef __WINDOWS__
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#ifdef __WIN32__
+#include "core/windows/SDL_windows.h"
+
+#ifndef WS_OVERLAPPEDWINDOW
+#define WS_OVERLAPPEDWINDOW 0
+#endif
 #else  /* fprintf, _exit(), etc. */
 #include <stdio.h>
 #include <stdlib.h>
@@ -57,11 +60,12 @@
 static void
 debug_print(const char *fmt, ...)
 {
-#ifdef __WINDOWS__
+#ifdef __WIN32__
     /* Format into a buffer for OutputDebugStringA(). */
     char buf[1024];
     char *startptr;
     char *ptr;
+    LPTSTR tstr;
     int len;
     va_list ap;
     va_start(ap, fmt);
@@ -78,15 +82,19 @@
     for (ptr = startptr; *ptr; ptr++) {
         if (*ptr == '\n') {
             *ptr = '\0';
-            OutputDebugStringA(startptr);
-            OutputDebugStringA("\r\n");
+            tstr = WIN_UTF8ToString(startptr);
+            OutputDebugString(tstr);
+            SDL_free(tstr);
+            OutputDebugString(TEXT("\r\n"));
             startptr = ptr+1;
         }
     }
 
     /* catch that last piece if it didn't have a newline... */
     if (startptr != ptr) {
-        OutputDebugStringA(startptr);
+        tstr = WIN_UTF8ToString(startptr);
+        OutputDebugString(tstr);
+        SDL_free(tstr);
     }
 #else
     /* Unix has it easy. Just dump it to stderr. */
@@ -99,7 +107,7 @@
 }
 
 
-#ifdef __WINDOWS__
+#ifdef __WIN32__
 static SDL_assert_state SDL_Windows_AssertChoice = SDL_ASSERTION_ABORT;
 static const SDL_assert_data *SDL_Windows_AssertData = NULL;
 
@@ -113,6 +121,7 @@
             /* !!! FIXME: all this code stinks. */
             const SDL_assert_data *data = SDL_Windows_AssertData;
             char buf[1024];
+            LPTSTR tstr;
             const int w = 100;
             const int h = 25;
             const int gap = 10;
@@ -121,14 +130,14 @@
             int len;
             int i;
             static const struct { 
-                const char *name;
+                LPCTSTR name;
                 SDL_assert_state state;
             } buttons[] = {
-                {"Abort", SDL_ASSERTION_ABORT },
-                {"Break", SDL_ASSERTION_BREAK },
-                {"Retry", SDL_ASSERTION_RETRY },
-                {"Ignore", SDL_ASSERTION_IGNORE },
-                {"Always Ignore", SDL_ASSERTION_ALWAYS_IGNORE },
+                {TEXT("Abort"), SDL_ASSERTION_ABORT },
+                {TEXT("Break"), SDL_ASSERTION_BREAK },
+                {TEXT("Retry"), SDL_ASSERTION_RETRY },
+                {TEXT("Ignore"), SDL_ASSERTION_IGNORE },
+                {TEXT("Always Ignore"), SDL_ASSERTION_ALWAYS_IGNORE },
             };
 
             len = (int) SDL_snprintf(buf, sizeof (buf), 
@@ -140,14 +149,16 @@
                 buf[sizeof (buf) - 1] = '\0';
             }
 
-            CreateWindowA("STATIC", buf,
+            tstr = WIN_UTF8ToString(buf);
+            CreateWindow(TEXT("STATIC"), tstr,
                          WS_VISIBLE | WS_CHILD | SS_LEFT,
                          x, y, 550, 100,
                          hwnd, (HMENU) 1, NULL, NULL);
+            SDL_free(tstr);
             y += 110;
 
             for (i = 0; i < (sizeof (buttons) / sizeof (buttons[0])); i++) {
-                CreateWindowA("BUTTON", buttons[i].name,
+                CreateWindow(TEXT("BUTTON"), buttons[i].name,
                          WS_VISIBLE | WS_CHILD,
                          x, y, w, h,
                          hwnd, (HMENU) buttons[i].state, NULL, NULL);
@@ -248,7 +259,7 @@
 
 static void SDL_ExitProcess(int exitcode)
 {
-#ifdef __WINDOWS__
+#ifdef __WIN32__
     ExitProcess(42);
 #else
     _exit(42);
@@ -311,7 +322,7 @@
 
     /* platform-specific UI... */
 
-#ifdef __WINDOWS__
+#ifdef __WIN32__
     state = SDL_PromptAssertion_windows(data);
 
 #elif __MACOSX__
--- a/src/SDL_compat.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/SDL_compat.c	Tue Feb 01 00:37:02 2011 -0800
@@ -1760,6 +1760,31 @@
     return previous;
 }
 
+static Uint32
+SDL_SetTimerCallback(Uint32 interval, void* param)
+{
+    return ((SDL_OldTimerCallback)param)(interval);
+}
+
+int
+SDL_SetTimer(Uint32 interval, SDL_OldTimerCallback callback)
+{
+    static SDL_TimerID compat_timer;
+
+    if (compat_timer) {
+        SDL_RemoveTimer(compat_timer);
+        compat_timer = 0;
+    }
+
+    if (interval && callback) {
+        compat_timer = SDL_AddTimer(interval, SDL_SetTimerCallback, callback);
+        if (!compat_timer) {
+            return -1;
+        }
+    }
+    return 0;
+}
+
 int
 SDL_putenv(const char *_var)
 {
--- a/src/atomic/SDL_atomic.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/atomic/SDL_atomic.c	Tue Feb 01 00:37:02 2011 -0800
@@ -70,61 +70,8 @@
     SDL_AtomicUnlock(&locks[index]);
 }
 
-#undef SDL_AtomicSet
-int
-SDL_AtomicSet(SDL_atomic_t *a, int value)
-{
-    int oldvalue;
-
-    enterLock(a);
-    oldvalue = a->value;
-    a->value = value;
-    leaveLock(a);
-
-    return oldvalue;
-}
-
-#undef SDL_AtomicGet
-int
-SDL_AtomicGet(SDL_atomic_t *a)
-{
-    /* Assuming integral reads on this platform, we're safe here since the
-       functions that set the variable have the necessary memory barriers.
-    */
-    return a->value;
-}
-
-#undef SDL_AtomicAdd
-int
-SDL_AtomicAdd(SDL_atomic_t *a, int value)
-{
-    int oldvalue;
-
-    enterLock(a);
-    oldvalue = a->value;
-    a->value += value;
-    leaveLock(a);
-
-    return oldvalue;
-}
-
-#undef SDL_AtomicIncRef
-void
-SDL_AtomicIncRef(SDL_atomic_t *a)
-{
-    SDL_AtomicAdd(a, 1);
-}
-
-#undef SDL_AtomicDecRef
 SDL_bool
-SDL_AtomicDecRef(SDL_atomic_t *a)
-{
-    return SDL_AtomicAdd(a, -1) == 1;
-}
-
-#undef SDL_AtomicCAS
-SDL_bool
-SDL_AtomicCAS(SDL_atomic_t *a, int oldval, int newval)
+SDL_AtomicCAS_(SDL_atomic_t *a, int oldval, int newval)
 {
     SDL_bool retval = SDL_FALSE;
 
@@ -138,28 +85,8 @@
     return retval;
 }
 
-#undef SDL_AtomicSetPtr
-void
-SDL_AtomicSetPtr(void** a, void* value)
-{
-    void *prevval;
-    do {
-        prevval = *a;
-    } while (!SDL_AtomicCASPtr(a, prevval, value));
-}
-
-#undef SDL_AtomicGetPtr
-void*
-SDL_AtomicGetPtr(void** a)
-{
-    /* Assuming integral reads on this platform, we're safe here since the
-       functions that set the pointer have the necessary memory barriers.
-    */
-    return *a;
-}
-
-#undef SDL_AtomicCASPtr
-SDL_bool SDL_AtomicCASPtr(void **a, void *oldval, void *newval)
+SDL_bool
+SDL_AtomicCASPtr_(void **a, void *oldval, void *newval)
 {
     SDL_bool retval = SDL_FALSE;
 
--- a/src/atomic/SDL_spinlock.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/atomic/SDL_spinlock.c	Tue Feb 01 00:37:02 2011 -0800
@@ -25,8 +25,8 @@
 #include "SDL_timer.h"
 
 /* Don't do the check for Visual Studio 2005, it's safe here */
-#if defined(_MSC_VER)
-#include <intrin.h>
+#ifdef __WIN32__
+#include "../core/windows/SDL_windows.h"
 #endif
 
 /* This function is where all the magic happens... */
@@ -35,12 +35,12 @@
 {
 #if defined(_MSC_VER)
     SDL_COMPILE_TIME_ASSERT(locksize, sizeof(*lock) == sizeof(long));
-    return (_InterlockedExchange((long*)lock, 1) == 0);
+    return (InterlockedExchange((long*)lock, 1) == 0);
 
 #elif defined(__MACOSX__)
     return OSAtomicCompareAndSwap32Barrier(0, 1, lock);
 
-#elif defined(HAVE_GCC_ATOMICS) || defined(HAVE_GCC_SYNC_LOCK_TEST_AND_SET)
+#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
     return (__sync_lock_test_and_set(lock, 1) == 0);
 
 #elif defined(__GNUC__) && defined(__arm__) && defined(__ARM_ARCH_5__)
@@ -75,8 +75,16 @@
 void
 SDL_AtomicUnlock(SDL_SpinLock *lock)
 {
-    /* Assuming atomic assignment operation and full memory barrier in lock */
+#if defined(_MSC_VER)
+    _ReadWriteBarrier();
     *lock = 0;
+
+#elif HAVE_GCC_ATOMICS || HAVE_GCC_SYNC_LOCK_TEST_AND_SET
+    __sync_lock_release(lock);
+
+#else
+    *lock = 0;
+#endif
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/audio/SDL_audio.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/audio/SDL_audio.c	Tue Feb 01 00:37:02 2011 -0800
@@ -971,7 +971,7 @@
     if (!current_audio.impl.ProvidesOwnCallbackThread) {
         /* Start the audio thread */
 /* !!! FIXME: this is nasty. */
-#if (defined(__WINDOWS__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
+#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
 #undef SDL_CreateThread
         device->thread = SDL_CreateThread(SDL_RunAudio, device, NULL, NULL);
 #else
--- a/src/audio/android/SDL_androidaudio.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/audio/android/SDL_androidaudio.c	Tue Feb 01 00:37:02 2011 -0800
@@ -27,7 +27,7 @@
 #include "../SDL_audio_c.h"
 #include "SDL_androidaudio.h"
 
-#include "../../SDL_android.h"
+#include "../../core/android/SDL_android.h"
 
 #include <android/log.h>
 
--- a/src/audio/pulseaudio/SDL_pulseaudio.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/audio/pulseaudio/SDL_pulseaudio.c	Tue Feb 01 00:37:02 2011 -0800
@@ -304,38 +304,6 @@
 }
 
 
-/* !!! FIXME: this could probably be expanded. */
-/* Try to get the name of the program */
-static char *
-get_progname(void)
-{
-#ifdef __LINUX__
-    char *progname = NULL;
-    FILE *fp;
-    static char temp[BUFSIZ];
-
-    SDL_snprintf(temp, SDL_arraysize(temp), "/proc/%d/cmdline", getpid());
-    fp = fopen(temp, "r");
-    if (fp != NULL) {
-        if (fgets(temp, sizeof(temp) - 1, fp)) {
-            progname = SDL_strrchr(temp, '/');
-            if (progname == NULL) {
-                progname = temp;
-            } else {
-                progname = progname + 1;
-            }
-        }
-        fclose(fp);
-    }
-    return(progname);
-#elif defined(__NetBSD__)
-    return getprogname();
-#else
-    return("unknown");
-#endif
-}
-
-
 static int
 PULSEAUDIO_OpenDevice(_THIS, const char *devname, int iscapture)
 {
@@ -438,7 +406,7 @@
     }
 
     h->mainloop_api = PULSEAUDIO_pa_mainloop_get_api(h->mainloop);
-    h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, get_progname());
+    h->context = PULSEAUDIO_pa_context_new(h->mainloop_api, NULL);
     if (!h->context) {
         PULSEAUDIO_CloseDevice(this);
         SDL_SetError("pa_context_new() failed");
--- a/src/audio/windib/SDL_dibaudio.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/audio/windib/SDL_dibaudio.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,8 +23,7 @@
 
 /* Allow access to a raw mixing buffer */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 #include <mmsystem.h>
 
 #include "SDL_timer.h"
@@ -67,21 +66,14 @@
 {
     size_t len;
     char errbuf[MAXERRORLENGTH];
-#ifdef _WIN32_WCE
     wchar_t werrbuf[MAXERRORLENGTH];
-#endif
 
     SDL_snprintf(errbuf, SDL_arraysize(errbuf), "%s: ", function);
     len = SDL_strlen(errbuf);
 
-#ifdef _WIN32_WCE
-    /* UNICODE version */
     waveOutGetErrorText(code, werrbuf, MAXERRORLENGTH - len);
     WideCharToMultiByte(CP_ACP, 0, werrbuf, -1, errbuf + len,
                         MAXERRORLENGTH - len, NULL, NULL);
-#else
-    waveOutGetErrorText(code, errbuf + len, (UINT) (MAXERRORLENGTH - len));
-#endif
 
     SDL_SetError("%s", errbuf);
 }
--- a/src/audio/windx5/SDL_dx5audio.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/audio/windx5/SDL_dx5audio.c	Tue Feb 01 00:37:02 2011 -0800
@@ -24,6 +24,7 @@
 /* Allow access to a raw mixing buffer */
 
 #include "SDL_timer.h"
+#include "SDL_loadso.h"
 #include "SDL_audio.h"
 #include "../SDL_audio_c.h"
 #include "SDL_dx5audio.h"
@@ -38,19 +39,19 @@
 #endif
 
 /* DirectX function pointers for audio */
-static HINSTANCE DSoundDLL = NULL;
+static void* DSoundDLL = NULL;
 static HRESULT(WINAPI * DSoundCreate) (LPGUID, LPDIRECTSOUND *, LPUNKNOWN) =
     NULL;
 
 static void
 DSOUND_Unload(void)
 {
+    DSoundCreate = NULL;
+
     if (DSoundDLL != NULL) {
-        FreeLibrary(DSoundDLL);
+        SDL_UnloadObject(DSoundDLL);
+        DSoundDLL = NULL;
     }
-
-    DSoundCreate = NULL;
-    DSoundDLL = NULL;
 }
 
 
@@ -61,17 +62,16 @@
 
     DSOUND_Unload();
 
-    DSoundDLL = LoadLibrary(TEXT("DSOUND.DLL"));
+    DSoundDLL = SDL_LoadObject("DSOUND.DLL");
     if (DSoundDLL == NULL) {
         SDL_SetError("DirectSound: failed to load DSOUND.DLL");
     } else {
         /* Now make sure we have DirectX 5 or better... */
         /*  (DirectSoundCaptureCreate was added in DX5) */
-        if (!GetProcAddress(DSoundDLL, TEXT("DirectSoundCaptureCreate"))) {
+        if (!SDL_LoadFunction(DSoundDLL, "DirectSoundCaptureCreate")) {
             SDL_SetError("DirectSound: System doesn't appear to have DX5.");
         } else {
-            DSoundCreate = (void *) GetProcAddress(DSoundDLL,
-                                                   TEXT("DirectSoundCreate"));
+            DSoundCreate = SDL_LoadFunction(DSoundDLL, "DirectSoundCreate");
         }
 
         if (!DSoundCreate) {
--- a/src/audio/windx5/directx.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/audio/windx5/directx.h	Tue Feb 01 00:37:02 2011 -0800
@@ -4,8 +4,7 @@
 
 /* Include all of the DirectX 5.0 headers and adds any necessary tweaks */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 #include <mmsystem.h>
 #ifndef WIN32
 #define WIN32
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/android/SDL_android.cpp	Tue Feb 01 00:37:02 2011 -0800
@@ -0,0 +1,258 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_android.h"
+
+extern "C" {
+#include "../../events/SDL_events_c.h"
+#include "../../video/android/SDL_androidkeyboard.h"
+#include "../../video/android/SDL_androidtouch.h"
+#include "../../video/android/SDL_androidvideo.h"
+
+/* Impelemented in audio/android/SDL_androidaudio.c */
+extern void Android_RunAudioThread();
+} // C
+
+/*******************************************************************************
+ This file links the Java side of Android with libsdl
+*******************************************************************************/
+#include <jni.h>
+#include <android/log.h>
+
+
+/*******************************************************************************
+                               Globals
+*******************************************************************************/
+static JNIEnv* mEnv = NULL;
+static JNIEnv* mAudioEnv = NULL;
+
+// Main activity
+static jclass mActivityClass;
+
+// method signatures
+static jmethodID midCreateGLContext;
+static jmethodID midFlipBuffers;
+static jmethodID midAudioInit;
+static jmethodID midAudioWriteShortBuffer;
+static jmethodID midAudioWriteByteBuffer;
+static jmethodID midAudioQuit;
+
+// Accelerometer data storage
+static float fLastAccelerometer[3];
+
+
+/*******************************************************************************
+                 Functions called by JNI
+*******************************************************************************/
+
+// Library init
+extern "C" jint JNI_OnLoad(JavaVM* vm, void* reserved)
+{
+    return JNI_VERSION_1_4;
+}
+
+// Called before SDL_main() to initialize JNI bindings
+extern "C" void SDL_Android_Init(JNIEnv* env, jclass cls)
+{
+    __android_log_print(ANDROID_LOG_INFO, "SDL", "SDL_Android_Init()");
+
+    mEnv = env;
+    mActivityClass = cls;
+
+    midCreateGLContext = mEnv->GetStaticMethodID(mActivityClass,
+                                "createGLContext","()V");
+    midFlipBuffers = mEnv->GetStaticMethodID(mActivityClass,
+                                "flipBuffers","()V");
+    midAudioInit = mEnv->GetStaticMethodID(mActivityClass, 
+                                "audioInit", "(IZZI)Ljava/lang/Object;");
+    midAudioWriteShortBuffer = mEnv->GetStaticMethodID(mActivityClass,
+                                "audioWriteShortBuffer", "([S)V");
+    midAudioWriteByteBuffer = mEnv->GetStaticMethodID(mActivityClass,
+                                "audioWriteByteBuffer", "([B)V");
+    midAudioQuit = mEnv->GetStaticMethodID(mActivityClass,
+                                "audioQuit", "()V");
+
+    if(!midCreateGLContext || !midFlipBuffers || !midAudioInit ||
+       !midAudioWriteShortBuffer || !midAudioWriteByteBuffer || !midAudioQuit) {
+        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL: Couldn't locate Java callbacks, check that they're named and typed correctly");
+    }
+}
+
+// Resize
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeResize(
+                                    JNIEnv* env, jclass jcls,
+                                    jint width, jint height, jint format)
+{
+    Android_SetScreenResolution(width, height, format);
+}
+
+// Keydown
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyDown(
+                                    JNIEnv* env, jclass jcls, jint keycode)
+{
+    Android_OnKeyDown(keycode);
+}
+
+// Keyup
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeKeyUp(
+                                    JNIEnv* env, jclass jcls, jint keycode)
+{
+    Android_OnKeyUp(keycode);
+}
+
+// Touch
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeTouch(
+                                    JNIEnv* env, jclass jcls,
+                                    jint action, jfloat x, jfloat y, jfloat p)
+{
+    Android_OnTouch(action, x, y, p);
+}
+
+// Accelerometer
+extern "C" void Java_org_libsdl_app_SDLActivity_onNativeAccel(
+                                    JNIEnv* env, jclass jcls,
+                                    jfloat x, jfloat y, jfloat z)
+{
+    fLastAccelerometer[0] = x;
+    fLastAccelerometer[1] = y;
+    fLastAccelerometer[2] = z;   
+}
+
+// Quit
+extern "C" void Java_org_libsdl_app_SDLActivity_nativeQuit(
+                                    JNIEnv* env, jclass cls)
+{    
+    // Inject a SDL_QUIT event
+    SDL_SendQuit();
+}
+
+extern "C" void Java_org_libsdl_app_SDLActivity_nativeRunAudioThread(
+                                    JNIEnv* env, jclass cls)
+{
+    /* This is the audio thread, with a different environment */
+    mAudioEnv = env;
+
+    Android_RunAudioThread();
+}
+
+
+/*******************************************************************************
+             Functions called by SDL into Java
+*******************************************************************************/
+extern "C" void Android_JNI_CreateContext()
+{
+    mEnv->CallStaticVoidMethod(mActivityClass, midCreateGLContext); 
+}
+
+extern "C" void Android_JNI_SwapWindow()
+{
+    mEnv->CallStaticVoidMethod(mActivityClass, midFlipBuffers); 
+}
+
+extern "C" void Android_JNI_SetActivityTitle(const char *title)
+{
+    jmethodID mid;
+
+    mid = mEnv->GetStaticMethodID(mActivityClass,"setActivityTitle","(Ljava/lang/String;)V");
+    if (mid) {
+        mEnv->CallStaticVoidMethod(mActivityClass, mid, mEnv->NewStringUTF(title));
+    }
+}
+
+extern "C" void Android_JNI_GetAccelerometerValues(float values[3])
+{
+    int i;
+    for (i = 0; i < 3; ++i) {
+        values[i] = fLastAccelerometer[i];
+    }
+}
+
+//
+// Audio support
+//
+static jboolean audioBuffer16Bit = JNI_FALSE;
+static jboolean audioBufferStereo = JNI_FALSE;
+static jobject audioBuffer = NULL;
+static void* audioBufferPinned = NULL;
+
+extern "C" int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames)
+{
+    int audioBufferFrames;
+
+    __android_log_print(ANDROID_LOG_VERBOSE, "SDL", "SDL audio: opening device");
+    audioBuffer16Bit = is16Bit;
+    audioBufferStereo = channelCount > 1;
+
+    audioBuffer = mEnv->CallStaticObjectMethod(mActivityClass, midAudioInit, sampleRate, audioBuffer16Bit, audioBufferStereo, desiredBufferFrames);
+
+    if (audioBuffer == NULL) {
+        __android_log_print(ANDROID_LOG_WARN, "SDL", "SDL audio: didn't get back a good audio buffer!");
+        return 0;
+    }
+    audioBuffer = mEnv->NewGlobalRef(audioBuffer);
+
+    jboolean isCopy = JNI_FALSE;
+    if (audioBuffer16Bit) {
+        audioBufferPinned = mEnv->GetShortArrayElements((jshortArray)audioBuffer, &isCopy);
+        audioBufferFrames = mEnv->GetArrayLength((jshortArray)audioBuffer);
+    } else {
+        audioBufferPinned = mEnv->GetByteArrayElements((jbyteArray)audioBuffer, &isCopy);
+        audioBufferFrames = mEnv->GetArrayLength((jbyteArray)audioBuffer);
+    }
+    if (audioBufferStereo) {
+        audioBufferFrames /= 2;
+    }
+
+    return audioBufferFrames;
+}
+
+extern "C" void * Android_JNI_GetAudioBuffer()
+{
+    return audioBufferPinned;
+}
+
+extern "C" void Android_JNI_WriteAudioBuffer()
+{
+    if (audioBuffer16Bit) {
+        mAudioEnv->ReleaseShortArrayElements((jshortArray)audioBuffer, (jshort *)audioBufferPinned, JNI_COMMIT);
+        mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteShortBuffer, (jshortArray)audioBuffer);
+    } else {
+        mAudioEnv->ReleaseByteArrayElements((jbyteArray)audioBuffer, (jbyte *)audioBufferPinned, JNI_COMMIT);
+        mAudioEnv->CallStaticVoidMethod(mActivityClass, midAudioWriteByteBuffer, (jbyteArray)audioBuffer);
+    }
+
+    /* JNI_COMMIT means the changes are committed to the VM but the buffer remains pinned */
+}
+
+extern "C" void Android_JNI_CloseAudioDevice()
+{
+    mEnv->CallStaticVoidMethod(mActivityClass, midAudioQuit); 
+
+    if (audioBuffer) {
+        mEnv->DeleteGlobalRef(audioBuffer);
+        audioBuffer = NULL;
+        audioBufferPinned = NULL;
+    }
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/android/SDL_android.h	Tue Feb 01 00:37:02 2011 -0800
@@ -0,0 +1,50 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+/* Set up for C function definitions, even when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+extern "C" {
+/* *INDENT-ON* */
+#endif
+
+/* Interface from the SDL library into the Android Java activity */
+extern void Android_JNI_CreateContext();
+extern void Android_JNI_SwapWindow();
+extern void Android_JNI_SetActivityTitle(const char *title);
+extern void Android_JNI_GetAccelerometerValues(float values[3]);
+
+// Audio support
+extern int Android_JNI_OpenAudioDevice(int sampleRate, int is16Bit, int channelCount, int desiredBufferFrames);
+extern void* Android_JNI_GetAudioBuffer();
+extern void Android_JNI_WriteAudioBuffer();
+extern void Android_JNI_CloseAudioDevice();
+
+/* Ends C function definitions when using C++ */
+#ifdef __cplusplus
+/* *INDENT-OFF* */
+}
+/* *INDENT-ON* */
+#endif
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/windows/SDL_windows.c	Tue Feb 01 00:37:02 2011 -0800
@@ -0,0 +1,41 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_error.h"
+#include "SDL_windows.h"
+
+
+/* Sets an error message based on GetLastError() */
+void
+WIN_SetError(const char *prefix)
+{
+    TCHAR buffer[1024];
+    char *message;
+    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
+                  buffer, SDL_arraysize(buffer), NULL);
+    message = WIN_StringToUTF8(buffer);
+    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
+    SDL_free(message);
+}
+
+/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/core/windows/SDL_windows.h	Tue Feb 01 00:37:02 2011 -0800
@@ -0,0 +1,53 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2010 Sam Lantinga
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+
+    Sam Lantinga
+    slouken@libsdl.org
+*/
+
+/* This is an include file for windows.h with the SDL build settings */
+
+#ifndef _INCLUDED_WINDOWS_H
+#define _INCLUDED_WINDOWS_H
+
+#define WIN32_LEAN_AND_MEAN
+#define STRICT
+#ifndef UNICODE
+#define UNICODE 1
+#endif
+#undef WINVER
+#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
+
+#include <windows.h>
+
+
+/* Routines to convert from UTF8 to native Windows text */
+#if UNICODE
+#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)(S), (SDL_wcslen(S)+1)*sizeof(WCHAR))
+#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)(S), SDL_strlen(S)+1)
+#else
+#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)(S), (SDL_strlen(S)+1))
+#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)(S), SDL_strlen(S)+1)
+#endif
+
+/* Sets an error message based on GetLastError() */
+extern void WIN_SetError(const char *prefix);
+
+#endif /* _INCLUDED_WINDOWS_H */
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/src/cpuinfo/SDL_cpuinfo.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/cpuinfo/SDL_cpuinfo.c	Tue Feb 01 00:37:02 2011 -0800
@@ -38,9 +38,8 @@
 #include <signal.h>
 #include <setjmp.h>
 #endif
-#ifdef __WINDOWS__
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#ifdef __WIN32__
+#include "../core/windows/SDL_windows.h"
 #endif
 
 #define CPU_HAS_RDTSC   0x00000001
@@ -305,7 +304,7 @@
 static int SDL_CPUCount = 0;
 
 int
-SDL_GetCPUCount()
+SDL_GetCPUCount(void)
 {
     if (!SDL_CPUCount) {
 #if defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
@@ -319,7 +318,7 @@
             sysctlbyname("hw.ncpu", &SDL_CPUCount, &size, NULL, 0);
         }
 #endif
-#ifdef __WINDOWS__
+#ifdef __WIN32__
         if (SDL_CPUCount <= 0) {
             SYSTEM_INFO info;
             GetSystemInfo(&info);
@@ -336,75 +335,127 @@
 
 /* Oh, such a sweet sweet trick, just not very useful. :) */
 static const char *
-SDL_GetCPUType()
+SDL_GetCPUType(void)
 {
-    static char SDL_CPUType[48];
+    static char SDL_CPUType[13];
 
     if (!SDL_CPUType[0]) {
         int i = 0;
         int a, b, c, d;
 
         if (CPU_haveCPUID()) {
+            cpuid(0x00000000, a, b, c, d);
+            SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
+            SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
+            SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
+            SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
+            SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
+            SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
+            SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
+            SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
+            SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
+            SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
+            SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
+            SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
+        }
+        if (!SDL_CPUType[0]) {
+            SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType));
+        }
+    }
+    return SDL_CPUType;
+}
+
+static const char *
+SDL_GetCPUName(void)
+{
+    static char SDL_CPUName[48];
+
+    if (!SDL_CPUName[0]) {
+        int i = 0;
+        int a, b, c, d;
+
+        if (CPU_haveCPUID()) {
             cpuid(0x80000000, a, b, c, d);
             if (a >= 0x80000004) {
                 cpuid(0x80000002, a, b, c, d);
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
                 cpuid(0x80000003, a, b, c, d);
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
                 cpuid(0x80000004, a, b, c, d);
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(a & 0xff); a >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(b & 0xff); b >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(c & 0xff); c >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
-                SDL_CPUType[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(a & 0xff); a >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(b & 0xff); b >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(c & 0xff); c >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
+                SDL_CPUName[i++] = (char)(d & 0xff); d >>= 8;
             }
         }
-        if (!SDL_CPUType[0]) {
-            SDL_strlcpy(SDL_CPUType, "Unknown", sizeof(SDL_CPUType));
+        if (!SDL_CPUName[0]) {
+            SDL_strlcpy(SDL_CPUName, "Unknown", sizeof(SDL_CPUName));
         }
     }
-    return SDL_CPUType;
+    return SDL_CPUName;
+}
+
+int
+SDL_GetCPUCacheLineSize(void)
+{
+    const char *cpuType = SDL_GetCPUType();
+
+    if (SDL_strcmp(cpuType, "GenuineIntel") == 0) {
+        int a, b, c, d;
+
+        cpuid(0x00000001, a, b, c, d);
+        return (((b >> 8) & 0xff) * 8);
+    } else if (SDL_strcmp(cpuType, "AuthenticAMD") == 0) {
+        int a, b, c, d;
+
+        cpuid(0x80000005, a, b, c, d);
+        return (c & 0xff);
+    } else {
+        /* Just make a guess here... */
+        return SDL_CACHELINE_SIZE;
+    }
 }
 
 static Uint32 SDL_CPUFeatures = 0xFFFFFFFF;
@@ -522,7 +573,9 @@
 main()
 {
     printf("CPU count: %d\n", SDL_GetCPUCount());
-    printf("CPU name: %s\n", SDL_GetCPUType());
+    printf("CPU type: %s\n", SDL_GetCPUType());
+    printf("CPU name: %s\n", SDL_GetCPUName());
+    printf("CacheLine size: %d\n", SDL_GetCPUCacheLineSize());
     printf("RDTSC: %d\n", SDL_HasRDTSC());
     printf("MMX: %d\n", SDL_HasMMX());
     printf("MMXExt: %d\n", SDL_HasMMXExt());
--- a/src/events/SDL_events.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/SDL_events.c	Tue Feb 01 00:37:02 2011 -0800
@@ -27,12 +27,12 @@
 #include "SDL_events.h"
 #include "SDL_syswm.h"
 #include "SDL_thread.h"
-#include "SDL_sysevents.h"
 #include "SDL_events_c.h"
 #include "../timer/SDL_timer_c.h"
 #if !SDL_JOYSTICK_DISABLED
 #include "../joystick/SDL_joystick_c.h"
 #endif
+#include "../video/SDL_sysvideo.h"
 
 /* Public data -- the event filter */
 SDL_EventFilter SDL_EventOK = NULL;
@@ -58,36 +58,6 @@
     struct SDL_SysWMmsg wmmsg[MAXEVENTS];
 } SDL_EventQ;
 
-/* Private data -- event locking structure */
-static struct
-{
-    SDL_mutex *lock;
-    int safe;
-} SDL_EventLock;
-
-/* Thread functions */
-static SDL_Thread *SDL_EventThread = NULL;      /* Thread handle */
-static SDL_threadID event_thread;     /* The event thread id */
-
-void
-SDL_Lock_EventThread(void)
-{
-    if (SDL_EventThread && (SDL_ThreadID() != event_thread)) {
-        /* Grab lock and spin until we're sure event thread stopped */
-        SDL_mutexP(SDL_EventLock.lock);
-        while (!SDL_EventLock.safe) {
-            SDL_Delay(1);
-        }
-    }
-}
-
-void
-SDL_Unlock_EventThread(void)
-{
-    if (SDL_EventThread && (SDL_ThreadID() != event_thread)) {
-        SDL_mutexV(SDL_EventLock.lock);
-    }
-}
 
 static __inline__ SDL_bool
 SDL_ShouldPollJoystick()
@@ -102,112 +72,6 @@
     return SDL_FALSE;
 }
 
-static int SDLCALL
-SDL_GobbleEvents(void *unused)
-{
-    event_thread = SDL_ThreadID();
-
-    while (SDL_EventQ.active) {
-        SDL_VideoDevice *_this = SDL_GetVideoDevice();
-
-        /* Get events from the video subsystem */
-        if (_this) {
-            _this->PumpEvents(_this);
-        }
-#if !SDL_JOYSTICK_DISABLED
-        /* Check for joystick state change */
-        if (SDL_ShouldPollJoystick()) {
-            SDL_JoystickUpdate();
-        }
-#endif
-
-        /* Give up the CPU for the rest of our timeslice */
-        SDL_EventLock.safe = 1;
-        if (SDL_timer_running) {
-            SDL_ThreadedTimerCheck();
-        }
-        SDL_Delay(1);
-
-        /* Check for event locking.
-           On the P of the lock mutex, if the lock is held, this thread
-           will wait until the lock is released before continuing.  The
-           safe flag will be set, meaning that the other thread can go
-           about it's business.  The safe flag is reset before the V,
-           so as soon as the mutex is free, other threads can see that
-           it's not safe to interfere with the event thread.
-         */
-        SDL_mutexP(SDL_EventLock.lock);
-        SDL_EventLock.safe = 0;
-        SDL_mutexV(SDL_EventLock.lock);
-    }
-    SDL_SetTimerThreaded(0);
-    event_thread = 0;
-    return (0);
-}
-
-static int
-SDL_StartEventThread(Uint32 flags)
-{
-    /* Reset everything to zero */
-    SDL_EventThread = NULL;
-    SDL_memset(&SDL_EventLock, 0, sizeof(SDL_EventLock));
-
-    /* Create the lock and set ourselves active */
-#if !SDL_THREADS_DISABLED
-    SDL_EventQ.lock = SDL_CreateMutex();
-    if (SDL_EventQ.lock == NULL) {
-        return (-1);
-    }
-#endif /* !SDL_THREADS_DISABLED */
-    SDL_EventQ.active = 1;
-
-    if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
-        SDL_EventLock.lock = SDL_CreateMutex();
-        if (SDL_EventLock.lock == NULL) {
-            return (-1);
-        }
-        SDL_EventLock.safe = 0;
-
-        /* The event thread will handle timers too */
-        SDL_SetTimerThreaded(2);
-#if (defined(__WINDOWS__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
-#undef SDL_CreateThread
-        SDL_EventThread =
-            SDL_CreateThread(SDL_GobbleEvents, NULL, NULL, NULL);
-#else
-        SDL_EventThread = SDL_CreateThread(SDL_GobbleEvents, NULL);
-#endif
-        if (SDL_EventThread == NULL) {
-            return (-1);
-        }
-    } else {
-        event_thread = 0;
-    }
-    return (0);
-}
-
-static void
-SDL_StopEventThread(void)
-{
-    SDL_EventQ.active = 0;
-    if (SDL_EventThread) {
-        SDL_WaitThread(SDL_EventThread, NULL);
-        SDL_EventThread = NULL;
-        SDL_DestroyMutex(SDL_EventLock.lock);
-        SDL_EventLock.lock = NULL;
-    }
-    if (SDL_EventQ.lock) {
-        SDL_DestroyMutex(SDL_EventQ.lock);
-        SDL_EventQ.lock = NULL;
-    }
-}
-
-SDL_threadID
-SDL_EventThreadID(void)
-{
-    return (event_thread);
-}
-
 /* Public functions */
 
 void
@@ -215,13 +79,10 @@
 {
     int i;
 
-    /* Halt the event thread, if running */
-    SDL_StopEventThread();
-
-    /* Shutdown event handlers */
-    SDL_KeyboardQuit();
-    SDL_MouseQuit();
-    SDL_QuitQuit();
+    if (SDL_EventQ.lock) {
+        SDL_DestroyMutex(SDL_EventQ.lock);
+        SDL_EventQ.lock = NULL;
+    }
 
     /* Clean out EventQ */
     SDL_EventQ.head = 0;
@@ -239,12 +100,11 @@
 
 /* This function (and associated calls) may be called more than once */
 int
-SDL_StartEventLoop(Uint32 flags)
+SDL_StartEventLoop(void)
 {
     int retcode;
 
     /* Clean out the event queue */
-    SDL_EventThread = NULL;
     SDL_EventQ.lock = NULL;
     SDL_StopEventLoop();
 
@@ -252,22 +112,15 @@
     SDL_EventOK = NULL;
     SDL_EventState(SDL_SYSWMEVENT, SDL_DISABLE);
 
-    /* Initialize event handlers */
-    retcode = 0;
-    retcode += SDL_KeyboardInit();
-    retcode += SDL_MouseInit();
-    retcode += SDL_TouchInit();
-    retcode += SDL_QuitInit();
-    if (retcode < 0) {
-        /* We don't expect them to fail, but... */
+    /* Create the lock and set ourselves active */
+#if !SDL_THREADS_DISABLED
+    SDL_EventQ.lock = SDL_CreateMutex();
+    if (SDL_EventQ.lock == NULL) {
         return (-1);
     }
+#endif /* !SDL_THREADS_DISABLED */
+    SDL_EventQ.active = 1;
 
-    /* Create the lock and event thread */
-    if (SDL_StartEventThread(flags) < 0) {
-        SDL_StopEventLoop();
-        return (-1);
-    }
     return (0);
 }
 
@@ -426,20 +279,18 @@
 void
 SDL_PumpEvents(void)
 {
-    if (!SDL_EventThread) {
-        SDL_VideoDevice *_this = SDL_GetVideoDevice();
+    SDL_VideoDevice *_this = SDL_GetVideoDevice();
 
-        /* Get events from the video subsystem */
-        if (_this) {
-            _this->PumpEvents(_this);
-        }
+    /* Get events from the video subsystem */
+    if (_this) {
+        _this->PumpEvents(_this);
+    }
 #if !SDL_JOYSTICK_DISABLED
-        /* Check for joystick state change */
-        if (SDL_ShouldPollJoystick()) {
-            SDL_JoystickUpdate();
-        }
+    /* Check for joystick state change */
+    if (SDL_ShouldPollJoystick()) {
+        SDL_JoystickUpdate();
+    }
 #endif
-    }
 }
 
 /* Public functions */
--- a/src/events/SDL_events_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/SDL_events_c.h	Tue Feb 01 00:37:02 2011 -0800
@@ -29,15 +29,12 @@
 #include "SDL_touch_c.h"
 #include "SDL_windowevents_c.h"
 #include "SDL_gesture_c.h"
+
 /* Start and stop the event processing loop */
-extern int SDL_StartEventLoop(Uint32 flags);
+extern int SDL_StartEventLoop(void);
 extern void SDL_StopEventLoop(void);
 extern void SDL_QuitInterrupt(void);
 
-extern void SDL_Lock_EventThread(void);
-extern void SDL_Unlock_EventThread(void);
-extern SDL_threadID SDL_EventThreadID(void);
-
 extern int SDL_SendSysWMEvent(SDL_SysWMmsg * message);
 
 extern int SDL_QuitInit(void);
--- a/src/events/SDL_keyboard.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/SDL_keyboard.c	Tue Feb 01 00:37:02 2011 -0800
@@ -26,7 +26,7 @@
 #include "SDL_timer.h"
 #include "SDL_events.h"
 #include "SDL_events_c.h"
-#include "SDL_sysevents.h"
+#include "../video/SDL_sysvideo.h"
 
 
 /* Global keyboard information */
@@ -562,7 +562,7 @@
 SDL_ResetKeyboard(void)
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
-    SDL_scancode scancode;
+    SDL_ScanCode scancode;
 
     for (scancode = 0; scancode < SDL_NUM_SCANCODES; ++scancode) {
         if (keyboard->keystate[scancode] == SDL_PRESSED) {
@@ -590,7 +590,7 @@
 }
 
 void
-SDL_SetScancodeName(SDL_scancode scancode, const char *name)
+SDL_SetScancodeName(SDL_ScanCode scancode, const char *name)
 {
     SDL_scancode_names[scancode] = name;
 }
@@ -638,7 +638,7 @@
 }
 
 int
-SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode)
+SDL_SendKeyboardKey(Uint8 state, SDL_ScanCode scancode)
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
     int posted;
@@ -849,18 +849,18 @@
 }
 
 SDLKey
-SDL_GetKeyFromScancode(SDL_scancode scancode)
+SDL_GetKeyFromScancode(SDL_ScanCode scancode)
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
 
     return keyboard->keymap[scancode];
 }
 
-SDL_scancode
+SDL_ScanCode
 SDL_GetScancodeFromKey(SDLKey key)
 {
     SDL_Keyboard *keyboard = &SDL_keyboard;
-    SDL_scancode scancode;
+    SDL_ScanCode scancode;
 
     for (scancode = SDL_SCANCODE_UNKNOWN; scancode < SDL_NUM_SCANCODES;
          ++scancode) {
@@ -872,7 +872,7 @@
 }
 
 const char *
-SDL_GetScancodeName(SDL_scancode scancode)
+SDL_GetScancodeName(SDL_ScanCode scancode)
 {
     const char *name = SDL_scancode_names[scancode];
 
@@ -890,7 +890,7 @@
 
     if (key & SDLK_SCANCODE_MASK) {
         return
-            SDL_GetScancodeName((SDL_scancode) (key & ~SDLK_SCANCODE_MASK));
+            SDL_GetScancodeName((SDL_ScanCode) (key & ~SDLK_SCANCODE_MASK));
     }
 
     switch (key) {
--- a/src/events/SDL_keyboard_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/SDL_keyboard_c.h	Tue Feb 01 00:37:02 2011 -0800
@@ -43,13 +43,13 @@
    name. Encoded as UTF-8. The string is not copied, thus the pointer given to
    this function must stay valid forever (or at least until the call to
    VideoQuit()). */
-extern void SDL_SetScancodeName(SDL_scancode scancode, const char *name);
+extern void SDL_SetScancodeName(SDL_ScanCode scancode, const char *name);
 
 /* Set the keyboard focus window */
 extern void SDL_SetKeyboardFocus(SDL_Window * window);
 
 /* Send a keyboard key event */
-extern int SDL_SendKeyboardKey(Uint8 state, SDL_scancode scancode);
+extern int SDL_SendKeyboardKey(Uint8 state, SDL_ScanCode scancode);
 
 /* Send keyboard text input */
 extern int SDL_SendKeyboardText(const char *text);
--- a/src/events/SDL_sysevents.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/SDL_sysevents.h	Tue Feb 01 00:37:02 2011 -0800
@@ -29,7 +29,7 @@
 #define MUST_THREAD_EVENTS
 #endif
 
-#ifdef __WINDOWS__              /* Windows doesn't allow a separate event thread */
+#ifdef __WIN32__              /* Windows doesn't allow a separate event thread */
 #define CANT_THREAD_EVENTS
 #endif
 
--- a/src/events/SDL_touch.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/SDL_touch.c	Tue Feb 01 00:37:02 2011 -0800
@@ -397,15 +397,16 @@
                     float xin, float yin, float pressurein)
 {
     int index = SDL_GetTouchIndexId(id);
-    SDL_Touch *touch = SDL_GetTouch(id);
-    SDL_Finger *finger = SDL_GetFinger(touch,fingerid);
+    SDL_Touch *touch;
+    SDL_Finger *finger;
     int posted;
     Sint16 xrel, yrel;
     float x_max = 0, y_max = 0;
-        Uint16 x;
-        Uint16 y;
-        Uint16 pressure;
+    Uint16 x;
+    Uint16 y;
+    Uint16 pressure;
     
+    touch = SDL_GetTouch(id);
     if (!touch) {
       return SDL_TouchNotFoundError(id);
     }
@@ -418,6 +419,7 @@
         return 0;
     }
     
+    finger = SDL_GetFinger(touch,fingerid);
     if(finger == NULL || !finger->down) {
         return SDL_SendFingerDown(id,fingerid,SDL_TRUE,xin,yin,pressurein);        
     } else {
@@ -496,14 +498,16 @@
         return posted;
     }
 }
+
 int
 SDL_SendTouchButton(SDL_TouchID id, Uint8 state, Uint8 button)
 {
-    SDL_Touch *touch = SDL_GetTouch(id);
+    SDL_Touch *touch;
     int posted;
     Uint32 type;
 
     
+    touch = SDL_GetTouch(id);
     if (!touch) {
       return SDL_TouchNotFoundError(id);
     }
--- a/src/events/SDL_windowevents.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/SDL_windowevents.c	Tue Feb 01 00:37:02 2011 -0800
@@ -176,6 +176,14 @@
 
         posted = (SDL_PushEvent(&event) > 0);
     }
+	
+	if (windowevent == SDL_WINDOWEVENT_CLOSE) {
+		if ( !window->prev && !window->next ) {
+			// This is the last window in the list so send the SDL_QUIT event
+			SDL_SendQuit();
+		}
+	}
+
     return (posted);
 }
 
--- a/src/events/scancodes_darwin.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/scancodes_darwin.h	Tue Feb 01 00:37:02 2011 -0800
@@ -27,7 +27,7 @@
    - experimentation on various ADB and USB ISO keyboards and one ADB ANSI keyboard
 */
 /* *INDENT-OFF* */
-static const SDL_scancode darwin_scancode_table[] = {
+static const SDL_ScanCode darwin_scancode_table[] = {
     /*   0 */   SDL_SCANCODE_A,
     /*   1 */   SDL_SCANCODE_S,
     /*   2 */   SDL_SCANCODE_D,
--- a/src/events/scancodes_linux.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/scancodes_linux.h	Tue Feb 01 00:37:02 2011 -0800
@@ -26,7 +26,7 @@
    - Linux kernel source input.h
 */
 /* *INDENT-OFF* */
-static SDL_scancode const linux_scancode_table[] = {
+static SDL_ScanCode const linux_scancode_table[] = {
     /*  0 */    SDL_SCANCODE_UNKNOWN,
     /*  1 */    SDL_SCANCODE_ESCAPE,
     /*  2 */    SDL_SCANCODE_1,
--- a/src/events/scancodes_windows.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/scancodes_windows.h	Tue Feb 01 00:37:02 2011 -0800
@@ -26,7 +26,7 @@
    - msdn.microsoft.com
 */
 /* *INDENT-OFF* */
-static const SDL_scancode windows_scancode_table[] = {
+static const SDL_ScanCode windows_scancode_table[] = {
     /*  0, 0x00 */      SDL_SCANCODE_UNKNOWN,
     /*  1, 0x01 */      SDL_SCANCODE_UNKNOWN,
     /*  2, 0x02 */      SDL_SCANCODE_UNKNOWN,
--- a/src/events/scancodes_xfree86.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/events/scancodes_xfree86.h	Tue Feb 01 00:37:02 2011 -0800
@@ -26,7 +26,7 @@
    - atKeyNames.h from XFree86 source code
 */
 /* *INDENT-OFF* */
-static const SDL_scancode xfree86_scancode_table[] = {
+static const SDL_ScanCode xfree86_scancode_table[] = {
     /*  0 */    SDL_SCANCODE_UNKNOWN,
     /*  1 */    SDL_SCANCODE_ESCAPE,
     /*  2 */    SDL_SCANCODE_1,
@@ -177,7 +177,7 @@
 };
 
 /* for wireless usb keyboard (manufacturer TRUST) without numpad. */
-static const SDL_scancode xfree86_scancode_table2[] = {
+static const SDL_ScanCode xfree86_scancode_table2[] = {
     /*  0 */    SDL_SCANCODE_UNKNOWN,
     /*  1 */    SDL_SCANCODE_ESCAPE,
     /*  2 */    SDL_SCANCODE_1,
--- a/src/file/SDL_rwops.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/file/SDL_rwops.c	Tue Feb 01 00:37:02 2011 -0800
@@ -37,15 +37,14 @@
 #include <fat.h>
 #endif /* __NDS__ */
 
-#ifdef __WINDOWS__
+#ifdef __WIN32__
 
 /* Functions to read/write Win32 API file pointers */
 /* Will not use it on WinCE because stdio is buffered, it means
    faster, and all stdio functions anyway are embedded in coredll.dll - 
    the main wince dll*/
 
-#define WINDOWS_LEAN_AND_MEAN
-#include <windows.h>
+#include "../core/windows/SDL_windows.h"
 
 #ifndef INVALID_SET_FILE_POINTER
 #define INVALID_SET_FILE_POINTER 0xFFFFFFFF
@@ -98,34 +97,28 @@
     }
 #ifdef _WIN32_WCE
     {
-        size_t size = SDL_strlen(filename) + 1;
-        wchar_t *filenameW = SDL_stack_alloc(wchar_t, size);
-
-        if (MultiByteToWideChar(CP_UTF8, 0, filename, -1, filenameW, size) ==
-            0) {
-            SDL_stack_free(filenameW);
-            SDL_free(context->hidden.windowsio.buffer.data);
-            context->hidden.windowsio.buffer.data = NULL;
-            SDL_SetError("Unable to convert filename to Unicode");
-            return -1;
-        }
-        h = CreateFile(filenameW, (w_right | r_right),
+        LPTSTR tstr = WIN_UTF8ToString(filename);
+        h = CreateFile(tstr, (w_right | r_right),
                        (w_right) ? 0 : FILE_SHARE_READ, NULL,
                        (must_exist | truncate | a_mode),
                        FILE_ATTRIBUTE_NORMAL, NULL);
-        SDL_stack_free(filenameW);
+        SDL_free(tstr);
     }
 #else
     /* Do not open a dialog box if failure */
     old_error_mode =
         SetErrorMode(SEM_NOOPENFILEERRORBOX | SEM_FAILCRITICALERRORS);
 
-    h = CreateFile(filename, (w_right | r_right),
-                   (w_right) ? 0 : FILE_SHARE_READ, NULL,
-                   (must_exist | truncate | a_mode), FILE_ATTRIBUTE_NORMAL,
-                   NULL);
+    {
+        LPTSTR tstr = WIN_UTF8ToString(filename);
+        h = CreateFile(tstr, (w_right | r_right),
+                       (w_right) ? 0 : FILE_SHARE_READ, NULL,
+                       (must_exist | truncate | a_mode),
+                       FILE_ATTRIBUTE_NORMAL, NULL);
+        SDL_free(tstr);
+    }
 
-    /* restore old behaviour */
+    /* restore old behavior */
     SetErrorMode(old_error_mode);
 #endif /* _WIN32_WCE */
 
@@ -295,7 +288,7 @@
     }
     return (0);
 }
-#endif /* __WINDOWS__ */
+#endif /* __WIN32__ */
 
 #ifdef HAVE_STDIO_H
 
@@ -449,7 +442,7 @@
         SDL_SetError("SDL_RWFromFile(): No file or no mode specified");
         return NULL;
     }
-#if defined(__WINDOWS__)
+#if defined(__WIN32__)
     rwops = SDL_AllocRW();
     if (!rwops)
         return NULL;            /* SDL_SetError already setup by SDL_AllocRW() */
--- a/src/haptic/windows/SDL_syshaptic.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/haptic/windows/SDL_syshaptic.c	Tue Feb 01 00:37:02 2011 -0800
@@ -39,6 +39,7 @@
 static struct
 {
     DIDEVICEINSTANCE instance;
+    char *name;
     SDL_Haptic *haptic;
     DIDEVCAPS capabilities;
 } SDL_hapticlist[MAX_HAPTICS];
@@ -220,6 +221,9 @@
         return DIENUM_CONTINUE;
     }
 
+    /* Copy the name */
+    SDL_hapticlist[SDL_numhaptics].name = WIN_StringToUTF8(SDL_hapticlist[SDL_numhaptics].instance.tszProductName);
+
     /* Close up device and count it. */
     IDirectInputDevice_Release(device);
     SDL_numhaptics++;
@@ -238,7 +242,7 @@
 const char *
 SDL_SYS_HapticName(int index)
 {
-    return SDL_hapticlist[index].instance.tszProductName;
+    return SDL_hapticlist[index].name;
 }
 
 
@@ -630,6 +634,15 @@
 void
 SDL_SYS_HapticQuit(void)
 {
+    int i;
+
+    for (i = 0; i < SDL_arraysize(SDL_hapticlist); ++i) {
+        if (SDL_hapticlist[i].name) {
+            SDL_free(SDL_hapticlist[i].name);
+            SDL_hapticlist[i].name = NULL;
+        }
+    }
+
     IDirectInput_Release(dinput);
     dinput = NULL;
 }
--- a/src/joystick/SDL_joystick.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/joystick/SDL_joystick.c	Tue Feb 01 00:37:02 2011 -0800
@@ -30,12 +30,6 @@
 #include "../events/SDL_events_c.h"
 #endif
 
-/* This is used for Quake III Arena */
-#if SDL_EVENTS_DISABLED
-#define SDL_Lock_EventThread()
-#define SDL_Unlock_EventThread()
-#endif
-
 Uint8 SDL_numjoysticks = 0;
 SDL_Joystick **SDL_joysticks = NULL;
 static SDL_Joystick *default_joystick = NULL;
@@ -165,11 +159,9 @@
 
     /* Add joystick to list */
     ++joystick->ref_count;
-    SDL_Lock_EventThread();
     for (i = 0; SDL_joysticks[i]; ++i)
         /* Skip to next joystick */ ;
     SDL_joysticks[i] = joystick;
-    SDL_Unlock_EventThread();
 
     return (joystick);
 }
@@ -379,9 +371,6 @@
         return;
     }
 
-    /* Lock the event queue - prevent joystick polling */
-    SDL_Lock_EventThread();
-
     if (joystick == default_joystick) {
         default_joystick = NULL;
     }
@@ -396,9 +385,6 @@
         }
     }
 
-    /* Let the event thread keep running */
-    SDL_Unlock_EventThread();
-
     /* Free the data associated with this joystick */
     if (joystick->axes) {
         SDL_free(joystick->axes);
@@ -419,9 +405,7 @@
 SDL_JoystickQuit(void)
 {
     /* Stop the event polling */
-    SDL_Lock_EventThread();
     SDL_numjoysticks = 0;
-    SDL_Unlock_EventThread();
 
     /* Quit the joystick setup */
     SDL_SYS_JoystickQuit();
--- a/src/joystick/android/SDL_sysjoystick.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/joystick/android/SDL_sysjoystick.c	Tue Feb 01 00:37:02 2011 -0800
@@ -32,7 +32,7 @@
 #include "SDL_joystick.h"
 #include "../SDL_sysjoystick.h"
 #include "../SDL_joystick_c.h"
-#include "../../SDL_android.h"
+#include "../../core/android/SDL_android.h"
 
 static const char *accelerometerName = "Android accelerometer";
 
--- a/src/joystick/linux/SDL_sysjoystick.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/joystick/linux/SDL_sysjoystick.c	Tue Feb 01 00:37:02 2011 -0800
@@ -701,25 +701,26 @@
                 continue;
             }
             if (test_bit(i, absbit)) {
-                int values[6];
+                struct input_absinfo absinfo;
 
-                if (ioctl(fd, EVIOCGABS(i), values) < 0)
+                if (ioctl(fd, EVIOCGABS(i), &absinfo) < 0)
                     continue;
 #ifdef DEBUG_INPUT_EVENTS
                 printf("Joystick has absolute axis: %x\n", i);
                 printf("Values = { %d, %d, %d, %d, %d }\n",
-                       values[0], values[1], values[2], values[3], values[4]);
+                       absinfo.value, absinfo.minimum, absinfo.maximum,
+                       absinfo.fuzz, absinfo.flat);
 #endif /* DEBUG_INPUT_EVENTS */
                 joystick->hwdata->abs_map[i] = joystick->naxes;
-                if (values[1] == values[2]) {
+                if (absinfo.minimum == absinfo.maximum) {
                     joystick->hwdata->abs_correct[i].used = 0;
                 } else {
                     joystick->hwdata->abs_correct[i].used = 1;
                     joystick->hwdata->abs_correct[i].coef[0] =
-                        (values[2] + values[1]) / 2 - values[4];
+                        (absinfo.maximum + absinfo.minimum) / 2 - absinfo.flat;
                     joystick->hwdata->abs_correct[i].coef[1] =
-                        (values[2] + values[1]) / 2 + values[4];
-                    t = ((values[2] - values[1]) / 2 - 2 * values[4]);
+                        (absinfo.maximum + absinfo.minimum) / 2 + absinfo.flat;
+                    t = ((absinfo.maximum - absinfo.minimum) / 2 - 2 * absinfo.flat);
                     if (t != 0) {
                         joystick->hwdata->abs_correct[i].coef[2] =
                             (1 << 29) / t;
--- a/src/joystick/riscos/SDL_sysjoystick.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,180 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifdef SDL_JOYSTICK_RISCOS
-
-/*
-   RISC OS - Joystick support by Alan Buckley (alan_baa@hotmail.com) - 10 April 2003
-
-   Note: Currently assumes joystick is present if joystick module is loaded
-   and that there is one joystick with four buttons.
-*/
-
-/* This is the system specific header for the SDL joystick API */
-
-#include "SDL_events.h"
-#include "SDL_joystick.h"
-#include "../SDL_sysjoystick.h"
-#include "../SDL_joystick_c.h"
-
-#include "kernel.h"
-
-#define JOYSTICK_READ 0x43F40
-
-struct joystick_hwdata
-{
-    int joystate;
-};
-
-
-/* Function to scan the system for joysticks.
- * This function should set SDL_numjoysticks to the number of available
- * joysticks.  Joystick 0 should be the system default joystick.
- * It should return number of joysticks, or -1 on an unrecoverable fatal error.
- */
-int
-SDL_SYS_JoystickInit(void)
-{
-    _kernel_swi_regs regs;
-
-    /* Try to read joystick 0 */
-    regs.r[0] = 0;
-    if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) {
-        /* Switch works so assume we've got a joystick */
-        return 1;
-    }
-    /* Switch fails so it looks like there's no joystick here */
-
-    return (0);
-}
-
-/* Function to get the device-dependent name of a joystick */
-const char *
-SDL_SYS_JoystickName(int index)
-{
-    if (index == 0) {
-        return "RISC OS Joystick 0";
-    }
-
-    SDL_SetError("No joystick available with that index");
-    return (NULL);
-}
-
-/* Function to open a joystick for use.
-   The joystick to open is specified by the index field of the joystick.
-   This should fill the nbuttons and naxes fields of the joystick structure.
-   It returns 0, or -1 if there is an error.
- */
-int
-SDL_SYS_JoystickOpen(SDL_Joystick * joystick)
-{
-    _kernel_swi_regs regs;
-
-    if (!(joystick->hwdata = SDL_malloc(sizeof(struct joystick_hwdata))))
-        return -1;
-
-    regs.r[0] = joystick->index;
-
-    /* Don't know how to get exact count of buttons so assume max of 4 for now */
-    joystick->nbuttons = 4;
-
-    joystick->nhats = 0;
-    joystick->nballs = 0;
-    joystick->naxes = 2;
-    joystick->hwdata->joystate = 0;
-
-    return 0;
-
-}
-
-/* Function to update the state of a joystick - called as a device poll.
- * This function shouldn't update the joystick structure directly,
- * but instead should call SDL_PrivateJoystick*() to deliver events
- * and update joystick device state.
- */
-void
-SDL_SYS_JoystickUpdate(SDL_Joystick * joystick)
-{
-    _kernel_swi_regs regs;
-    regs.r[0] = joystick->index;
-
-    if (_kernel_swi(JOYSTICK_READ, &regs, &regs) == NULL) {
-        int newstate = regs.r[0];
-        int oldstate = joystick->hwdata->joystate;
-        if (newstate != oldstate) {
-            if ((newstate & 0xFF) != (oldstate & 0xFF)) {
-                int y = regs.r[0] & 0xFF;
-                /* Convert to signed values */
-                if (y >= 128)
-                    y -= 256;
-                SDL_PrivateJoystickAxis(joystick, 1, -y * 256); /* Up and down opposite to result in SDL */
-            }
-            if ((newstate & 0xFF00) != (oldstate & 0xFF00)) {
-                int x = (regs.r[0] & 0xFF00) >> 8;
-                if (x >= 128)
-                    x -= 256;
-                SDL_PrivateJoystickAxis(joystick, 0, x * 256);
-            }
-
-            if ((newstate & 0xFF0000) != (oldstate & 0xFF0000)) {
-                int buttons = (regs.r[0] & 0xFF0000) >> 16;
-                int oldbuttons = (oldstate & 0xFF0000) >> 16;
-                int i;
-                for (i = 0; i < joystick->nbuttons; i++) {
-                    if ((buttons & (1 << i)) != (oldbuttons & (1 << i))) {
-                        if (buttons & (1 << i))
-                            SDL_PrivateJoystickButton(joystick, i,
-                                                      SDL_PRESSED);
-                        else
-                            SDL_PrivateJoystickButton(joystick, i,
-                                                      SDL_RELEASED);
-                    }
-                }
-            }
-            joystick->hwdata->joystate = newstate;
-        }
-    }
-
-    return;
-}
-
-/* Function to close a joystick after use */
-void
-SDL_SYS_JoystickClose(SDL_Joystick * joystick)
-{
-    if (joystick->hwdata)
-        SDL_free(joystick->hwdata);
-    return;
-}
-
-/* Function to perform any system-specific joystick related cleanup */
-void
-SDL_SYS_JoystickQuit(void)
-{
-    SDL_numjoysticks = 0;
-
-    return;
-}
-
-#endif /* SDL_JOYSTICK_RISCOS */
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/joystick/windows/SDL_dxjoystick.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/joystick/windows/SDL_dxjoystick.c	Tue Feb 01 00:37:02 2011 -0800
@@ -63,6 +63,7 @@
                                        LPDIRECTINPUT * ppDI,
                                        LPUNKNOWN punkOuter);
 static DIDEVICEINSTANCE SYS_Joystick[MAX_JOYSTICKS];    /* array to hold joystick ID values */
+static char *SYS_JoystickNames[MAX_JOYSTICKS];
 static int SYS_NumJoysticks;
 static HINSTANCE DInputDLL = NULL;
 
@@ -326,6 +327,7 @@
 {
     SDL_memcpy(&SYS_Joystick[SYS_NumJoysticks], pdidInstance,
                sizeof(DIDEVICEINSTANCE));
+    SYS_JoystickNames[SYS_NumJoysticks] = WIN_StringToUTF8(pdidInstance->tszProductName);
     SYS_NumJoysticks++;
 
     if (SYS_NumJoysticks >= MAX_JOYSTICKS)
@@ -338,8 +340,7 @@
 const char *
 SDL_SYS_JoystickName(int index)
 {
-        /***-> test for invalid index ? */
-    return (SYS_Joystick[index].tszProductName);
+    return SYS_JoystickNames[index];
 }
 
 /* Function to open a joystick for use.
@@ -793,6 +794,15 @@
 void
 SDL_SYS_JoystickQuit(void)
 {
+    int i;
+
+    for (i = 0; i < SDL_arraysize(SYS_JoystickNames); ++i) {
+        if (SYS_JoystickNames[i]) {
+            SDL_free(SYS_JoystickNames[i]);
+            SYS_JoystickNames[i] = NULL;
+        }
+    }
+
     IDirectInput_Release(dinput);
     dinput = NULL;
 }
--- a/src/joystick/windows/SDL_dxjoystick_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/joystick/windows/SDL_dxjoystick_c.h	Tue Feb 01 00:37:02 2011 -0800
@@ -33,8 +33,7 @@
  * with polled devices, and it's fine to call IDirectInputDevice2_GetDeviceData and
  * let it return 0 events. */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 
 #define DIRECTINPUT_VERSION 0x0700      /* Need version 7 for force feedback. */
 #include <dinput.h>
--- a/src/joystick/windows/SDL_mmjoystick.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/joystick/windows/SDL_mmjoystick.c	Tue Feb 01 00:37:02 2011 -0800
@@ -25,8 +25,7 @@
 
 /* Win32 MultiMedia Joystick driver, contributed by Andrei de A. Formiga */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 #include <mmsystem.h>
 #include <regstr.h>
 
--- a/src/libm/math_private.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/libm/math_private.h	Tue Feb 01 00:37:02 2011 -0800
@@ -19,7 +19,7 @@
 
 /*#include <endian.h>*/
 #include "SDL_endian.h"
-#include <sys/types.h>
+/*#include <sys/types.h>*/
 
 #define attribute_hidden
 #define libm_hidden_proto(x)
--- a/src/loadso/windows/SDL_sysloadso.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/loadso/windows/SDL_sysloadso.c	Tue Feb 01 00:37:02 2011 -0800
@@ -26,110 +26,45 @@
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 /* System dependent library loading routines                           */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 
 #include "SDL_loadso.h"
 
 void *
 SDL_LoadObject(const char *sofile)
 {
-    void *handle = NULL;
-    const char *loaderror = "Unknown error";
-
-#if defined(_WIN32_WCE)
-    char errbuf[512];
-
-    wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
-    wchar_t *sofile_t = SDL_malloc((MAX_PATH + 1) * sizeof(wchar_t));
-
-    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, sofile, -1, sofile_t,
-                        MAX_PATH);
-    handle = (void *) LoadLibrary(sofile_t);
+    LPTSTR tstr = WIN_UTF8ToString(sofile);
+    void *handle = (void *) LoadLibrary(tstr);
+    SDL_free(tstr);
 
     /* Generate an error message if all loads failed */
     if (handle == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf_t, SDL_arraysize(errbuf), NULL);
-        WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
-        loaderror = errbuf;
+        char errbuf[512];
+        SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
+        SDL_strlcat(errbuf, sofile, SDL_arraysize(errbuf));
+        WIN_SetError(errbuf);
     }
-
-    SDL_free(sofile_t);
-    SDL_free(errbuf_t);
-
-#else /*if defined(__WINDOWS__) */
-    char errbuf[512];
-
-    handle = (void *) LoadLibrary(sofile);
-
-    /* Generate an error message if all loads failed */
-    if (handle == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf, SDL_arraysize(errbuf), NULL);
-        loaderror = errbuf;
-    }
-#endif
-
-    if (handle == NULL) {
-        SDL_SetError("Failed loading %s: %s", sofile, loaderror);
-    }
-    return (handle);
+    return handle;
 }
 
 void *
 SDL_LoadFunction(void *handle, const char *name)
 {
-    void *symbol = NULL;
-    const char *loaderror = "Unknown error";
-
-#if defined(_WIN32_WCE)
-    char errbuf[512];
-    int length = SDL_strlen(name);
-
-    wchar_t *name_t = SDL_malloc((length + 1) * sizeof(wchar_t));
-    wchar_t *errbuf_t = SDL_malloc(512 * sizeof(wchar_t));
-
-    MultiByteToWideChar(CP_ACP, MB_PRECOMPOSED, name, -1, name_t, length + 1);
-
-    symbol = (void *) GetProcAddress((HMODULE) handle, name_t);
-    if (symbol == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf_t, SDL_arraysize(errbuf), NULL);
-        WideCharToMultiByte(CP_ACP, 0, errbuf_t, -1, errbuf, 511, NULL, NULL);
-        loaderror = errbuf;
-    }
-
-    SDL_free(name_t);
-    SDL_free(errbuf_t);
-
-#else /*if defined(WIN32) */
-    char errbuf[512];
-
-    symbol = (void *) GetProcAddress((HMODULE) handle, name);
-    if (symbol == NULL) {
-        FormatMessage((FORMAT_MESSAGE_IGNORE_INSERTS |
-                       FORMAT_MESSAGE_FROM_SYSTEM),
-                      NULL, GetLastError(),
-                      MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
-                      errbuf, SDL_arraysize(errbuf), NULL);
-        loaderror = errbuf;
-    }
+#ifdef _WIN32_WCE
+    LPTSTR tstr = WIN_UTF8ToString(name);
+    void *symbol = (void *) GetProcAddress((HMODULE) handle, tstr);
+    SDL_free(tstr);
+#else
+    void *symbol = (void *) GetProcAddress((HMODULE) handle, name);
 #endif
 
     if (symbol == NULL) {
-        SDL_SetError("Failed loading %s: %s", name, loaderror);
+        char errbuf[512];
+        SDL_strlcpy(errbuf, "Failed loading ", SDL_arraysize(errbuf));
+        SDL_strlcat(errbuf, name, SDL_arraysize(errbuf));
+        WIN_SetError(errbuf);
     }
-    return (symbol);
+    return symbol;
 }
 
 void
--- a/src/power/windows/SDL_syspower.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/power/windows/SDL_syspower.c	Tue Feb 01 00:37:02 2011 -0800
@@ -24,19 +24,27 @@
 #ifndef SDL_POWER_DISABLED
 #ifdef SDL_POWER_WINDOWS
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 
 #include "SDL_power.h"
 
 SDL_bool
 SDL_GetPowerInfo_Windows(SDL_PowerState * state, int *seconds, int *percent)
 {
+#ifdef _WIN32_WCE
+    SYSTEM_POWER_STATUS_EX status;
+#else
     SYSTEM_POWER_STATUS status;
+#endif
     SDL_bool need_details = SDL_FALSE;
 
     /* This API should exist back to Win95 and Windows CE. */
-    if (!GetSystemPowerStatus(&status)) {
+#ifdef _WIN32_WCE
+    if (!GetSystemPowerStatusEx(&status, FALSE))
+#else
+    if (!GetSystemPowerStatus(&status))
+#endif
+    {
         /* !!! FIXME: push GetLastError() into SDL_GetError() */
         *state = SDL_POWERSTATE_UNKNOWN;
     } else if (status.BatteryFlag == 0xFF) {    /* unknown state */
--- a/src/stdlib/SDL_getenv.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/stdlib/SDL_getenv.c	Tue Feb 01 00:37:02 2011 -0800
@@ -25,10 +25,9 @@
 
 #ifndef HAVE_GETENV
 
-#if defined(__WINDOWS__) && !defined(_WIN32_WCE)
+#if defined(__WIN32__) && !defined(_WIN32_WCE)
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../core/windows/SDL_windows.h"
 
 /* Note this isn't thread-safe! */
 
@@ -41,12 +40,12 @@
 {
     if (!overwrite) {
         char ch = 0;
-        const size_t len = GetEnvironmentVariable(name, &ch, sizeof (ch));
+        const size_t len = GetEnvironmentVariableA(name, &ch, sizeof (ch));
         if (len > 0) {
             return 0;  /* asked not to overwrite existing value. */
         }
     }
-    if (!SetEnvironmentVariable(name, *value ? value : NULL)) {
+    if (!SetEnvironmentVariableA(name, *value ? value : NULL)) {
         return -1;
     }
     return 0;
@@ -59,7 +58,7 @@
     size_t bufferlen;
 
     bufferlen =
-        GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen);
+        GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
     if (bufferlen == 0) {
         return NULL;
     }
@@ -70,7 +69,7 @@
         }
         SDL_envmem = newmem;
         SDL_envmemlen = bufferlen;
-        GetEnvironmentVariable(name, SDL_envmem, (DWORD) SDL_envmemlen);
+        GetEnvironmentVariableA(name, SDL_envmem, (DWORD) SDL_envmemlen);
     }
     return SDL_envmem;
 }
@@ -163,7 +162,7 @@
     return value;
 }
 
-#endif /* __WINDOWS__ */
+#endif /* __WIN32__ */
 
 #endif /* !HAVE_GETENV */
 
--- a/src/stdlib/SDL_stdlib.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/stdlib/SDL_stdlib.c	Tue Feb 01 00:37:02 2011 -0800
@@ -35,9 +35,7 @@
 __declspec(selectany) int _fltused = 1;
 #endif
 
-#ifdef _WIN64
-
-#else
+#ifdef _M_IX86
 
 void
 __declspec(naked)
--- a/src/thread/generic/SDL_syscond.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/generic/SDL_syscond.c	Tue Feb 01 00:37:02 2011 -0800
@@ -145,18 +145,19 @@
 Typical use:
 
 Thread A:
-	SDL_LockMutex(lock);
-	while ( ! condition ) {
-		SDL_CondWait(cond);
-	}
-	SDL_UnlockMutex(lock);
+    SDL_LockMutex(lock);
+    while ( ! condition ) {
+        SDL_CondWait(cond, lock);
+    }
+    SDL_UnlockMutex(lock);
 
 Thread B:
-	SDL_LockMutex(lock);
-	...
-	condition = true;
-	...
-	SDL_UnlockMutex(lock);
+    SDL_LockMutex(lock);
+    ...
+    condition = true;
+    ...
+    SDL_CondSignal(cond);
+    SDL_UnlockMutex(lock);
  */
 int
 SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
--- a/src/thread/pthread/SDL_syssem.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/pthread/SDL_syssem.c	Tue Feb 01 00:37:02 2011 -0800
@@ -21,6 +21,7 @@
 */
 #include "SDL_config.h"
 
+#include <errno.h>
 #include <pthread.h>
 #include <semaphore.h>
 
@@ -102,6 +103,8 @@
 SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
 {
     int retval;
+    struct timeval now;
+    struct timespec ts_timeout;
 
     if (!sem) {
         SDL_SetError("Passed a NULL semaphore");
@@ -116,16 +119,34 @@
         return SDL_SemWait(sem);
     }
 
-    /* Ack!  We have to busy wait... */
-    /* FIXME: Use sem_timedwait()? */
-    timeout += SDL_GetTicks();
+    /* Setup the timeout. sem_timedwait doesn't wait for
+    * a lapse of time, but until we reach a certain time.
+    * This time is now plus the timeout.
+    */
+    gettimeofday(&now, NULL);
+
+    /* Add our timeout to current time */
+    now.tv_usec += (timeout % 1000) * 1000;
+    now.tv_sec += timeout / 1000;
+
+    /* Wrap the second if needed */
+    if ( now.tv_usec >= 1000000 ) {
+        now.tv_usec -= 1000000;
+        now.tv_sec ++;
+    }
+
+    /* Convert to timespec */
+    ts_timeout.tv_sec = now.tv_sec;
+    ts_timeout.tv_nsec = now.tv_usec * 1000;
+
+    /* Wait. */
     do {
-        retval = SDL_SemTryWait(sem);
-        if (retval == 0) {
-            break;
-        }
-        SDL_Delay(1);
-    } while (SDL_GetTicks() < timeout);
+        retval = sem_timedwait(&sem->sem, &ts_timeout);
+    } while (retval < 0 && errno == EINTR);
+
+    if (retval < 0) {
+        SDL_SetError("sem_timedwait() failed");
+    }
 
     return retval;
 }
--- a/src/thread/pthread/SDL_systhread.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/pthread/SDL_systhread.c	Tue Feb 01 00:37:02 2011 -0800
@@ -34,14 +34,6 @@
     SIGVTALRM, SIGPROF, 0
 };
 
-#ifdef __RISCOS__
-/* RISC OS needs to know the main thread for
- * it's timer and event processing. */
-int riscos_using_threads = 0;
-SDL_threadID riscos_main_thread = 0;  /* Thread running events */
-#endif
-
-
 static void *
 RunThread(void *data)
 {
@@ -67,12 +59,6 @@
         SDL_SetError("Not enough resources to create thread");
         return (-1);
     }
-#ifdef __RISCOS__
-    if (riscos_using_threads == 0) {
-        riscos_using_threads = 1;
-        riscos_main_thread = SDL_ThreadID();
-    }
-#endif
 
     return (0);
 }
--- a/src/thread/riscos/SDL_syscond.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,167 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* RISC OS implementations uses pthreads based on linux code */
-
-#if SDL_THREADS_DISABLED
-#include "../generic/SDL_syscond.c"
-#else
-#include <sys/time.h>
-#include <unistd.h>
-#include <pthread.h>
-
-#include "SDL_thread.h"
-#include "SDL_sysmutex_c.h"
-
-struct SDL_cond
-{
-    pthread_cond_t cond;
-};
-
-/* Create a condition variable */
-SDL_cond *
-SDL_CreateCond(void)
-{
-    SDL_cond *cond;
-
-    cond = (SDL_cond *) SDL_malloc(sizeof(SDL_cond));
-    if (cond) {
-        if (pthread_cond_init(&cond->cond, NULL) < 0) {
-            SDL_SetError("pthread_cond_init() failed");
-            SDL_free(cond);
-            cond = NULL;
-        }
-    }
-    return (cond);
-}
-
-/* Destroy a condition variable */
-void
-SDL_DestroyCond(SDL_cond * cond)
-{
-    if (cond) {
-        pthread_cond_destroy(&cond->cond);
-        SDL_free(cond);
-    }
-}
-
-/* Restart one of the threads that are waiting on the condition variable */
-int
-SDL_CondSignal(SDL_cond * cond)
-{
-    int retval;
-
-    if (!cond) {
-        SDL_SetError("Passed a NULL condition variable");
-        return -1;
-    }
-
-    retval = 0;
-    if (pthread_cond_signal(&cond->cond) != 0) {
-        SDL_SetError("pthread_cond_signal() failed");
-        retval = -1;
-    }
-    return retval;
-}
-
-/* Restart all threads that are waiting on the condition variable */
-int
-SDL_CondBroadcast(SDL_cond * cond)
-{
-    int retval;
-
-    if (!cond) {
-        SDL_SetError("Passed a NULL condition variable");
-        return -1;
-    }
-
-    retval = 0;
-    if (pthread_cond_broadcast(&cond->cond) != 0) {
-        SDL_SetError("pthread_cond_broadcast() failed");
-        retval = -1;
-    }
-    return retval;
-}
-
-int
-SDL_CondWaitTimeout(SDL_cond * cond, SDL_mutex * mutex, Uint32 ms)
-{
-    int retval;
-    struct timeval delta;
-    struct timespec abstime;
-
-    if (!cond) {
-        SDL_SetError("Passed a NULL condition variable");
-        return -1;
-    }
-
-    gettimeofday(&delta, NULL);
-
-    abstime.tv_sec = delta.tv_sec + (ms / 1000);
-    abstime.tv_nsec = (delta.tv_usec + (ms % 1000) * 1000) * 1000;
-    if (abstime.tv_nsec > 1000000000) {
-        abstime.tv_sec += 1;
-        abstime.tv_nsec -= 1000000000;
-    }
-
-  tryagain:
-    retval = pthread_cond_timedwait(&cond->cond, &mutex->id, &abstime);
-    switch (retval) {
-    case EINTR:
-        goto tryagain;
-        break;
-    case ETIMEDOUT:
-        retval = SDL_MUTEX_TIMEDOUT;
-        break;
-    case 0:
-        break;
-    default:
-        SDL_SetError("pthread_cond_timedwait() failed");
-        retval = -1;
-        break;
-    }
-    return retval;
-}
-
-/* Wait on the condition variable, unlocking the provided mutex.
-   The mutex must be locked before entering this function!
- */
-int
-SDL_CondWait(SDL_cond * cond, SDL_mutex * mutex)
-{
-    int retval;
-
-    if (!cond) {
-        SDL_SetError("Passed a NULL condition variable");
-        return -1;
-    }
-
-    retval = 0;
-    if (pthread_cond_wait(&cond->cond, &mutex->id) != 0) {
-        SDL_SetError("pthread_cond_wait() failed");
-        retval = -1;
-    }
-    return retval;
-}
-#endif
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/riscos/SDL_sysmutex.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,159 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* RISC OS implementations uses pthreads based on linux code */
-
-#include "SDL_thread.h"
-
-#if SDL_THREADS_DISABLED
-#include "../generic/SDL_sysmutex.c"
-#else
-
-#include <pthread.h>
-
-struct SDL_mutex
-{
-    pthread_mutex_t id;
-#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
-    int recursive;
-    pthread_t owner;
-#endif
-};
-
-SDL_mutex *
-SDL_CreateMutex(void)
-{
-    SDL_mutex *mutex;
-    pthread_mutexattr_t attr;
-
-    /* Allocate the structure */
-    mutex = (SDL_mutex *) SDL_calloc(1, sizeof(*mutex));
-    if (mutex) {
-        pthread_mutexattr_init(&attr);
-#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
-        /* No extra attributes necessary */
-#else
-        pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */
-        if (pthread_mutex_init(&mutex->id, &attr) != 0) {
-            SDL_SetError("pthread_mutex_init() failed");
-            SDL_free(mutex);
-            mutex = NULL;
-        }
-    } else {
-        SDL_OutOfMemory();
-    }
-    return (mutex);
-}
-
-void
-SDL_DestroyMutex(SDL_mutex * mutex)
-{
-    if (mutex) {
-        pthread_mutex_destroy(&mutex->id);
-        SDL_free(mutex);
-    }
-}
-
-/* Lock the mutex */
-int
-SDL_mutexP(SDL_mutex * mutex)
-{
-    int retval;
-#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
-    pthread_t this_thread;
-#endif
-
-    if (mutex == NULL) {
-        SDL_SetError("Passed a NULL mutex");
-        return -1;
-    }
-
-    retval = 0;
-#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
-    this_thread = pthread_self();
-    if (mutex->owner == this_thread) {
-        ++mutex->recursive;
-    } else {
-        /* The order of operations is important.
-           We set the locking thread id after we obtain the lock
-           so unlocks from other threads will fail.
-         */
-        if (pthread_mutex_lock(&mutex->id) == 0) {
-            mutex->owner = this_thread;
-            mutex->recursive = 0;
-        } else {
-            SDL_SetError("pthread_mutex_lock() failed");
-            retval = -1;
-        }
-    }
-#else
-    if (pthread_mutex_lock(&mutex->id) < 0) {
-        SDL_SetError("pthread_mutex_lock() failed");
-        retval = -1;
-    }
-#endif
-    return retval;
-}
-
-int
-SDL_mutexV(SDL_mutex * mutex)
-{
-    int retval;
-
-    if (mutex == NULL) {
-        SDL_SetError("Passed a NULL mutex");
-        return -1;
-    }
-
-    retval = 0;
-#if SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX
-    /* We can only unlock the mutex if we own it */
-    if (pthread_self() == mutex->owner) {
-        if (mutex->recursive) {
-            --mutex->recursive;
-        } else {
-            /* The order of operations is important.
-               First reset the owner so another thread doesn't lock
-               the mutex and set the ownership before we reset it,
-               then release the lock semaphore.
-             */
-            mutex->owner = 0;
-            pthread_mutex_unlock(&mutex->id);
-        }
-    } else {
-        SDL_SetError("mutex not owned by this thread");
-        retval = -1;
-    }
-
-#else
-    if (pthread_mutex_unlock(&mutex->id) < 0) {
-        SDL_SetError("pthread_mutex_unlock() failed");
-        retval = -1;
-    }
-#endif /* SDL_THREAD_PTHREAD_NO_RECURSIVE_MUTEX */
-
-    return retval;
-}
-#endif
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/riscos/SDL_sysmutex_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifndef _SDL_mutex_c_h
-#define _SDL_mutex_c_h
-
-#if !SDL_THREADS_DISABLED
-struct SDL_mutex
-{
-    pthread_mutex_t id;
-};
-#endif
-
-
-#endif /* _SDL_mutex_c_h */
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/riscos/SDL_syssem.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,216 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* RISC OS semiphores based on linux code */
-
-
-#include "SDL_timer.h"
-#include "SDL_thread.h"
-#include "SDL_systhread_c.h"
-
-#if !SDL_THREADS_DISABLED
-
-SDL_sem *
-SDL_CreateSemaphore(Uint32 initial_value)
-{
-    SDL_SetError("SDL not configured with thread support");
-    return (SDL_sem *) 0;
-}
-
-void
-SDL_DestroySemaphore(SDL_sem * sem)
-{
-    return;
-}
-
-int
-SDL_SemTryWait(SDL_sem * sem)
-{
-    SDL_SetError("SDL not configured with thread support");
-    return -1;
-}
-
-int
-SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
-{
-    SDL_SetError("SDL not configured with thread support");
-    return -1;
-}
-
-int
-SDL_SemWait(SDL_sem * sem)
-{
-    SDL_SetError("SDL not configured with thread support");
-    return -1;
-}
-
-Uint32
-SDL_SemValue(SDL_sem * sem)
-{
-    return 0;
-}
-
-int
-SDL_SemPost(SDL_sem * sem)
-{
-    SDL_SetError("SDL not configured with thread support");
-    return -1;
-}
-
-#else
-
-
-#include <unistd.h>             /* For getpid() */
-#include <pthread.h>
-#include <semaphore.h>
-
-struct SDL_semaphore
-{
-    sem_t *sem;
-    sem_t sem_data;
-};
-
-/* Create a semaphore, initialized with value */
-SDL_sem *
-SDL_CreateSemaphore(Uint32 initial_value)
-{
-    SDL_sem *sem = (SDL_sem *) SDL_malloc(sizeof(SDL_sem));
-    if (sem) {
-        if (sem_init(&sem->sem_data, 0, initial_value) < 0) {
-            SDL_SetError("sem_init() failed");
-            SDL_free(sem);
-            sem = NULL;
-        } else {
-            sem->sem = &sem->sem_data;
-        }
-    } else {
-        SDL_OutOfMemory();
-    }
-    return sem;
-}
-
-void
-SDL_DestroySemaphore(SDL_sem * sem)
-{
-    if (sem) {
-        sem_destroy(sem->sem);
-        SDL_free(sem);
-    }
-}
-
-int
-SDL_SemTryWait(SDL_sem * sem)
-{
-    int retval;
-
-    if (!sem) {
-        SDL_SetError("Passed a NULL semaphore");
-        return -1;
-    }
-    retval = SDL_MUTEX_TIMEDOUT;
-    if (sem_trywait(sem->sem) == 0) {
-        retval = 0;
-    }
-    return retval;
-}
-
-int
-SDL_SemWait(SDL_sem * sem)
-{
-    int retval;
-
-    if (!sem) {
-        SDL_SetError("Passed a NULL semaphore");
-        return -1;
-    }
-
-    retval = sem_wait(sem->sem);
-    if (retval < 0) {
-        SDL_SetError("sem_wait() failed");
-    }
-    return retval;
-}
-
-int
-SDL_SemWaitTimeout(SDL_sem * sem, Uint32 timeout)
-{
-    int retval;
-
-    if (!sem) {
-        SDL_SetError("Passed a NULL semaphore");
-        return -1;
-    }
-
-    /* Try the easy cases first */
-    if (timeout == 0) {
-        return SDL_SemTryWait(sem);
-    }
-    if (timeout == SDL_MUTEX_MAXWAIT) {
-        return SDL_SemWait(sem);
-    }
-
-    /* Ack!  We have to busy wait... */
-    timeout += SDL_GetTicks();
-    do {
-        retval = SDL_SemTryWait(sem);
-        if (retval == 0) {
-            break;
-        }
-        SDL_Delay(1);
-    } while (SDL_GetTicks() < timeout);
-
-    return retval;
-}
-
-Uint32
-SDL_SemValue(SDL_sem * sem)
-{
-    int ret = 0;
-    if (sem) {
-        sem_getvalue(sem->sem, &ret);
-        if (ret < 0) {
-            ret = 0;
-        }
-    }
-    return (Uint32) ret;
-}
-
-int
-SDL_SemPost(SDL_sem * sem)
-{
-    int retval;
-
-    if (!sem) {
-        SDL_SetError("Passed a NULL semaphore");
-        return -1;
-    }
-
-    retval = sem_post(sem->sem);
-    if (retval < 0) {
-        SDL_SetError("sem_post() failed");
-    }
-    return retval;
-}
-
-#endif /* !SDL_THREADS_DISABLED */
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/riscos/SDL_systhread.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,141 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* RISC OS version based on pthreads linux source */
-
-#include "SDL_thread.h"
-#include "../SDL_systhread.h"
-
-#if SDL_THREADS_DISABLED
-
-int
-SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
-{
-    SDL_SetError
-        ("Threads have not been compiled into this version of the library");
-    return (-1);
-}
-
-void
-SDL_SYS_SetupThread(void)
-{
-    return;
-}
-
-SDL_threadID
-SDL_ThreadID(void)
-{
-    return (0);
-}
-
-void
-SDL_SYS_WaitThread(SDL_Thread * thread)
-{
-    return;
-}
-
-#else
-
-#include <signal.h>
-
-/* List of signals to mask in the subthreads */
-static int sig_list[] = {
-    SIGHUP, SIGINT, SIGQUIT, SIGPIPE, SIGALRM, SIGTERM, SIGCHLD, SIGWINCH,
-    SIGVTALRM, SIGPROF, 0
-};
-
-#include <pthread.h>
-
-int riscos_using_threads = 0;
-Uint32 riscos_main_thread = 0;  /* Thread running events */
-
-static void *
-RunThread(void *data)
-{
-    SDL_RunThread(data);
-    pthread_exit((void *) 0);
-    return ((void *) 0);        /* Prevent compiler warning */
-}
-
-int
-SDL_SYS_CreateThread(SDL_Thread * thread, void *args)
-{
-    pthread_attr_t type;
-
-    /* Set the thread attributes */
-    if (pthread_attr_init(&type) != 0) {
-        SDL_SetError("Couldn't initialize pthread attributes");
-        return (-1);
-    }
-    pthread_attr_setdetachstate(&type, PTHREAD_CREATE_JOINABLE);
-
-    /* Create the thread and go! */
-    if (pthread_create(&thread->handle, &type, RunThread, args) != 0) {
-        SDL_SetError("Not enough resources to create thread");
-        return (-1);
-    }
-
-    if (riscos_using_threads == 0) {
-        riscos_using_threads = 1;
-        riscos_main_thread = SDL_ThreadID();
-    }
-
-    return (0);
-}
-
-void
-SDL_SYS_SetupThread(void)
-{
-    int i;
-    sigset_t mask;
-
-    /* Mask asynchronous signals for this thread */
-    sigemptyset(&mask);
-    for (i = 0; sig_list[i]; ++i) {
-        sigaddset(&mask, sig_list[i]);
-    }
-    pthread_sigmask(SIG_BLOCK, &mask, 0);
-
-#ifdef PTHREAD_CANCEL_ASYNCHRONOUS
-    /* Allow ourselves to be asynchronously cancelled */
-    {
-        int oldstate;
-        pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
-    }
-#endif
-}
-
-Uint32
-SDL_ThreadID(void)
-{
-    return ((Uint32) pthread_self());
-}
-
-void
-SDL_SYS_WaitThread(SDL_Thread * thread)
-{
-    pthread_join(thread->handle, 0);
-}
-
-#endif
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/riscos/SDL_systhread_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#if SDL_THREADS_DISABLED
-
-typedef int SYS_ThreadHandle;
-
-#else
-
-#include <pthread.h>
-
-typedef pthread_t SYS_ThreadHandle;
-
-#endif
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/windows/SDL_sysmutex.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/windows/SDL_sysmutex.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,8 +23,7 @@
 
 /* Mutex functions using the Win32 API */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 
 #include "SDL_mutex.h"
 
--- a/src/thread/windows/SDL_syssem.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/windows/SDL_syssem.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,8 +23,7 @@
 
 /* Semaphore functions using the Win32 API */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 
 #include "SDL_thread.h"
 #if defined(_WIN32_WCE) && (_WIN32_WCE < 300)
@@ -39,7 +38,7 @@
 #else
     HANDLE id;
 #endif
-    LONG volatile count;
+    LONG count;
 };
 
 
--- a/src/thread/windows/SDL_systhread.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/windows/SDL_systhread.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,12 +23,10 @@
 
 /* Win32 thread management routines for SDL */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-
 #include "SDL_thread.h"
 #include "../SDL_thread_c.h"
 #include "../SDL_systhread.h"
+#include "SDL_systhread_c.h"
 
 #ifndef SDL_PASSED_BEGINTHREAD_ENDTHREAD
 #ifndef _WIN32_WCE
--- a/src/thread/windows/SDL_systhread_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/windows/SDL_systhread_c.h	Tue Feb 01 00:37:02 2011 -0800
@@ -21,9 +21,13 @@
 */
 #include "SDL_config.h"
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#ifndef _SDL_systhread_c_h
+#define _SDL_systhread_c_h
+
+#include "../../core/windows/SDL_windows.h"
 
 typedef HANDLE SYS_ThreadHandle;
 
+#endif /* _SDL_systhread_c_h */
+
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/thread/windows/win_ce_semaphore.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/thread/windows/win_ce_semaphore.c	Tue Feb 01 00:37:02 2011 -0800
@@ -28,8 +28,7 @@
       and it is not clear how to handle a mixture of WCE semaphores and normal
       events and mutexes. */
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 
 #include "win_ce_semaphore.h"
 
--- a/src/timer/SDL_systimer.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,42 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/* The system dependent timer handling functions */
-
-#include "SDL_timer.h"
-#include "SDL_timer_c.h"
-
-
-/* Initialize the system dependent timer subsystem */
-extern int SDL_SYS_TimerInit(void);
-
-/* Quit the system dependent timer subsystem */
-extern void SDL_SYS_TimerQuit(void);
-
-/* Start a timer set up by SDL_SetTimer() */
-extern int SDL_SYS_StartTimer(void);
-
-/* Stop a previously started timer */
-extern void SDL_SYS_StopTimer(void);
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/SDL_timer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/SDL_timer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,289 +23,364 @@
 
 #include "SDL_timer.h"
 #include "SDL_timer_c.h"
-#include "SDL_mutex.h"
-#include "SDL_systimer.h"
+#include "SDL_atomic.h"
+#include "SDL_cpuinfo.h"
+#include "SDL_thread.h"
 
 /* #define DEBUG_TIMERS */
 
-int SDL_timer_started = 0;
-int SDL_timer_running = 0;
+typedef struct _SDL_Timer
+{
+    int timerID;
+    SDL_TimerCallback callback;
+    void *param;
+    Uint32 interval;
+    Uint32 scheduled;
+    volatile SDL_bool canceled;
+    struct _SDL_Timer *next;
+} SDL_Timer;
+
+typedef struct _SDL_TimerMap
+{
+    int timerID;
+    SDL_Timer *timer;
+    struct _SDL_TimerMap *next;
+} SDL_TimerMap;
 
-/* Data to handle a single periodic alarm */
-Uint32 SDL_alarm_interval = 0;
-SDL_TimerCallback SDL_alarm_callback;
+/* The timers are kept in a sorted list */
+typedef struct {
+    /* Data used by the main thread */
+    SDL_Thread *thread;
+    SDL_atomic_t nextID;
+    SDL_TimerMap *timermap;
+    SDL_mutex *timermap_lock;
+
+    /* Padding to separate cache lines between threads */
+    char cache_pad[SDL_CACHELINE_SIZE];
+
+    /* Data used to communicate with the timer thread */
+    SDL_SpinLock lock;
+    SDL_sem *sem;
+    SDL_Timer * volatile pending;
+    SDL_Timer * volatile freelist;
+    volatile SDL_bool active;
+
+    /* List of timers - this is only touched by the timer thread */
+    SDL_Timer *timers;
+} SDL_TimerData;
 
-/* Data used for a thread-based timer */
-static int SDL_timer_threaded = 0;
+static SDL_TimerData SDL_timer_data;
+
 
-struct _SDL_TimerID
+/* The idea here is that any thread might add a timer, but a single
+ * thread manages the active timer queue, sorted by scheduling time.
+ *
+ * Timers are removed by simply setting a canceled flag
+ */
+
+static void
+SDL_AddTimerInternal(SDL_TimerData *data, SDL_Timer *timer)
 {
-    Uint32 interval;
-    SDL_NewTimerCallback cb;
-    void *param;
-    Uint32 last_alarm;
-    struct _SDL_TimerID *next;
-};
+    SDL_Timer *prev, *curr;
+
+    prev = NULL;
+    for (curr = data->timers; curr; prev = curr, curr = curr->next) {
+        if ((Sint32)(timer->scheduled-curr->scheduled) < 0) {
+            break;
+        }
+    }
+
+    /* Insert the timer here! */
+    if (prev) {
+        prev->next = timer;
+    } else {
+        data->timers = timer;
+    }
+    timer->next = curr;
+}
+
+static int
+SDL_TimerThread(void *_data)
+{
+    SDL_TimerData *data = (SDL_TimerData *)_data;
+    SDL_Timer *pending;
+    SDL_Timer *current;
+    SDL_Timer *freelist_head = NULL;
+    SDL_Timer *freelist_tail = NULL;
+    Uint32 tick, now, interval, delay;
 
-static SDL_TimerID SDL_timers = NULL;
-static SDL_mutex *SDL_timer_mutex;
-static volatile SDL_bool list_changed = SDL_FALSE;
+    /* Threaded timer loop:
+     *  1. Queue timers added by other threads
+     *  2. Handle any timers that should dispatch this cycle
+     *  3. Wait until next dispatch time or new timer arrives
+     */
+    for ( ; ; ) {
+        /* Pending and freelist maintenance */
+        SDL_AtomicLock(&data->lock);
+        {
+            /* Get any timers ready to be queued */
+            pending = data->pending;
+            data->pending = NULL;
+
+            /* Make any unused timer structures available */
+            if (freelist_head) {
+                freelist_tail->next = data->freelist;
+                data->freelist = freelist_head;
+            }
+        }
+        SDL_AtomicUnlock(&data->lock);
+
+        /* Sort the pending timers into our list */
+        while (pending) {
+            current = pending;
+            pending = pending->next;
+            SDL_AddTimerInternal(data, current);
+        }
+        freelist_head = NULL;
+        freelist_tail = NULL;
+
+        /* Check to see if we're still running, after maintenance */
+        if (!data->active) {
+            break;
+        }
+
+        /* Initial delay if there are no timers */
+        delay = SDL_MUTEX_MAXWAIT;
+
+        tick = SDL_GetTicks();
+
+        /* Process all the pending timers for this tick */
+        while (data->timers) {
+            current = data->timers;
 
-/* Set whether or not the timer should use a thread.
-   This should not be called while the timer subsystem is running.
-*/
-int
-SDL_SetTimerThreaded(int value)
-{
-    int retval;
+            if ((Sint32)(tick-current->scheduled) < 0) {
+                /* Scheduled for the future, wait a bit */
+                delay = (current->scheduled - tick);
+                break;
+            }
+
+            /* We're going to do something with this timer */
+            data->timers = current->next;
+
+            if (current->canceled) {
+                interval = 0;
+            } else {
+                interval = current->callback(current->interval, current->param);
+            }
 
-    if (SDL_timer_started) {
-        SDL_SetError("Timer already initialized");
-        retval = -1;
-    } else {
-        retval = 0;
-        SDL_timer_threaded = value;
+            if (interval > 0) {
+                /* Reschedule this timer */
+                current->scheduled = tick + interval;
+                SDL_AddTimerInternal(data, current);
+            } else {
+                if (!freelist_head) {
+                    freelist_head = current;
+                }
+                if (freelist_tail) {
+                    freelist_tail->next = current;
+                }
+                freelist_tail = current;
+
+                current->canceled = SDL_TRUE;
+            }
+        }
+
+        /* Adjust the delay based on processing time */
+        now = SDL_GetTicks();
+        interval = (now - tick);
+        if (interval > delay) {
+            delay = 0;
+        } else {
+            delay -= interval;
+        }
+
+        /* Note that each time a timer is added, this will return
+           immediately, but we process the timers added all at once.
+           That's okay, it just means we run through the loop a few
+           extra times.
+         */
+        SDL_SemWaitTimeout(data->sem, delay);
     }
-    return retval;
+    return 0;
 }
 
 int
 SDL_TimerInit(void)
 {
-    int retval;
+    SDL_TimerData *data = &SDL_timer_data;
+
+    if (!data->active) {
+        data->timermap_lock = SDL_CreateMutex();
+        if (!data->timermap_lock) {
+            return -1;
+        }
+
+        data->sem = SDL_CreateSemaphore(0);
+        if (!data->sem) {
+            SDL_DestroyMutex(data->timermap_lock);
+            return -1;
+        }
 
-    retval = 0;
-    if (SDL_timer_started) {
-        SDL_TimerQuit();
+        data->active = SDL_TRUE;
+        /* !!! FIXME: this is nasty. */
+#if (defined(__WIN32__) && !defined(_WIN32_WCE)) && !defined(HAVE_LIBC)
+#undef SDL_CreateThread
+        data->thread = SDL_CreateThread(SDL_TimerThread, data, NULL, NULL);
+#else
+        data->thread = SDL_CreateThread(SDL_TimerThread, data);
+#endif
+        if (!data->thread) {
+            SDL_TimerQuit();
+            return -1;
+        }
+
+        SDL_AtomicSet(&data->nextID, 1);
     }
-    if (!SDL_timer_threaded) {
-        retval = SDL_SYS_TimerInit();
-    }
-    if (SDL_timer_threaded) {
-        SDL_timer_mutex = SDL_CreateMutex();
-    }
-    if (retval == 0) {
-        SDL_timer_started = 1;
-    }
-    return (retval);
+    return 0;
 }
 
 void
 SDL_TimerQuit(void)
 {
-    SDL_SetTimer(0, NULL);
-    if (SDL_timer_threaded < 2) {
-        SDL_SYS_TimerQuit();
-    }
-    if (SDL_timer_threaded) {
-        SDL_DestroyMutex(SDL_timer_mutex);
-        SDL_timer_mutex = NULL;
-    }
-    SDL_timer_started = 0;
-    SDL_timer_threaded = 0;
-}
+    SDL_TimerData *data = &SDL_timer_data;
+    SDL_Timer *timer;
+    SDL_TimerMap *entry;
+
+    if (data->active) {
+        data->active = SDL_FALSE;
 
-void
-SDL_ThreadedTimerCheck(void)
-{
-    Uint32 now, ms;
-    SDL_TimerID t, prev, next;
-    SDL_bool removed;
-
-    SDL_mutexP(SDL_timer_mutex);
+        /* Shutdown the timer thread */
+        if (data->thread) {
+            SDL_SemPost(data->sem);
+            SDL_WaitThread(data->thread, NULL);
+            data->thread = NULL;
+        }
 
-    now = SDL_GetTicks();
-    do {
-        list_changed = SDL_FALSE;
-        for (prev = NULL, t = SDL_timers; t; t = next) {
-            removed = SDL_FALSE;
-            ms = t->interval - SDL_TIMESLICE;
-            next = t->next;
-            if ((int) (now - t->last_alarm) > (int) ms) {
-                struct _SDL_TimerID timer;
+        SDL_DestroySemaphore(data->sem);
+        data->sem = NULL;
 
-                if ((now - t->last_alarm) < t->interval) {
-                    t->last_alarm += t->interval;
-                } else {
-                    t->last_alarm = now;
-                }
-#ifdef DEBUG_TIMERS
-                printf("Executing timer %p (thread = %lu)\n",
-                       t, SDL_ThreadID());
-#endif
-                timer = *t;
-                SDL_mutexV(SDL_timer_mutex);
-                ms = timer.cb(timer.interval, timer.param);
-                SDL_mutexP(SDL_timer_mutex);
-                if (list_changed) {
-                    next = t->next;
-                    for (prev = SDL_timers; prev; prev = prev->next) {
-                        if (prev->next == t)
-                            break;
-                    }
-                }
-                if (ms != t->interval) {
-                    if (ms) {
-                        t->interval = ROUND_RESOLUTION(ms);
-                    } else {
-                        /* Remove timer from the list */
-#ifdef DEBUG_TIMERS
-                        printf("SDL: Removing timer %p\n", t);
-#endif
-                        if (prev) {
-                            prev->next = next;
-                        } else {
-                            SDL_timers = next;
-                        }
-                        SDL_free(t);
-                        --SDL_timer_running;
-                        removed = SDL_TRUE;
-                    }
-                }
-                if (list_changed) {
-                    /* Abort, list of timers modified */
-                    break;
-                }
-            }
-            /* Don't update prev if the timer has disappeared */
-            if (!removed) {
-                prev = t;
-            }
+        /* Clean up the timer entries */
+        while (data->timers) {
+            timer = data->timers;
+            data->timers = timer->next;
+            SDL_free(timer);
         }
-    } while (list_changed);
-
-    SDL_mutexV(SDL_timer_mutex);
-}
+        while (data->freelist) {
+            timer = data->freelist;
+            data->freelist = timer->next;
+            SDL_free(timer);
+        }
+        while (data->timermap) {
+            entry = data->timermap;
+            data->timermap = entry->next;
+            SDL_free(entry);
+        }
 
-static SDL_TimerID
-SDL_AddTimerInternal(Uint32 interval, SDL_NewTimerCallback callback,
-                     void *param)
-{
-    SDL_TimerID t;
-    t = (SDL_TimerID) SDL_malloc(sizeof(struct _SDL_TimerID));
-    if (t) {
-        t->interval = ROUND_RESOLUTION(interval);
-        t->cb = callback;
-        t->param = param;
-        t->last_alarm = SDL_GetTicks();
-        t->next = SDL_timers;
-        SDL_timers = t;
-        ++SDL_timer_running;
-        list_changed = SDL_TRUE;
+        SDL_DestroyMutex(data->timermap_lock);
+        data->timermap_lock = NULL;
     }
-#ifdef DEBUG_TIMERS
-    printf("SDL_AddTimer(%d) = %08x num_timers = %d\n", interval, (Uint32) t,
-           SDL_timer_running);
-#endif
-    return t;
 }
 
 SDL_TimerID
-SDL_AddTimer(Uint32 interval, SDL_NewTimerCallback callback, void *param)
+SDL_AddTimer(Uint32 interval, SDL_TimerCallback callback, void *param)
 {
-    SDL_TimerID t;
-    if (!SDL_timer_mutex) {
-        if (SDL_timer_started) {
-            SDL_SetError("This platform doesn't support multiple timers");
-        } else {
-            SDL_SetError("You must call SDL_Init(SDL_INIT_TIMER) first");
+    SDL_TimerData *data = &SDL_timer_data;
+    SDL_Timer *timer;
+    SDL_TimerMap *entry;
+
+    if (!data->active) {
+        int status = 0;
+
+        SDL_AtomicLock(&data->lock);
+        if (!data->active) {
+            status = SDL_TimerInit();
+        }
+        SDL_AtomicUnlock(&data->lock);
+
+        if (status < 0) {
+            return 0;
         }
-        return NULL;
+    }
+
+    SDL_AtomicLock(&data->lock);
+    timer = data->freelist;
+    if (timer) {
+        data->freelist = timer->next;
+    }
+    SDL_AtomicUnlock(&data->lock);
+
+    if (timer) {
+        SDL_RemoveTimer(timer->timerID);
+    } else {
+        timer = (SDL_Timer *)SDL_malloc(sizeof(*timer));
+        if (!timer) {
+            SDL_OutOfMemory();
+            return 0;
+        }
     }
-    if (!SDL_timer_threaded) {
-        SDL_SetError("Multiple timers require threaded events!");
-        return NULL;
+    timer->timerID = SDL_AtomicIncRef(&data->nextID);
+    timer->callback = callback;
+    timer->param = param;
+    timer->interval = interval;
+    timer->scheduled = SDL_GetTicks() + interval;
+    timer->canceled = SDL_FALSE;
+ 
+    entry = (SDL_TimerMap *)SDL_malloc(sizeof(*entry));
+    if (!entry) {
+        SDL_free(timer);
+        SDL_OutOfMemory();
+        return 0;
     }
-    SDL_mutexP(SDL_timer_mutex);
-    t = SDL_AddTimerInternal(interval, callback, param);
-    SDL_mutexV(SDL_timer_mutex);
-    return t;
+    entry->timer = timer;
+    entry->timerID = timer->timerID;
+
+    SDL_mutexP(data->timermap_lock);
+    entry->next = data->timermap;
+    data->timermap = entry;
+    SDL_mutexV(data->timermap_lock);
+
+    /* Add the timer to the pending list for the timer thread */
+    SDL_AtomicLock(&data->lock);
+    timer->next = data->pending;
+    data->pending = timer;
+    SDL_AtomicUnlock(&data->lock);
+
+    /* Wake up the timer thread if necessary */
+    SDL_SemPost(data->sem);
+
+    return entry->timerID;
 }
 
 SDL_bool
 SDL_RemoveTimer(SDL_TimerID id)
 {
-    SDL_TimerID t, prev = NULL;
-    SDL_bool removed;
+    SDL_TimerData *data = &SDL_timer_data;
+    SDL_TimerMap *prev, *entry;
+    SDL_bool canceled = SDL_FALSE;
 
-    removed = SDL_FALSE;
-    SDL_mutexP(SDL_timer_mutex);
-    /* Look for id in the linked list of timers */
-    for (t = SDL_timers; t; prev = t, t = t->next) {
-        if (t == id) {
+    /* Find the timer */
+    SDL_mutexP(data->timermap_lock);
+    prev = NULL;
+    for (entry = data->timermap; entry; prev = entry, entry = entry->next) {
+        if (entry->timerID == id) {
             if (prev) {
-                prev->next = t->next;
+                prev->next = entry->next;
             } else {
-                SDL_timers = t->next;
+                data->timermap = entry->next;
             }
-            SDL_free(t);
-            --SDL_timer_running;
-            removed = SDL_TRUE;
-            list_changed = SDL_TRUE;
             break;
         }
     }
-#ifdef DEBUG_TIMERS
-    printf("SDL_RemoveTimer(%08x) = %d num_timers = %d thread = %lu\n",
-           (Uint32) id, removed, SDL_timer_running, SDL_ThreadID());
-#endif
-    SDL_mutexV(SDL_timer_mutex);
-    return removed;
-}
+    SDL_mutexV(data->timermap_lock);
 
-/* Old style callback functions are wrapped through this */
-static Uint32 SDLCALL
-callback_wrapper(Uint32 ms, void *param)
-{
-    SDL_TimerCallback func = (SDL_TimerCallback) param;
-    return (*func) (ms);
-}
-
-int
-SDL_SetTimer(Uint32 ms, SDL_TimerCallback callback)
-{
-    int retval;
-
-#ifdef DEBUG_TIMERS
-    printf("SDL_SetTimer(%d)\n", ms);
-#endif
-    retval = 0;
-
-    if (SDL_timer_threaded) {
-        SDL_mutexP(SDL_timer_mutex);
+    if (entry) {
+        if (!entry->timer->canceled) {
+            entry->timer->canceled = SDL_TRUE;
+            canceled = SDL_TRUE;
+        }
+        SDL_free(entry);
     }
-    if (SDL_timer_running) {    /* Stop any currently running timer */
-        if (SDL_timer_threaded) {
-            while (SDL_timers) {
-                SDL_TimerID freeme = SDL_timers;
-                SDL_timers = SDL_timers->next;
-                SDL_free(freeme);
-            }
-            SDL_timer_running = 0;
-            list_changed = SDL_TRUE;
-        } else {
-            SDL_SYS_StopTimer();
-            SDL_timer_running = 0;
-        }
-    }
-    if (ms) {
-        if (SDL_timer_threaded) {
-            if (SDL_AddTimerInternal
-                (ms, callback_wrapper, (void *) callback) == NULL) {
-                retval = -1;
-            }
-        } else {
-            SDL_timer_running = 1;
-            SDL_alarm_interval = ms;
-            SDL_alarm_callback = callback;
-            retval = SDL_SYS_StartTimer();
-        }
-    }
-    if (SDL_timer_threaded) {
-        SDL_mutexV(SDL_timer_mutex);
-    }
-
-    return retval;
+    return canceled;
 }
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/SDL_timer_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/SDL_timer_c.h	Tue Feb 01 00:37:02 2011 -0800
@@ -27,21 +27,7 @@
 #define ROUND_RESOLUTION(X)	\
 	(((X+TIMER_RESOLUTION-1)/TIMER_RESOLUTION)*TIMER_RESOLUTION)
 
-extern int SDL_timer_started;
-extern int SDL_timer_running;
-
-/* Data to handle a single periodic alarm */
-extern Uint32 SDL_alarm_interval;
-extern SDL_TimerCallback SDL_alarm_callback;
-
-/* Set whether or not the timer should use a thread.
-   This should be called while the timer subsystem is running.
-*/
-extern int SDL_SetTimerThreaded(int value);
-
 extern int SDL_TimerInit(void);
 extern void SDL_TimerQuit(void);
 
-/* This function is called from the SDL event thread if it is available */
-extern void SDL_ThreadedTimerCheck(void);
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/beos/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/beos/SDL_systimer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -25,9 +25,7 @@
 
 #include <be/kernel/OS.h>
 
-#include "SDL_thread.h"
 #include "SDL_timer.h"
-#include "../SDL_timer_c.h"
 
 static bigtime_t start;
 
@@ -50,55 +48,6 @@
     snooze(ms * 1000);
 }
 
-/* Data to handle a single periodic alarm */
-static int timer_alive = 0;
-static SDL_Thread *timer = NULL;
-
-static int
-RunTimer(void *unused)
-{
-    while (timer_alive) {
-        if (SDL_timer_running) {
-            SDL_ThreadedTimerCheck();
-        }
-        SDL_Delay(10);
-    }
-    return (0);
-}
+#endif /* SDL_TIMER_BEOS */
 
-/* This is only called if the event thread is not running */
-int
-SDL_SYS_TimerInit(void)
-{
-    timer_alive = 1;
-    timer = SDL_CreateThread(RunTimer, NULL);
-    if (timer == NULL)
-        return (-1);
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    timer_alive = 0;
-    if (timer) {
-        SDL_WaitThread(timer, NULL);
-        timer = NULL;
-    }
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: BeOS uses threaded timer");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
-#endif /* SDL_TIMER_BEOS */
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/dummy/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/dummy/SDL_systimer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -24,7 +24,6 @@
 #if defined(SDL_TIMER_DUMMY) || defined(SDL_TIMERS_DISABLED)
 
 #include "SDL_timer.h"
-#include "../SDL_timer_c.h"
 
 void
 SDL_StartTicks(void)
@@ -44,57 +43,6 @@
     SDL_Unsupported();
 }
 
-#include "SDL_thread.h"
-
-/* Data to handle a single periodic alarm */
-static int timer_alive = 0;
-static SDL_Thread *timer = NULL;
-
-static int
-RunTimer(void *unused)
-{
-    while (timer_alive) {
-        if (SDL_timer_running) {
-            SDL_ThreadedTimerCheck();
-        }
-        SDL_Delay(1);
-    }
-    return (0);
-}
+#endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */
 
-/* This is only called if the event thread is not running */
-int
-SDL_SYS_TimerInit(void)
-{
-    timer_alive = 1;
-    timer = SDL_CreateThread(RunTimer, NULL);
-    if (timer == NULL)
-        return (-1);
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    timer_alive = 0;
-    if (timer) {
-        SDL_WaitThread(timer, NULL);
-        timer = NULL;
-    }
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: threaded timer in use");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
-#endif /* SDL_TIMER_DUMMY || SDL_TIMERS_DISABLED */
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/nds/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/nds/SDL_systimer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -27,22 +27,25 @@
 #include <nds/timers.h>
 
 #include "SDL_timer.h"
-#include "../SDL_timer_c.h"
-#include "../SDL_systimer.h"
+
+
+static volatile Uint32 timer_ticks;
 
-/* Data to handle a single periodic alarm */
-static int timer_alive = 0;
-static Uint32 timer_ticks;
+static void
+NDS_TimerInterrupt(void)
+{
+    timer_ticks++;
+}
 
 void
 SDL_StartTicks(void)
 {
-    if (!timer_alive) {
-        SDL_SYS_TimerInit();
-        SDL_SYS_StartTimer();
-    }
+    timer_ticks = 0;
 
-    timer_ticks = 0;
+    TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
+    TIMER_DATA(3) = TIMER_FREQ_1024(1000);
+    irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
+    irqEnable(IRQ_TIMER3);
 }
 
 Uint32
@@ -61,60 +64,6 @@
     }
 }
 
-static int
-RunTimer(void *unused)
-{
-    while (timer_alive) {
-        if (SDL_timer_running) {
-        }
-        SDL_Delay(1);
-    }
-    return (0);
-}
-
-void
-NDS_TimerInterrupt(void)
-{
-    timer_ticks++;
-}
+#endif /* SDL_TIMER_NDS */
 
-/* This is only called if the event thread is not running */
-int
-SDL_SYS_TimerInit(void)
-{
-    timer_alive = 1;
-    timer_ticks = 0;
-    TIMER_CR(3) = TIMER_DIV_1024 | TIMER_IRQ_REQ;
-    TIMER_DATA(3) = TIMER_FREQ_1024(1000);
-    irqSet(IRQ_TIMER3, NDS_TimerInterrupt);
-    irqEnable(IRQ_TIMER3);
-    return 0;
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    if (timer_alive) {
-        TIMER_CR(3) = 0;
-    }
-    timer_alive = 0;
-    irqDisable(IRQ_TIMER3);
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    TIMER_CR(3) |= TIMER_ENABLE;
-    return 0;
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    TIMER_CR(3) &= ~TIMER_ENABLE;
-    return;
-}
-
-
-#endif /* SDL_TIMER_NDS */
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/riscos/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,248 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifdef SDL_TIMER_RISCOS
-
-#include <stdio.h>
-#include <time.h>
-#include <sys/time.h>
-#include <unistd.h>
-#include <string.h>
-#include <errno.h>
-
-#include "SDL_timer.h"
-#include "../SDL_timer_c.h"
-
-#if SDL_THREADS_DISABLED
-/* Timer  SDL_arraysize(Timer ),start/reset time */
-static Uint32 timerStart;
-/* Timer running function */
-void RISCOS_CheckTimer();
-#else
-#include <pthread.h>
-extern SDL_threadID riscos_main_thread;
-extern int riscos_using_threads;
-extern SDL_threadID SDL_ThreadID();
-extern SDL_threadID SDL_EventThreadID(void);
-#endif
-
-
-extern void RISCOS_BackgroundTasks(void);
-
-/* The first ticks value of the application */
-clock_t start;
-
-void
-SDL_StartTicks(void)
-{
-    /* Set first ticks value */
-    start = clock();
-}
-
-Uint32
-SDL_GetTicks(void)
-{
-    clock_t ticks;
-
-    ticks = clock() - start;
-
-
-#if CLOCKS_PER_SEC == 1000
-
-    return (ticks);
-
-#elif CLOCKS_PER_SEC == 100
-
-    return (ticks * 10);
-
-#else
-
-    return ticks * (1000 / CLOCKS_PER_SEC);
-
-#endif
-
-}
-
-void
-SDL_Delay(Uint32 ms)
-{
-    Uint32 now, then, elapsed;
-#if !SDL_THREADS_DISABLED
-    int is_event_thread;
-    if (riscos_using_threads) {
-        is_event_thread = 0;
-        if (SDL_EventThreadID()) {
-            if (SDL_EventThreadID() == SDL_ThreadID())
-                is_event_thread = 1;
-        } else if (SDL_ThreadID() == riscos_main_thread)
-            is_event_thread = 1;
-    } else
-        is_event_thread = 1;
-#endif
-
-    /*TODO: Next version of Unixlib may allow us to use usleep here */
-    /*      for non event threads */
-
-    /* Set the timeout interval - Linux only needs to do this once */
-    then = SDL_GetTicks();
-
-    do {
-        /* Do background tasks required while sleeping as we are not multithreaded */
-#if SDL_THREADS_DISABLED
-        RISCOS_BackgroundTasks();
-#else
-        /* For threaded build only run background tasks in event thread */
-        if (is_event_thread)
-            RISCOS_BackgroundTasks();
-#endif
-
-        /* Calculate the time interval left (in case of interrupt) */
-        now = SDL_GetTicks();
-        elapsed = (now - then);
-        then = now;
-        if (elapsed >= ms) {
-            break;
-        }
-        ms -= elapsed;
-#if !SDL_THREADS_DISABLED
-        /* Need to yield to let other threads have a go */
-        if (riscos_using_threads)
-            pthread_yield();
-#endif
-
-    } while (1);
-}
-
-#if SDL_THREADS_DISABLED
-
-/* Non-threaded version of timer */
-
-int
-SDL_SYS_TimerInit(void)
-{
-    return (0);
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    SDL_SetTimer(0, NULL);
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    timerStart = SDL_GetTicks();
-
-    return (0);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    /* Don't need to do anything as we use SDL_timer_running
-       to detect if we need to check the timer */
-}
-
-
-void
-RISCOS_CheckTimer()
-{
-    if (SDL_timer_running
-        && SDL_GetTicks() - timerStart >= SDL_alarm_interval) {
-        Uint32 ms;
-
-        ms = SDL_alarm_callback(SDL_alarm_interval);
-        if (ms != SDL_alarm_interval) {
-            if (ms) {
-                SDL_alarm_interval = ROUND_RESOLUTION(ms);
-            } else {
-                SDL_alarm_interval = 0;
-                SDL_timer_running = 0;
-            }
-        }
-        if (SDL_alarm_interval)
-            timerStart = SDL_GetTicks();
-    }
-}
-
-#else
-
-/* Threaded version of timer - based on code for linux */
-
-#include "SDL_thread.h"
-
-/* Data to handle a single periodic alarm */
-static int timer_alive = 0;
-static SDL_Thread *timer = NULL;
-
-static int
-RunTimer(void *unused)
-{
-    while (timer_alive) {
-        if (SDL_timer_running) {
-            SDL_ThreadedTimerCheck();
-        }
-        SDL_Delay(1);
-    }
-    return (0);
-}
-
-/* This is only called if the event thread is not running */
-int
-SDL_SYS_TimerInit(void)
-{
-    timer_alive = 1;
-    timer = SDL_CreateThread(RunTimer, NULL);
-    if (timer == NULL)
-        return (-1);
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    timer_alive = 0;
-    if (timer) {
-        SDL_WaitThread(timer, NULL);
-        timer = NULL;
-    }
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: RISC OS uses threaded timer");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
-#endif /* SDL_THREADS_DISABLED */
-
-#endif /* SDL_TIMER_RISCOS */
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/unix/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/unix/SDL_systimer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -25,14 +25,10 @@
 
 #include <stdio.h>
 #include <sys/time.h>
-#include <signal.h>
 #include <unistd.h>
-#include <string.h>
 #include <errno.h>
 
 #include "SDL_timer.h"
-#include "../SDL_systimer.h"
-#include "../SDL_timer_c.h"
 
 /* The clock_gettime provides monotonous time, so we should use it if
    it's available. The clock_gettime function is behind ifdef
@@ -43,10 +39,6 @@
 #include <time.h>
 #endif
 
-#if SDL_THREADS_DISABLED
-#define USE_ITIMER
-#endif
-
 /* The first ticks value of the application */
 #ifdef HAVE_CLOCK_GETTIME
 static struct timespec start;
@@ -131,118 +123,6 @@
     } while (was_error && (errno == EINTR));
 }
 
-#ifdef USE_ITIMER
-
-static void
-HandleAlarm(int sig)
-{
-    Uint32 ms;
-
-    if (SDL_alarm_callback) {
-        ms = (*SDL_alarm_callback) (SDL_alarm_interval);
-        if (ms != SDL_alarm_interval) {
-            SDL_SetTimer(ms, SDL_alarm_callback);
-        }
-    }
-}
-
-int
-SDL_SYS_TimerInit(void)
-{
-    struct sigaction action;
-
-    /* Set the alarm handler (Linux specific) */
-    SDL_memset(&action, 0, sizeof(action));
-    action.sa_handler = HandleAlarm;
-    action.sa_flags = SA_RESTART;
-    sigemptyset(&action.sa_mask);
-    sigaction(SIGALRM, &action, NULL);
-    return (0);
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    SDL_SetTimer(0, NULL);
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    struct itimerval timer;
-
-    timer.it_value.tv_sec = (SDL_alarm_interval / 1000);
-    timer.it_value.tv_usec = (SDL_alarm_interval % 1000) * 1000;
-    timer.it_interval.tv_sec = (SDL_alarm_interval / 1000);
-    timer.it_interval.tv_usec = (SDL_alarm_interval % 1000) * 1000;
-    setitimer(ITIMER_REAL, &timer, NULL);
-    return (0);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    struct itimerval timer;
-
-    SDL_memset(&timer, 0, (sizeof timer));
-    setitimer(ITIMER_REAL, &timer, NULL);
-}
+#endif /* SDL_TIMER_UNIX */
 
-#else /* USE_ITIMER */
-
-#include "SDL_thread.h"
-
-/* Data to handle a single periodic alarm */
-static int timer_alive = 0;
-static SDL_Thread *timer = NULL;
-
-static int
-RunTimer(void *unused)
-{
-    while (timer_alive) {
-        if (SDL_timer_running) {
-            SDL_ThreadedTimerCheck();
-        }
-        SDL_Delay(1);
-    }
-    return (0);
-}
-
-/* This is only called if the event thread is not running */
-int
-SDL_SYS_TimerInit(void)
-{
-    timer_alive = 1;
-    timer = SDL_CreateThread(RunTimer, NULL);
-    if (timer == NULL)
-        return (-1);
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    timer_alive = 0;
-    if (timer) {
-        SDL_WaitThread(timer, NULL);
-        timer = NULL;
-    }
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: Linux uses threaded timer");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
-#endif /* USE_ITIMER */
-
-#endif /* SDL_TIMER_UNIX */
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/wince/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/wince/SDL_systimer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,13 +23,9 @@
 
 #ifdef SDL_TIMER_WINCE
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
-#include <mmsystem.h>
+#include "../../core/windows/SDL_windows.h"
 
-#include "SDL_thread.h"
 #include "SDL_timer.h"
-#include "../SDL_timer_c.h"
 
 static Uint64 start_date;
 static Uint64 start_ticks;
@@ -70,6 +66,14 @@
     return ((Sint32) (wce_date() - start_date));
 }
 
+/* Recard start-time of application for reference */
+void
+SDL_StartTicks(void)
+{
+    start_date = wce_date();
+    start_ticks = wce_ticks();
+}
+
 /* Return time in ms relative to when SDL was started */
 Uint32
 SDL_GetTicks()
@@ -90,122 +94,6 @@
     Sleep(ms);
 }
 
-/* Recard start-time of application for reference */
-void
-SDL_StartTicks(void)
-{
-    start_date = wce_date();
-    start_ticks = wce_ticks();
-}
-
-static UINT WIN_timer;
-
-#if ( _WIN32_WCE <= 420 )
-
-static HANDLE timersThread = 0;
-static HANDLE timersQuitEvent = 0;
-
-DWORD
-TimersThreadProc(void *data)
-{
-    while (WaitForSingleObject(timersQuitEvent, 10) == WAIT_TIMEOUT) {
-        SDL_ThreadedTimerCheck();
-    }
-    return 0;
-}
-
-int
-SDL_SYS_TimerInit(void)
-{
-    // create a thread to process a threaded timers
-    // SetTimer does not suit the needs because 
-    // TimerCallbackProc will be called only when WM_TIMER occured
-
-    timersQuitEvent = CreateEvent(0, TRUE, FALSE, 0);
-    if (!timersQuitEvent) {
-        SDL_SetError("Cannot create event for timers thread");
-        return -1;
-    }
-    timersThread = CreateThread(NULL, 0, TimersThreadProc, 0, 0, 0);
-    if (!timersThread) {
-        SDL_SetError
-            ("Cannot create timers thread, check amount of RAM available");
-        return -1;
-    }
-    SetThreadPriority(timersThread, THREAD_PRIORITY_HIGHEST);
-
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    SetEvent(timersQuitEvent);
-    if (WaitForSingleObject(timersThread, 2000) == WAIT_TIMEOUT)
-        TerminateThread(timersThread, 0);
-    CloseHandle(timersThread);
-    CloseHandle(timersQuitEvent);
-    return;
-}
-
-#else
+#endif /* SDL_TIMER_WINCE */
 
-#pragma comment(lib, "mmtimer.lib")
-
-/* Data to handle a single periodic alarm */
-static UINT timerID = 0;
-
-static void CALLBACK
-HandleAlarm(UINT uID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
-{
-    SDL_ThreadedTimerCheck();
-}
-
-
-int
-SDL_SYS_TimerInit(void)
-{
-    MMRESULT result;
-
-    /* Set timer resolution */
-    result = timeBeginPeriod(TIMER_RESOLUTION);
-    if (result != TIMERR_NOERROR) {
-        SDL_SetError("Warning: Can't set %d ms timer resolution",
-                     TIMER_RESOLUTION);
-    }
-    /* Allow 10 ms of drift so we don't chew on CPU */
-    timerID =
-        timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC);
-    if (!timerID) {
-        SDL_SetError("timeSetEvent() failed");
-        return (-1);
-    }
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    if (timerID) {
-        timeKillEvent(timerID);
-    }
-    timeEndPeriod(TIMER_RESOLUTION);
-}
-
-#endif
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: WinCE uses threaded timer");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
-#endif /* SDL_TIMER_WINCE */
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/timer/windows/SDL_systimer.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/timer/windows/SDL_systimer.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,12 +23,10 @@
 
 #ifdef SDL_TIMER_WINDOWS
 
-#define WIN32_LEAN_AND_MEAN
-#include <windows.h>
+#include "../../core/windows/SDL_windows.h"
 #include <mmsystem.h>
 
 #include "SDL_timer.h"
-#include "../SDL_timer_c.h"
 
 #ifdef _WIN32_WCE
 #error This is WinCE. Please use src/timer/wince/SDL_systimer.c instead.
@@ -107,60 +105,6 @@
     Sleep(ms);
 }
 
-/* Data to handle a single periodic alarm */
-static UINT timerID = 0;
-
-static void CALLBACK
-HandleAlarm(UINT uID, UINT uMsg, DWORD_PTR dwUser,
-            DWORD_PTR dw1, DWORD_PTR dw2)
-{
-    SDL_ThreadedTimerCheck();
-}
-
-
-int
-SDL_SYS_TimerInit(void)
-{
-    MMRESULT result;
-
-    /* Set timer resolution */
-    result = timeBeginPeriod(TIMER_RESOLUTION);
-    if (result != TIMERR_NOERROR) {
-        SDL_SetError("Warning: Can't set %d ms timer resolution",
-                     TIMER_RESOLUTION);
-    }
-    /* Allow 10 ms of drift so we don't chew on CPU */
-    timerID =
-        timeSetEvent(TIMER_RESOLUTION, 1, HandleAlarm, 0, TIME_PERIODIC);
-    if (!timerID) {
-        SDL_SetError("timeSetEvent() failed");
-        return (-1);
-    }
-    return (SDL_SetTimerThreaded(1));
-}
-
-void
-SDL_SYS_TimerQuit(void)
-{
-    if (timerID) {
-        timeKillEvent(timerID);
-    }
-    timeEndPeriod(TIMER_RESOLUTION);
-}
-
-int
-SDL_SYS_StartTimer(void)
-{
-    SDL_SetError("Internal logic error: Win32 uses threaded timer");
-    return (-1);
-}
-
-void
-SDL_SYS_StopTimer(void)
-{
-    return;
-}
-
 #endif /* SDL_TIMER_WINDOWS */
 
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_renderer_gl.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/SDL_renderer_gl.c	Tue Feb 01 00:37:02 2011 -0800
@@ -1181,7 +1181,7 @@
         }
         data->glEnd();
     } else {
-#if defined(__APPLE__) || defined(__WINDOWS__)
+#if defined(__APPLE__) || defined(__WIN32__)
 #else
         int x1, y1, x2, y2;
 #endif
@@ -1200,7 +1200,7 @@
          * least it would be pixel perfect.
          */
         data->glBegin(GL_POINTS);
-#if defined(__APPLE__) || defined(__WINDOWS__)
+#if defined(__APPLE__) || defined(__WIN32__)
         /* Mac OS X and Windows seem to always leave the second point open */
         data->glVertex2f(0.5f + points[count-1].x, 0.5f + points[count-1].y);
 #else
--- a/src/video/SDL_sysvideo.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/SDL_sysvideo.h	Tue Feb 01 00:37:02 2011 -0800
@@ -426,9 +426,6 @@
 #if SDL_VIDEO_DRIVER_EPOC
 extern VideoBootStrap EPOC_bootstrap;
 #endif
-#if SDL_VIDEO_DRIVER_RISCOS
-extern VideoBootStrap RISCOS_bootstrap;
-#endif
 #if SDL_VIDEO_DRIVER_UIKIT
 extern VideoBootStrap UIKIT_bootstrap;
 #endif
--- a/src/video/SDL_video.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/SDL_video.c	Tue Feb 01 00:37:02 2011 -0800
@@ -31,7 +31,6 @@
 #include "SDL_renderer_gl.h"
 #include "SDL_renderer_gles.h"
 #include "SDL_renderer_sw.h"
-#include "../events/SDL_sysevents.h"
 #include "../events/SDL_events_c.h"
 
 #if SDL_VIDEO_DRIVER_WINDOWS
@@ -80,9 +79,6 @@
 #if SDL_VIDEO_DRIVER_EPOC
     &EPOC_bootstrap,
 #endif
-#if SDL_VIDEO_DRIVER_RISCOS
-    &RISCOS_bootstrap,
-#endif
 #if SDL_VIDEO_DRIVER_NDS
     &NDS_bootstrap,
 #endif
@@ -175,7 +171,7 @@
  * Initialize the video and event subsystems -- determine native pixel format
  */
 int
-SDL_VideoInit(const char *driver_name, Uint32 flags)
+SDL_VideoInit(const char *driver_name)
 {
     SDL_VideoDevice *video;
     int index;
@@ -186,18 +182,12 @@
         SDL_VideoQuit();
     }
 
-    /* Toggle the event thread flags, based on OS requirements */
-#if defined(MUST_THREAD_EVENTS)
-    flags |= SDL_INIT_EVENTTHREAD;
-#elif defined(CANT_THREAD_EVENTS)
-    if ((flags & SDL_INIT_EVENTTHREAD) == SDL_INIT_EVENTTHREAD) {
-        SDL_SetError("OS doesn't support threaded events");
-        return -1;
-    }
-#endif
-
     /* Start the event loop */
-    if (SDL_StartEventLoop(flags) < 0) {
+    if (SDL_StartEventLoop() < 0 ||
+        SDL_KeyboardInit() < 0 ||
+        SDL_MouseInit() < 0 ||
+        SDL_TouchInit() < 0 ||
+        SDL_QuitInit() < 0) {
         return -1;
     }
 
@@ -890,7 +880,7 @@
 
     if (!_this) {
         /* Initialize the video system if needed */
-        if (SDL_VideoInit(NULL, 0) < 0) {
+        if (SDL_VideoInit(NULL) < 0) {
             return NULL;
         }
     }
@@ -2810,8 +2800,13 @@
     if (!_this) {
         return;
     }
+
     /* Halt event processing before doing anything else */
+    SDL_QuitQuit();
+    SDL_MouseQuit();
+    SDL_KeyboardQuit();
     SDL_StopEventLoop();
+
     SDL_EnableScreenSaver();
 
     /* Clean up the system video */
--- a/src/video/android/SDL_androidgl.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/android/SDL_androidgl.c	Tue Feb 01 00:37:02 2011 -0800
@@ -26,7 +26,7 @@
 #include "SDL_video.h"
 
 #include "SDL_androidvideo.h"
-#include "../../SDL_android.h"
+#include "../../core/android/SDL_android.h"
 
 #include <android/log.h>
 
--- a/src/video/android/SDL_androidkeyboard.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/android/SDL_androidkeyboard.c	Tue Feb 01 00:37:02 2011 -0800
@@ -37,7 +37,7 @@
     SDL_SetKeymap(0, keymap, SDL_NUM_SCANCODES);
 }
 
-static SDL_scancode Android_Keycodes[] = {
+static SDL_ScanCode Android_Keycodes[] = {
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_UNKNOWN */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_LEFT */
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_SOFT_RIGHT */
@@ -151,10 +151,10 @@
     SDL_SCANCODE_UNKNOWN, /* AKEYCODE_BUTTON_MODE */
 };
 
-static SDL_scancode
+static SDL_ScanCode
 TranslateKeycode(int keycode)
 {
-    SDL_scancode scancode = SDL_SCANCODE_UNKNOWN;
+    SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
 
     if (keycode < SDL_arraysize(Android_Keycodes)) {
         scancode = Android_Keycodes[keycode];
--- a/src/video/bwindow/SDL_BWin.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/bwindow/SDL_BWin.h	Tue Feb 01 00:37:02 2011 -0800
@@ -509,7 +509,7 @@
 
                 if (msg->FindInt32("key", &key) == B_OK
                     && msg->FindInt32("modifiers", &modifiers) == B_OK) {
-                    SDL_keysym keysym;
+                    SDL_KeySym keysym;
                     keysym.scancode = key;
                     if ((key > 0) && (key < 128)) {
                         keysym.sym = keymap[key];
@@ -543,7 +543,7 @@
                 int32 modifiers;
                 if (msg->FindInt32("key", &key) == B_OK
                     && msg->FindInt32("modifiers", &modifiers) == B_OK) {
-                    SDL_keysym keysym;
+                    SDL_KeySym keysym;
                     keysym.scancode = key;
                     if ((key > 0) && (key < 128)) {
                         keysym.sym = keymap[key];
--- a/src/video/cocoa/SDL_cocoakeyboard.m	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/cocoa/SDL_cocoakeyboard.m	Tue Feb 01 00:37:02 2011 -0800
@@ -246,7 +246,7 @@
 HandleNonDeviceModifier(unsigned int device_independent_mask,
                         unsigned int oldMods,
                         unsigned int newMods,
-                        SDL_scancode scancode)
+                        SDL_ScanCode scancode)
 {
     unsigned int oldMask, newMask;
     
@@ -268,7 +268,7 @@
  */
 static void
 HandleModifierOneSide(unsigned int oldMods, unsigned int newMods,
-                      SDL_scancode scancode, 
+                      SDL_ScanCode scancode, 
                       unsigned int sided_device_dependent_mask)
 {
     unsigned int old_dep_mask, new_dep_mask;
@@ -297,8 +297,8 @@
 static void
 HandleModifierSide(int device_independent_mask, 
                    unsigned int oldMods, unsigned int newMods, 
-                   SDL_scancode left_scancode, 
-                   SDL_scancode right_scancode,
+                   SDL_ScanCode left_scancode, 
+                   SDL_ScanCode right_scancode,
                    unsigned int left_device_dependent_mask, 
                    unsigned int right_device_dependent_mask)
 {
@@ -341,8 +341,8 @@
 static void
 ReleaseModifierSide(unsigned int device_independent_mask, 
                     unsigned int oldMods, unsigned int newMods,
-                    SDL_scancode left_scancode, 
-                    SDL_scancode right_scancode,
+                    SDL_ScanCode left_scancode, 
+                    SDL_ScanCode right_scancode,
                     unsigned int left_device_dependent_mask, 
                     unsigned int right_device_dependent_mask)
 {
@@ -409,13 +409,13 @@
                  unsigned int oldMods, unsigned int newMods)
 {
 	/* Set up arrays for the key syms for the left and right side. */
-    const SDL_scancode left_mapping[]  = {
+    const SDL_ScanCode left_mapping[]  = {
         SDL_SCANCODE_LSHIFT,
         SDL_SCANCODE_LCTRL,
         SDL_SCANCODE_LALT,
         SDL_SCANCODE_LGUI
     };
-    const SDL_scancode right_mapping[] = {
+    const SDL_ScanCode right_mapping[] = {
         SDL_SCANCODE_RSHIFT,
         SDL_SCANCODE_RCTRL,
         SDL_SCANCODE_RALT,
@@ -489,7 +489,7 @@
 #endif
     const void *chr_data;
     int i;
-    SDL_scancode scancode;
+    SDL_ScanCode scancode;
     SDLKey keymap[SDL_NUM_SCANCODES];
 
     /* See if the keymap needs to be updated */
@@ -675,7 +675,7 @@
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     unsigned short scancode = [event keyCode];
-    SDL_scancode code;
+    SDL_ScanCode code;
 #if 0
     const char *text;
 #endif
--- a/src/video/cocoa/SDL_cocoavideo.m	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/cocoa/SDL_cocoavideo.m	Tue Feb 01 00:37:02 2011 -0800
@@ -98,7 +98,7 @@
     device->shape_driver.SetWindowShape = Cocoa_SetWindowShape;
     device->shape_driver.ResizeWindowShape = Cocoa_ResizeWindowShape;
     
-#ifdef SDL_VIDEO_OPENGL_CGL
+#if SDL_VIDEO_OPENGL_CGL
     device->GL_LoadLibrary = Cocoa_GL_LoadLibrary;
     device->GL_GetProcAddress = Cocoa_GL_GetProcAddress;
     device->GL_UnloadLibrary = Cocoa_GL_UnloadLibrary;
--- a/src/video/directfb/SDL_DirectFB_events.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/directfb/SDL_DirectFB_events.c	Tue Feb 01 00:37:02 2011 -0800
@@ -26,7 +26,6 @@
 #include <directfb.h>
 
 #include "../SDL_sysvideo.h"
-#include "../../events/SDL_sysevents.h"
 #include "../../events/SDL_events_c.h"
 #include "../../events/SDL_keyboard_c.h"
 #include "../../events/scancodes_linux.h"
@@ -56,11 +55,11 @@
 static SDLKey oskeymap[256];
 
 
-static SDL_keysym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
-                                         SDL_keysym * keysym);
-static SDL_keysym *DirectFB_TranslateKeyInputEvent(_THIS, int index,
+static SDL_KeySym *DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt,
+                                         SDL_KeySym * keysym);
+static SDL_KeySym *DirectFB_TranslateKeyInputEvent(_THIS, int index,
                                                    DFBInputEvent * evt,
-                                                   SDL_keysym * keysym);
+                                                   SDL_KeySym * keysym);
 
 static void DirectFB_InitOSKeymap(_THIS, SDLKey * keypmap, int numkeys);
 static int DirectFB_TranslateButton(DFBInputDeviceButtonIdentifier button);
@@ -168,7 +167,7 @@
                    DFBWindowEvent * evt)
 {
     SDL_DFB_DEVICEDATA(_this);
-    SDL_keysym keysym;
+    SDL_KeySym keysym;
     char text[5];
 
     if (evt->clazz == DFEC_WINDOW) {
@@ -300,7 +299,7 @@
 ProcessInputEvent(_THIS, DFBInputEvent * ievt)
 {
     SDL_DFB_DEVICEDATA(_this);
-    SDL_keysym keysym;
+    SDL_KeySym keysym;
     int kbd_idx;
     char text[5];
 
@@ -549,8 +548,8 @@
 
 }
 
-static SDL_keysym *
-DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_keysym * keysym)
+static SDL_KeySym *
+DirectFB_TranslateKey(_THIS, DFBWindowEvent * evt, SDL_KeySym * keysym)
 {
     SDL_DFB_DEVICEDATA(_this);
 
@@ -577,9 +576,9 @@
     return keysym;
 }
 
-static SDL_keysym *
+static SDL_KeySym *
 DirectFB_TranslateKeyInputEvent(_THIS, int index, DFBInputEvent * evt,
-                                SDL_keysym * keysym)
+                                SDL_KeySym * keysym)
 {
     SDL_DFB_DEVICEDATA(_this);
 
@@ -719,7 +718,7 @@
 
     while (devdata->eventbuffer->GetEvent(devdata->eventbuffer,
                                           DFB_EVENT(&evt)) == DFB_OK) {
-        SDL_keysym keysym;
+        SDL_KeySym keysym;
         DFBInputDeviceModifierMask mod;
 
         if (evt.clazz = DFEC_INPUT) {
--- a/src/video/dummy/SDL_nullevents.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/dummy/SDL_nullevents.c	Tue Feb 01 00:37:02 2011 -0800
@@ -24,7 +24,6 @@
 /* Being a null driver, there's no event stream. We just define stubs for
    most of the API. */
 
-#include "../../events/SDL_sysevents.h"
 #include "../../events/SDL_events_c.h"
 
 #include "SDL_nullvideo.h"
--- a/src/video/mmx.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/mmx.h	Tue Feb 01 00:37:02 2011 -0800
@@ -293,7 +293,7 @@
 
 #define	mmx_r2m(op, reg, mem) \
 	__asm__ __volatile__ (#op " %%" #reg ", %0" \
-			      : "=X" (mem) \
+			      : "=m" (mem) \
 			      : /* nothing */ )
 
 #define	mmx_r2r(op, regs, regd) \
--- a/src/video/nds/SDL_ndsevents.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/nds/SDL_ndsevents.c	Tue Feb 01 00:37:02 2011 -0800
@@ -28,7 +28,6 @@
 #include <stdlib.h>
 #include <nds.h>
 
-#include "../../events/SDL_sysevents.h"
 #include "../../events/SDL_events_c.h"
 
 #include "SDL_ndsvideo.h"
--- a/src/video/pandora/SDL_pandora_events.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/pandora/SDL_pandora_events.c	Tue Feb 01 00:37:02 2011 -0800
@@ -24,7 +24,6 @@
 /* Being a null driver, there's no event stream. We just define stubs for
    most of the API. */
 
-#include "../../events/SDL_sysevents.h"
 #include "../../events/SDL_events_c.h"
 
 void
--- a/src/video/photon/SDL_photon.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/photon/SDL_photon.c	Tue Feb 01 00:37:02 2011 -0800
@@ -2488,7 +2488,7 @@
                 case Ph_EV_KEY:
                     {
                         PhKeyEvent_t *keyevent = NULL;
-                        SDL_scancode scancode = SDL_SCANCODE_UNKNOWN;
+                        SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
                         SDL_bool pressed = SDL_FALSE;
 
                         keyevent = PhGetData(event);
--- a/src/video/photon/SDL_photon_input.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/photon/SDL_photon_input.c	Tue Feb 01 00:37:02 2011 -0800
@@ -460,10 +460,10 @@
     return;
 }
 
-SDL_scancode
+SDL_ScanCode
 photon_to_sdl_keymap(uint32_t key)
 {
-    SDL_scancode scancode = SDL_SCANCODE_UNKNOWN;
+    SDL_ScanCode scancode = SDL_SCANCODE_UNKNOWN;
 
     switch (key & 0x0000007F) {
     case PHOTON_SCANCODE_ESCAPE:
--- a/src/video/photon/SDL_photon_input.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/photon/SDL_photon_input.h	Tue Feb 01 00:37:02 2011 -0800
@@ -45,6 +45,6 @@
 #define SDL_PHOTON_MOUSE_COLOR_WHITE 0xFFFFFFFF
 #define SDL_PHOTON_MOUSE_COLOR_TRANS 0x00000000
 
-SDL_scancode photon_to_sdl_keymap(uint32_t key);
+SDL_ScanCode photon_to_sdl_keymap(uint32_t key);
 
 #endif /* __SDL_GF_INPUT_H__ */
--- a/src/video/riscos/SDL_riscosASM.S	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,116 +0,0 @@
-;
-;    SDL - Simple DirectMedia Layer
-;    Copyright (C) 1997-2009 Sam Lantinga
-;
-;    This library is free software; you can redistribute it and/or
-;    modify it under the terms of the GNU Library General Public
-;    License as published by the Free Software Foundation; either
-;    version 2 of the License, or (at your option) any later version.
-;
-;    This library is distributed in the hope that it will be useful,
-;    but WITHOUT ANY WARRANTY; without even the implied warranty of
-;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-;    Library General Public License for more details.
-;
-;    You should have received a copy of the GNU Library General Public
-;    License along with this library; if not, write to the Free
-;    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
-;
-;    Sam Lantinga
-;    slouken@libsdl.org
-;
-; Assembler routines for RISC OS display
-;
-
-	AREA |C$$CODE|
-
-	EXPORT |RISCOS_Put32|
-
-; Display 32bpp to 32bpp, 1:1
-;
-; Code provided by Adrain Lees
-;
-; entry a1 -> destination
-;       a2 =  dest width in pixels
-;       a3 =  dest line length in bytes
-;       a4 =  dest height in scanlines
-;       arg5 -> source
-;       arg6 =  byte offset from end of source line to start of next
-
-Arg5    *       10*4
-Arg6    *       Arg5+4
-
-RISCOS_Put32    ROUT
-                STMFD   sp!,{a2,v1-v6,sl,fp,lr}
-                LDR     ip,[sp,#Arg5]
-                MOV     lr,a1
-                B       ucp64lp
-
-00              ;tail strip of 1-15 pixels
-
-                LDR     v1,[ip],#4
-01              SUBS    a2,a2,#1
-                STR     v1,[lr],#4
-                LDRHI   v1,[ip],#4
-                BHI     %01
-                B       %02
-
-ucp64end        ADDS    a2,a2,#16
-                BNE     %00
-
-02              SUBS    a4,a4,#1                ;height--
-                LDRHI   v1,[sp,#Arg6]
-                LDRHI   a2,[sp]                 ;reload width
-                BLS     %03
-
-                ;move to start of next scanline
-
-                ADD     lr,a1,a3
-                ADD     a1,a1,a3
-                ADD     ip,ip,v1
-
-ucp64lp         SUBS    a2,a2,#16
-                BLO     ucp64end
-
-                PLD     [ip,#64]
-
-                LDR     v1,[ip],#4
-                LDR     v2,[ip],#4
-                LDR     v3,[ip],#4
-                LDR     v4,[ip],#4
-                LDR     v5,[ip],#4
-                LDR     v6,[ip],#4
-                LDR     sl,[ip],#4
-                LDR     fp,[ip],#4
-                STR     v1,[lr],#4
-                STR     v2,[lr],#4
-                STR     v3,[lr],#4
-                STR     v4,[lr],#4
-                STR     v5,[lr],#4
-                STR     v6,[lr],#4
-                STR     sl,[lr],#4
-                STR     fp,[lr],#4
-
-                PLD     [ip,#64]
-
-                LDR     v1,[ip],#4
-                LDR     v2,[ip],#4
-                LDR     v3,[ip],#4
-                LDR     v4,[ip],#4
-                LDR     v5,[ip],#4
-                LDR     v6,[ip],#4
-                LDR     sl,[ip],#4
-                LDR     fp,[ip],#4
-                STR     v1,[lr],#4
-                STR     v2,[lr],#4
-                STR     v3,[lr],#4
-                STR     v4,[lr],#4
-                STR     v5,[lr],#4
-                STR     v6,[lr],#4
-                STR     sl,[lr],#4
-                STR     fp,[lr],#4
-
-                B       ucp64lp
-
-03              LDMFD   sp!,{a2,v1-v6,sl,fp,pc}
-
--- a/src/video/riscos/SDL_riscosFullScreenVideo.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,802 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
-	 27 March 2003
-
-     Implements RISC OS full screen display.
-*/
-
-#include "SDL_video.h"
-#include "SDL_mouse.h"
-#include "../SDL_sysvideo.h"
-#include "../SDL_pixels_c.h"
-#include "../../events/SDL_events_c.h"
-
-#include "SDL_riscostask.h"
-#include "SDL_riscosvideo.h"
-#include "SDL_riscosevents_c.h"
-#include "SDL_riscosmouse_c.h"
-
-#include "kernel.h"
-#include "swis.h"
-#include "unixlib/os.h"
-#include "unixlib/local.h"
-
-/* Private structures */
-typedef struct tagScreenModeBlock
-{
-    int flags;                  // mode selector flags, bit 0 = 1, bit 1-7 format specifier, 8-31 reserved
-    int x_pixels;
-    int y_pixels;
-    int pixel_depth;            // 2^pixel_depth = bpp,i.e. 0 = 1, 1 = 2, 4 = 16, 5 = 32
-    int frame_rate;             // -1 use first match
-    int mode_vars[5];           // array of index, value pairs terminated by -1
-} SCREENMODEBLOCK;
-
-
-/* Helper functions */
-void FULLSCREEN_SetDeviceMode(_THIS);
-int FULLSCREEN_SetMode(int width, int height, int bpp);
-void FULLSCREEN_SetupBanks(_THIS);
-
-/* SDL video device functions for fullscreen mode */
-static int FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors,
-                                SDL_Color * colors);
-static int FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface);
-void FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon);
-extern int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info);
-
-/* UpdateRects variants */
-static void FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
-static void FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects,
-                                         SDL_Rect * rects);
-static void FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects);
-static void FULLSCREEN_UpdateRects16bpp(_THIS, int numrects,
-                                        SDL_Rect * rects);
-static void FULLSCREEN_UpdateRects32bpp(_THIS, int numrects,
-                                        SDL_Rect * rects);
-static void FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects);
-
-/* Local helper functions */
-static int cmpmodes(const void *va, const void *vb);
-static int FULLSCREEN_AddMode(_THIS, int bpp, int w, int h);
-void FULLSCREEN_SetWriteBank(int bank);
-void FULLSCREEN_SetDisplayBank(int bank);
-static void FULLSCREEN_DisableEscape();
-static void FULLSCREEN_EnableEscape();
-void FULLSCREEN_BuildModeList(_THIS);
-
-/* Following variable is set up in riskosTask.c */
-extern int riscos_backbuffer;   /* Create a back buffer in system memory for full screen mode */
-
-/* Following is used to create a sprite back buffer */
-extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp);
-
-/* Fast assembler copy */
-extern void RISCOS_Put32(void *to, int pixels, int pitch, int rows,
-                         void *from, int src_skip_bytes);
-
-SDL_Surface *
-FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current,
-                        int width, int height, int bpp, Uint32 flags)
-{
-    _kernel_swi_regs regs;
-    Uint32 Rmask = 0;
-    Uint32 Gmask = 0;
-    Uint32 Bmask = 0;
-    int create_back_buffer = riscos_backbuffer;
-
-    switch (bpp) {
-    case 8:
-        flags |= SDL_HWPALETTE;
-        break;
-
-    case 15:
-    case 16:
-        Bmask = 0x00007c00;
-        Gmask = 0x000003e0;
-        Rmask = 0x0000001f;
-        break;
-
-    case 32:
-        Bmask = 0x00ff0000;
-        Gmask = 0x0000ff00;
-        Rmask = 0x000000ff;
-        break;
-
-    default:
-        SDL_SetError("Pixel depth not supported");
-        return NULL;
-        break;
-    }
-
-    if (FULLSCREEN_SetMode(width, height, bpp) == 0) {
-        SDL_SetError("Couldn't set requested mode");
-        return (NULL);
-    }
-
-/* 	printf("Setting mode %dx%d\n", width, height); */
-
-    /* Allocate the new pixel format for the screen */
-    if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
-        RISCOS_RestoreWimpMode();
-        SDL_SetError("Couldn't allocate new pixel format for requested mode");
-        return (NULL);
-    }
-
-    /* Set up the new mode framebuffer */
-    current->w = width;
-    this->hidden->height = current->h = height;
-
-    regs.r[0] = -1;             /* -1 for current screen mode */
-
-    /* Get screen width in bytes */
-    regs.r[1] = 6;              // Screen Width in bytes
-    _kernel_swi(OS_ReadModeVariable, &regs, &regs);
-
-    current->pitch = regs.r[2];
-
-    if (flags & SDL_DOUBLEBUF) {
-        regs.r[0] = 2;          /* Screen area */
-        _kernel_swi(OS_ReadDynamicArea, &regs, &regs);
-
-        /* Reg 1 has amount of memory currently used for display */
-        regs.r[0] = 2;          /* Screen area */
-        regs.r[1] = (current->pitch * height * 2) - regs.r[1];
-        if (_kernel_swi(OS_ChangeDynamicArea, &regs, &regs) != NULL) {
-            /* Can't allocate enough screen memory for double buffer */
-            flags &= ~SDL_DOUBLEBUF;
-        }
-    }
-
-    current->flags = flags | SDL_FULLSCREEN | SDL_HWSURFACE | SDL_PREALLOC;
-
-
-    /* Need to set display banks here for double buffering */
-    if (flags & SDL_DOUBLEBUF) {
-        FULLSCREEN_SetWriteBank(0);
-        FULLSCREEN_SetDisplayBank(1);
-
-        create_back_buffer = 0; /* Don't need a back buffer for a double buffered display */
-    }
-
-    FULLSCREEN_SetupBanks(this);
-
-    if (create_back_buffer) {
-        /* If not double buffered we may need to create a memory
-         ** back buffer to simulate processing on other OSes.
-         ** This is turned on by setting the enviromental variable
-         ** SDL$<name>$BackBuffer >= 1
-         */
-        if (riscos_backbuffer == 3)
-            this->hidden->bank[0] = WIMP_CreateBuffer(width, height, bpp);
-        else
-            this->hidden->bank[0] = SDL_malloc(height * current->pitch);
-        if (this->hidden->bank[0] == 0) {
-            RISCOS_RestoreWimpMode();
-            SDL_SetError("Couldnt allocate memory for back buffer");
-            return (NULL);
-        }
-        /* Surface updated in programs is now a software surface */
-        current->flags &= ~SDL_HWSURFACE;
-    }
-
-    /* Store address of allocated screen bank to be freed later */
-    if (this->hidden->alloc_bank)
-        SDL_free(this->hidden->alloc_bank);
-    if (create_back_buffer) {
-        this->hidden->alloc_bank = this->hidden->bank[0];
-        if (riscos_backbuffer == 3) {
-            this->hidden->bank[0] += 60;        /* Start of sprite data */
-            if (bpp == 8)
-                this->hidden->bank[0] += 2048;  /* 8bpp sprite have palette first */
-        }
-    } else
-        this->hidden->alloc_bank = 0;
-
-    // Clear both banks to black
-    SDL_memset(this->hidden->bank[0], 0, height * current->pitch);
-    SDL_memset(this->hidden->bank[1], 0, height * current->pitch);
-
-    this->hidden->current_bank = 0;
-    current->pixels = this->hidden->bank[0];
-
-    /* Have to set the screen here, so SetDeviceMode will pick it up */
-    this->screen = current;
-
-    /* Reset device functions for the wimp */
-    FULLSCREEN_SetDeviceMode(this);
-
-/*	FULLSCREEN_DisableEscape(); */
-
-    /* We're done */
-    return (current);
-}
-
-/* Reset any device functions that have been changed because we have run in WIMP mode */
-void
-FULLSCREEN_SetDeviceMode(_THIS)
-{
-    /* Update rects is different if we have a backbuffer */
-
-    if (riscos_backbuffer && (this->screen->flags & SDL_DOUBLEBUF) == 0) {
-        switch (riscos_backbuffer) {
-        case 2:                /* ARM code full word copy */
-            switch (this->screen->format->BytesPerPixel) {
-            case 1:            /* 8bpp modes */
-                this->UpdateRects = FULLSCREEN_UpdateRects8bpp;
-                break;
-            case 2:            /* 15/16bpp modes */
-                this->UpdateRects = FULLSCREEN_UpdateRects16bpp;
-                break;
-            case 4:            /* 32 bpp modes */
-                this->UpdateRects = FULLSCREEN_UpdateRects32bpp;
-                break;
-
-            default:           /* Just default to the memcpy routine */
-                this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
-                break;
-            }
-            break;
-
-        case 3:                /* Use OS sprite plot routine */
-            this->UpdateRects = FULLSCREEN_UpdateRectsOS;
-            break;
-
-        default:               /* Old but safe memcpy */
-            this->UpdateRects = FULLSCREEN_UpdateRectsMemCpy;
-            break;
-        }
-    } else
-        this->UpdateRects = FULLSCREEN_UpdateRects;     /* Default do nothing implementation */
-
-    this->SetColors = FULLSCREEN_SetColors;
-
-    this->FlipHWSurface = FULLSCREEN_FlipHWSurface;
-
-    this->SetCaption = FULLSCREEN_SetWMCaption;
-    this->SetIcon = NULL;
-    this->IconifyWindow = NULL;
-
-    this->ShowWMCursor = RISCOS_ShowWMCursor;
-    this->WarpWMCursor = FULLSCREEN_WarpWMCursor;
-
-    this->PumpEvents = FULLSCREEN_PumpEvents;
-}
-
-/* Query for the list of available video modes */
-void
-FULLSCREEN_BuildModeList(_THIS)
-{
-    _kernel_swi_regs regs;
-    char *enumInfo = NULL;
-    char *enum_ptr;
-    int *blockInfo;
-    int j;
-    int num_modes;
-
-    /* Find out how much space we need */
-    regs.r[0] = 2;              /* Reason code */
-    regs.r[2] = 0;              /* Number of modes to skip */
-    regs.r[6] = 0;              /* pointer to block or 0 for count */
-    regs.r[7] = 0;              /* Size of block in bytes */
-    _kernel_swi(OS_ScreenMode, &regs, &regs);
-
-    num_modes = -regs.r[2];
-
-    /* Video memory should be in r[5] */
-    this->info.video_mem = regs.r[5] / 1024;
-
-    enumInfo = (unsigned char *) SDL_malloc(-regs.r[7]);
-    if (enumInfo == NULL) {
-        SDL_OutOfMemory();
-        return;
-    }
-    /* Read mode information into block */
-    regs.r[2] = 0;
-    regs.r[6] = (int) enumInfo;
-    regs.r[7] = -regs.r[7];
-    _kernel_swi(OS_ScreenMode, &regs, &regs);
-
-    enum_ptr = enumInfo;
-
-    for (j = 0; j < num_modes; j++) {
-        blockInfo = (int *) enum_ptr;
-        if ((blockInfo[1] & 255) == 1) {        /* We understand this format */
-            switch (blockInfo[4]) {
-            case 3:            /* 8 bits per pixel */
-                FULLSCREEN_AddMode(this, 8, blockInfo[2], blockInfo[3]);
-                break;
-            case 4:            /* 15 bits per pixel */
-                FULLSCREEN_AddMode(this, 15, blockInfo[2], blockInfo[3]);
-                break;
-            case 5:            /* 32 bits per pixel */
-                FULLSCREEN_AddMode(this, 32, blockInfo[2], blockInfo[3]);
-                break;
-            }
-        }
-
-        enum_ptr += blockInfo[0];
-    }
-
-    SDL_free(enumInfo);
-
-    /* Sort the mode lists */
-    for (j = 0; j < NUM_MODELISTS; ++j) {
-        if (SDL_nummodes[j] > 0) {
-            SDL_qsort(SDL_modelist[j], SDL_nummodes[j],
-                      sizeof *SDL_modelist[j], cmpmodes);
-        }
-    }
-}
-
-static int
-FULLSCREEN_FlipHWSurface(_THIS, SDL_Surface * surface)
-{
-    _kernel_swi_regs regs;
-    regs.r[0] = 19;
-
-    FULLSCREEN_SetDisplayBank(this->hidden->current_bank);
-    this->hidden->current_bank ^= 1;
-    FULLSCREEN_SetWriteBank(this->hidden->current_bank);
-    surface->pixels = this->hidden->bank[this->hidden->current_bank];
-
-    /* Wait for Vsync */
-    _kernel_swi(OS_Byte, &regs, &regs);
-
-    return (0);
-}
-
-/* Nothing to do if we are writing direct to hardware */
-static void
-FULLSCREEN_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
-{
-}
-
-/* Safe but slower Memory copy from our allocated back buffer */
-static void
-FULLSCREEN_UpdateRectsMemCpy(_THIS, int numrects, SDL_Rect * rects)
-{
-    int j;
-    char *to, *from;
-    int pitch = this->screen->pitch;
-    int row;
-    int xmult = this->screen->format->BytesPerPixel;
-    for (j = 0; j < numrects; j++) {
-        from = this->hidden->bank[0] + rects->x * xmult + rects->y * pitch;
-        to = this->hidden->bank[1] + rects->x * xmult + rects->y * pitch;
-        for (row = 0; row < rects->h; row++) {
-            SDL_memcpy(to, from, rects->w * xmult);
-            from += pitch;
-            to += pitch;
-        }
-        rects++;
-    }
-}
-
-/* Use optimized assembler memory copy. Deliberately copies extra columns if
-   necessary to ensure the rectangle is word aligned. */
-static void
-FULLSCREEN_UpdateRects8bpp(_THIS, int numrects, SDL_Rect * rects)
-{
-    int j;
-    char *to, *from;
-    int pitch = this->screen->pitch;
-    int width_bytes;
-    int src_skip_bytes;
-
-    for (j = 0; j < numrects; j++) {
-        from = this->hidden->bank[0] + rects->x + rects->y * pitch;
-        to = this->hidden->bank[1] + rects->x + rects->y * pitch;
-        width_bytes = rects->w;
-        if ((int) from & 3) {
-            int extra = ((int) from & 3);
-            from -= extra;
-            to -= extra;
-            width_bytes += extra;
-        }
-        if (width_bytes & 3)
-            width_bytes += 4 - (width_bytes & 3);
-        src_skip_bytes = pitch - width_bytes;
-
-        RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from,
-                     src_skip_bytes);
-        rects++;
-    }
-}
-
-/* Use optimized assembler memory copy. Deliberately copies extra columns if
-   necessary to ensure the rectangle is word aligned. */
-static void
-FULLSCREEN_UpdateRects16bpp(_THIS, int numrects, SDL_Rect * rects)
-{
-    int j;
-    char *to, *from;
-    int pitch = this->screen->pitch;
-    int width_bytes;
-    int src_skip_bytes;
-
-    for (j = 0; j < numrects; j++) {
-        from = this->hidden->bank[0] + (rects->x << 1) + rects->y * pitch;
-        to = this->hidden->bank[1] + (rects->x << 1) + rects->y * pitch;
-        width_bytes = (((int) rects->w) << 1);
-        if ((int) from & 3) {
-            from -= 2;
-            to -= 2;
-            width_bytes += 2;
-        }
-        if (width_bytes & 3)
-            width_bytes += 2;
-        src_skip_bytes = pitch - width_bytes;
-
-        RISCOS_Put32(to, (width_bytes >> 2), pitch, (int) rects->h, from,
-                     src_skip_bytes);
-        rects++;
-    }
-}
-
-/* Use optimized assembler memory copy. 32 bpp modes are always word aligned */
-static void
-FULLSCREEN_UpdateRects32bpp(_THIS, int numrects, SDL_Rect * rects)
-{
-    int j;
-    char *to, *from;
-    int pitch = this->screen->pitch;
-    int width;
-
-    for (j = 0; j < numrects; j++) {
-        from = this->hidden->bank[0] + (rects->x << 2) + rects->y * pitch;
-        to = this->hidden->bank[1] + (rects->x << 2) + rects->y * pitch;
-        width = (int) rects->w;
-
-        RISCOS_Put32(to, width, pitch, (int) rects->h, from,
-                     pitch - (width << 2));
-        rects++;
-    }
-}
-
-/* Use operating system sprite plots. Currently this is much slower than the
-   other variants however accelerated sprite plotting can be seen on the horizon
-   so this prepares for it. */
-static void
-FULLSCREEN_UpdateRectsOS(_THIS, int numrects, SDL_Rect * rects)
-{
-    _kernel_swi_regs regs;
-    _kernel_oserror *err;
-    int j;
-    int y;
-
-    regs.r[0] = 28 + 512;
-    regs.r[1] = (unsigned int) this->hidden->alloc_bank;
-    regs.r[2] = (unsigned int) this->hidden->alloc_bank + 16;
-    regs.r[5] = 0;
-
-    for (j = 0; j < numrects; j++) {
-        y = this->screen->h - rects->y; /* top of clipping region */
-        _kernel_oswrch(24);     /* Set graphics clip region */
-        _kernel_oswrch((rects->x << this->hidden->xeig) & 0xFF);        /* left */
-        _kernel_oswrch(((rects->x << this->hidden->xeig) >> 8) & 0xFF);
-        _kernel_oswrch(((y - rects->h) << this->hidden->yeig) & 0xFF);  /* bottom */
-        _kernel_oswrch((((y - rects->h) << this->hidden->yeig) >> 8) & 0xFF);
-        _kernel_oswrch(((rects->x + rects->w - 1) << this->hidden->xeig) & 0xFF);       /* right */
-        _kernel_oswrch((((rects->x + rects->w -
-                          1) << this->hidden->xeig) >> 8) & 0xFF);
-        _kernel_oswrch(((y - 1) << this->hidden->yeig) & 0xFF); /* top */
-        _kernel_oswrch((((y - 1) << this->hidden->yeig) >> 8) & 0xFF);
-
-        regs.r[3] = 0;
-        regs.r[4] = 0;
-
-        if ((err = _kernel_swi(OS_SpriteOp, &regs, &regs)) != 0) {
-            printf("OS_SpriteOp failed \n%s\n", err->errmess);
-        }
-
-        rects++;
-
-        /* Reset to full screen clipping */
-        _kernel_oswrch(24);     /* Set graphics clip region */
-        _kernel_oswrch(0);      /* left */
-        _kernel_oswrch(0);
-        _kernel_oswrch(0);      /* bottom */
-        _kernel_oswrch(0);
-        _kernel_oswrch(((this->screen->w - 1) << this->hidden->xeig) & 0xFF);   /* right */
-        _kernel_oswrch((((this->screen->w -
-                          1) << this->hidden->xeig) >> 8) & 0xFF);
-        _kernel_oswrch(((this->screen->h - 1) << this->hidden->yeig) & 0xFF);   /* top */
-        _kernel_oswrch((((this->screen->h -
-                          1) << this->hidden->yeig) >> 8) & 0xFF);
-    }
-}
-
-
-int
-FULLSCREEN_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
-{
-    _kernel_swi_regs regs;
-    int palette[256];
-
-    regs.r[0] = -1;
-    regs.r[1] = -1;
-    regs.r[2] = (int) palette;
-    regs.r[3] = 1024;
-    regs.r[4] = 0;
-    _kernel_swi(ColourTrans_ReadPalette, &regs, &regs);
-
-    while (ncolors--) {
-        palette[firstcolor] =
-            ((colors->b) << 24) | ((colors->g) << 16) | ((colors->r) << 8);
-        firstcolor++;
-        colors++;
-    }
-
-    regs.r[0] = -1;
-    regs.r[1] = -1;
-    regs.r[2] = (int) palette;
-    regs.r[3] = 0;
-    regs.r[4] = 0;
-    _kernel_swi(ColourTrans_WritePalette, &regs, &regs);
-
-    return (1);
-}
-
-
-static int
-cmpmodes(const void *va, const void *vb)
-{
-    SDL_Rect *a = *(SDL_Rect **) va;
-    SDL_Rect *b = *(SDL_Rect **) vb;
-    if (a->w == b->w)
-        return b->h - a->h;
-    else
-        return b->w - a->w;
-}
-
-static int
-FULLSCREEN_AddMode(_THIS, int bpp, int w, int h)
-{
-    SDL_Rect *mode;
-    int i, index;
-    int next_mode;
-
-    /* Check to see if we already have this mode */
-    if (bpp < 8) {              /* Not supported */
-        return (0);
-    }
-    index = ((bpp + 7) / 8) - 1;
-    for (i = 0; i < SDL_nummodes[index]; ++i) {
-        mode = SDL_modelist[index][i];
-        if ((mode->w == w) && (mode->h == h)) {
-            return (0);
-        }
-    }
-
-    /* Set up the new video mode rectangle */
-    mode = (SDL_Rect *) SDL_malloc(sizeof *mode);
-    if (mode == NULL) {
-        SDL_OutOfMemory();
-        return (-1);
-    }
-    mode->x = 0;
-    mode->y = 0;
-    mode->w = w;
-    mode->h = h;
-
-    /* Allocate the new list of modes, and fill in the new mode */
-    next_mode = SDL_nummodes[index];
-    SDL_modelist[index] = (SDL_Rect **)
-        SDL_realloc(SDL_modelist[index],
-                    (1 + next_mode + 1) * sizeof(SDL_Rect *));
-    if (SDL_modelist[index] == NULL) {
-        SDL_OutOfMemory();
-        SDL_nummodes[index] = 0;
-        SDL_free(mode);
-        return (-1);
-    }
-    SDL_modelist[index][next_mode] = mode;
-    SDL_modelist[index][next_mode + 1] = NULL;
-    SDL_nummodes[index]++;
-
-    return (0);
-}
-
-void
-FULLSCREEN_SetWriteBank(int bank)
-{
-    _kernel_swi_regs regs;
-    regs.r[0] = 112;
-    regs.r[1] = bank + 1;
-    _kernel_swi(OS_Byte, &regs, &regs);
-}
-
-void
-FULLSCREEN_SetDisplayBank(int bank)
-{
-    _kernel_swi_regs regs;
-    regs.r[0] = 113;
-    regs.r[1] = bank + 1;
-    _kernel_swi(OS_Byte, &regs, &regs);
-}
-
-
-/** Disable special escape key processing */
-static void
-FULLSCREEN_DisableEscape()
-{
-    _kernel_swi_regs regs;
-    regs.r[0] = 229;
-    regs.r[1] = 1;
-    regs.r[2] = 0;
-    _kernel_swi(OS_Byte, &regs, &regs);
-
-}
-
-/** Enable special escape key processing */
-static void
-FULLSCREEN_EnableEscape()
-{
-    _kernel_swi_regs regs;
-    regs.r[0] = 229;
-    regs.r[1] = 0;
-    regs.r[2] = 0;
-    _kernel_swi(OS_Byte, &regs, &regs);
-
-}
-
-/** Store caption in case this is called before we create a window */
-void
-FULLSCREEN_SetWMCaption(_THIS, const char *title, const char *icon)
-{
-    SDL_strlcpy(this->hidden->title, title,
-                SDL_arraysize(this->hidden->title));
-}
-
-/* Set screen mode
-*
-*  Returns 1 if mode is set ok, otherwise 0
-*/
-
-int
-FULLSCREEN_SetMode(int width, int height, int bpp)
-{
-    SCREENMODEBLOCK smb;
-    _kernel_swi_regs regs;
-
-    smb.flags = 1;
-    smb.x_pixels = width;
-    smb.y_pixels = height;
-    smb.mode_vars[0] = -1;
-
-    switch (bpp) {
-    case 8:
-        smb.pixel_depth = 3;
-        /* Note: Need to set ModeFlags to 128 and NColour variables to 255 get full 8 bit palette */
-        smb.mode_vars[0] = 0;
-        smb.mode_vars[1] = 128; /* Mode flags */
-        smb.mode_vars[2] = 3;
-        smb.mode_vars[3] = 255; /* NColour (number of colours -1) */
-        smb.mode_vars[4] = -1;  /* End of list */
-        break;
-
-    case 15:
-    case 16:
-        smb.pixel_depth = 4;
-        break;
-
-    case 32:
-        smb.pixel_depth = 5;
-        break;
-
-    default:
-        SDL_SetError("Pixel depth not supported");
-        return 0;
-        break;
-    }
-
-    smb.frame_rate = -1;
-
-    regs.r[0] = 0;
-    regs.r[1] = (int) &smb;
-
-    if (_kernel_swi(OS_ScreenMode, &regs, &regs) != 0) {
-        SDL_SetError("Couldn't set requested mode");
-        return 0;
-    }
-
-    /* Turn cursor off */
-    _kernel_oswrch(23);
-    _kernel_oswrch(1);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-    _kernel_oswrch(0);
-
-    return 1;
-}
-
-/* Get Start addresses for the screen banks */
-void
-FULLSCREEN_SetupBanks(_THIS)
-{
-    _kernel_swi_regs regs;
-    int block[5];
-    block[0] = 148;             /* Write screen start */
-    block[1] = 149;             /* Display screen start */
-    block[2] = 4;               /* X eig factor */
-    block[3] = 5;               /* Y eig factor */
-    block[4] = -1;              /* End of list of variables to request */
-
-    regs.r[0] = (int) block;
-    regs.r[1] = (int) block;
-    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
-
-    this->hidden->bank[0] = (void *) block[0];
-    this->hidden->bank[1] = (void *) block[1];
-    this->hidden->xeig = block[2];
-    this->hidden->yeig = block[3];
-}
-
-/* Toggle to full screen mode from the WIMP */
-
-int
-FULLSCREEN_ToggleFromWimp(_THIS)
-{
-    int width = this->screen->w;
-    int height = this->screen->h;
-    int bpp = this->screen->format->BitsPerPixel;
-
-    RISCOS_StoreWimpMode();
-    if (FULLSCREEN_SetMode(width, height, bpp)) {
-        char *buffer = this->hidden->alloc_bank;        /* This is start of sprite data */
-        /* Support back buffer mode only */
-        if (riscos_backbuffer == 0)
-            riscos_backbuffer = 1;
-
-        FULLSCREEN_SetupBanks(this);
-
-        this->hidden->bank[0] = buffer + 60;    /* Start of sprite data */
-        if (bpp == 8)
-            this->hidden->bank[0] += 2048;      /* 8bpp sprite have palette first */
-
-        this->hidden->current_bank = 0;
-        this->screen->pixels = this->hidden->bank[0];
-
-        /* Copy back buffer to screen memory */
-        SDL_memcpy(this->hidden->bank[1], this->hidden->bank[0],
-                   width * height * this->screen->format->BytesPerPixel);
-
-        FULLSCREEN_SetDeviceMode(this);
-        return 1;
-    } else
-        RISCOS_RestoreWimpMode();
-
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscosevents.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,598 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
-	 27 March 2003
-
-     Implements keyboard setup, event pump and keyboard and mouse polling
-*/
-
-
-#include "../../timer/SDL_timer_c.h"
-#include "../../events/SDL_sysevents.h"
-#include "../../events/SDL_events_c.h"
-#include "../SDL_cursor_c.h"
-#include "SDL_riscosvideo.h"
-#include "SDL_riscosevents_c.h"
-
-#include "memory.h"
-#include "stdlib.h"
-#include "ctype.h"
-
-#include "kernel.h"
-#include "swis.h"
-
-/* The translation table from a RISC OS internal key numbers to a SDL keysym */
-static SDLKey RO_keymap[SDLK_LAST];
-
-/* RISC OS Key codes */
-#define ROKEY_SHIFT 0
-#define ROKEY_CTRL  1
-#define ROKEY_ALT   2
-/* Left shift is first key we will check for */
-#define ROKEY_LEFT_SHIFT 3
-
-/* Need to ignore mouse buttons as they are processed separately */
-#define ROKEY_LEFT_MOUSE   9
-#define ROKEY_CENTRE_MOUSE 10
-#define ROKEY_RIGHT_MOUSE  11
-
-/* No key has been pressed return value*/
-#define ROKEY_NONE 255
-
-/* Id of last key in keyboard */
-#define ROKEY_LAST_KEY  124
-
-/* Size of array for all keys */
-#define ROKEYBD_ARRAYSIZE 125
-
-static char RO_pressed[ROKEYBD_ARRAYSIZE];
-
-static SDL_keysym *TranslateKey(int intkey, SDL_keysym * keysym, int pressed);
-
-void RISCOS_PollMouse(_THIS);
-void RISCOS_PollKeyboard();
-
-void RISCOS_PollMouseHelper(_THIS, int fullscreen);
-
-#if SDL_THREADS_DISABLED
-extern void DRenderer_FillBuffers();
-
-/* Timer running function */
-extern void RISCOS_CheckTimer();
-
-#endif
-
-void
-FULLSCREEN_PumpEvents(_THIS)
-{
-    /* Current implementation requires keyboard and mouse polling */
-    RISCOS_PollKeyboard();
-    RISCOS_PollMouse(this);
-#if SDL_THREADS_DISABLED
-//      DRenderer_FillBuffers();
-    if (SDL_timer_running)
-        RISCOS_CheckTimer();
-#endif
-}
-
-
-void
-RISCOS_InitOSKeymap(_THIS)
-{
-    int i;
-
-    /* Map the VK keysyms */
-    for (i = 0; i < SDL_arraysize(RO_keymap); ++i)
-        RO_keymap[i] = SDLK_UNKNOWN;
-
-    RO_keymap[3] = SDLK_LSHIFT;
-    RO_keymap[4] = SDLK_LCTRL;
-    RO_keymap[5] = SDLK_LALT;
-    RO_keymap[6] = SDLK_RSHIFT;
-    RO_keymap[7] = SDLK_RCTRL;
-    RO_keymap[8] = SDLK_RALT;
-    RO_keymap[16] = SDLK_q;
-    RO_keymap[17] = SDLK_3;
-    RO_keymap[18] = SDLK_4;
-    RO_keymap[19] = SDLK_5;
-    RO_keymap[20] = SDLK_F4;
-    RO_keymap[21] = SDLK_8;
-    RO_keymap[22] = SDLK_F7;
-    RO_keymap[23] = SDLK_MINUS, RO_keymap[25] = SDLK_LEFT;
-    RO_keymap[26] = SDLK_KP6;
-    RO_keymap[27] = SDLK_KP7;
-    RO_keymap[28] = SDLK_F11;
-    RO_keymap[29] = SDLK_F12;
-    RO_keymap[30] = SDLK_F10;
-    RO_keymap[31] = SDLK_SCROLLOCK;
-    RO_keymap[32] = SDLK_PRINT;
-    RO_keymap[33] = SDLK_w;
-    RO_keymap[34] = SDLK_e;
-    RO_keymap[35] = SDLK_t;
-    RO_keymap[36] = SDLK_7;
-    RO_keymap[37] = SDLK_i;
-    RO_keymap[38] = SDLK_9;
-    RO_keymap[39] = SDLK_0;
-    RO_keymap[41] = SDLK_DOWN;
-    RO_keymap[42] = SDLK_KP8;
-    RO_keymap[43] = SDLK_KP9;
-    RO_keymap[44] = SDLK_BREAK;
-    RO_keymap[45] = SDLK_BACKQUOTE;
-/*  RO_keymap[46] = SDLK_currency; TODO: Figure out if this has a value */
-    RO_keymap[47] = SDLK_BACKSPACE;
-    RO_keymap[48] = SDLK_1;
-    RO_keymap[49] = SDLK_2;
-    RO_keymap[50] = SDLK_d;
-    RO_keymap[51] = SDLK_r;
-    RO_keymap[52] = SDLK_6;
-    RO_keymap[53] = SDLK_u;
-    RO_keymap[54] = SDLK_o;
-    RO_keymap[55] = SDLK_p;
-    RO_keymap[56] = SDLK_LEFTBRACKET;
-    RO_keymap[57] = SDLK_UP;
-    RO_keymap[58] = SDLK_KP_PLUS;
-    RO_keymap[59] = SDLK_KP_MINUS;
-    RO_keymap[60] = SDLK_KP_ENTER;
-    RO_keymap[61] = SDLK_INSERT;
-    RO_keymap[62] = SDLK_HOME;
-    RO_keymap[63] = SDLK_PAGEUP;
-    RO_keymap[64] = SDLK_CAPSLOCK;
-    RO_keymap[65] = SDLK_a;
-    RO_keymap[66] = SDLK_x;
-    RO_keymap[67] = SDLK_f;
-    RO_keymap[68] = SDLK_y;
-    RO_keymap[69] = SDLK_j;
-    RO_keymap[70] = SDLK_k;
-    RO_keymap[72] = SDLK_SEMICOLON;
-    RO_keymap[73] = SDLK_RETURN;
-    RO_keymap[74] = SDLK_KP_DIVIDE;
-    RO_keymap[76] = SDLK_KP_PERIOD;
-    RO_keymap[77] = SDLK_NUMLOCK;
-    RO_keymap[78] = SDLK_PAGEDOWN;
-    RO_keymap[79] = SDLK_QUOTE;
-    RO_keymap[81] = SDLK_s;
-    RO_keymap[82] = SDLK_c;
-    RO_keymap[83] = SDLK_g;
-    RO_keymap[84] = SDLK_h;
-    RO_keymap[85] = SDLK_n;
-    RO_keymap[86] = SDLK_l;
-    RO_keymap[87] = SDLK_SEMICOLON;
-    RO_keymap[88] = SDLK_RIGHTBRACKET;
-    RO_keymap[89] = SDLK_DELETE;
-    RO_keymap[90] = SDLK_KP_MINUS;
-    RO_keymap[91] = SDLK_KP_MULTIPLY;
-    RO_keymap[93] = SDLK_EQUALS;
-    RO_keymap[94] = SDLK_BACKSLASH;
-    RO_keymap[96] = SDLK_TAB;
-    RO_keymap[97] = SDLK_z;
-    RO_keymap[98] = SDLK_SPACE;
-    RO_keymap[99] = SDLK_v;
-    RO_keymap[100] = SDLK_b;
-    RO_keymap[101] = SDLK_m;
-    RO_keymap[102] = SDLK_COMMA;
-    RO_keymap[103] = SDLK_PERIOD;
-    RO_keymap[104] = SDLK_SLASH;
-    RO_keymap[105] = SDLK_END;
-    RO_keymap[106] = SDLK_KP0;
-    RO_keymap[107] = SDLK_KP1;
-    RO_keymap[108] = SDLK_KP3;
-    RO_keymap[112] = SDLK_ESCAPE;
-    RO_keymap[113] = SDLK_F1;
-    RO_keymap[114] = SDLK_F2;
-    RO_keymap[115] = SDLK_F3;
-    RO_keymap[116] = SDLK_F5;
-    RO_keymap[117] = SDLK_F6;
-    RO_keymap[118] = SDLK_F8;
-    RO_keymap[119] = SDLK_F9;
-    RO_keymap[120] = SDLK_HASH;
-    RO_keymap[121] = SDLK_RIGHT;
-    RO_keymap[122] = SDLK_KP4;
-    RO_keymap[123] = SDLK_KP5;
-    RO_keymap[124] = SDLK_KP2;
-
-    SDL_memset(RO_pressed, 0, ROKEYBD_ARRAYSIZE);
-}
-
-
-/* Variable for mouse relative processing */
-int mouse_relative = 0;
-
-/* Check to see if we need to enter or leave mouse relative mode */
-
-void
-RISCOS_CheckMouseMode(_THIS)
-{
-    /* If the mouse is hidden and input is grabbed, we use relative mode */
-    if (!(SDL_cursorstate & CURSOR_VISIBLE) &&
-        (this->input_grab != SDL_GRAB_OFF)) {
-        mouse_relative = 1;
-    } else {
-        mouse_relative = 0;
-    }
-}
-
-
-void
-RISCOS_PollMouse(_THIS)
-{
-    RISCOS_PollMouseHelper(this, 1);
-}
-
-extern int mouseInWindow;
-
-void
-WIMP_PollMouse(_THIS)
-{
-    /* Only poll when mouse is over the window */
-    if (!mouseInWindow)
-        return;
-
-    RISCOS_PollMouseHelper(this, 0);
-}
-
-/* Static variables so only changes are reported */
-static Sint16 last_x = -1, last_y = -1;
-static int last_buttons = 0;
-
-/* Share routine between WIMP and FULLSCREEN for polling mouse and
-   passing on events */
-void
-RISCOS_PollMouseHelper(_THIS, int fullscreen)
-{
-    _kernel_swi_regs regs;
-    static int starting = 1;
-
-    if (_kernel_swi(OS_Mouse, &regs, &regs) == NULL) {
-        Sint16 new_x = regs.r[0];       /* Initialy get as OS units */
-        Sint16 new_y = regs.r[1];
-
-        /* Discard mouse events until they let go of the mouse after starting */
-        if (starting && regs.r[2] != 0)
-            return;
-        else
-            starting = 0;
-
-        if (new_x != last_x || new_y != last_y || last_buttons != regs.r[2]) {
-            /* Something changed so generate appropriate events */
-            int topLeftX, topLeftY;     /* Top left OS units */
-            int x, y;           /* Mouse position in SDL pixels */
-
-            if (fullscreen) {
-                topLeftX = 0;
-                topLeftY = (this->hidden->height << this->hidden->yeig) - 1;
-            } else {
-                int window_state[9];
-
-                /* Get current window state */
-                window_state[0] = this->hidden->window_handle;
-                regs.r[1] = (unsigned int) window_state;
-                _kernel_swi(Wimp_GetWindowState, &regs, &regs);
-
-                topLeftX = window_state[1];
-                topLeftY = window_state[4];
-            }
-
-            /* Convert co-ordinates to workspace */
-            x = new_x - topLeftX;
-            y = topLeftY - new_y;       /* Y goes from top of window/screen */
-
-            /* Convert OS units to pixels */
-            x >>= this->hidden->xeig;
-            y >>= this->hidden->yeig;
-
-            if (last_x != new_x || last_y != new_y) {
-                if (mouse_relative) {
-                    int centre_x = SDL_VideoSurface->w / 2;
-                    int centre_y = SDL_VideoSurface->h / 2;
-
-                    if (centre_x != x || centre_y != y) {
-                        if (SDL_VideoSurface)
-                            SDL_PrivateMouseMotion(0, 1,
-                                                   x - centre_x,
-                                                   y - centre_y);
-                        last_x = topLeftX + (centre_x << this->hidden->xeig);
-                        last_y = topLeftY - (centre_y << this->hidden->yeig);
-
-                        /* Re-centre the mouse pointer, so we still get relative
-                           movement when the mouse is at the edge of the window
-                           or screen.
-                         */
-                        {
-                            unsigned char block[5];
-
-                            block[0] = 3;       /* OSWORD move pointer sub-reason code */
-                            block[1] = last_x & 0xFF;
-                            block[2] = (last_x >> 8) & 0xFF;
-                            block[3] = last_y & 0xFF;
-                            block[4] = (last_y >> 8) & 0xFF;
-
-                            regs.r[0] = 21;     /* OSWORD pointer stuff code */
-                            regs.r[1] = (int) block;
-                            _kernel_swi(OS_Word, &regs, &regs);
-                        }
-                    }
-                } else {
-                    last_x = new_x;
-                    last_y = new_y;
-                    SDL_PrivateMouseMotion(0, 0, x, y);
-                }
-            }
-
-            if (last_buttons != regs.r[2]) {
-                int changed = last_buttons ^ regs.r[2];
-                last_buttons = regs.r[2];
-                if (changed & 4)
-                    SDL_PrivateMouseButton((last_buttons & 4) ?
-                                           SDL_PRESSED : SDL_RELEASED,
-                                           SDL_BUTTON_LEFT, 0, 0);
-                if (changed & 2)
-                    SDL_PrivateMouseButton((last_buttons & 2) ?
-                                           SDL_PRESSED : SDL_RELEASED,
-                                           SDL_BUTTON_MIDDLE, 0, 0);
-                if (changed & 1)
-                    SDL_PrivateMouseButton((last_buttons & 1) ?
-                                           SDL_PRESSED : SDL_RELEASED,
-                                           SDL_BUTTON_RIGHT, 0, 0);
-            }
-        }
-    }
-}
-
-void
-RISCOS_PollKeyboard()
-{
-    int which_key = ROKEY_LEFT_SHIFT;
-    int j;
-    int min_key, max_key;
-    SDL_keysym key;
-
-    /* Scan the keyboard to see what is pressed */
-    while (which_key <= ROKEY_LAST_KEY) {
-        which_key = (_kernel_osbyte(121, which_key, 0) & 0xFF);
-        if (which_key != ROKEY_NONE) {
-            switch (which_key) {
-                /* Skip over mouse keys */
-            case ROKEY_LEFT_MOUSE:
-            case ROKEY_CENTRE_MOUSE:
-            case ROKEY_RIGHT_MOUSE:
-                which_key = ROKEY_RIGHT_MOUSE;
-                break;
-
-                /* Ignore keys that cause 2 internal number to be generated */
-            case 71:
-            case 24:
-            case 87:
-            case 40:
-                break;
-
-                /* Ignore break as it can be latched on */
-            case 44:
-                break;
-
-            default:
-                RO_pressed[which_key] += 2;
-                break;
-            }
-            which_key++;
-        }
-    }
-
-    /* Generate key released messages */
-    min_key = ROKEY_LAST_KEY + 1;
-    max_key = ROKEY_LEFT_SHIFT;
-
-    for (j = ROKEY_LEFT_SHIFT; j <= ROKEY_LAST_KEY; j++) {
-        if (RO_pressed[j]) {
-            if (RO_pressed[j] == 1) {
-                RO_pressed[j] = 0;
-                SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(j, &key, 0));
-            } else {
-                if (j < min_key)
-                    min_key = j;
-                if (j > max_key)
-                    max_key = j;
-            }
-        }
-    }
-
-    /* Generate key pressed messages */
-    for (j = min_key; j <= max_key; j++) {
-        if (RO_pressed[j]) {
-            if (RO_pressed[j] == 2) {
-                SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(j, &key, 1));
-            }
-            RO_pressed[j] = 1;
-        }
-    }
-}
-
-static SDL_keysym *
-TranslateKey(int intkey, SDL_keysym * keysym, int pressed)
-{
-    /* Set the keysym information */
-    keysym->scancode = (unsigned char) intkey;
-    keysym->sym = RO_keymap[intkey];
-    keysym->mod = KMOD_NONE;
-    keysym->unicode = 0;
-    if (pressed && SDL_TranslateUNICODE) {
-        int state;
-        int ch;
-
-        state = (_kernel_osbyte(202, 0, 255) & 0xFF);
-
-        /*TODO: Take into account other keyboard layouts */
-
-        ch = keysym->sym;       /* This should handle most unshifted keys */
-
-        if (intkey < 9 || ch == SDLK_UNKNOWN) {
-            ch = 0;
-
-        } else if (state & 64) {        /* Control on */
-            ch = ch & 31;
-
-        } else {
-            int topOfKey = 0;
-            if (state & 8) {    /* Shift on */
-                topOfKey = 1;
-            }
-
-            if ((state & 16) == 0) {    /* Caps lock is on */
-                if (ch >= SDLK_a && ch <= SDLK_z) {
-                    if ((state & 128) == 0) {   /* Shift Enable off */
-                        /* All letter become upper case */
-                        topOfKey = 1;
-                    } else {
-                        /* Shift+Letters gives lower case */
-                        topOfKey = 1 - topOfKey;
-                    }
-                }
-            }
-
-            if (topOfKey) {
-                /* Key produced with shift held down */
-
-                /* Letters just give upper case version */
-                if (ch >= SDLK_a && ch <= SDLK_z)
-                    ch = toupper(ch);
-                else {
-                    switch (ch) {
-                    case SDLK_HASH:
-                        ch = '~';
-                        break;
-                    case SDLK_QUOTE:
-                        ch = '@';
-                        break;
-                    case SDLK_COMMA:
-                        ch = '<';
-                        break;
-                    case SDLK_MINUS:
-                        ch = '_';
-                        break;
-                    case SDLK_PERIOD:
-                        ch = '>';
-                        break;
-                    case SDLK_SLASH:
-                        ch = '?';
-                        break;
-
-                    case SDLK_0:
-                        ch = ')';
-                        break;
-                    case SDLK_1:
-                        ch = '!';
-                        break;
-                    case SDLK_2:
-                        ch = '"';
-                        break;
-                    case SDLK_3:
-                        ch = '£';
-                        break;
-                    case SDLK_4:
-                        ch = '$';
-                        break;
-                    case SDLK_5:
-                        ch = '%';
-                        break;
-                    case SDLK_6:
-                        ch = '^';
-                        break;
-                    case SDLK_7:
-                        ch = '&';
-                        break;
-                    case SDLK_8:
-                        ch = '*';
-                        break;
-                    case SDLK_9:
-                        ch = '(';
-                        break;
-
-                    case SDLK_SEMICOLON:
-                        ch = ':';
-                        break;
-                    case SDLK_EQUALS:
-                        ch = '+';
-                        break;
-                    case SDLK_LEFTBRACKET:
-                        ch = '{';
-                        break;
-                    case SDLK_BACKSLASH:
-                        ch = '|';
-                        break;
-                    case SDLK_RIGHTBRACKET:
-                        ch = '}';
-                        break;
-                    case SDLK_BACKQUOTE:
-                        ch = '¬';
-                        break;
-
-                    default:
-                        ch = 0; /* Map to zero character if we don't understand it */
-                        break;
-                    }
-                }
-
-            } else if (ch > 126) {
-                /* SDL key code < 126 map directly onto their Unicode equivalents */
-                /* Keypad 0 to 9 maps to numeric equivalent */
-                if (ch >= SDLK_KP0 && ch <= SDLK_KP9)
-                    ch = ch - SDLK_KP0 + '0';
-                else {
-                    /* Following switch maps other keys that produce an Ascii value */
-                    switch (ch) {
-                    case SDLK_KP_PERIOD:
-                        ch = '.';
-                        break;
-                    case SDLK_KP_DIVIDE:
-                        ch = '/';
-                        break;
-                    case SDLK_KP_MULTIPLY:
-                        ch = '*';
-                        break;
-                    case SDLK_KP_MINUS:
-                        ch = '-';
-                        break;
-                    case SDLK_KP_PLUS:
-                        ch = '+';
-                        break;
-                    case SDLK_KP_EQUALS:
-                        ch = '=';
-                        break;
-
-                    default:
-                        /* If we don't know what it is set the Unicode to 0 */
-                        ch = 0;
-                        break;
-                    }
-                }
-            }
-        }
-
-        keysym->unicode = ch;
-    }
-    return (keysym);
-}
-
-/* end of SDL_riscosevents.c ... */
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscosevents_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,34 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_riscosvideo.h"
-
-/* Variables and functions exported by SDL_sysevents.c to other parts 
-   of the native video subsystem (SDL_sysvideo.c)
-*/
-extern void RISCOS_InitOSKeymap(_THIS);
-extern void FULLSCREEN_PumpEvents(_THIS);
-extern void WIMP_PumpEvents(_THIS);
-
-/* end of SDL_nullevents_c.h ... */
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscosmouse.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,380 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
-	 27 March 2003
-
-     Implements mouse cursor shape definitions and positioning
-*/
-
-#include "SDL_mouse.h"
-#include "../../events/SDL_events_c.h"
-
-#include "SDL_riscosmouse_c.h"
-
-#include "kernel.h"
-#include "swis.h"
-
-static WMcursor *current_cursor = NULL;
-static WMcursor *defined_cursor = NULL;
-
-extern int mouseInWindow;
-
-/* Area to save cursor palette colours changed by SDL.
-   Actual values will be read before we change to the SDL cursor */
-static Uint8 wimp_cursor_palette[2][5] = {
-    {1, 25, 255, 255, 255},
-    {3, 25, 255, 255, 255}
-};
-
-static int cursor_palette_saved = 0;
-
-void WIMP_SaveCursorPalette();
-void WIMP_RestoreWimpCursor();
-void WIMP_SetSDLCursorPalette();
-
-
-void
-RISCOS_FreeWMCursor(_THIS, WMcursor * cursor)
-{
-    SDL_free(cursor->data);
-    SDL_free(cursor);
-}
-
-WMcursor *
-RISCOS_CreateWMCursor(_THIS,
-                      Uint8 * data, Uint8 * mask, int w, int h, int hot_x,
-                      int hot_y)
-{
-    WMcursor *cursor;
-    Uint8 *cursor_data;
-    Uint8 *ptr;
-    int i, j, k;
-    int data_byte, mask_byte;
-
-    /* Check to make sure the cursor size is okay */
-    if ((w > 32) || (h > 32)) {
-        SDL_SetError("Only with width and height <= 32 pixels are allowed");
-        return (NULL);
-    }
-
-    /* Allocate the cursor */
-    cursor = (WMcursor *) SDL_malloc(sizeof(*cursor));
-    if (cursor == NULL) {
-        SDL_SetError("Out of memory");
-        return (NULL);
-    }
-
-    /* Note: SDL says width must be a multiple of 8 */
-    cursor_data = SDL_malloc(w / 4 * h);
-    if (cursor_data == NULL) {
-        SDL_free(cursor);
-        SDL_SetError("Out of memory");
-        return (NULL);
-    }
-
-    cursor->w = w;
-    cursor->h = h;
-    cursor->hot_x = hot_x;
-    cursor->hot_y = hot_y;
-    cursor->data = cursor_data;
-
-
-/* Data / Mask Resulting pixel on screen 
-   0 / 1 White 
-   1 / 1 Black 
-   0 / 0 Transparent 
-   1 / 0 Inverted color if possible, black if not. 
-*/
-    ptr = cursor_data;
-
-    for (i = 0; i < h; ++i) {
-        for (j = 0; j < w / 8; ++j) {
-            data_byte = *data;
-            mask_byte = *mask;
-            *ptr++ = 0;         /* Sets whole byte transparent */
-            *ptr = 0;
-            for (k = 0; k < 8; k++) {
-                (*ptr) <<= 2;
-                if (data_byte & 1)
-                    *ptr |= 3;  /* Black or inverted */
-                else if (mask_byte & 1)
-                    *ptr |= 1;  /* White */
-                if ((k & 3) == 3)
-                    ptr--;
-                data_byte >>= 1;
-                mask_byte >>= 1;
-            }
-
-            ptr += 3;
-            data++;
-            mask++;
-        }
-    }
-
-    return (cursor);
-}
-
-int
-RISCOS_ShowWMCursor(_THIS, WMcursor * cursor)
-{
-    current_cursor = cursor;
-
-    if (cursor == NULL) {
-        _kernel_osbyte(106, 0, 0);
-        defined_cursor = NULL;
-    } else {
-        WMcursor *old_cursor = defined_cursor;
-
-        if (cursor != defined_cursor) {
-            Uint8 cursor_def[10];
-
-            cursor_def[0] = 0;
-            cursor_def[1] = 2;  /* Use shape number 2 */
-            cursor_def[2] = cursor->w / 4;      /* Width in bytes */
-            cursor_def[3] = cursor->h;  /* Height (h) in pixels */
-            cursor_def[4] = cursor->hot_x;      /* ActiveX in pixels from left */
-            cursor_def[5] = cursor->hot_y;      /* ActiveY in pixels from top */
-            cursor_def[6] = ((int) (cursor->data) & 0xFF);      /* Least significant byte of pointer to data */
-            cursor_def[7] = ((int) (cursor->data) >> 8) & 0xFF; /* ... */
-            cursor_def[8] = ((int) (cursor->data) >> 16) & 0xFF;        /* ... */
-            cursor_def[9] = ((int) (cursor->data) >> 24) & 0xFF;        /* Most significant byte of pointer to data */
-
-            if (_kernel_osword(21, (int *) cursor_def) != 0) {
-                SDL_SetError("RISCOS couldn't create the cursor to show");
-                return (0);
-            }
-            defined_cursor = cursor;
-        }
-
-        if (old_cursor == NULL) {
-            /* First time or reshow in window, so save/setup palette */
-            if (!cursor_palette_saved) {
-                WIMP_SaveCursorPalette();
-            }
-            WIMP_SetSDLCursorPalette();
-        }
-
-        _kernel_osbyte(106, 2, 0);
-    }
-
-    return (1);
-}
-
-void
-FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
-{
-    Uint8 move_block[5];
-    int eig_block[3];
-    _kernel_swi_regs regs;
-    int os_x, os_y;
-
-    eig_block[0] = 4;           /* X eig factor */
-    eig_block[1] = 5;           /* Y eig factor */
-    eig_block[2] = -1;          /* End of list of variables to request */
-
-    regs.r[0] = (int) eig_block;
-    regs.r[1] = (int) eig_block;
-    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
-
-    os_x = x << eig_block[0];
-    os_y = y << eig_block[1];
-
-    move_block[0] = 3;          /* Move cursor */
-    move_block[1] = os_x & 0xFF;
-    move_block[2] = (os_x >> 8) & 0xFF;
-    move_block[3] = os_y & 0xFF;
-    move_block[4] = (os_y >> 8) & 0xFF;
-
-    _kernel_osword(21, (int *) move_block);
-    SDL_PrivateMouseMotion(0, 0, x, y);
-}
-
-
-/* Reshow cursor when mouse re-enters the window */
-void
-WIMP_ReshowCursor(_THIS)
-{
-    defined_cursor = NULL;
-    cursor_palette_saved = 0;
-    RISCOS_ShowWMCursor(this, current_cursor);
-}
-
-void
-WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
-{
-    _kernel_swi_regs regs;
-    int window_state[9];
-    char block[5];
-    int osX, osY;
-
-    window_state[0] = this->hidden->window_handle;
-    regs.r[1] = (unsigned int) window_state;
-    _kernel_swi(Wimp_GetWindowState, &regs, &regs);
-
-    osX = (x << this->hidden->xeig) + window_state[1];
-    osY = window_state[4] - (y << this->hidden->yeig);
-
-    block[0] = 3;
-    block[1] = osX & 0xFF;
-    block[2] = (osX >> 8) & 0xFF;
-    block[3] = osY & 0xFF;
-    block[4] = (osY >> 8) & 0xFF;
-
-    regs.r[0] = 21;
-    regs.r[1] = (int) block;
-    _kernel_swi(OS_Word, &regs, &regs);
-    SDL_PrivateMouseMotion(0, 0, x, y);
-}
-
-int
-WIMP_ShowWMCursor(_THIS, WMcursor * cursor)
-{
-    if (mouseInWindow)
-        return RISCOS_ShowWMCursor(this, cursor);
-    else
-        current_cursor = cursor;
-
-    return 1;
-}
-
-SDL_GrabMode
-RISCOS_GrabInput(_THIS, SDL_GrabMode mode)
-{
-    /* In fullscreen mode we don't need to do anything */
-    if (mode < SDL_GRAB_FULLSCREEN) {
-        _kernel_swi_regs regs;
-        unsigned char block[9];
-        block[0] = 1;           /* Define mouse cursor bounding block */
-
-        if (mode == SDL_GRAB_OFF) {
-            /* Clip to whole screen */
-
-            int r = (this->hidden->screen_width << this->hidden->xeig) - 1;
-            int t = (this->hidden->screen_height << this->hidden->yeig) - 1;
-
-            block[1] = 0;
-            block[2] = 0;       /* Left */
-            block[3] = 0;
-            block[4] = 0;       /* Bottom */
-            block[5] = r & 0xFF;
-            block[6] = (r >> 8) & 0xFF; /* Right */
-            block[7] = t & 0xFF;
-            block[8] = (t >> 8) & 0xFF; /* Top */
-        } else {
-            /* Clip to window */
-            unsigned char window_state[36];
-
-            *((int *) window_state) = this->hidden->window_handle;
-            regs.r[1] = (unsigned int) window_state;
-            _kernel_swi(Wimp_GetWindowState, &regs, &regs);
-
-            block[1] = window_state[4];
-            block[2] = window_state[5];
-            block[3] = window_state[8];
-            block[4] = window_state[9];
-            block[5] = window_state[12];
-            block[6] = window_state[13];
-            block[7] = window_state[16];
-            block[8] = window_state[17];
-
-        }
-
-        regs.r[0] = 21;         /* OS word code */
-        regs.r[1] = (int) block;
-        _kernel_swi(OS_Word, &regs, &regs);
-    }
-
-    return mode;
-}
-
-/* Save mouse cursor palette to be restore when we are no longer
-   defining a cursor */
-
-void
-WIMP_SaveCursorPalette()
-{
-    _kernel_swi_regs regs;
-    int colour;
-
-    for (colour = 0; colour < 2; colour++) {
-        regs.r[0] = (int) wimp_cursor_palette[colour][0];
-        regs.r[1] = 25;
-        /* Read settings with OS_ReadPalette */
-        if (_kernel_swi(0x2f, &regs, &regs) == NULL) {
-            wimp_cursor_palette[colour][2] =
-                (unsigned char) ((regs.r[2] >> 8) & 0xFF);
-            wimp_cursor_palette[colour][3] =
-                (unsigned char) ((regs.r[2] >> 16) & 0xFF);
-            wimp_cursor_palette[colour][4] =
-                (unsigned char) ((regs.r[2] >> 24) & 0xFF);
-        }
-    }
-
-    cursor_palette_saved = 1;
-}
-
-/* Restore the WIMP's cursor when we leave the SDL window */
-void
-WIMP_RestoreWimpCursor()
-{
-    int colour;
-
-    /* Reset to pointer shape 1 */
-    _kernel_osbyte(106, 1, 0);
-
-    /* Reset pointer colours */
-    if (cursor_palette_saved) {
-        for (colour = 0; colour < 2; colour++) {
-            _kernel_osword(12, (int *) wimp_cursor_palette[colour]);
-        }
-    }
-    cursor_palette_saved = 0;
-}
-
-/* Set palette used for SDL mouse cursors */
-void
-WIMP_SetSDLCursorPalette()
-{
-    /* First time set up the mouse colours */
-    Uint8 block[5];
-
-    /* Set up colour 1 as white */
-    block[0] = 1;               /* Colour to change 1 - 3 */
-    block[1] = 25;              /* Set pointer colour */
-    block[2] = 255;             /* red component */
-    block[3] = 255;             /* green component */
-    block[4] = 255;             /* blue component */
-    _kernel_osword(12, (int *) block);
-
-    /* Set colour 3 to back */
-    block[0] = 3;               /* Colour to change 1 - 3 */
-    block[1] = 25;              /* Set pointer colour */
-    block[2] = 0;               /* red component */
-    block[3] = 0;               /* green component */
-    block[4] = 0;               /* blue component */
-    _kernel_osword(12, (int *) block);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscosmouse_c.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,46 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#include "SDL_riscosvideo.h"
-
-/* The implementation dependent data for the window manager cursor */
-struct WMcursor
-{
-    int w;
-    int h;
-    int hot_x;
-    int hot_y;
-    Uint8 *data;
-};
-
-/* Functions to be exported */
-void RISCOS_FreeWMCursor(_THIS, WMcursor * cursor);
-WMcursor *RISCOS_CreateWMCursor(_THIS, Uint8 * data, Uint8 * mask, int w,
-                                int h, int hot_x, int hot_y);
-
-int RISCOS_ShowWMCursor(_THIS, WMcursor * cursor);
-void FULLSCREEN_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
-
-int WIMP_ShowWMCursor(_THIS, WMcursor * cursor);
-void WIMP_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscossprite.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,263 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
-	 27 March 2003
-
-     Implements Sprite plotting code for wimp display.window
-*/
-
-#include "kernel.h"
-#include "swis.h"
-
-#include "SDL_stdinc.h"
-#include "SDL_riscosvideo.h"
-
-extern void WIMP_ReadModeInfo(_THIS);
-
-void WIMP_PaletteChanged(_THIS);
-
-
-/* Create sprite buffer for screen */
-
-unsigned char *
-WIMP_CreateBuffer(int width, int height, int bpp)
-{
-    int size;
-    char sprite_name[12] = "display";
-    unsigned char *buffer;
-    _kernel_swi_regs regs;
-    int bytesPerPixel;
-    int bytesPerRow;
-    int offsetToSpriteData = 60;
-
-    switch (bpp) {
-    case 32:
-        bytesPerPixel = 4;
-        break;
-    case 16:
-        bytesPerPixel = 2;
-        break;
-    case 8:
-        bytesPerPixel = 1;
-        offsetToSpriteData += 2048;     /* Add in size of palette */
-        break;
-    default:
-        return NULL;
-        break;
-    }
-
-    bytesPerRow = bytesPerPixel * width;
-
-    if ((bytesPerRow & 3) != 0) {
-        bytesPerRow += 4 - (bytesPerRow & 3);
-    }
-    size = bytesPerRow * height;
-
-    buffer = SDL_malloc((size_t) size + offsetToSpriteData);
-    if (!buffer)
-        return NULL;
-
-    /* Initialise a sprite area */
-
-    *(unsigned int *) buffer = size + offsetToSpriteData;
-    *(unsigned int *) (buffer + 8) = 16;
-
-    regs.r[0] = 256 + 9;
-    regs.r[1] = (unsigned int) buffer;
-    _kernel_swi(OS_SpriteOp, &regs, &regs);
-
-    regs.r[0] = 256 + 15;
-    regs.r[1] = (unsigned int) buffer;
-    regs.r[2] = (unsigned int) &sprite_name;
-    regs.r[3] = 0;              /* Palette flag: 0 = no palette */
-    regs.r[4] = width;
-    regs.r[5] = height;
-    if (bpp == 8) {
-        /* Use old style mode number */
-        regs.r[6] = 28;         /* 8bpp 90x90dpi */
-    } else {
-        regs.r[6] = (((bpp == 16) ? 5 : 6) << 27)       /* Type 6 = 32bpp sprite, 5 = 16bpp sprite */
-            |(90 << 14)         /* Vertical dpi */
-            |(90 << 1)          /* Horizontal dpi */
-            |1;                 /* Marker to distinguish between mode selectors and sprite modes */
-    }
-    if (_kernel_swi(OS_SpriteOp, &regs, &regs) == NULL) {
-        if (bpp == 8) {
-            /* Modify sprite to take into account 256 colour palette */
-            int *sprite = (int *) (buffer + 16);
-            /* Adjust sprite offsets */
-            sprite[0] += 2048;
-            sprite[8] += 2048;
-            sprite[9] += 2048;
-            /* Adjust sprite area next free pointer */
-            (*(int *) (buffer + 12)) += 2048;
-
-            /* Don't need to set up palette as SDL sets up the default
-               256 colour palette */
-/*          {
-             int *pal = sprite + 11;
-             unsigned int j;
-             unsigned int entry;
-             for (j = 0; j < 255; j++)
-             {
-                entry = (j << 24) | (j << 16) | (j << 8);
-                *pal++ = entry;
-                *pal++ = entry;
-             }
-          }
-*/
-        }
-    } else {
-        SDL_free(buffer);
-        buffer = NULL;
-    }
-
-    return buffer;
-}
-
-
-/* Setup translation buffers for the sprite plotting */
-
-void
-WIMP_SetupPlotInfo(_THIS)
-{
-    _kernel_swi_regs regs;
-    int *sprite = ((int *) this->hidden->bank[1]) + 4;
-
-    regs.r[0] = (unsigned int) this->hidden->bank[1];
-    regs.r[1] = (unsigned int) sprite;
-    regs.r[2] = -1;             /* Current mode */
-    regs.r[3] = -1;             /* Current palette */
-    regs.r[4] = 0;              /* Get size of buffer */
-    regs.r[5] = 1 | 2 | 16;     /* R1 - pointer to sprite and can use full palette words */
-    regs.r[6] = 0;
-    regs.r[7] = 0;
-
-    if (this->hidden->pixtrans)
-        SDL_free(this->hidden->pixtrans);
-    this->hidden->pixtrans = 0;
-
-    /* Get the size required for the buffer */
-    _kernel_swi(ColourTrans_GenerateTable, &regs, &regs);
-    if (regs.r[4]) {
-        this->hidden->pixtrans = SDL_malloc(regs.r[4]);
-
-        regs.r[4] = (unsigned int) this->hidden->pixtrans;
-        /* Actually read the buffer */
-        _kernel_swi(ColourTrans_GenerateTable, &regs, &regs);
-    }
-}
-
-/* Plot the sprite in the given context */
-void
-WIMP_PlotSprite(_THIS, int x, int y)
-{
-    _kernel_swi_regs regs;
-    _kernel_oserror *err;
-
-    regs.r[0] = 52 + 512;
-    regs.r[1] = (unsigned int) this->hidden->bank[1];
-    regs.r[2] = (unsigned int) this->hidden->bank[1] + 16;
-    regs.r[3] = x;
-    regs.r[4] = y;
-    regs.r[5] = 0 | 32;         /* Overwrite screen and pixtrans contains wide colour entries */
-    regs.r[6] = 0;              /* No scale factors i.e. 1:1 */
-    regs.r[7] = (int) this->hidden->pixtrans;
-
-    if ((err = _kernel_swi(OS_SpriteOp, &regs, &regs)) != 0) {
-        int *p = (int *) this->hidden->pixtrans;
-        printf("OS_SpriteOp failed \n%s\n", err->errmess);
-        printf("pixtrans %d\n", (int) this->hidden->pixtrans);
-        printf("%x %x %x\n", p[0], p[1], p[2]);
-    }
-}
-
-
-/* Wimp mode has changes so update colour mapping and pixel sizes 
-   of windows and the sprites they plot */
-
-void
-WIMP_ModeChanged(_THIS)
-{
-    int oldXeig = this->hidden->xeig;
-    int oldYeig = this->hidden->yeig;
-
-    WIMP_ReadModeInfo(this);
-
-    if (oldXeig == this->hidden->xeig && oldYeig == this->hidden->yeig) {
-        /* Only need to update the palette */
-        WIMP_PaletteChanged(this);
-    } else {
-        _kernel_swi_regs regs;
-        int window_state[9];
-        int extent[4];
-        int currWidth, currHeight;
-        int newWidth, newHeight;
-
-        /* Need to resize windows and update the palette */
-        WIMP_SetupPlotInfo(this);
-
-
-        window_state[0] = this->hidden->window_handle;
-        regs.r[1] = (unsigned int) window_state;
-        _kernel_swi(Wimp_GetWindowState, &regs, &regs);
-
-        currWidth = window_state[3] - window_state[1];
-        currHeight = window_state[4] - window_state[2];
-
-        newWidth = (currWidth >> oldXeig) << this->hidden->xeig;
-        newHeight = (currHeight >> oldYeig) << this->hidden->yeig;
-        /* Need to avoid extent getting too small for visible part
-           of window */
-        extent[0] = 0;
-        if (currHeight <= newHeight) {
-            extent[1] = -newHeight;
-        } else {
-            extent[1] = -currHeight;
-        }
-        if (currWidth <= newWidth) {
-            extent[2] = newWidth;
-        } else {
-            extent[2] = currWidth;
-        }
-        extent[3] = 0;
-
-        regs.r[0] = this->hidden->window_handle;
-        regs.r[1] = (int) extent;
-        _kernel_swi(Wimp_SetExtent, &regs, &regs);
-
-        /*TODO: May need to set flag to resize window on next open */
-    }
-}
-
-/* Palette has changed so update palettes used for windows sprites */
-
-void
-WIMP_PaletteChanged(_THIS)
-{
-    WIMP_SetupPlotInfo(this);
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscostask.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,367 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
-	26 March 2003
-
-	File includes routines for:
-	  Setting up as a WIMP Task
-	  Reading information about the current desktop
-	  Storing information before a switch to full screen
-	  Restoring desktop after switching to full screen
-*/
-
-#include "kernel.h"
-#include "swis.h"
-
-#include "SDL_stdinc.h"
-#include "SDL_riscostask.h"
-
-#if !SDL_THREADS_DISABLED
-#include <pthread.h>
-pthread_t main_thread;
-#endif
-
-/* RISC OS variables */
-
-static int task_handle = 0;
-static int wimp_version = 0;
-
-/* RISC OS variables to help compatability with certain programs */
-int riscos_backbuffer = 0;      /* Create a back buffer in system memory for full screen mode */
-int riscos_closeaction = 1;     /* Close icon action */
-
-static int stored_mode = -1;    /* -1 when in desktop, mode number or pointer when full screen */
-
-extern int mouseInWindow;       /* Mouse is in WIMP window */
-
-/* Local function */
-
-static int RISCOS_GetTaskName(char *task_name, size_t maxlen);
-
-/* Uncomment next line to copy mode changes/restores to stderr */
-/* #define DUMP_MODE */
-#ifdef DUMP_MODE
-#include "stdio.h"
-static void
-dump_mode()
-{
-    fprintf(stderr, "mode %d\n", stored_mode);
-    if (stored_mode < -1 || stored_mode >= 256) {
-        int blockSize = 0;
-        int *storeBlock = (int *) stored_mode;
-
-        while (blockSize < 5 || storeBlock[blockSize] != -1) {
-            fprintf(stderr, "   %d\n", storeBlock[blockSize++]);
-        }
-    }
-}
-#endif
-
-/******************************************************************
-
- Initialise as RISC OS Wimp task
-
-*******************************************************************/
-
-int
-RISCOS_InitTask()
-{
-    char task_name[32];
-    _kernel_swi_regs regs;
-    int messages[4];
-
-    if (RISCOS_GetTaskName(task_name, SDL_arraysize(task_name)) == 0)
-        return 0;
-
-    messages[0] = 9;            /* Palette changed */
-    messages[1] = 0x400c1;      /* Mode changed */
-    messages[2] = 8;            /* Pre quit */
-    messages[2] = 0;
-
-    regs.r[0] = (unsigned int) 360;     /* Minimum version 3.6 */
-    regs.r[1] = (unsigned int) 0x4b534154;
-    regs.r[2] = (unsigned int) task_name;
-    regs.r[3] = (unsigned int) messages;
-
-    if (_kernel_swi(Wimp_Initialise, &regs, &regs) == 0) {
-        wimp_version = regs.r[0];
-        task_handle = regs.r[1];
-        return 1;
-    }
-#if !SDL_THREADS_DISABLED
-    main_thread = pthread_self();
-#endif
-
-    return 0;
-}
-
-/*********************************************************************
-
-  Close down application on exit.
-
-**********************************************************************/
-
-void
-RISCOS_ExitTask()
-{
-    _kernel_swi_regs regs;
-
-    if (stored_mode == -1) {
-        /* Ensure cursor is put back to standard pointer shape if
-           we have been running in a window */
-        _kernel_osbyte(106, 1, 0);
-    }
-
-    /* Ensure we end up back in the wimp */
-    RISCOS_RestoreWimpMode();
-
-    /* Neatly exit the task */
-    regs.r[0] = task_handle;
-    regs.r[1] = (unsigned int) 0x4b534154;
-    _kernel_swi(Wimp_CloseDown, &regs, &regs);
-    task_handle = 0;
-}
-
-/**************************************************************************
-
-  Get the name of the task for the desktop.
-
-  Param:   task_name - name of task 32 characters.
-
-  Returns: 1 is successful, otherwise 0
-
-  Notes:   Works by getting using OS_GetEnv to get the command line
-		   used to run the program and then parsing a name from it
-		   as follows.
-
-		   1. Use name after final period if not !RunImage
-		   2. If name is !RunImage then process item before the period
-		      in front of !RunImage.
-		   3. If directory name use that
-		   4. if in form <XXX$Dir> use the XXX.
-
-		   Finally once this value has been retrieved use it unless
-		   there is a variable set up in the form SDL$<name>$TaskName
-		   in which case the value of this variable will be used.
-
-		   Now also gets other RISC OS configuration varibles
-                SDL$<name>$BackBuffer - set to 1 to use a system memory backbuffer in fullscreen mode
-						    so updates wait until a call to SDL_UpdateRects. (default 0)
-						    This is required for programmes where they have assumed this is
-						    always the case which is contrary to the documentation.
-               SDL$<name>$CloseAction
-                    0 Don't show close icon
-                    1 Show close icon
-
-***************************************************************************/
-
-int
-RISCOS_GetTaskName(char *task_name, size_t maxlen)
-{
-    _kernel_swi_regs regs;
-
-    task_name[0] = 0;
-
-    /* Figure out a sensible task name */
-    if (_kernel_swi(OS_GetEnv, &regs, &regs) == 0) {
-        char *command_line = (char *) regs.r[0];
-        size_t len = SDL_strlen(command_line) + 1;
-        char *buffer = SDL_stack_alloc(char, len);
-        char *env_var;
-        char *p;
-
-        SDL_strlcpy(buffer, command_line, len);
-        p = SDL_strchr(buffer, ' ');
-        if (p)
-            *p = 0;
-        p = SDL_strrchr(buffer, '.');
-        if (p == 0)
-            p = buffer;
-        if (stricmp(p + 1, "!RunImage") == 0) {
-            *p = 0;
-            p = SDL_strrchr(buffer, '.');
-            if (p == 0)
-                p = buffer;
-        }
-        if (*p == '.')
-            p++;
-        if (*p == '!')
-            p++;                /* Skip "!" at beginning of application directories */
-
-        if (*p == '<') {
-            // Probably in the form <appname$Dir>
-            char *q = SDL_strchr(p, '$');
-            if (q == 0)
-                q = SDL_strchr(p, '>'); /* Use variable name if not */
-            if (q)
-                *q = 0;
-            p++;                /* Move over the < */
-        }
-
-        if (*p) {
-            /* Read variables that effect the RISC OS SDL engine for this task */
-            len = SDL_strlen(p) + 18;   /* 18 is larger than the biggest variable name */
-            env_var = SDL_stack_alloc(char, len);
-            if (env_var) {
-                char *env_val;
-
-                /* See if a variable of form SDL$<dirname>$TaskName exists */
-
-                SDL_strlcpy(env_var, "SDL$", len);
-                SDL_strlcat(env_var, p, len);
-                SDL_strlcat(env_var, "$TaskName", len);
-
-                env_val = SDL_getenv(env_var);
-                if (env_val)
-                    SDL_strlcpy(task_name, env_val, maxlen);
-
-                SDL_strlcpy(env_var, "SDL$", len);
-                SDL_strlcat(env_var, p, len);
-                SDL_strlcat(env_var, "$BackBuffer", len);
-
-                env_val = SDL_getenv(env_var);
-                if (env_val)
-                    riscos_backbuffer = atoi(env_val);
-
-                SDL_strlcpy(env_var, "SDL$", len);
-                SDL_strlcat(env_var, p, len);
-                SDL_strlcat(env_var, "$CloseAction", len);
-
-                env_val = SDL_getenv(env_var);
-                if (env_val && SDL_strcmp(env_val, "0") == 0)
-                    riscos_closeaction = 0;
-
-                SDL_stack_free(env_var);
-            }
-
-            if (!*task_name)
-                SDL_strlcpy(task_name, p, maxlen);
-        }
-
-        SDL_stack_free(buffer);
-    }
-
-    if (task_name[0] == 0)
-        SDL_strlcpy(task_name, "SDL Task", maxlen);
-
-    return 1;
-}
-
-/*****************************************************************
-
-  Store the current desktop screen mode if we are in the desktop.
-
-******************************************************************/
-
-void
-RISCOS_StoreWimpMode()
-{
-    _kernel_swi_regs regs;
-
-    /* Don't store if in full screen mode */
-    if (stored_mode != -1)
-        return;
-
-    regs.r[0] = 1;
-    _kernel_swi(OS_ScreenMode, &regs, &regs);
-    if (regs.r[1] >= 0 && regs.r[1] < 256)
-        stored_mode = regs.r[1];
-    else {
-        int blockSize = 0;
-        int *retBlock = (int *) regs.r[1];
-        int *storeBlock;
-        int j;
-
-        while (blockSize < 5 || retBlock[blockSize] != -1)
-            blockSize++;
-        blockSize++;
-        storeBlock = (int *) SDL_malloc(blockSize * sizeof(int));
-        retBlock = (int *) regs.r[1];
-        for (j = 0; j < blockSize; j++)
-            storeBlock[j] = retBlock[j];
-
-        stored_mode = (int) storeBlock;
-    }
-#if DUMP_MODE
-    fprintf(stderr, "Stored ");
-    dump_mode();
-#endif
-}
-
-/*****************************************************************
-
-  Restore desktop screen mode if we are in full screen mode.
-
-*****************************************************************/
-
-void
-RISCOS_RestoreWimpMode()
-{
-    _kernel_swi_regs regs;
-
-    /* Only need to restore if we are in full screen mode */
-    if (stored_mode == -1)
-        return;
-
-#if DUMP_MODE
-    fprintf(stderr, "Restored");
-    dump_mode();
-#endif
-
-    regs.r[0] = stored_mode;
-    _kernel_swi(Wimp_SetMode, &regs, &regs);
-    if (stored_mode < 0 || stored_mode > 256) {
-        SDL_free((int *) stored_mode);
-    }
-    stored_mode = -1;
-
-    /* Flush keyboard buffer to dump the keystrokes we've already polled */
-    regs.r[0] = 21;
-    regs.r[1] = 0;              /* Keyboard buffer number */
-    _kernel_swi(OS_Byte, &regs, &regs);
-
-    mouseInWindow = 0;
-
-}
-
-/*********************************************************************
-
-  Get version of Wimp running when task was initialised.
-
-*********************************************************************/
-
-int
-RISCOS_GetWimpVersion()
-{
-    return wimp_version;
-}
-
-int
-RISCOS_GetTaskHandle()
-{
-    return task_handle;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscostask.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,41 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-    This file added by Alan Buckley (alan_baa@hotmail.com) to support RISC OS 
-	26 March 2003
-*/
-
-/* Task initialisation/Clean up */
-
-extern int RISCOS_InitTask();
-extern void RISCOS_ExitTask();
-extern int RISCOS_GetWimpVersion();
-extern int RISCOS_GetTaskHandle();
-
-
-/* Wimp mode saveing/restoring */
-extern void RISCOS_StoreWimpMode();
-extern void RISCOS_RestoreWimpMode();
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscosvideo.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,337 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
-	 23 March 2003
-
-     Implements RISC OS display device management.
-	 Routines for full screen and wimp modes are split
-	 into other source files.
-*/
-
-#include "SDL_video.h"
-#include "SDL_mouse.h"
-#include "SDL_syswm.h"
-#include "../SDL_sysvideo.h"
-#include "../SDL_pixels_c.h"
-#include "../../events/SDL_events_c.h"
-
-#include "SDL_riscostask.h"
-#include "SDL_riscosvideo.h"
-#include "SDL_riscosevents_c.h"
-#include "SDL_riscosmouse_c.h"
-
-#include "kernel.h"
-#include "swis.h"
-
-#define RISCOSVID_DRIVER_NAME "riscos"
-
-/* Initialization/Query functions */
-static int RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat);
-static void RISCOS_VideoQuit(_THIS);
-
-static SDL_Rect **RISCOS_ListModes(_THIS, SDL_PixelFormat * format,
-                                   Uint32 flags);
-static SDL_Surface *RISCOS_SetVideoMode(_THIS, SDL_Surface * current,
-                                        int width, int height, int bpp,
-                                        Uint32 flags);
-
-int RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info);
-
-int RISCOS_ToggleFullScreen(_THIS, int fullscreen);
-/* Mouse checking */
-void RISCOS_CheckMouseMode(_THIS);
-extern SDL_GrabMode RISCOS_GrabInput(_THIS, SDL_GrabMode mode);
-
-/* Fullscreen mode functions */
-extern SDL_Surface *FULLSCREEN_SetVideoMode(_THIS, SDL_Surface * current,
-                                            int width, int height, int bpp,
-                                            Uint32 flags);
-extern void FULLSCREEN_BuildModeList(_THIS);
-extern void FULLSCREEN_SetDeviceMode(_THIS);
-extern int FULLSCREEN_ToggleFromWimp(_THIS);
-
-/* Wimp mode functions */
-extern SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current,
-                                      int width, int height, int bpp,
-                                      Uint32 flags);
-extern void WIMP_DeleteWindow(_THIS);
-extern int WIMP_ToggleFromFullScreen(_THIS);
-
-/* Hardware surface functions - common to WIMP and FULLSCREEN */
-static int RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface);
-static int RISCOS_LockHWSurface(_THIS, SDL_Surface * surface);
-static void RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface);
-static void RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface);
-
-/* RISC OS driver bootstrap functions */
-
-static int
-RISCOS_Available(void)
-{
-    return (1);
-}
-
-static void
-RISCOS_DeleteDevice(SDL_VideoDevice * device)
-{
-    SDL_free(device->hidden);
-    SDL_free(device);
-}
-
-static SDL_VideoDevice *
-RISCOS_CreateDevice(int devindex)
-{
-    SDL_VideoDevice *device;
-
-    /* Initialize all variables that we clean on shutdown */
-    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
-    if (device) {
-        SDL_memset(device, 0, (sizeof *device));
-        device->hidden = (struct SDL_PrivateVideoData *)
-            SDL_malloc((sizeof *device->hidden));
-    }
-    if ((device == NULL) || (device->hidden == NULL)) {
-        SDL_OutOfMemory();
-        if (device) {
-            SDL_free(device);
-        }
-        return (0);
-    }
-    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
-
-    /* Set the function pointers */
-    device->VideoInit = RISCOS_VideoInit;
-    device->VideoQuit = RISCOS_VideoQuit;
-
-    device->ListModes = RISCOS_ListModes;
-    device->SetVideoMode = RISCOS_SetVideoMode;
-    device->CreateYUVOverlay = NULL;
-    device->AllocHWSurface = RISCOS_AllocHWSurface;
-    device->CheckHWBlit = NULL;
-    device->FillHWRect = NULL;
-    device->SetHWColorKey = NULL;
-    device->SetHWAlpha = NULL;
-    device->LockHWSurface = RISCOS_LockHWSurface;
-    device->UnlockHWSurface = RISCOS_UnlockHWSurface;
-    device->FreeHWSurface = RISCOS_FreeHWSurface;
-
-    device->FreeWMCursor = RISCOS_FreeWMCursor;
-    device->CreateWMCursor = RISCOS_CreateWMCursor;
-    device->CheckMouseMode = RISCOS_CheckMouseMode;
-    device->GrabInput = RISCOS_GrabInput;
-
-    device->InitOSKeymap = RISCOS_InitOSKeymap;
-
-    device->GetWMInfo = RISCOS_GetWmInfo;
-
-    device->free = RISCOS_DeleteDevice;
-
-/* Can't get Toggle screen to work if program starts up in Full screen mode so
-   disable it here and re-enable it when a wimp screen is chosen */
-    device->ToggleFullScreen = NULL;    /*RISCOS_ToggleFullScreen; */
-
-    /* Set other entries for fullscreen mode */
-    FULLSCREEN_SetDeviceMode(device);
-
-    /* Mouse pointer needs to use the WIMP ShowCursor version so
-       that it doesn't modify the pointer until the SDL Window is
-       entered or the application goes full screen */
-    device->ShowWMCursor = WIMP_ShowWMCursor;
-
-    return device;
-}
-
-VideoBootStrap RISCOS_bootstrap = {
-    RISCOSVID_DRIVER_NAME, "RISC OS video driver",
-    RISCOS_Available, RISCOS_CreateDevice
-};
-
-
-int
-RISCOS_VideoInit(_THIS, SDL_PixelFormat * vformat)
-{
-    _kernel_swi_regs regs;
-    int vars[4], vals[3];
-
-    if (RISCOS_InitTask() == 0) {
-        SDL_SetError("Unable to start task");
-        return 0;
-    }
-
-    vars[0] = 9;                /* Log base 2 bpp */
-    vars[1] = 11;               /* XWndLimit - num x pixels -1 */
-    vars[2] = 12;               /* YWndLimit - num y pixels -1 */
-    vars[3] = -1;               /* Terminate list */
-    regs.r[0] = (int) vars;
-    regs.r[1] = (int) vals;
-
-    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
-    vformat->BitsPerPixel = (1 << vals[0]);
-
-    /* Determine the current screen size */
-    this->info.current_w = vals[1] + 1;
-    this->info.current_h = vals[2] + 1;
-
-    /* Minimum bpp for SDL is 8 */
-    if (vformat->BitsPerPixel < 8)
-        vformat->BitsPerPixel = 8;
-
-
-    switch (vformat->BitsPerPixel) {
-    case 15:
-    case 16:
-        vformat->Bmask = 0x00007c00;
-        vformat->Gmask = 0x000003e0;
-        vformat->Rmask = 0x0000001f;
-        vformat->BitsPerPixel = 16;     /* SDL wants actual number of bits used */
-        vformat->BytesPerPixel = 2;
-        break;
-
-    case 24:
-    case 32:
-        vformat->Bmask = 0x00ff0000;
-        vformat->Gmask = 0x0000ff00;
-        vformat->Rmask = 0x000000ff;
-        vformat->BytesPerPixel = 4;
-        break;
-
-    default:
-        vformat->Bmask = 0;
-        vformat->Gmask = 0;
-        vformat->Rmask = 0;
-        vformat->BytesPerPixel = 1;
-        break;
-    }
-
-    /* Fill in some window manager capabilities */
-    this->info.wm_available = 1;
-
-    /* We're done! */
-    return (0);
-}
-
-/* Note:  If we are terminated, this could be called in the middle of
-   another SDL video routine -- notably UpdateRects.
-*/
-void
-RISCOS_VideoQuit(_THIS)
-{
-    RISCOS_ExitTask();
-
-    if (this->hidden->alloc_bank)
-        SDL_free(this->hidden->alloc_bank);
-    this->hidden->alloc_bank = 0;
-}
-
-
-SDL_Rect **
-RISCOS_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
-{
-    if (flags & SDL_FULLSCREEN) {
-        /* Build mode list when first required. */
-        if (SDL_nummodes[0] == 0)
-            FULLSCREEN_BuildModeList(this);
-
-        return (SDL_modelist[((format->BitsPerPixel + 7) / 8) - 1]);
-    } else
-        return (SDL_Rect **) - 1;
-}
-
-
-/* Set up video mode */
-SDL_Surface *
-RISCOS_SetVideoMode(_THIS, SDL_Surface * current,
-                    int width, int height, int bpp, Uint32 flags)
-{
-    if (flags & SDL_FULLSCREEN) {
-        RISCOS_StoreWimpMode();
-        /* Dump wimp window on switch to full screen */
-        if (this->hidden->window_handle)
-            WIMP_DeleteWindow(this);
-
-        return FULLSCREEN_SetVideoMode(this, current, width, height, bpp,
-                                       flags);
-    } else {
-        RISCOS_RestoreWimpMode();
-        return WIMP_SetVideoMode(this, current, width, height, bpp, flags);
-    }
-}
-
-
-/* We don't actually allow hardware surfaces other than the main one */
-static int
-RISCOS_AllocHWSurface(_THIS, SDL_Surface * surface)
-{
-    return (-1);
-}
-
-static void
-RISCOS_FreeHWSurface(_THIS, SDL_Surface * surface)
-{
-    return;
-}
-
-/* We need to wait for vertical retrace on page flipped displays */
-static int
-RISCOS_LockHWSurface(_THIS, SDL_Surface * surface)
-{
-    return (0);
-}
-
-static void
-RISCOS_UnlockHWSurface(_THIS, SDL_Surface * surface)
-{
-    return;
-}
-
-
-int
-RISCOS_GetWmInfo(_THIS, SDL_SysWMinfo * info)
-{
-    SDL_VERSION(&(info->version));
-    info->wimpVersion = RISCOS_GetWimpVersion();
-    info->taskHandle = RISCOS_GetTaskHandle();
-    info->window = this->hidden->window_handle;
-
-    return 1;
-}
-
-/* Toggle full screen mode.
-   Returns 1 if successful otherwise 0
-*/
-
-int
-RISCOS_ToggleFullScreen(_THIS, int fullscreen)
-{
-    if (fullscreen) {
-        return FULLSCREEN_ToggleFromWimp(this);
-    } else {
-        return WIMP_ToggleFromFullScreen(this);
-    }
-
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_riscosvideo.h	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,64 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-#ifndef _SDL_riscosvideo_h
-#define _SDL_riscosvideo_h
-
-#include "SDL_mouse.h"
-#include "SDL_mutex.h"
-#include "../SDL_sysvideo.h"
-
-/* Hidden "this" pointer for the video functions */
-#define _THIS	SDL_VideoDevice *this
-
-
-/* Private display data */
-
-struct SDL_PrivateVideoData
-{
-    unsigned char *bank[2];
-    int current_bank;
-    unsigned char *alloc_bank;
-    int height;
-    int xeig;
-    int yeig;
-    int screen_bpp;
-    int screen_width;
-    int screen_height;
-    char *pixtrans;
-
-    /* Wimp variables */
-    unsigned int window_handle;
-    char title[256];
-
-#define NUM_MODELISTS	4       /* 8, 16, 24, and 32 bits-per-pixel */
-    int SDL_nummodes[NUM_MODELISTS];
-    SDL_Rect **SDL_modelist[NUM_MODELISTS];
-};
-
-/* Old variable names */
-#define SDL_nummodes		(this->hidden->SDL_nummodes)
-#define SDL_modelist		(this->hidden->SDL_modelist)
-
-#endif /* _SDL_risosvideo_h */
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_wimppoll.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,334 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
-	 27 March 2003
-
-     Implements Pumping of events and WIMP polling
-*/
-
-#include "SDL_syswm.h"
-#include "../../events/SDL_sysevents.h"
-#include "../../events/SDL_events_c.h"
-#include "SDL_riscosvideo.h"
-#include "SDL_riscosevents_c.h"
-#include "SDL_riscosmouse_c.h"
-#include "../../timer/SDL_timer_c.h"
-
-#include "memory.h"
-#include "stdlib.h"
-#include "ctype.h"
-
-#include "kernel.h"
-#include "swis.h"
-#include "unixlib/os.h"
-
-#if !SDL_THREADS_DISABLED
-#include <pthread.h>
-#endif
-
-/* Local functions */
-void WIMP_Poll(_THIS, int waitTime);
-void WIMP_SetFocus(int win);
-
-/* SDL_riscossprite functions */
-void WIMP_PlotSprite(_THIS, int x, int y);
-void WIMP_ModeChanged(_THIS);
-void WIMP_PaletteChanged(_THIS);
-
-
-extern void WIMP_PollMouse(_THIS);
-extern void RISCOS_PollKeyboard();
-
-#if SDL_THREADS_DISABLED
-/* Timer running function */
-extern void RISCOS_CheckTimer();
-#else
-extern int riscos_using_threads;
-#endif
-
-/* Mouse cursor handling */
-extern void WIMP_ReshowCursor(_THIS);
-extern void WIMP_RestoreWimpCursor();
-
-int hasFocus = 0;
-int mouseInWindow = 0;
-
-/* Flag to ensure window is correct size after a mode change */
-static int resizeOnOpen = 0;
-
-void
-WIMP_PumpEvents(_THIS)
-{
-    WIMP_Poll(this, 0);
-    if (hasFocus)
-        RISCOS_PollKeyboard();
-    if (mouseInWindow)
-        WIMP_PollMouse(this);
-#if SDL_THREADS_DISABLED
-    if (SDL_timer_running)
-        RISCOS_CheckTimer();
-#endif
-}
-
-
-void
-WIMP_Poll(_THIS, int waitTime)
-{
-    _kernel_swi_regs regs;
-    int message[64];
-    unsigned int code;
-    int pollMask = 0;
-    int doPoll = 1;
-    int sysEvent;
-    int sdlWindow = this->hidden->window_handle;
-
-    if (this->PumpEvents != WIMP_PumpEvents)
-        return;
-
-    if (waitTime > 0) {
-        _kernel_swi(OS_ReadMonotonicTime, &regs, &regs);
-        waitTime += regs.r[0];
-    }
-
-    while (doPoll) {
-#if !SDL_THREADS_DISABLED
-        /* Stop thread callbacks while program is paged out */
-        if (riscos_using_threads)
-            __pthread_stop_ticker();
-#endif
-
-        if (waitTime <= 0) {
-            regs.r[0] = pollMask;       /* Poll Mask */
-            /* For no wait time mask out null event so we wait until something happens */
-            if (waitTime < 0)
-                regs.r[0] |= 1;
-            regs.r[1] = (int) message;
-            _kernel_swi(Wimp_Poll, &regs, &regs);
-        } else {
-            regs.r[0] = pollMask;
-            regs.r[1] = (int) message;
-            regs.r[2] = waitTime;
-            _kernel_swi(Wimp_PollIdle, &regs, &regs);
-        }
-
-        /* Flag to specify if we post a SDL_SysWMEvent */
-        sysEvent = 0;
-
-        code = (unsigned int) regs.r[0];
-
-        switch (code) {
-        case 0:                /* Null Event - drop out for standard processing */
-            doPoll = 0;
-            break;
-
-        case 1:                /* Redraw window */
-            _kernel_swi(Wimp_RedrawWindow, &regs, &regs);
-            if (message[0] == sdlWindow) {
-                while (regs.r[0]) {
-                    WIMP_PlotSprite(this, message[1], message[2]);
-                    _kernel_swi(Wimp_GetRectangle, &regs, &regs);
-                }
-            } else {
-                /* TODO: Currently we just eat them - we may need to pass them on */
-                while (regs.r[0]) {
-                    _kernel_swi(Wimp_GetRectangle, &regs, &regs);
-                }
-            }
-            break;
-
-        case 2:                /* Open window */
-            if (resizeOnOpen && message[0] == sdlWindow) {
-                /* Ensure window is correct size */
-                resizeOnOpen = 0;
-                message[3] =
-                    message[1] + (this->screen->w << this->hidden->xeig);
-                message[4] =
-                    message[2] + (this->screen->h << this->hidden->yeig);
-            }
-            _kernel_swi(Wimp_OpenWindow, &regs, &regs);
-            break;
-
-        case 3:                /* Close window */
-            if (message[0] == sdlWindow) {
-                /* Documentation makes it looks as if the following line is correct:
-                 **    if (SDL_PrivateQuit() == 1) _kernel_swi(Wimp_CloseWindow, &regs, &regs);
-                 ** However some programs don't process this message and so sit there invisibly
-                 ** in the background so I just post the quit message and hope the application
-                 ** does the correct thing.
-                 */
-                SDL_PrivateQuit();
-            } else
-                sysEvent = 1;
-            doPoll = 0;
-            break;
-
-        case 4:                /* Pointer_Leaving_Window */
-            if (message[0] == sdlWindow) {
-                mouseInWindow = 0;
-                //TODO: Lose buttons / dragging
-                /* Reset to default pointer */
-                WIMP_RestoreWimpCursor();
-                SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
-            } else
-                sysEvent = 1;
-            break;
-
-        case 5:                /* Pointer_Entering_Window */
-            if (message[0] == sdlWindow) {
-                mouseInWindow = 1;
-                WIMP_ReshowCursor(this);
-                SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
-            } else
-                sysEvent = 1;
-            break;
-
-        case 6:                /* Mouse_Click */
-            if (hasFocus == 0) {
-                /* First click gives focus if it's not a menu */
-                /* we only count non-menu clicks on a window that has the focus */
-                WIMP_SetFocus(message[3]);
-            } else
-                doPoll = 0;     // So PollMouse gets a chance to pick it up
-            break;
-
-        case 7:                /* User_Drag_Box - Used for mouse release */
-            //TODO: May need to implement this in the future
-            sysEvent = 1;
-            break;
-
-        case 8:                /* Keypressed */
-            doPoll = 0;         /* PollKeyboard should pick it up */
-            if (message[0] != sdlWindow)
-                sysEvent = 1;
-            /*TODO: May want to always pass F12 etc to the wimp
-               {
-               regs.r[0] = message[6];
-               _kernel_swi(Wimp_ProcessKey, &regs, &regs);
-               }
-             */
-            break;
-
-        case 11:               /* Lose Caret */
-            hasFocus = 0;
-            if (message[0] == sdlWindow)
-                SDL_PrivateAppActive(0, SDL_APPINPUTFOCUS);
-            else
-                sysEvent = 1;
-            break;
-
-        case 12:               /* Gain Caret */
-            hasFocus = 1;
-            if (message[0] == sdlWindow)
-                SDL_PrivateAppActive(1, SDL_APPINPUTFOCUS);
-            else
-                sysEvent = 1;
-            break;
-
-        case 17:
-        case 18:
-            sysEvent = 1;       /* All messages are passed on */
-
-            switch (message[4]) {
-            case 0:            /* Quit Event */
-                /* No choice - have to quit */
-                SDL_Quit();
-                exit(0);
-                break;
-
-            case 8:            /* Pre Quit */
-                SDL_PrivateQuit();
-                break;
-
-            case 0x400c1:      /* Mode change */
-                WIMP_ModeChanged(this);
-                resizeOnOpen = 1;
-                break;
-
-            case 9:            /* Palette changed */
-                WIMP_PaletteChanged(this);
-                break;
-            }
-            break;
-
-        default:
-            /* Pass unknown events on */
-            sysEvent = 1;
-            break;
-        }
-
-        if (sysEvent) {
-            SDL_SysWMmsg wmmsg;
-
-            SDL_VERSION(&wmmsg.version);
-            wmmsg.eventCode = code;
-            SDL_memcpy(wmmsg.pollBlock, message, 64 * sizeof(int));
-
-            /* Fall out of polling loop if message is successfully posted */
-            if (SDL_PrivateSysWMEvent(&wmmsg))
-                doPoll = 0;
-        }
-#if !SDL_THREADS_DISABLED
-        if (riscos_using_threads) {
-            /* Restart ticker here so other thread can not interfere
-               with the Redraw processing */
-            if (riscos_using_threads)
-                __pthread_start_ticker();
-            /* Give other threads a better chance of running */
-            pthread_yield();
-        }
-#endif
-    }
-}
-
-/* Set focus to specified window */
-void
-WIMP_SetFocus(int win)
-{
-    _kernel_swi_regs regs;
-
-    regs.r[0] = win;
-    regs.r[1] = -1;             /* Icon handle */
-    regs.r[2] = 0;              /* X-offset we just put it at position 0 */
-    regs.r[3] = 0;              /* Y-offset as above */
-    regs.r[4] = 1 << 25;        /* Caret is invisible */
-    regs.r[5] = 0;              /* index into string */
-
-    _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
-}
-
-/** Run background task while in a sleep command */
-void
-RISCOS_BackgroundTasks(void)
-{
-    if (current_video && current_video->hidden->window_handle) {
-        WIMP_Poll(current_video, 0);
-    }
-#if SDL_THREADS_DISABLED
-    if (SDL_timer_running)
-        RISCOS_CheckTimer();
-#endif
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/riscos/SDL_wimpvideo.c	Mon Jan 31 07:36:12 2011 -0800
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,511 +0,0 @@
-/*
-    SDL - Simple DirectMedia Layer
-    Copyright (C) 1997-2010 Sam Lantinga
-
-    This library is free software; you can redistribute it and/or
-    modify it under the terms of the GNU Lesser General Public
-    License as published by the Free Software Foundation; either
-    version 2.1 of the License, or (at your option) any later version.
-
-    This library is distributed in the hope that it will be useful,
-    but WITHOUT ANY WARRANTY; without even the implied warranty of
-    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-    Lesser General Public License for more details.
-
-    You should have received a copy of the GNU Lesser General Public
-    License along with this library; if not, write to the Free Software
-    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-
-    Sam Lantinga
-    slouken@libsdl.org
-*/
-#include "SDL_config.h"
-
-/*
-     File added by Alan Buckley (alan_baa@hotmail.com) for RISC OS compatability
-	 27 March 2003
-
-     Implements RISC OS Wimp display.
-*/
-
-#include "SDL_video.h"
-#include "SDL_mouse.h"
-#include "../SDL_sysvideo.h"
-#include "../SDL_pixels_c.h"
-#include "../../events/SDL_events_c.h"
-
-#include "SDL_riscostask.h"
-#include "SDL_riscosvideo.h"
-#include "SDL_riscosevents_c.h"
-#include "SDL_riscosmouse_c.h"
-
-#include "kernel.h"
-#include "swis.h"
-
-/* Initialization/Query functions */
-SDL_Rect **WIMP_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags);
-SDL_Surface *WIMP_SetVideoMode(_THIS, SDL_Surface * current, int width,
-                               int height, int bpp, Uint32 flags);
-int WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors);
-void WIMP_SetWMCaption(_THIS, const char *title, const char *icon);
-
-
-extern unsigned char *WIMP_CreateBuffer(int width, int height, int bpp);
-extern void WIMP_PumpEvents(_THIS);
-extern void WIMP_PlotSprite(_THIS, int x, int y);
-extern void WIMP_SetupPlotInfo(_THIS);
-extern void WIMP_SetFocus(int win);
-
-/* etc. */
-static void WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
-
-/* RISC OS Wimp handling helpers */
-void WIMP_ReadModeInfo(_THIS);
-unsigned int WIMP_SetupWindow(_THIS, SDL_Surface * surface);
-void WIMP_SetDeviceMode(_THIS);
-void WIMP_DeleteWindow(_THIS);
-
-/* FULLSCREEN function required for wimp/fullscreen toggling */
-extern int FULLSCREEN_SetMode(int width, int height, int bpp);
-
-/* Currently need to set this up here as it only works if you
-   start up in a Wimp mode */
-extern int RISCOS_ToggleFullScreen(_THIS, int fullscreen);
-
-extern int riscos_backbuffer;
-extern int mouseInWindow;
-extern int riscos_closeaction;
-
-/* Following needed to ensure window is shown immediately */
-extern int hasFocus;
-extern void WIMP_Poll(_THIS, int waitTime);
-
-SDL_Surface *
-WIMP_SetVideoMode(_THIS, SDL_Surface * current,
-                  int width, int height, int bpp, Uint32 flags)
-{
-    Uint32 Rmask = 0;
-    Uint32 Gmask = 0;
-    Uint32 Bmask = 0;
-    char *buffer = NULL;
-    int bytesPerPixel = 1;
-
-    /* Don't support double buffering in Wimp mode */
-    flags &= ~SDL_DOUBLEBUF;
-    flags &= ~SDL_HWSURFACE;
-
-    switch (bpp) {
-    case 8:
-        /* Emulated palette using ColourTrans */
-        flags |= SDL_HWPALETTE;
-        break;
-
-    case 15:
-    case 16:
-        Bmask = 0x00007c00;
-        Gmask = 0x000003e0;
-        Rmask = 0x0000001f;
-        bytesPerPixel = 2;
-        break;
-
-    case 32:
-        Bmask = 0x00ff0000;
-        Gmask = 0x0000ff00;
-        Rmask = 0x000000ff;
-        bytesPerPixel = 4;
-        break;
-
-    default:
-        SDL_SetError("Pixel depth not supported");
-        return NULL;
-        break;
-    }
-
-/* 	printf("Setting mode %dx%d\n", width, height);*/
-
-    /* Allocate the new pixel format for the screen */
-    if (!SDL_ReallocFormat(current, bpp, Rmask, Gmask, Bmask, 0)) {
-        SDL_SetError("Couldn't allocate new pixel format for requested mode");
-        return (NULL);
-    }
-
-    /* Set up the new mode framebuffer */
-    current->w = width;
-    this->hidden->height = current->h = height;
-
-    if (bpp == 15)
-        bpp = 16;
-    buffer = WIMP_CreateBuffer(width, height, bpp);
-    if (buffer == NULL) {
-        SDL_SetError("Couldn't create sprite for video memory");
-        return (NULL);
-    }
-
-    this->hidden->bank[0] = buffer + 60;        /* Start of sprite data */
-    if (bpp == 8)
-        this->hidden->bank[0] += 2048;  /* 8bpp sprite have palette first */
-
-    this->hidden->bank[1] = buffer;     /* Start of buffer */
-
-    /* Remember sprite buffer so it can be freed later */
-    if (this->hidden->alloc_bank)
-        SDL_free(this->hidden->alloc_bank);
-    this->hidden->alloc_bank = buffer;
-
-    current->pitch = width * bytesPerPixel;
-    if ((current->pitch & 3)) {
-        /* Sprites are 32bit word aligned */
-        current->pitch += (4 - (current->pitch & 3));
-    }
-
-    current->flags = flags | SDL_PREALLOC;
-
-    WIMP_ReadModeInfo(this);
-
-    SDL_memset(this->hidden->bank[0], 0, height * current->pitch);
-
-    this->hidden->current_bank = 0;
-    current->pixels = this->hidden->bank[0];
-
-
-    if (WIMP_SetupWindow(this, current) == 0) {
-        SDL_SetError("Unable to create window to display surface");
-        return NULL;
-    }
-
-    /* Reset device functions for the wimp */
-    WIMP_SetDeviceMode(this);
-
-    /* Needs to set up plot info after window has been created */
-    /* Not sure why, but plots don't work if I do it earlier */
-    WIMP_SetupPlotInfo(this);
-
-    /* Poll until window is shown */
-    {
-        /* We wait until it gets the focus, but give up after 5 seconds
-           in case the focus is prevented in any way.
-         */
-        Uint32 now = SDL_GetTicks();
-        while (!hasFocus && SDL_GetTicks() - now < 5000) {
-            WIMP_Poll(this, 0);
-        }
-    }
-
-    /* We're done */
-    return (current);
-}
-
-
-void
-WIMP_ReadModeInfo(_THIS)
-{
-    _kernel_swi_regs regs;
-    int vars[6];
-    int vals[5];
-
-    vars[0] = 4;                /* XEig */
-    vars[1] = 5;                /* YEig */
-    vars[2] = 9;                /* Log base 2 bpp */
-    vars[3] = 11;               /* Screen Width - 1 */
-    vars[4] = 12;               /* Screen Depth - 1 */
-    vars[5] = -1;               /* Terminate list */
-
-    regs.r[0] = (int) vars;
-    regs.r[1] = (int) vals;
-    _kernel_swi(OS_ReadVduVariables, &regs, &regs);
-    this->hidden->xeig = vals[0];
-    this->hidden->yeig = vals[1];
-    this->hidden->screen_bpp = 1 << vals[2];
-    this->hidden->screen_width = vals[3] + 1;
-    this->hidden->screen_height = vals[4] + 1;
-}
-
-/* Set device function to call the correct versions for running
-   in a wimp window */
-
-void
-WIMP_SetDeviceMode(_THIS)
-{
-    if (this->UpdateRects == WIMP_UpdateRects)
-        return;                 /* Already set up */
-
-    this->SetColors = WIMP_SetColors;
-    this->UpdateRects = WIMP_UpdateRects;
-
-    this->FlipHWSurface = NULL;
-
-    this->SetCaption = WIMP_SetWMCaption;
-    this->SetIcon = NULL;
-    this->IconifyWindow = NULL;
-
-    this->ShowWMCursor = WIMP_ShowWMCursor;
-    this->WarpWMCursor = WIMP_WarpWMCursor;
-
-    this->ToggleFullScreen = RISCOS_ToggleFullScreen;
-
-    this->PumpEvents = WIMP_PumpEvents;
-}
-
-/* Setup the Window to display the surface */
-unsigned int
-WIMP_SetupWindow(_THIS, SDL_Surface * surface)
-{
-    _kernel_swi_regs regs;
-    int window_data[23];
-    int *window_block = window_data + 1;
-    int x = (this->hidden->screen_width - surface->w) / 2;
-    int y = (this->hidden->screen_height - surface->h) / 2;
-    int xeig = this->hidden->xeig;
-    int yeig = this->hidden->yeig;
-
-    mouseInWindow = 0;
-
-    /* Always delete the window and recreate on a change */
-    if (this->hidden->window_handle)
-        WIMP_DeleteWindow(this);
-
-    /* Setup window co-ordinates */
-    window_block[0] = x << xeig;
-    window_block[1] = y << yeig;
-    window_block[2] = window_block[0] + (surface->w << xeig);
-    window_block[3] = window_block[1] + (surface->h << yeig);
-
-
-    window_block[4] = 0;        /* Scroll offsets */
-    window_block[5] = 0;
-    window_block[6] = -1;       /* Open on top of window stack */
-
-    window_block[7] = 0x85040042;       /* Window flags */
-    if (riscos_closeaction != 0)
-        window_block[7] |= 0x2000000;
-
-    /* TODO: Take into account surface->flags */
-
-    window_block[8] = 0xff070207;       /* Window colours */
-    window_block[9] = 0x000c0103;
-    window_block[10] = 0;       /* Work area minimum */
-    window_block[11] = -surface->h << yeig;
-    window_block[12] = surface->w << xeig;      /* Work area maximum */
-    window_block[13] = 0;
-    window_block[14] = 0x2700013d;      /* Title icon flags */
-    window_block[15] = 0x00003000;      /* Work area flags - Mouse click down reported */
-    window_block[16] = 1;       /* Sprite area control block pointer */
-    window_block[17] = 0x00100010;      /* Minimum window size (width & height) (16x16) */
-    window_block[18] = (int) this->hidden->title;       /* Title data */
-    window_block[19] = -1;
-    window_block[20] = 256;
-    window_block[21] = 0;       /* Number of icons */
-
-    regs.r[1] = (unsigned int) (window_block);
-
-    /* Create the window */
-    if (_kernel_swi(Wimp_CreateWindow, &regs, &regs) == NULL) {
-        this->hidden->window_handle = window_data[0] = regs.r[0];
-
-        /* Show the window on the screen */
-        regs.r[1] = (unsigned int) window_data;
-        if (_kernel_swi(Wimp_OpenWindow, &regs, &regs) == NULL) {
-            WIMP_SetFocus(this->hidden->window_handle);
-        } else {
-            WIMP_DeleteWindow(this);
-        }
-    }
-
-    return this->hidden->window_handle;
-}
-
-/* Destroy the Window */
-
-void
-WIMP_DeleteWindow(_THIS)
-{
-    _kernel_swi_regs regs;
-    regs.r[1] = (unsigned int) &(this->hidden->window_handle);
-    _kernel_swi(Wimp_DeleteWindow, &regs, &regs);
-    this->hidden->window_handle = 0;
-}
-
-
-void
-WIMP_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
-{
-    _kernel_swi_regs regs;
-    int update_block[12];
-    int xeig = this->hidden->xeig;
-    int yeig = this->hidden->yeig;
-    int j;
-    update_block[0] = this->hidden->window_handle;
-
-    for (j = 0; j < numrects; j++) {
-        update_block[1] = rects[j].x << xeig;   /* Min X */
-        update_block[4] = -(rects[j].y << yeig);
-        update_block[3] = update_block[1] + (rects[j].w << xeig);
-        update_block[2] = update_block[4] - (rects[j].h << yeig);
-
-        regs.r[1] = (int) update_block;
-        /* Update window can fail if called before first poll */
-        if (_kernel_swi(Wimp_UpdateWindow, &regs, &regs) == 0) {
-            while (regs.r[0]) {
-                WIMP_PlotSprite(this, update_block[1], update_block[2]);
-                _kernel_swi(Wimp_GetRectangle, &regs, &regs);
-            }
-        }
-    }
-}
-
-
-int
-WIMP_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
-{
-    unsigned int *pal = (unsigned int *) (this->hidden->bank[1] + 60);
-    int j;
-    SDL_Rect update;
-
-    pal += firstcolor * 2;
-    for (j = 0; j < ncolors; j++) {
-        *pal = (((unsigned int) colors->r) << 8)
-            + (((unsigned int) colors->g) << 16)
-            + (((unsigned int) colors->b) << 24);
-        pal[1] = *pal;
-        pal += 2;
-        colors++;
-    }
-
-    WIMP_SetupPlotInfo(this);
-
-    /* Need to refresh the window */
-    update.x = 0;
-    update.y = 0;
-    update.w = SDL_VideoSurface->w;
-    update.h = SDL_VideoSurface->h;
-    WIMP_UpdateRects(this, 1, &update);
-
-    return 1;
-}
-
-void
-WIMP_SetWMCaption(_THIS, const char *title, const char *icon)
-{
-    _kernel_swi_regs regs;
-
-    SDL_strlcpy(this->hidden->title, title,
-                SDL_arraysize(this->hidden->title));
-
-    if (RISCOS_GetWimpVersion() < 380) {
-        int block[6];
-
-        regs.r[1] = (int) block;
-        _kernel_swi(Wimp_GetCaretPosition, &regs, &regs);
-        if (block[0] == (int) this->hidden->window_handle) {
-            regs.r[0] = -1;
-            _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
-        } else {
-            regs.r[0] = this->hidden->window_handle;
-            regs.r[1] = -1;
-            regs.r[2] = -1;
-            regs.r[3] = -1;
-            _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
-        }
-        regs.r[0] = block[0];
-        regs.r[1] = block[1];
-        regs.r[2] = block[2];
-        regs.r[3] = block[3];
-        regs.r[4] = block[4];
-        regs.r[5] = block[5];
-        _kernel_swi(Wimp_SetCaretPosition, &regs, &regs);
-    } else {
-        regs.r[0] = this->hidden->window_handle;
-        regs.r[1] = 0x4b534154; /* "TASK" */
-        regs.r[2] = 3;          /* Redraw title */
-        _kernel_swi(Wimp_ForceRedraw, &regs, &regs);
-    }
-}
-
-void
-WIMP_RefreshDesktop(_THIS)
-{
-    int width = this->hidden->screen_width << this->hidden->xeig;
-    int height = this->hidden->screen_height << this->hidden->yeig;
-    _kernel_swi_regs regs;
-    regs.r[0] = -1;             /* Whole screen */
-    regs.r[1] = 0;
-    regs.r[2] = 0;
-    regs.r[3] = width;
-    regs.r[4] = height;
-    _kernel_swi(Wimp_ForceRedraw, &regs, &regs);
-}
-
-/* Toggle to window from full screen */
-int
-WIMP_ToggleFromFullScreen(_THIS)
-{
-    int width = this->screen->w;
-    int height = this->screen->h;
-    int bpp = this->screen->format->BitsPerPixel;
-    char *buffer = NULL;
-    char *old_bank[2];
-    char *old_alloc_bank;
-
-    /* Ensure flags are OK */
-    this->screen->flags &= ~(SDL_DOUBLEBUF | SDL_HWSURFACE);
-
-    if (this->hidden->bank[0] == this->hidden->alloc_bank
-        || riscos_backbuffer == 0) {
-        /* Need to create a sprite for the screen and copy the data to it */
-        char *data;
-        buffer = WIMP_CreateBuffer(width, height, bpp);
-        data = buffer + 60;     /* Start of sprite data */
-        if (bpp == 8)
-            data += 2048;       /* 8bpp sprite have palette first */
-
-        if (buffer == NULL)
-            return 0;
-        SDL_memcpy(data, this->hidden->bank[0],
-                   width * height * this->screen->format->BytesPerPixel);
-    }
-    /* else We've switch to full screen before so we already have a sprite */
-
-    old_bank[0] = this->hidden->bank[0];
-    old_bank[1] = this->hidden->bank[1];
-    old_alloc_bank = this->hidden->alloc_bank;
-
-    if (buffer != NULL)
-        this->hidden->alloc_bank = buffer;
-
-    this->hidden->bank[1] = this->hidden->alloc_bank;
-    this->hidden->bank[0] = this->hidden->bank[1] + 60; /* Start of sprite data */
-    if (bpp == 8)
-        this->hidden->bank[0] += 2048;  /* 8bpp sprite have palette first */
-
-    this->hidden->current_bank = 0;
-    this->screen->pixels = this->hidden->bank[0];
-
-    RISCOS_RestoreWimpMode();
-    WIMP_ReadModeInfo(this);
-    if (WIMP_SetupWindow(this, this->screen)) {
-        WIMP_SetDeviceMode(this);
-        WIMP_SetupPlotInfo(this);
-
-        if (riscos_backbuffer == 0)
-            riscos_backbuffer = 1;
-
-        if (buffer && old_alloc_bank)
-            SDL_free(old_alloc_bank);
-
-        return 1;
-    } else {
-        /* Drop back to full screen mode on failure */
-        this->hidden->bank[0] = old_bank[0];
-        this->hidden->bank[1] = old_bank[1];
-        this->hidden->alloc_bank = old_alloc_bank;
-        if (buffer)
-            SDL_free(buffer);
-
-        RISCOS_StoreWimpMode();
-        FULLSCREEN_SetMode(width, height, bpp);
-    }
-
-    return 0;
-}
-
-/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/uikit/SDL_uikitevents.m	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/uikit/SDL_uikitevents.m	Tue Feb 01 00:37:02 2011 -0800
@@ -21,7 +21,6 @@
 */
 #include "SDL_config.h"
 
-#include "../../events/SDL_sysevents.h"
 #include "../../events/SDL_events_c.h"
 
 #include "SDL_uikitvideo.h"
--- a/src/video/uikit/SDL_uikitview.m	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/uikit/SDL_uikitview.m	Tue Feb 01 00:37:02 2011 -0800
@@ -267,10 +267,10 @@
 			unichar c = [string characterAtIndex: i];
 			
 			Uint16 mod = 0;
-			SDL_scancode code;
+			SDL_ScanCode code;
 			
 			if (c < 127) {
-				/* figure out the SDL_scancode and SDL_keymod for this unichar */
+				/* figure out the SDL_ScanCode and SDL_keymod for this unichar */
 				code = unicharToUIKeyInfoTable[c].code;
 				mod  = unicharToUIKeyInfoTable[c].mod;
 			}
--- a/src/video/uikit/keyinfotable.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/uikit/keyinfotable.h	Tue Feb 01 00:37:02 2011 -0800
@@ -27,14 +27,14 @@
 
 /*
 	This file is used by the keyboard code in SDL_uikitview.m to convert between characters
-	passed in from the iPhone's virtual keyboard, and tuples of SDL_scancodes and SDL_keymods.
+	passed in from the iPhone's virtual keyboard, and tuples of SDL_ScanCodes and SDL_keymods.
 	For example unicharToUIKeyInfoTable['a'] would give you the scan code and keymod for lower
 	case a.
 */
 
 typedef struct
 {
-    SDL_scancode code;
+    SDL_ScanCode code;
     Uint16 mod;
 } UIKitKeyInfo;
 
--- a/src/video/windows/SDL_gapirender.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_gapirender.c	Tue Feb 01 00:37:02 2011 -0800
@@ -78,7 +78,7 @@
 typedef struct
 {
     // gx.dll
-    HMODULE                   hGapiLib;
+    void*                     hGapiLib;
     PFNGXOpenDisplay          GXOpenDisplay;
     PFNGXCloseDisplay         GXCloseDisplay;
     PFNGXBeginDraw            GXBeginDraw;
@@ -92,19 +92,19 @@
 //#define DM_DISPLAYORIENTATION 0x00800000L
 //#endif
 
-#define FORMAT_565		1
-#define FORMAT_555		2
-#define FORMAT_OTHER		3
+#define FORMAT_565                1
+#define FORMAT_555                2
+#define FORMAT_OTHER                3
 
-#define GETRAWFRAMEBUFFER	0x00020001
-#define GETGXINFO		0x00020000
+#define GETRAWFRAMEBUFFER        0x00020001
+#define GETGXINFO                0x00020000
 
-#define kfPalette		0x10
-#define kfDirect		0x20
-#define kfDirect555		0x40
-#define kfDirect565		0x80
+#define kfPalette                0x10
+#define kfDirect                0x20
+#define kfDirect555                0x40
+#define kfDirect565                0x80
 
-#define GX_FULLSCREEN		0x01
+#define GX_FULLSCREEN                0x01
 
 enum ScreenOrientation { ORIENTATION_UNKNOWN = -1, ORIENTATION_UP = DMDO_0, ORIENTATION_DOWN = DMDO_180, ORIENTATION_LEFT = DMDO_270, ORIENTATION_RIGHT = DMDO_90 };
 enum ScreenGeometry { GEOMETRY_UNKNOWN, GEOMETRY_PORTRAIT, GEOMETRY_LANDSCAPE, GEOMETRY_SQUARE };
@@ -123,15 +123,15 @@
 // private display data
 typedef struct
 {
-    unsigned char* pixels;	// video memory
-    int format;			// video format
-    FrameBufferInfo fb;		// framebuffer geometry
-    GapiInfo* gapi;		// GAPI module
+    unsigned char* pixels;        // video memory
+    int format;                        // video format
+    FrameBufferInfo fb;                // framebuffer geometry
+    GapiInfo* gapi;                // GAPI module
     int userOrientation;
     int systemOrientation;
     int hardwareGeometry;
-    int flags;			// fb flags
-    float scale;		// scale pointer position
+    int flags;                        // fb flags
+    float scale;                // scale pointer position
     int debug;
 
 } WINCE_RenderData;
@@ -147,110 +147,111 @@
 
 
 // system func
-SDL_Renderer*	WINCE_CreateRenderer(SDL_Window* window, Uint32 flags);
-void		WINCE_DestroyRenderer(SDL_Renderer* renderer);
+SDL_Renderer*        WINCE_CreateRenderer(SDL_Window* window, Uint32 flags);
+void                WINCE_DestroyRenderer(SDL_Renderer* renderer);
 
-int		WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture);
-void		WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture);
-int		WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
-int		WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
-int		WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch);
-void		WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture);
+int                WINCE_CreateTexture(SDL_Renderer* renderer, SDL_Texture* texture);
+void                WINCE_DestroyTexture(SDL_Renderer* renderer, SDL_Texture* texture);
+int                WINCE_QueryTexturePixels(SDL_Renderer* renderer, SDL_Texture* texture, void** pixels, int* pitch);
+int                WINCE_UpdateTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, const void* pixels, int pitch);
+int                WINCE_LockTexture(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* rect, int dirty, void** pixels, int* pitch);
+void                WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture);
 
-int		WINCE_Available(void);
-void		WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height);
+int                WINCE_Available(void);
+void                WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height);
 
-int		WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect);
-void		WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
+int                WINCE_RenderCopy(SDL_Renderer* renderer, SDL_Texture* texture, const SDL_Rect* srect, const SDL_Rect* drect);
+void                WINCE_ShowWindow(_THIS, SDL_Window* window, int visible);
 
-void		WINCE_RenderPresent(SDL_Renderer* renderer);
-int		WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count);
-int		WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count);
-int		WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count);
-int		WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count);
+void                WINCE_RenderPresent(SDL_Renderer* renderer);
+int                WINCE_RenderDrawPoints(SDL_Renderer* renderer, const SDL_Point* points, int count);
+int                WINCE_RenderDrawLines(SDL_Renderer* renderer, const SDL_Point* points, int count);
+int                WINCE_RenderDrawRects(SDL_Renderer* renderer, const SDL_Rect ** rects, int count);
+int                WINCE_RenderFillRects(SDL_Renderer* renderer, const SDL_Rect** rects, int count);
 
-void		WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt);
-void		WINCE_DumpVideoInfo(WINCE_RenderData* data);
-void		WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height);
-void		WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height);
-void		WINCE_SquareTransform(WINCE_RenderData* data, int width, int height);
-int		WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug);
-int		WINCE_GetDMOrientation(void);
-int		WINCE_SetDMOrientation(int orientation);
-void		WINCE_UpdateYUVTextureData(SDL_Texture* texture);
+void                WINCE_PointerCoordinateTransform(SDL_Window* window, POINT* pt);
+void                WINCE_DumpVideoInfo(WINCE_RenderData* data);
+void                WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height);
+void                WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height);
+void                WINCE_SquareTransform(WINCE_RenderData* data, int width, int height);
+int                WINCE_FixedGeometry(FrameBufferInfo* fb, int bpp, int debug);
+int                WINCE_GetDMOrientation(void);
+int                WINCE_SetDMOrientation(int orientation);
+void                WINCE_UpdateYUVTextureData(SDL_Texture* texture);
 
 // gapi engine specific
-int		GAPI_Init(WINCE_RenderData* data, HWND hwnd);
-void		GAPI_Quit(WINCE_RenderData* data);
+int                GAPI_Init(WINCE_RenderData* data, HWND hwnd);
+void                GAPI_Quit(WINCE_RenderData* data);
 
 // raw engine specific
-int		RAW_Init(WINCE_RenderData* data);
-void		RAW_Quit(WINCE_RenderData* data);
+int                RAW_Init(WINCE_RenderData* data);
+void                RAW_Quit(WINCE_RenderData* data);
 
 // tools
-void		FrameBufferRotate(FrameBufferInfo* src, int orientation);
-int		GetFrameBufferOrientation(const FrameBufferInfo* src);
-void		PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation);
-void		FrameBufferInitialize(FrameBufferInfo* fb);
-void		FrameBufferDumpInfo(const FrameBufferInfo* fb, const char*);
-const		char* GetOrientationName(int orientation);
-void		UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width);
+void                FrameBufferRotate(FrameBufferInfo* src, int orientation);
+int                GetFrameBufferOrientation(const FrameBufferInfo* src);
+void                PointerRotate(POINT* pt, const FrameBufferInfo* fb, int orientation);
+void                FrameBufferInitialize(FrameBufferInfo* fb);
+void                FrameBufferDumpInfo(const FrameBufferInfo* fb, const char*);
+const                char* GetOrientationName(int orientation);
+void                UpdateLine16to16(const FrameBufferInfo* fb, const Uint16* src, Uint16* dst, Uint16 width);
 
 // stdlib
-inline int	__abs(int x){ return x < 0 ? -x : x; };
-inline void	__swap(int* a, int* b){ int t = *a; *a = *b; *b = t; };
+static __inline__ int        __abs(int x){ return x < 0 ? -x : x; };
+static __inline__ void        __swap(int* a, int* b){ int t = *a; *a = *b; *b = t; };
 
-#define GAPI_RENDER_NAME	"gapi"
-#define RAW_RENDER_NAME		"raw"
+#define GAPI_RENDER_NAME        "gapi"
+#define RAW_RENDER_NAME                "raw"
 //
 SDL_RenderDriver GAPI_RenderDriver = {
     WINCE_CreateRenderer,
     {
-	GAPI_RENDER_NAME,
-	(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
-	(SDL_TEXTUREMODULATE_NONE),
-	(SDL_BLENDMODE_NONE),
-	(SDL_SCALEMODE_NONE),
-	7,
-	{
-	    SDL_PIXELFORMAT_RGB555,
-	    SDL_PIXELFORMAT_RGB565,
-	    SDL_PIXELFORMAT_YV12,
-	    SDL_PIXELFORMAT_IYUV,
-	    SDL_PIXELFORMAT_YUY2,
-	    SDL_PIXELFORMAT_UYVY,
-	    SDL_PIXELFORMAT_YVYU
-	},
-	0,
-	0
+        GAPI_RENDER_NAME,
+        (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
+        (SDL_TEXTUREMODULATE_NONE),
+        (SDL_BLENDMODE_NONE),
+        (SDL_SCALEMODE_NONE),
+        7,
+        {
+            SDL_PIXELFORMAT_RGB555,
+            SDL_PIXELFORMAT_RGB565,
+            SDL_PIXELFORMAT_YV12,
+            SDL_PIXELFORMAT_IYUV,
+            SDL_PIXELFORMAT_YUY2,
+            SDL_PIXELFORMAT_UYVY,
+            SDL_PIXELFORMAT_YVYU
+        },
+        0,
+        0
     }
 };
 
 SDL_RenderDriver RAW_RenderDriver = {
     WINCE_CreateRenderer,
     {
-	RAW_RENDER_NAME,
-	(SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
-	(SDL_TEXTUREMODULATE_NONE),
-	(SDL_BLENDMODE_NONE),
-	(SDL_SCALEMODE_NONE),
-	7,
-	{
-	    SDL_PIXELFORMAT_RGB555,
-	    SDL_PIXELFORMAT_RGB565,
-	    SDL_PIXELFORMAT_YV12,
-	    SDL_PIXELFORMAT_IYUV,
-	    SDL_PIXELFORMAT_YUY2,
-	    SDL_PIXELFORMAT_UYVY,
-	    SDL_PIXELFORMAT_YVYU
-	},
-	0,
-	0
+        RAW_RENDER_NAME,
+        (SDL_RENDERER_SINGLEBUFFER | SDL_RENDERER_PRESENTDISCARD),
+        (SDL_TEXTUREMODULATE_NONE),
+        (SDL_BLENDMODE_NONE),
+        (SDL_SCALEMODE_NONE),
+        7,
+        {
+            SDL_PIXELFORMAT_RGB555,
+            SDL_PIXELFORMAT_RGB565,
+            SDL_PIXELFORMAT_YV12,
+            SDL_PIXELFORMAT_IYUV,
+            SDL_PIXELFORMAT_YUY2,
+            SDL_PIXELFORMAT_UYVY,
+            SDL_PIXELFORMAT_YVYU
+        },
+        0,
+        0
     }
 };
 
 int WINCE_Available(void)
 {
+    void* render_gapi;
     const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
 
     // raw check
@@ -260,16 +261,16 @@
     ReleaseDC(NULL, hdc);
 
     if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
-        rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
-	    render_raw = 1;
+       rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
+        render_raw = 1;
 
     if(preferably && 0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0 != render_raw;
 
     // gapi check
-    HMODULE render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll"));
+    render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
     if(0 == render_gapi)
-        render_gapi = LoadLibrary(TEXT("gx.dll"));
-    FreeLibrary(render_gapi);
+        render_gapi = SDL_LoadObject("gx.dll");
+    SDL_UnloadObject(render_gapi);
 
     if(preferably && 0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0 != render_gapi;
 
@@ -279,7 +280,7 @@
 void WINCE_AddRenderDriver(_THIS)
 {
     HDC hdc;
-    HMODULE render_gapi;
+    void* render_gapi;
     int render_raw, ii;
     const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
 
@@ -290,34 +291,34 @@
     ReleaseDC(NULL, hdc);
 
     if(render_raw != 0 && rfbi.cxPixels != 0 && rfbi.cyPixels != 0 &&
-    	rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
-	    render_raw = 1;
+            rfbi.pFramePointer != 0 && rfbi.cxStride != 0 && rfbi.cyStride != 0)
+            render_raw = 1;
 
     // gapi check
-    render_gapi = LoadLibrary(TEXT("\\Windows\\gx.dll"));
+    render_gapi = SDL_LoadObject("\\Windows\\gx.dll");
     if(0 == render_gapi)
-        render_gapi = LoadLibrary(TEXT("gx.dll"));
+        render_gapi = SDL_LoadObject("gx.dll");
 
     if(render_gapi)
-	FreeLibrary(render_gapi);
+        SDL_UnloadObject(render_gapi);
 
     for(ii = 0; ii < _this->num_displays; ++ii)
     {
-	if(preferably)
-	{
-	    if(0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME) && render_raw)
-    		SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
-	    else
-	    if(0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME) && render_gapi)
-    		SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
-	}
-	else
-	{
-	    if(render_raw)
-    		SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
-	    if(render_gapi)
-    		SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
-	}
+        if(preferably)
+        {
+            if(0 == SDL_strcasecmp(preferably, RAW_RENDER_NAME) && render_raw)
+                SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
+            else
+            if(0 == SDL_strcasecmp(preferably, GAPI_RENDER_NAME) && render_gapi)
+                SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
+        }
+        else
+        {
+            if(render_raw)
+                SDL_AddRenderDriver(&_this->displays[ii], &RAW_RenderDriver);
+            if(render_gapi)
+                SDL_AddRenderDriver(&_this->displays[ii], &GAPI_RenderDriver);
+        }
     }
 }
 
@@ -332,7 +333,7 @@
     Uint32 Rmask, Gmask, Bmask, Amask;
 
     if(!(window->flags & SDL_WINDOW_FULLSCREEN))
-	window->flags |= SDL_WINDOW_FULLSCREEN;
+        window->flags |= SDL_WINDOW_FULLSCREEN;
 
     if(!SDL_PixelFormatEnumToMasks(displayMode->format, &bpp, &Rmask, &Gmask, &Bmask, &Amask))
     {
@@ -342,13 +343,13 @@
 
     switch(window->fullscreen_mode.format)
     {
-	case SDL_PIXELFORMAT_RGB555:
-	case SDL_PIXELFORMAT_RGB565:
-	    break;
+        case SDL_PIXELFORMAT_RGB555:
+        case SDL_PIXELFORMAT_RGB565:
+            break;
 
-	default:
-    	    SDL_SetError("Support only 16 or 15 bpp");
-	    return NULL;
+        default:
+            SDL_SetError("Support only 16 or 15 bpp");
+            return NULL;
     }
 
     renderer = (SDL_Renderer*) SDL_calloc(1, sizeof(SDL_Renderer));
@@ -375,9 +376,9 @@
 
 
     // set debug
-    data->debug	= SDL_getenv("DEBUG_VIDEO_GAPI") || SDL_getenv("GAPI_RENDERER_DEBUG") ? 1 : 0;
+    data->debug        = SDL_getenv("DEBUG_VIDEO_GAPI") || SDL_getenv("GAPI_RENDERER_DEBUG") ? 1 : 0;
 #if defined(DEBUG_VIDEO_GAPI) || defined(GAPI_RENDERER_DEBUG)
-    data->debug	= 1;
+    data->debug        = 1;
 #endif
 
     windowdata->videodata->render = data->gapi ? RENDER_GAPI : RENDER_RAW;
@@ -418,10 +419,10 @@
 
     if(renderdata)
     {
-	if(renderdata->gapi)
-    	    GAPI_Quit(renderdata);
-	else
-	    RAW_Quit(renderdata);
+        if(renderdata->gapi)
+            GAPI_Quit(renderdata);
+        else
+            RAW_Quit(renderdata);
 
         SDL_free(renderdata);
     }
@@ -448,20 +449,21 @@
 
     if(SDL_ISPIXELFORMAT_FOURCC(texture->format))
     {
-	texturedata->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
+        SDL_Window* window = renderer->window;
+        SDL_VideoDisplay* display = window->display;
+
+        texturedata->yuv = SDL_SW_CreateYUVTexture(texture->format, texture->w, texture->h);
         if(NULL == texturedata->yuv)
-	{
-    	    SDL_OutOfMemory();
+        {
+            SDL_OutOfMemory();
             return -1;
         }
-	SDL_Window* window = renderer->window;
-	SDL_VideoDisplay* display = window->display;
-	texturedata->format = display->current_mode.format;
+        texturedata->format = display->current_mode.format;
     }
     else
     {
-	texturedata->yuv = NULL;
-	texturedata->format = texture->format;
+        texturedata->yuv = NULL;
+        texturedata->format = texture->format;
     }
 
     texture->driverdata = texturedata;
@@ -475,10 +477,10 @@
 
     if(texturedata)
     {
-	if(texturedata->yuv) SDL_SW_DestroyYUVTexture(texturedata->yuv);
-	if(texturedata->pixels) SDL_free(texturedata->pixels);
-	SDL_free(texturedata);
-	texture->driverdata = NULL;
+        if(texturedata->yuv) SDL_SW_DestroyYUVTexture(texturedata->yuv);
+        if(texturedata->pixels) SDL_free(texturedata->pixels);
+        SDL_free(texturedata);
+        texture->driverdata = NULL;
     }
 }
 
@@ -509,19 +511,19 @@
 
     if(0 < rect->w && 0 < rect->h)
     {
-	const unsigned char *src = ((const unsigned char*) pixels);
-	unsigned char *dst = ((unsigned char*) texturedata->pixels) +
-				rect->y * texturedata->pitch +
-				rect->x * SDL_BYTESPERPIXEL(texture->format);
+        const unsigned char *src = ((const unsigned char*) pixels);
+        unsigned char *dst = ((unsigned char*) texturedata->pixels) +
+                                rect->y * texturedata->pitch +
+                                rect->x * SDL_BYTESPERPIXEL(texture->format);
         int length = rect->w * SDL_BYTESPERPIXEL(texture->format);
-	int height = rect->h;
+        int height = rect->h;
 
-	while(height--)
-	{
-	    SDL_memcpy(dst, src, length);
-	    dst += texturedata->pitch;
-	    src += pitch;
-	}
+        while(height--)
+        {
+            SDL_memcpy(dst, src, length);
+            dst += texturedata->pitch;
+            src += pitch;
+        }
     }
 
     return 0;
@@ -535,9 +537,10 @@
         return SDL_SW_LockYUVTexture(texturedata->yuv, rect, dirty, pixels, pitch);
 
     *pixels = (void *) ((unsigned char*) texturedata->pixels +
-		    rect->y * texturedata->pitch +
-		    rect->x * SDL_BYTESPERPIXEL(texture->format));
+                    rect->y * texturedata->pitch +
+                    rect->x * SDL_BYTESPERPIXEL(texture->format));
     *pitch = texturedata->pitch;
+    return 0;
 }
 
 void WINCE_UnlockTexture(SDL_Renderer* renderer, SDL_Texture* texture)
@@ -547,7 +550,7 @@
     if(texturedata->yuv)
     {
         SDL_SW_UnlockYUVTexture(texturedata->yuv);
-	WINCE_UpdateYUVTextureData(texture);
+        WINCE_UpdateYUVTextureData(texture);
     }
 }
 
@@ -555,41 +558,43 @@
 {
     WINCE_RenderData* dstdata = (WINCE_RenderData*) renderer->driverdata;
     WINCE_TextureData* srcdata = (WINCE_TextureData*) texture->driverdata;
+    const unsigned char *src;
+    unsigned char *dst;
 
     if((dstdata->flags & FB_SUSPENDED) ||
-       0 >= srect->w || 0 >= srect->h) return;
+       0 >= srect->w || 0 >= srect->h) return 0;
 
     // lock gapi
     if(dstdata->gapi) dstdata->gapi->GXBeginDraw();
 
-    const unsigned char *src = ((const unsigned char*) srcdata->pixels);
-    unsigned char *dst = dstdata->pixels + (dstdata->flags & FB_SKIP_OFFSET ? 0 : dstdata->fb.offset) +
-				drect->y * dstdata->fb.ypitch +
-				drect->x * dstdata->fb.xpitch;
+    src = ((const unsigned char*) srcdata->pixels);
+    dst = dstdata->pixels + (dstdata->flags & FB_SKIP_OFFSET ? 0 : dstdata->fb.offset) +
+                                drect->y * dstdata->fb.ypitch +
+                                drect->x * dstdata->fb.xpitch;
     if(srcdata->yuv)
     {
-	return SDL_SW_CopyYUVToRGB(srcdata->yuv,
+        return SDL_SW_CopyYUVToRGB(srcdata->yuv,
                                    srect, srcdata->format,
                                    drect->w, drect->h, dst,
                                    dstdata->fb.ypitch);
     }
     else
     {
-	int height = drect->h;
-	int length = drect->w * SDL_BYTESPERPIXEL(texture->format); // in bytes
+        int height = drect->h;
+        int length = drect->w * SDL_BYTESPERPIXEL(texture->format); // in bytes
 
-	while(height--)
-	{
-	    switch(SDL_BYTESPERPIXEL(texture->format))
-	    {
-		case 2: UpdateLine16to16(&dstdata->fb, (Uint16*) src, (Uint16*) dst, length >> 1); break;
+        while(height--)
+        {
+            switch(SDL_BYTESPERPIXEL(texture->format))
+            {
+                case 2: UpdateLine16to16(&dstdata->fb, (Uint16*) src, (Uint16*) dst, length >> 1); break;
 
-		default: break;
-	    }
+                default: break;
+            }
 
-	    dst += dstdata->fb.ypitch;
-	    src += srcdata->pitch;
-	}
+            dst += dstdata->fb.ypitch;
+            src += srcdata->pitch;
+        }
     }
 
     // unlock gapi
@@ -630,8 +635,8 @@
 
 void WINCE_SetupOrientation(WINCE_RenderData* data, int width, int height)
 {
-    const float maxW1 = GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) ? GetSystemMetrics(SM_CXSCREEN) : GetSystemMetrics(SM_CYSCREEN);
-    const float maxW2 = data->fb.width > data->fb.height ? data->fb.width : data->fb.height;
+    const float maxW1 = (float)(GetSystemMetrics(SM_CXSCREEN) > GetSystemMetrics(SM_CYSCREEN) ? GetSystemMetrics(SM_CXSCREEN) : GetSystemMetrics(SM_CYSCREEN));
+    const float maxW2 = (float)(data->fb.width > data->fb.height ? data->fb.width : data->fb.height);
 
     // scale define
     data->scale = maxW2 / maxW1;
@@ -643,31 +648,31 @@
     data->userOrientation = ORIENTATION_UP;
     data->systemOrientation = WINCE_GetDMOrientation();
     data->hardwareGeometry = data->fb.width == data->fb.height ? GEOMETRY_SQUARE :
-				(data->fb.width < data->fb.height ? GEOMETRY_PORTRAIT : GEOMETRY_LANDSCAPE);
+                                (data->fb.width < data->fb.height ? GEOMETRY_PORTRAIT : GEOMETRY_LANDSCAPE);
 
     if(data->debug)
-	WINCE_DumpVideoInfo(data);
+        WINCE_DumpVideoInfo(data);
 
     if(data->systemOrientation == ORIENTATION_UNKNOWN)
-	data->systemOrientation == ORIENTATION_UP;
+        data->systemOrientation = ORIENTATION_UP;
 
     data->userOrientation = ORIENTATION_UP;
 
     switch(data->hardwareGeometry)
     {
-	case GEOMETRY_PORTRAIT:  WINCE_PortraitTransform(data, width, height); break;
-	case GEOMETRY_LANDSCAPE: WINCE_LandscapeTransform(data, width, height); break;
-	case GEOMETRY_SQUARE:    WINCE_SquareTransform(data, width, height); break;
-	default: break;
+        case GEOMETRY_PORTRAIT:  WINCE_PortraitTransform(data, width, height); break;
+        case GEOMETRY_LANDSCAPE: WINCE_LandscapeTransform(data, width, height); break;
+        case GEOMETRY_SQUARE:    WINCE_SquareTransform(data, width, height); break;
+        default: break;
     }
 
     // debug
     if(data->debug)
     {
-	printf("\n");
-	printf("user video width:          %d\n", width);
-	printf("user video height:         %d\n", height);
-	FrameBufferDumpInfo(&data->fb, "user");
+        printf("\n");
+        printf("user video width:          %d\n", width);
+        printf("user video height:         %d\n", height);
+        FrameBufferDumpInfo(&data->fb, "user");
     }
 }
 
@@ -705,42 +710,42 @@
 
     if(visible)
     {
-	if(window->flags & SDL_WINDOW_FULLSCREEN)
-	{
-	    if(videodata->SHFullScreen)
-		videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
-	    ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
-	}
+        if(window->flags & SDL_WINDOW_FULLSCREEN)
+        {
+            if(videodata->SHFullScreen)
+                videodata->SHFullScreen(windowdata->hwnd, SHFS_HIDETASKBAR | SHFS_HIDESTARTICON | SHFS_HIDESIPBUTTON);
+            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_HIDE);
+        }
 
-	ShowWindow(windowdata->hwnd, SW_SHOW);
+        ShowWindow(windowdata->hwnd, SW_SHOW);
         SetForegroundWindow(windowdata->hwnd);
 
-	if(renderer &&
-	    (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
-	{
-	    WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
-	    renderdata->flags &= ~FB_SUSPENDED;
-	    if(renderdata->gapi) renderdata->gapi->GXResume();
-	}
+        if(renderer &&
+            (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
+        {
+            WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
+            renderdata->flags &= ~FB_SUSPENDED;
+            if(renderdata->gapi) renderdata->gapi->GXResume();
+        }
     }
     else
     {
-	if(renderer &&
-	    (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
-	{
-	    WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
-	    if(renderdata->gapi) renderdata->gapi->GXSuspend();
-	    renderdata->flags |= FB_SUSPENDED;
-	}
+        if(renderer &&
+            (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
+        {
+            WINCE_RenderData* renderdata = (WINCE_RenderData*) renderer->driverdata;
+            if(renderdata->gapi) renderdata->gapi->GXSuspend();
+            renderdata->flags |= FB_SUSPENDED;
+        }
 
-	ShowWindow(windowdata->hwnd, SW_HIDE);
+        ShowWindow(windowdata->hwnd, SW_HIDE);
 
-	if(window->flags & SDL_WINDOW_FULLSCREEN)
-	{
-	    if(videodata->SHFullScreen)
-		videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
-	    ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
-	}
+        if(window->flags & SDL_WINDOW_FULLSCREEN)
+        {
+            if(videodata->SHFullScreen)
+                videodata->SHFullScreen(windowdata->hwnd, SHFS_SHOWTASKBAR | SHFS_SHOWSTARTICON | SHFS_SHOWSIPBUTTON);
+            ShowWindow(FindWindow(TEXT("HHTaskBar"), NULL), SW_SHOW);
+        }
     }
 }
 
@@ -749,8 +754,8 @@
 {
     WINCE_RenderData* data = (WINCE_RenderData*) window->renderer->driverdata;
 
-    pt->x *= data->scale;
-    pt->y *= data->scale;
+    pt->x = (LONG)(pt->x * data->scale);
+    pt->y = (LONG)(pt->y * data->scale);
 
     PointerRotate(pt, &data->fb, data->userOrientation);
 }
@@ -758,44 +763,45 @@
 void WINCE_PortraitTransform(WINCE_RenderData* data, int width, int height)
 {
     if(data->systemOrientation != ORIENTATION_UP)
-	FrameBufferRotate(&data->fb, data->systemOrientation);
+        FrameBufferRotate(&data->fb, data->systemOrientation);
 
-    if(data->fb.width != width || data->fb.height != height)
-    switch(data->systemOrientation)
-    {
-	case ORIENTATION_UP:
-	case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
-	case ORIENTATION_RIGHT:
-	case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
-	default: break;
+    if(data->fb.width != width || data->fb.height != height) {
+        switch(data->systemOrientation)
+        {
+            case ORIENTATION_UP:
+            case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
+            case ORIENTATION_RIGHT:
+            case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
+            default: break;
+        }
     }
 
     if(data->userOrientation != ORIENTATION_UP)
-	FrameBufferRotate(&data->fb, data->userOrientation);
+        FrameBufferRotate(&data->fb, data->userOrientation);
 }
 
 void WINCE_LandscapeTransform(WINCE_RenderData* data, int width, int height)
 {
     switch(data->systemOrientation)
     {
-	case ORIENTATION_UP:  FrameBufferRotate(&data->fb, ORIENTATION_LEFT); break;
-	case ORIENTATION_LEFT:FrameBufferRotate(&data->fb, ORIENTATION_DOWN); break;
-	case ORIENTATION_DOWN:FrameBufferRotate(&data->fb, ORIENTATION_RIGHT); break;
-	default: break;
+        case ORIENTATION_UP:  FrameBufferRotate(&data->fb, ORIENTATION_LEFT); break;
+        case ORIENTATION_LEFT:FrameBufferRotate(&data->fb, ORIENTATION_DOWN); break;
+        case ORIENTATION_DOWN:FrameBufferRotate(&data->fb, ORIENTATION_RIGHT); break;
+        default: break;
     }
 
     if(data->fb.width != width || data->fb.height != height)
     switch(data->systemOrientation)
     {
-	case ORIENTATION_UP:
-	case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
-	case ORIENTATION_RIGHT:
-	case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
-	default: break;
+        case ORIENTATION_UP:
+        case ORIENTATION_LEFT: data->userOrientation = ORIENTATION_RIGHT; break;
+        case ORIENTATION_RIGHT:
+        case ORIENTATION_DOWN: data->userOrientation = ORIENTATION_LEFT; break;
+        default: break;
     }
 
     if(data->userOrientation != ORIENTATION_UP)
-	FrameBufferRotate(&data->fb, data->userOrientation);
+        FrameBufferRotate(&data->fb, data->userOrientation);
 }
 
 void WINCE_SquareTransform(WINCE_RenderData* data, int width, int height)
@@ -807,43 +813,43 @@
 {
     // check square
     if(GetSystemMetrics(SM_CXSCREEN) == GetSystemMetrics(SM_CYSCREEN) &&
-	fb->width != fb->height)
+        fb->width != fb->height)
     {
-	if(fb->width < fb->height)
-	    fb->height = fb->width;
-	else
-	if(fb->height < fb->width)
-	    fb->width = fb->height;
+        if(fb->width < fb->height)
+            fb->height = fb->width;
+        else
+        if(fb->height < fb->width)
+            fb->width = fb->height;
     }
 
     // check width
     if(__abs(fb->xpitch) == bpp &&
-	fb->width  != __abs(fb->ypitch) / bpp)
+        fb->width  != __abs(fb->ypitch) / bpp)
     {
-	if(fb->height == __abs(fb->ypitch) / bpp)
-    	{
-	    __swap(&fb->width, &fb->height);
+        if(fb->height == __abs(fb->ypitch) / bpp)
+            {
+            __swap(&fb->width, &fb->height);
 
-	    if(debug)
-		printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
-	}
-	else
-	    return -1;
+            if(debug)
+                printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
+        }
+        else
+            return -1;
     }
     else
     // check height
     if(__abs(fb->ypitch) == bpp &&
-	fb->height != __abs(fb->xpitch) / bpp)
+        fb->height != __abs(fb->xpitch) / bpp)
     {
-	if(fb->width  == __abs(fb->xpitch) / bpp)
-    	{
-	    __swap(&fb->width, &fb->height);
+        if(fb->width  == __abs(fb->xpitch) / bpp)
+            {
+            __swap(&fb->width, &fb->height);
 
-	    if(debug)
-		printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
-	}
-	else
-	    return -1;
+            if(debug)
+                printf("WINCE_FixedGeometry: width: %d, height: %d\n", fb->width, fb->height);
+        }
+        else
+            return -1;
     }
 
     return 0;
@@ -865,8 +871,12 @@
 {
     if(NULL == data->gapi)
     {
-	const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
-	if(preferably && 0 != SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0;
+        struct GXDisplayProperties gxProperties;
+        GXDeviceInfo gxInfo = { 0 };
+        HDC hdc;
+        int enable, result;
+        const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
+        if(preferably && 0 != SDL_strcasecmp(preferably, GAPI_RENDER_NAME)) return 0;
 
         data->gapi = (GapiInfo *) SDL_calloc(1, sizeof(GapiInfo));
         if(NULL == data->gapi)
@@ -875,116 +885,116 @@
             return 0;
         }
 
-	data->gapi->hGapiLib = LoadLibrary(TEXT("\\Windows\\gx.dll"));
-	if(0 == data->gapi->hGapiLib)
-	{
-	    data->gapi->hGapiLib = LoadLibrary(TEXT("gx.dll"));
-	    if(0 == data->gapi->hGapiLib) return 0;
-	}
+        data->gapi->hGapiLib = SDL_LoadObject("\\Windows\\gx.dll");
+        if(0 == data->gapi->hGapiLib)
+        {
+            data->gapi->hGapiLib = SDL_LoadObject("gx.dll");
+            if(0 == data->gapi->hGapiLib) return 0;
+        }
 
-	// load gapi library
-#define LINK(type,name,import) name=(PFN##type)GetProcAddress(data->gapi->hGapiLib,TEXT(import))
-	LINK(GXOpenDisplay,         data->gapi->GXOpenDisplay,         "?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
-	LINK(GXCloseDisplay,        data->gapi->GXCloseDisplay,        "?GXCloseDisplay@@YAHXZ");
-	LINK(GXBeginDraw,           data->gapi->GXBeginDraw,           "?GXBeginDraw@@YAPAXXZ");
-	LINK(GXEndDraw,             data->gapi->GXEndDraw,             "?GXEndDraw@@YAHXZ");
-	LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ");
-	LINK(GXSuspend,             data->gapi->GXSuspend,             "?GXSuspend@@YAHXZ");
-	LINK(GXResume,              data->gapi->GXResume,              "?GXResume@@YAHXZ");
+        // load gapi library
+#define LINK(type,name,import) name=(PFN##type)SDL_LoadFunction(data->gapi->hGapiLib,import)
+        LINK(GXOpenDisplay,         data->gapi->GXOpenDisplay,         "?GXOpenDisplay@@YAHPAUHWND__@@K@Z");
+        LINK(GXCloseDisplay,        data->gapi->GXCloseDisplay,        "?GXCloseDisplay@@YAHXZ");
+        LINK(GXBeginDraw,           data->gapi->GXBeginDraw,           "?GXBeginDraw@@YAPAXXZ");
+        LINK(GXEndDraw,             data->gapi->GXEndDraw,             "?GXEndDraw@@YAHXZ");
+        LINK(GXGetDisplayProperties,data->gapi->GXGetDisplayProperties,"?GXGetDisplayProperties@@YA?AUGXDisplayProperties@@XZ");
+        LINK(GXSuspend,             data->gapi->GXSuspend,             "?GXSuspend@@YAHXZ");
+        LINK(GXResume,              data->gapi->GXResume,              "?GXResume@@YAHXZ");
 #undef LINK
 
-	int enable = data->gapi->GXGetDisplayProperties && data->gapi->GXCloseDisplay && data->gapi->GXOpenDisplay &&
-	    data->gapi->GXBeginDraw && data->gapi->GXEndDraw && data->gapi->GXSuspend && data->gapi->GXResume;
+        enable = data->gapi->GXGetDisplayProperties && data->gapi->GXCloseDisplay && data->gapi->GXOpenDisplay &&
+            data->gapi->GXBeginDraw && data->gapi->GXEndDraw && data->gapi->GXSuspend && data->gapi->GXResume;
 
-	if(!enable)
-	{
-	    SDL_SetError("GAPI_Init: error gx.dll: internal error");
-	    GAPI_Quit(data);
-	    return 0;
-	}
+        if(!enable)
+        {
+            SDL_SetError("GAPI_Init: error gx.dll: internal error");
+            GAPI_Quit(data);
+            return 0;
+        }
 
-	if(0 == data->gapi->GXOpenDisplay(hwnd, GX_FULLSCREEN))
-	{
-	    SDL_SetError("GAPI_Init: couldn't initialize GAPI");
-	    GAPI_Quit(data);
-	    return 0;
-	}
+        if(0 == data->gapi->GXOpenDisplay(hwnd, GX_FULLSCREEN))
+        {
+            SDL_SetError("GAPI_Init: couldn't initialize GAPI");
+            GAPI_Quit(data);
+            return 0;
+        }
 
-	struct GXDisplayProperties gxProperties = data->gapi->GXGetDisplayProperties();
+        gxProperties = data->gapi->GXGetDisplayProperties();
 
-	// fill FrameBufferInfo
-	data->fb.xpitch = gxProperties.cbxPitch;
-	data->fb.ypitch = gxProperties.cbyPitch;
-	data->fb.width  = gxProperties.cxWidth;
-	data->fb.height = gxProperties.cyHeight;
-	data->fb.offset = 0;
+        // fill FrameBufferInfo
+        data->fb.xpitch = gxProperties.cbxPitch;
+        data->fb.ypitch = gxProperties.cbyPitch;
+        data->fb.width  = gxProperties.cxWidth;
+        data->fb.height = gxProperties.cyHeight;
+        data->fb.offset = 0;
 
         if((gxProperties.ffFormat & kfDirect565) || 16 == gxProperties.cBPP)
-	    data->format = SDL_PIXELFORMAT_RGB565;
-	else
-	if((gxProperties.ffFormat & kfDirect555) || 15 == gxProperties.cBPP)
-	    data->format = SDL_PIXELFORMAT_RGB555;
-	else
-	    data->format = 0;
+            data->format = SDL_PIXELFORMAT_RGB565;
+        else
+        if((gxProperties.ffFormat & kfDirect555) || 15 == gxProperties.cBPP)
+            data->format = SDL_PIXELFORMAT_RGB555;
+        else
+            data->format = 0;
 
-	// get pixels
-	GXDeviceInfo gxInfo = { 0 };
-	HDC hdc = GetDC(NULL);
+        // get pixels
+        hdc = GetDC(NULL);
 
-	gxInfo.Version = 100;
-	int result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *) &gxInfo);
-	ReleaseDC(NULL, hdc);
+        gxInfo.Version = 100;
+        result = ExtEscape(hdc, GETGXINFO, 0, NULL, sizeof(gxInfo), (char *) &gxInfo);
+        ReleaseDC(NULL, hdc);
 
-	if(result > 0)
-	{
-	    // more debug
-	    if(data->debug)
-	    {
-		printf("GXDeviceInfo.pvFrameBuffer:    %p\n", gxInfo.pvFrameBuffer);
-    		printf("GXDeviceInfo.cxWidth:          %d\n", gxInfo.cxWidth);
-    		printf("GXDeviceInfo.cyHeight:         %d\n", gxInfo.cyHeight);
-    		printf("GXDeviceInfo.cbStride:         %d\n", gxInfo.cbStride);
-    		printf("GXDeviceInfo.cBPP:             %d\n", gxInfo.cBPP);
-    		printf("GXDeviceInfo.ffFormat:        0x%x\n", gxInfo.ffFormat);
+        if(result > 0)
+        {
+            // more debug
+            if(data->debug)
+            {
+                int i;
 
-    		printf("GXDeviceInfo.unk:\n");
-		int ii; for(ii = 0; ii <  sizeof(gxInfo.unknown); ++ii)
-		printf("0x%02hhX,", gxInfo.unknown[ii]);
-		printf("\n");
-	    }
+                printf("GXDeviceInfo.pvFrameBuffer:    %p\n", gxInfo.pvFrameBuffer);
+                printf("GXDeviceInfo.cxWidth:          %d\n", gxInfo.cxWidth);
+                printf("GXDeviceInfo.cyHeight:         %d\n", gxInfo.cyHeight);
+                printf("GXDeviceInfo.cbStride:         %d\n", gxInfo.cbStride);
+                printf("GXDeviceInfo.cBPP:             %d\n", gxInfo.cBPP);
+                printf("GXDeviceInfo.ffFormat:        0x%x\n", gxInfo.ffFormat);
 
-    	    if(gxInfo.ffFormat && gxInfo.ffFormat != gxProperties.ffFormat)
-	    {
-		if((gxInfo.ffFormat & kfDirect565) || 16 == gxInfo.cBPP)
-		    data->format = SDL_PIXELFORMAT_RGB565;
-		else
-		if((gxInfo.ffFormat & kfDirect555) || 15 == gxInfo.cBPP)
-		    data->format = SDL_PIXELFORMAT_RGB555;
-	    }
+                printf("GXDeviceInfo.unk:\n");
+                for(i = 0; i <  sizeof(gxInfo.unknown); ++i)
+                    printf("0x%02hhX,", gxInfo.unknown[i]);
+                printf("\n");
+            }
 
-    	    data->pixels = gxInfo.pvFrameBuffer;
+                if(gxInfo.ffFormat && gxInfo.ffFormat != gxProperties.ffFormat) {
+                    if((gxInfo.ffFormat & kfDirect565) || 16 == gxInfo.cBPP)
+                        data->format = SDL_PIXELFORMAT_RGB565;
+                    else
+                    if((gxInfo.ffFormat & kfDirect555) || 15 == gxInfo.cBPP)
+                        data->format = SDL_PIXELFORMAT_RGB555;
+                }
+
+                data->pixels = gxInfo.pvFrameBuffer;
         }
-	else
-	{
-	    data->flags |= FB_SKIP_OFFSET;
-	    data->pixels = data->gapi->GXBeginDraw();
-	    data->gapi->GXEndDraw();
+        else
+        {
+            data->flags |= FB_SKIP_OFFSET;
+            data->pixels = data->gapi->GXBeginDraw();
+            data->gapi->GXEndDraw();
 
-	    if(data->debug)
-	    {
-		printf("GAPI_Init\n");
-		printf("use GXBeginDraw:               %p\n", data->pixels);
-		printf("use skip offset\n");
-	    }
-	}
+            if(data->debug)
+            {
+                printf("GAPI_Init\n");
+                printf("use GXBeginDraw:               %p\n", data->pixels);
+                printf("use skip offset\n");
+            }
+        }
 
-	if(0 == data->format ||
-	    0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
-	{
-	    SDL_SetError("GAPI_Init: unknown hardware");
-	    GAPI_Quit(data);
-	    return 0;
-	}
+        if(0 == data->format ||
+            0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
+        {
+            SDL_SetError("GAPI_Init: unknown hardware");
+            GAPI_Quit(data);
+            return 0;
+        }
     }
 
     return data->gapi && data->pixels ? 1 : 0;
@@ -994,28 +1004,30 @@
 {
     if(data->gapi)
     {
-	if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay(); 
-	if(data->gapi->hGapiLib)  FreeLibrary(data->gapi->hGapiLib);
+        if(data->gapi->GXCloseDisplay) data->gapi->GXCloseDisplay(); 
+        if(data->gapi->hGapiLib)  SDL_UnloadObject(data->gapi->hGapiLib);
 
-	SDL_free(data->gapi);
+        SDL_free(data->gapi);
         data->gapi = NULL;
     }
 }
 
 int RAW_Init(WINCE_RenderData* data)
 {
+    RawFrameBufferInfo rfbi = { 0 };
+    HDC hdc;
+    int result;
     const char* preferably = SDL_getenv("SDL_VIDEO_RENDERER");
     if(preferably && 0 != SDL_strcasecmp(preferably, RAW_RENDER_NAME)) return 0;
 
-    RawFrameBufferInfo rfbi = { 0 };
-    HDC hdc = GetDC(NULL);
-    int result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
+    hdc = GetDC(NULL);
+    result = ExtEscape(hdc, GETRAWFRAMEBUFFER, 0, NULL, sizeof(RawFrameBufferInfo), (char *) &rfbi);
     ReleaseDC(NULL, hdc);
 
     //disable
     if(result == 0 || rfbi.pFramePointer == 0 ||
-    	rfbi.cxPixels == 0 || rfbi.cyPixels == 0 ||
-	rfbi.cxStride == 0 || rfbi.cyStride == 0) return 0;
+            rfbi.cxPixels == 0 || rfbi.cyPixels == 0 ||
+        rfbi.cxStride == 0 || rfbi.cyStride == 0) return 0;
 
     data->flags     = FB_RAW_MODE;
 
@@ -1029,19 +1041,19 @@
     data->fb.offset = 0;
 
     if((FORMAT_565 & rfbi.wFormat) || 16 == rfbi.wBPP)
-	data->format = SDL_PIXELFORMAT_RGB565;
+        data->format = SDL_PIXELFORMAT_RGB565;
     else
     if((FORMAT_555 & rfbi.wFormat) || 15 == rfbi.wBPP)
-	data->format = SDL_PIXELFORMAT_RGB555;
+        data->format = SDL_PIXELFORMAT_RGB555;
     else
-	data->format = 0;
+        data->format = 0;
 
     if(0 == data->format ||
-	0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
+        0 > WINCE_FixedGeometry(&data->fb, SDL_BYTESPERPIXEL(data->format), data->debug))
     {
-	SDL_SetError("RAW_Init: unknown hardware");
-	RAW_Quit(data);
-	return 0;
+        SDL_SetError("RAW_Init: unknown hardware");
+        RAW_Quit(data);
+        return 0;
     }
 
     data->pixels = rfbi.pFramePointer;
@@ -1060,50 +1072,50 @@
     // set correct start offset
     switch(orientation)
     {
-	case ORIENTATION_UP:
-	    fb->offset = 0;
-	    break;
+        case ORIENTATION_UP:
+            fb->offset = 0;
+            break;
 
-	case ORIENTATION_LEFT:
-	    fb->offset = __abs(fb->ypitch * (fb->height - 1));
-	    break;
+        case ORIENTATION_LEFT:
+            fb->offset = __abs(fb->ypitch * (fb->height - 1));
+            break;
 
-	case ORIENTATION_RIGHT:
-	    fb->offset = __abs(fb->xpitch * (fb->width - 1));
-	    break;
+        case ORIENTATION_RIGHT:
+            fb->offset = __abs(fb->xpitch * (fb->width - 1));
+            break;
 
-	case ORIENTATION_DOWN:
-	    fb->offset = __abs(fb->xpitch * (fb->width - 1) +
-				fb->ypitch * (fb->height - 1));
-	    break;
+        case ORIENTATION_DOWN:
+            fb->offset = __abs(fb->xpitch * (fb->width - 1) +
+                                fb->ypitch * (fb->height - 1));
+            break;
 
-	default: break;
+        default: break;
     }
 
     //if(orientation != ORIENTATION_UP)
     switch(orientation)
     {
-	case ORIENTATION_LEFT: FrameBufferRotate(fb, ORIENTATION_RIGHT); break;
-	case ORIENTATION_RIGHT:FrameBufferRotate(fb, ORIENTATION_LEFT); break;
-	case ORIENTATION_DOWN: FrameBufferRotate(fb, ORIENTATION_DOWN); break;
+        case ORIENTATION_LEFT: FrameBufferRotate(fb, ORIENTATION_RIGHT); break;
+        case ORIENTATION_RIGHT:FrameBufferRotate(fb, ORIENTATION_LEFT); break;
+        case ORIENTATION_DOWN: FrameBufferRotate(fb, ORIENTATION_DOWN); break;
 
-	default: break;
+        default: break;
     }
 }
 
 int GetFrameBufferOrientation(const FrameBufferInfo* src)
 {
     if(src->xpitch > 0 && src->ypitch > 0)
-	return ORIENTATION_UP;
+        return ORIENTATION_UP;
     else
     if(src->xpitch > 0 && src->ypitch < 0)
-	return ORIENTATION_LEFT;
+        return ORIENTATION_LEFT;
     else
     if(src->xpitch < 0 && src->ypitch > 0)
-	return ORIENTATION_RIGHT;
+        return ORIENTATION_RIGHT;
     else
     if(src->xpitch < 0 && src->ypitch < 0)
-	return ORIENTATION_DOWN;
+        return ORIENTATION_DOWN;
 
     return ORIENTATION_UNKNOWN;
 }
@@ -1117,28 +1129,28 @@
     switch(orientation)
     {
         case ORIENTATION_LEFT:
-	    dst->width  = src.height;
-	    dst->height = src.width;
-	    dst->xpitch = src.ypitch;
-	    dst->ypitch = -src.xpitch;
-	    dst->offset = src.offset + src.xpitch * (src.width - 1);
-	    break;
+            dst->width  = src.height;
+            dst->height = src.width;
+            dst->xpitch = src.ypitch;
+            dst->ypitch = -src.xpitch;
+            dst->offset = src.offset + src.xpitch * (src.width - 1);
+            break;
 
         case ORIENTATION_RIGHT:
-	    dst->width  = src.height;
-	    dst->height = src.width;
-	    dst->xpitch = -src.ypitch;
-	    dst->ypitch = src.xpitch;
-	    dst->offset = src.offset + src.ypitch * (src.height - 1);
-	    break;
+            dst->width  = src.height;
+            dst->height = src.width;
+            dst->xpitch = -src.ypitch;
+            dst->ypitch = src.xpitch;
+            dst->offset = src.offset + src.ypitch * (src.height - 1);
+            break;
 
         case ORIENTATION_DOWN:
-	    FrameBufferRotate(dst, ORIENTATION_LEFT);
-	    FrameBufferRotate(dst, ORIENTATION_LEFT);
-	    break;
+            FrameBufferRotate(dst, ORIENTATION_LEFT);
+            FrameBufferRotate(dst, ORIENTATION_LEFT);
+            break;
 
         default:
-	    break;
+            break;
     }
 }
 
@@ -1146,31 +1158,31 @@
 {
     switch(orientation)
     {
-	case ORIENTATION_UP:
-	    break;
+        case ORIENTATION_UP:
+            break;
 
-	case ORIENTATION_LEFT:
-	{
-	    int temp = pt->y;
-	    pt->y = fb->height - pt->x;
-	    pt->x = temp;
-	}
-	    break;
+        case ORIENTATION_LEFT:
+        {
+            int temp = pt->y;
+            pt->y = fb->height - pt->x;
+            pt->x = temp;
+        }
+            break;
 
-	case ORIENTATION_RIGHT:
-	{
-	    int temp = pt->x;
-	    pt->x = fb->width - pt->y;
-	    pt->y = temp;
-	}
-	    break;
+        case ORIENTATION_RIGHT:
+        {
+            int temp = pt->x;
+            pt->x = fb->width - pt->y;
+            pt->y = temp;
+        }
+            break;
 
-	case ORIENTATION_DOWN:
-	    pt->x = fb->width  - pt->x;
-	    pt->y = fb->height - pt->y;
-	    break;
+        case ORIENTATION_DOWN:
+            pt->x = fb->width  - pt->x;
+            pt->y = fb->height - pt->y;
+            break;
 
-	default: break;
+        default: break;
     }
 }
 
@@ -1196,14 +1208,14 @@
 
     // DMDO_0, DMDO_90, DMDO_180, DMDO_270
     if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_TEST, NULL))
-	switch(sDevMode.dmDisplayOrientation)
-	{
-	    case DMDO_0:	return DMDO_0;
-	    case DMDO_90:	return DMDO_90;
-	    case DMDO_180:	return DMDO_180;
-	    case DMDO_270:	return DMDO_270;
-	    default: break;
-	}
+        switch(sDevMode.dmDisplayOrientation)
+        {
+            case DMDO_0:        return DMDO_0;
+            case DMDO_90:        return DMDO_90;
+            case DMDO_180:        return DMDO_180;
+            case DMDO_270:        return DMDO_270;
+            default: break;
+        }
 
     SDL_SetError("WINCE_GetDMOrientation: ChangeDisplaySettingsEx return BADMODE");
     return -1;
@@ -1217,15 +1229,15 @@
 
     switch(orientation)
     {
-	case DMDO_0:	sDevMode.dmDisplayOrientation = DMDO_0;   break;
-	case DMDO_90:	sDevMode.dmDisplayOrientation = DMDO_90;  break;
-	case DMDO_180:	sDevMode.dmDisplayOrientation = DMDO_180; break;
-	case DMDO_270:	sDevMode.dmDisplayOrientation = DMDO_270; break;
-	default: return 0;
+        case DMDO_0:        sDevMode.dmDisplayOrientation = DMDO_0;   break;
+        case DMDO_90:        sDevMode.dmDisplayOrientation = DMDO_90;  break;
+        case DMDO_180:        sDevMode.dmDisplayOrientation = DMDO_180; break;
+        case DMDO_270:        sDevMode.dmDisplayOrientation = DMDO_270; break;
+        default: return 0;
     }
 
     if(DISP_CHANGE_BADMODE != ChangeDisplaySettingsEx(NULL, &sDevMode, 0, CDS_RESET, NULL))
-	return 1;
+        return 1;
 
     SDL_SetError("WINCE_SetDMOrientation: ChangeDisplaySettingsEx return BADMODE");
     return -1;
@@ -1233,13 +1245,15 @@
 
 void FrameBufferDumpInfo(const FrameBufferInfo* fb, const char* name)
 {
+    int orientation;
+
     printf("%s fb.width:       %d\n", name, fb->width);
     printf("%s fb.height:      %d\n", name, fb->height);
     printf("%s fb.xpitch:      %d\n", name, fb->xpitch);
     printf("%s fb.ypitch:      %d\n", name, fb->ypitch);
     printf("%s fb.offset:      %d\n", name, fb->offset);
 
-    int orientation = GetFrameBufferOrientation(fb);
+    orientation = GetFrameBufferOrientation(fb);
     printf("%s fb.orientation: %d, %s\n", name, orientation, GetOrientationName(orientation));
 }
 
@@ -1247,34 +1261,34 @@
 {
     if(2 == fb->xpitch)
     {
-	switch(width)
-	{
-	    case 1:
-		*dst = *src;
-		break;
+        switch(width)
+        {
+            case 1:
+                *dst = *src;
+                break;
 
-	    case 2:
-		*((Uint32*) dst) = *((Uint32*) src);
-		break;
+            case 2:
+                *((Uint32*) dst) = *((Uint32*) src);
+                break;
 
-	    default:
-		SDL_memcpy(dst, src, width * 2);
-		break;
-	}
+            default:
+                SDL_memcpy(dst, src, width * 2);
+                break;
+        }
     }
     else
     if(-2 == fb->xpitch)
     {
-	while(width--)
-	    *dst-- = *src++;
+        while(width--)
+            *dst-- = *src++;
     }
     else
     {
-	while(width--)
-	{
-	    *dst = *src++;
-	    dst += fb->xpitch / 2;
-	}
+        while(width--)
+        {
+            *dst = *src++;
+            dst += fb->xpitch / 2;
+        }
     }
 }
 
--- a/src/video/windows/SDL_gdirender.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_gdirender.c	Tue Feb 01 00:37:02 2011 -0800
@@ -167,8 +167,10 @@
     SDL_WindowData *windowdata = (SDL_WindowData *) window->driverdata;
     SDL_Renderer *renderer;
     GDI_RenderData *data;
+#ifndef NO_GETDIBBITS
     int bmi_size;
     HBITMAP hbm;
+#endif
     int i, n;
 
     renderer = (SDL_Renderer *) SDL_calloc(1, sizeof(*renderer));
--- a/src/video/windows/SDL_windowsevents.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_windowsevents.c	Tue Feb 01 00:37:02 2011 -0800
@@ -192,20 +192,20 @@
 
 	case WM_MOUSEMOVE:
 #ifdef _WIN32_WCE
-	/* transform coords for VGA, WVGA... */
-	{
-	    SDL_VideoData *videodata = data->videodata;
-	    if(videodata->CoordTransform &&
-		(videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
-	    {
-		POINT pt;
-		pt.x = LOWORD(lParam);
-		pt.y = HIWORD(lParam);
-		videodata->CoordTransform(data->window, &pt);
-    		SDL_SendMouseMotion(data->window, 0, pt.x, pt.y);
-		break;
-	    }
-	}
+        /* transform coords for VGA, WVGA... */
+        {
+            SDL_VideoData *videodata = data->videodata;
+            if(videodata->CoordTransform &&
+                (videodata->render == RENDER_GAPI || videodata->render == RENDER_RAW))
+            {
+                POINT pt;
+                pt.x = LOWORD(lParam);
+                pt.y = HIWORD(lParam);
+                videodata->CoordTransform(data->window, &pt);
+                    SDL_SendMouseMotion(data->window, 0, pt.x, pt.y);
+                break;
+            }
+        }
 #endif
         SDL_SendMouseMotion(data->window, 0, LOWORD(lParam), HIWORD(lParam));
         break;
@@ -252,12 +252,15 @@
             break;
         }
 
+#ifdef WM_MOUSELEAVE
+    /* FIXME: Do we need the SDL 1.2 hack to generate WM_MOUSELEAVE now? */
     case WM_MOUSELEAVE:
         if (SDL_GetMouseFocus() == data->window) {
             SDL_SetMouseFocus(NULL);
         }
         returnCode = 0;
         break;
+#endif /* WM_MOUSELEAVE */
 
     case WM_SYSKEYDOWN:
     case WM_KEYDOWN:
@@ -382,13 +385,16 @@
         returnCode = 0;
         break;
 
+#ifdef WM_INPUTLANGCHANGE
     case WM_INPUTLANGCHANGE:
         {
             WIN_UpdateKeymap();
         }
         returnCode = 1;
         break;
+#endif /* WM_INPUTLANGCHANGE */
 
+#ifdef WM_GETMINMAXINFO
     case WM_GETMINMAXINFO:
         {
             MINMAXINFO *info;
@@ -447,6 +453,7 @@
         }
         returnCode = 0;
         break;
+#endif /* WM_GETMINMAXINFO */
 
     case WM_WINDOWPOSCHANGED:
         {
@@ -534,6 +541,7 @@
         }
         return (1);
 
+#if defined(SC_SCREENSAVE) || defined(SC_MONITORPOWER)
     case WM_SYSCOMMAND:
         {
             /* Don't start the screensaver or blank the monitor in fullscreen apps */
@@ -545,6 +553,7 @@
             }
         }
         break;
+#endif /* System has screensaver support */
 
     case WM_CLOSE:
         {
@@ -656,7 +665,9 @@
     }
     if (!name && !SDL_Appname) {
         name = "SDL_app";
+#if defined(CS_BYTEALIGNCLIENT) || defined(CS_OWNDC)
         SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC);
+#endif
         SDL_Instance = hInst ? hInst : GetModuleHandle(NULL);
     }
 
--- a/src/video/windows/SDL_windowskeyboard.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_windowskeyboard.c	Tue Feb 01 00:37:02 2011 -0800
@@ -21,6 +21,10 @@
 */
 #include "SDL_config.h"
 
+#ifdef _WIN32_WCE
+#define SDL_DISABLE_WINDOWS_IME
+#endif
+
 #include "SDL_windowsvideo.h"
 
 #include "../../events/SDL_keyboard_c.h"
@@ -29,10 +33,12 @@
 #include <imm.h>
 #include <oleauto.h>
 
+#ifndef SDL_DISABLE_WINDOWS_IME
 static void IME_Init(SDL_VideoData *videodata, HWND hwnd);
 static void IME_Enable(SDL_VideoData *videodata, HWND hwnd);
 static void IME_Disable(SDL_VideoData *videodata, HWND hwnd);
 static void IME_Quit(SDL_VideoData *videodata);
+#endif /* !SDL_DISABLE_WINDOWS_IME */
 
 #ifndef MAPVK_VK_TO_VSC
 #define MAPVK_VK_TO_VSC     0
@@ -145,7 +151,7 @@
 WIN_UpdateKeymap()
 {
     int i;
-    SDL_scancode scancode;
+    SDL_ScanCode scancode;
     SDLKey keymap[SDL_NUM_SCANCODES];
 
     SDL_GetDefaultKeymap(keymap);
@@ -172,12 +178,15 @@
 void
 WIN_QuitKeyboard(_THIS)
 {
+#ifndef SDL_DISABLE_WINDOWS_IME
     IME_Quit((SDL_VideoData *)_this->driverdata);
+#endif
 }
 
 void
 WIN_StartTextInput(_THIS)
 {
+#ifndef SDL_DISABLE_WINDOWS_IME
     SDL_Window *window = SDL_GetKeyboardFocus();
     if (window) {
         HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
@@ -186,11 +195,13 @@
         IME_Init(videodata, hwnd);
         IME_Enable(videodata, hwnd);
     }
+#endif /* !SDL_DISABLE_WINDOWS_IME */
 }
 
 void
 WIN_StopTextInput(_THIS)
 {
+#ifndef SDL_DISABLE_WINDOWS_IME
     SDL_Window *window = SDL_GetKeyboardFocus();
     if (window) {
         HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
@@ -198,6 +209,7 @@
         IME_Init(videodata, hwnd);
         IME_Disable(videodata, hwnd);
     }
+#endif /* !SDL_DISABLE_WINDOWS_IME */
 }
 
 void
@@ -207,6 +219,21 @@
     videodata->ime_rect = *rect;
 }
 
+#ifdef SDL_DISABLE_WINDOWS_IME
+
+
+SDL_bool
+IME_HandleMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM *lParam, SDL_VideoData *videodata)
+{
+    return SDL_FALSE;
+}
+
+void IME_Present(SDL_VideoData *videodata)
+{
+}
+
+#else
+
 #ifdef __GNUC__
 #undef DEFINE_GUID
 #define DEFINE_GUID(n,l,w1,w2,b1,b2,b3,b4,b5,b6,b7,b8) static const GUID n = {l,w1,w2,{b1,b2,b3,b4,b5,b6,b7,b8}}
@@ -285,15 +312,15 @@
         CoCreateInstance(&CLSID_TF_ThreadMgr, NULL, CLSCTX_INPROC_SERVER, &IID_ITfThreadMgr, (LPVOID *)&videodata->ime_threadmgr);
     }
     videodata->ime_initialized = SDL_TRUE;
-    videodata->ime_himm32 = LoadLibraryA("imm32.dll");
+    videodata->ime_himm32 = SDL_LoadObject("imm32.dll");
     if (!videodata->ime_himm32) {
         videodata->ime_available = SDL_FALSE;
         return;
     }
-    videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmLockIMC");
-    videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMC");
-    videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmLockIMCC");
-    videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))GetProcAddress(videodata->ime_himm32, "ImmUnlockIMCC");
+    videodata->ImmLockIMC = (LPINPUTCONTEXT2 (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMC");
+    videodata->ImmUnlockIMC = (BOOL (WINAPI *)(HIMC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMC");
+    videodata->ImmLockIMCC = (LPVOID (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmLockIMCC");
+    videodata->ImmUnlockIMCC = (BOOL (WINAPI *)(HIMCC))SDL_LoadFunction(videodata->ime_himm32, "ImmUnlockIMCC");
 
     IME_SetWindow(videodata, hwnd);
     videodata->ime_himc = ImmGetContext(hwnd);
@@ -356,7 +383,7 @@
     videodata->ime_hwnd_main = 0;
     videodata->ime_himc = 0;
     if (videodata->ime_himm32) {
-        FreeLibrary(videodata->ime_himm32);
+        SDL_UnloadObject(videodata->ime_himm32);
         videodata->ime_himm32 = 0;
     }
     if (videodata->ime_threadmgr) {
@@ -507,7 +534,7 @@
         return dwRet[uIndex];
 
     hklprev = hkl;
-    dwLang = ((DWORD)hkl & 0xffff);
+    dwLang = ((DWORD_PTR)hkl & 0xffff);
     if (videodata->ime_uiless && LANG() == LANG_CHT) {
         dwRet[0] = IMEID_CHT_VER_VISTA;
         dwRet[1] = 0;
@@ -579,7 +606,7 @@
 IME_SetupAPI(SDL_VideoData *videodata)
 {
     char ime_file[MAX_PATH + 1];
-    HMODULE hime = 0;
+    void* hime = 0;
     HKL hkl = 0;
     videodata->GetReadingString = 0;
     videodata->ShowReadingWindow = 0;
@@ -590,14 +617,14 @@
     if (ImmGetIMEFileNameA(hkl, ime_file, sizeof(ime_file) - 1) <= 0)
         return;
 
-    hime = LoadLibraryA(ime_file);
+    hime = SDL_LoadObject(ime_file);
     if (!hime)
         return;
 
     videodata->GetReadingString = (UINT (WINAPI *)(HIMC, UINT, LPWSTR, PINT, BOOL*, PUINT))
-        GetProcAddress(hime, "GetReadingString");
+        SDL_LoadFunction(hime, "GetReadingString");
     videodata->ShowReadingWindow = (BOOL (WINAPI *)(HIMC, BOOL))
-        GetProcAddress(hime, "ShowReadingWindow");
+        SDL_LoadFunction(hime, "ShowReadingWindow");
 
     if (videodata->ShowReadingWindow) {
         HIMC himc = ImmGetContext(videodata->ime_hwnd_current);
@@ -754,7 +781,7 @@
                     UINT cchars = 0;
 
                     for (; i < videodata->ime_candcount; ++i) {
-                        UINT len = SDL_wcslen((LPWSTR)((DWORD)cand_list + cand_list->dwOffset[i])) + 1;
+                        UINT len = SDL_wcslen((LPWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i])) + 1;
                         if (len + cchars > maxcandchar) {
                             if (i > cand_list->dwSelection)
                                 break;
@@ -774,7 +801,7 @@
                 }
                 SDL_memset(&videodata->ime_candidates, 0, sizeof(videodata->ime_candidates));
                 for (i = page_start, j = 0; (DWORD)i < cand_list->dwCount && j < (int)videodata->ime_candpgsize; i++, j++) {
-                    LPCWSTR candidate = (LPCWSTR)((DWORD)cand_list + cand_list->dwOffset[i]);
+                    LPCWSTR candidate = (LPCWSTR)((DWORD_PTR)cand_list + cand_list->dwOffset[i]);
                     IME_AddCandidate(videodata, j, candidate);
                 }
                 if (PRIMLANG() == LANG_KOREAN || (PRIMLANG() == LANG_CHT && !IME_GetId(videodata, 0)))
@@ -1552,4 +1579,6 @@
     SDL_RenderCopy(videodata->ime_candtex, NULL, &videodata->ime_candlistrect);
 }
 
+#endif /* SDL_DISABLE_WINDOWS_IME */
+
 /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/windows/SDL_windowsmodes.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_windowsmodes.c	Tue Feb 01 00:37:02 2011 -0800
@@ -23,13 +23,19 @@
 
 #include "SDL_windowsvideo.h"
 
+/* Windows CE compatibility */
+#ifndef CDS_FULLSCREEN
+#define CDS_FULLSCREEN 0
+#endif
 
 static SDL_bool
 WIN_GetDisplayMode(LPCTSTR deviceName, DWORD index, SDL_DisplayMode * mode)
 {
     SDL_DisplayModeData *data;
     DEVMODE devmode;
+#ifndef _WIN32_WCE
     HDC hdc;
+#endif
 
     devmode.dmSize = sizeof(devmode);
     devmode.dmDriverExtra = 0;
--- a/src/video/windows/SDL_windowsopengl.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_windowsopengl.c	Tue Feb 01 00:37:02 2011 -0800
@@ -101,7 +101,7 @@
         !_this->gl_data->wglDeleteContext ||
         !_this->gl_data->wglMakeCurrent) {
         SDL_SetError("Could not retrieve OpenGL functions");
-        FreeLibrary(handle);
+        SDL_UnloadObject(handle);
         return -1;
     }
 
--- a/src/video/windows/SDL_windowsvideo.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_windowsvideo.c	Tue Feb 01 00:37:02 2011 -0800
@@ -37,19 +37,6 @@
 static int WIN_VideoInit(_THIS);
 static void WIN_VideoQuit(_THIS);
 
-/* Sets an error message based on GetLastError() */
-void
-WIN_SetError(const char *prefix)
-{
-    TCHAR buffer[1024];
-    char *message;
-    FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, NULL, GetLastError(), 0,
-                  buffer, SDL_arraysize(buffer), NULL);
-    message = WIN_StringToUTF8(buffer);
-    SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ": " : "", message);
-    SDL_free(message);
-}
-
 
 /* Windows driver bootstrap functions */
 
@@ -68,22 +55,22 @@
 #if SDL_VIDEO_RENDER_D3D
     if (data->d3d) {
         IDirect3D9_Release(data->d3d);
-        FreeLibrary(data->d3dDLL);
+        SDL_UnloadObject(data->d3dDLL);
     }
 #endif
 #if SDL_VIDEO_RENDER_DDRAW
     if (data->ddraw) {
         data->ddraw->lpVtbl->Release(data->ddraw);
-        FreeLibrary(data->ddrawDLL);
+        SDL_UnloadObject(data->ddrawDLL);
     }
 #endif
 #ifdef _WIN32_WCE
     if(data->hAygShell) {
-       FreeLibrary(data->hAygShell);
+       SDL_UnloadObject(data->hAygShell);
     }
 #endif
 	if (data->userDLL) {
-		FreeLibrary(data->userDLL);
+		SDL_UnloadObject(data->userDLL);
 	}
 
     SDL_free(device->driverdata);
@@ -115,24 +102,24 @@
     device->driverdata = data;
 
 #if SDL_VIDEO_RENDER_D3D
-    data->d3dDLL = LoadLibrary(TEXT("D3D9.DLL"));
+    data->d3dDLL = SDL_LoadObject("D3D9.DLL");
     if (data->d3dDLL) {
         IDirect3D9 *(WINAPI * D3DCreate) (UINT SDKVersion);
 
         D3DCreate =
-            (IDirect3D9 * (WINAPI *) (UINT)) GetProcAddress(data->d3dDLL,
+            (IDirect3D9 * (WINAPI *) (UINT)) SDL_LoadFunction(data->d3dDLL,
                                                             "Direct3DCreate9");
         if (D3DCreate) {
             data->d3d = D3DCreate(D3D_SDK_VERSION);
         }
         if (!data->d3d) {
-            FreeLibrary(data->d3dDLL);
+            SDL_UnloadObject(data->d3dDLL);
             data->d3dDLL = NULL;
         }
     }
 #endif /* SDL_VIDEO_RENDER_D3D */
 #if SDL_VIDEO_RENDER_DDRAW
-    data->ddrawDLL = LoadLibrary(TEXT("ddraw.dll"));
+    data->ddrawDLL = SDL_LoadObject("ddraw.dll");
     if (data->ddrawDLL) {
         IDirectDraw *(WINAPI * DDCreate) (GUID FAR * lpGUID,
                                           LPDIRECTDRAW FAR * lplpDD,
@@ -141,9 +128,9 @@
         DDCreate =
             (IDirectDraw *
              (WINAPI *) (GUID FAR *, LPDIRECTDRAW FAR *, IUnknown FAR *))
-            GetProcAddress(data->ddrawDLL, TEXT("DirectDrawCreate"));
+            SDL_LoadFunction(data->ddrawDLL, "DirectDrawCreate");
         if (!DDCreate || DDCreate(NULL, &data->ddraw, NULL) != DD_OK) {
-            FreeLibrary(data->ddrawDLL);
+            SDL_UnloadObject(data->ddrawDLL);
             data->ddrawDLL = NULL;
             data->ddraw = NULL;
         }
@@ -151,19 +138,19 @@
 #endif /* SDL_VIDEO_RENDER_DDRAW */
 
 #ifdef _WIN32_WCE
-    data->hAygShell = LoadLibrary(TEXT("\\windows\\aygshell.dll"));
+    data->hAygShell = SDL_LoadObject("\\windows\\aygshell.dll");
     if(0 == data->hAygShell)
-        data->hAygShell = LoadLibrary(TEXT("aygshell.dll"));
+        data->hAygShell = SDL_LoadObject("aygshell.dll");
     data->SHFullScreen = (0 != data->hAygShell ?
-        (PFNSHFullScreen) GetProcAddress(data->hAygShell, TEXT("SHFullScreen")) : 0);
+        (PFNSHFullScreen) SDL_LoadFunction(data->hAygShell, "SHFullScreen") : 0);
     data->CoordTransform = NULL;
 #endif
 
-	data->userDLL = LoadLibrary(TEXT("USER32.DLL"));
+	data->userDLL = SDL_LoadObject("USER32.DLL");
 	if (data->userDLL) {
-		data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) GetProcAddress(data->userDLL, "CloseTouchInputHandle");
-		data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) GetProcAddress(data->userDLL, "GetTouchInputInfo");
-		data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) GetProcAddress(data->userDLL, "RegisterTouchWindow");
+		data->CloseTouchInputHandle = (BOOL (WINAPI *)( HTOUCHINPUT )) SDL_LoadFunction(data->userDLL, "CloseTouchInputHandle");
+		data->GetTouchInputInfo = (BOOL (WINAPI *)( HTOUCHINPUT, UINT, PTOUCHINPUT, int )) SDL_LoadFunction(data->userDLL, "GetTouchInputInfo");
+		data->RegisterTouchWindow = (BOOL (WINAPI *)( HWND, ULONG )) SDL_LoadFunction(data->userDLL, "RegisterTouchWindow");
 	}
 
     /* Set the function pointers */
@@ -197,7 +184,7 @@
     device->shape_driver.SetWindowShape = Win32_SetWindowShape;
     device->shape_driver.ResizeWindowShape = Win32_ResizeWindowShape;
     
-#ifdef SDL_VIDEO_OPENGL_WGL
+#if SDL_VIDEO_OPENGL_WGL
     device->GL_LoadLibrary = WIN_GL_LoadLibrary;
     device->GL_GetProcAddress = WIN_GL_GetProcAddress;
     device->GL_UnloadLibrary = WIN_GL_UnloadLibrary;
@@ -222,11 +209,7 @@
 }
 
 VideoBootStrap WINDOWS_bootstrap = {
-#ifdef _WIN32_WCE
-    "wince", "SDL WinCE video driver", WINCE_Available, WIN_CreateDevice
-#else
-    "windows", "SDL Win32/64 video driver", WIN_Available, WIN_CreateDevice
-#endif
+    "windows", "SDL Windows video driver", WIN_Available, WIN_CreateDevice
 };
 
 int
--- a/src/video/windows/SDL_windowsvideo.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_windowsvideo.h	Tue Feb 01 00:37:02 2011 -0800
@@ -26,17 +26,9 @@
 
 #include "../SDL_sysvideo.h"
 
-#define WIN32_LEAN_AND_MEAN
-#define STRICT
-#ifndef UNICODE
-#define UNICODE
-#endif
-#undef WINVER
-#define WINVER  0x500           /* Need 0x410 for AlphaBlend() and 0x500 for EnumDisplayDevices() */
+#include "../../core/windows/SDL_windows.h"
 
-#include <windows.h>
-
-#ifndef __GNUC__
+#if defined(_MSC_VER) && !defined(_WIN32_WCE)
 #include <msctf.h>
 #else
 #include "SDL_msctf.h"
@@ -68,15 +60,8 @@
 #include "SDL_windowsopengl.h"
 #include "SDL_windowswindow.h"
 #include "SDL_events.h"
+#include "SDL_loadso.h"
 
-#ifdef UNICODE
-#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "UCS-2", (char *)S, (SDL_wcslen(S)+1)*sizeof(WCHAR))
-#define WIN_UTF8ToString(S) (WCHAR *)SDL_iconv_string("UCS-2", "UTF-8", (char *)S, SDL_strlen(S)+1)
-#else
-#define WIN_StringToUTF8(S) SDL_iconv_string("UTF-8", "ASCII", (char *)S, (SDL_strlen(S)+1))
-#define WIN_UTF8ToString(S) SDL_iconv_string("ASCII", "UTF-8", (char *)S, SDL_strlen(S)+1)
-#endif
-extern void WIN_SetError(const char *prefix);
 
 enum { RENDER_NONE, RENDER_D3D, RENDER_DDRAW, RENDER_GDI, RENDER_GAPI, RENDER_RAW };
 
@@ -147,24 +132,24 @@
     int render;
 
 #if SDL_VIDEO_RENDER_D3D
-    HANDLE d3dDLL;
+    void* d3dDLL;
     IDirect3D9 *d3d;
 #endif
 #if SDL_VIDEO_RENDER_DDRAW
-    HANDLE ddrawDLL;
+    void* ddrawDLL;
     IDirectDraw *ddraw;
 #endif
 #ifdef _WIN32_WCE
-    HMODULE hAygShell;
+    void* hAygShell;
     PFNSHFullScreen SHFullScreen;
     PFCoordTransform CoordTransform;
 #endif
 
-    const SDL_scancode *key_layout;
+    const SDL_ScanCode *key_layout;
 	DWORD clipboard_count;
 
 	/* Touch input functions */
-	HANDLE userDLL;
+	void* userDLL;
 	BOOL (WINAPI *CloseTouchInputHandle)( HTOUCHINPUT );
 	BOOL (WINAPI *GetTouchInputInfo)( HTOUCHINPUT, UINT, PTOUCHINPUT, int );
 	BOOL (WINAPI *RegisterTouchWindow)( HWND, ULONG );
@@ -199,7 +184,7 @@
     int ime_winheight;
 
     HKL ime_hkl;
-    HMODULE ime_himm32;
+    void* ime_himm32;
     UINT (WINAPI *GetReadingString)(HIMC himc, UINT uReadingBufLen, LPWSTR lpwReadingBuf, PINT pnErrorIndex, BOOL *pfIsVertical, PUINT puMaxReadingLen);
     BOOL (WINAPI *ShowReadingWindow)(HIMC himc, BOOL bShow);
     LPINPUTCONTEXT2 (WINAPI *ImmLockIMC)(HIMC himc);
--- a/src/video/windows/SDL_windowswindow.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/windows/SDL_windowswindow.c	Tue Feb 01 00:37:02 2011 -0800
@@ -32,6 +32,10 @@
 #include "SDL_syswm.h"
 #include "SDL_gapirender.h"
 
+/* Windows CE compatibility */
+#ifndef SWP_NOCOPYBITS
+#define SWP_NOCOPYBITS 0
+#endif
 
 /* Fake window to help with DirectInput events. */
 HWND SDL_HelperWindow = NULL;
@@ -68,13 +72,21 @@
     }
 
     /* Set up the window proc function */
+#ifdef GWLP_WNDPROC
     data->wndproc = (WNDPROC) GetWindowLongPtr(hwnd, GWLP_WNDPROC);
     if (data->wndproc == WIN_WindowProc) {
         data->wndproc = NULL;
-    }
-    else {
+    } else {
         SetWindowLongPtr(hwnd, GWLP_WNDPROC, (LONG_PTR) WIN_WindowProc);
     }
+#else
+    data->wndproc = (WNDPROC) GetWindowLong(hwnd, GWL_WNDPROC);
+    if (data->wndproc == WIN_WindowProc) {
+        data->wndproc = NULL;
+    } else {
+        SetWindowLong(hwnd, GWL_WNDPROC, (LONG_PTR) WIN_WindowProc);
+    }
+#endif
 
     /* Fill in the SDL window with the window data */
     {
@@ -112,14 +124,20 @@
         } else {
             window->flags &= ~SDL_WINDOW_RESIZABLE;
         }
+#ifdef WS_MAXIMIZE
         if (style & WS_MAXIMIZE) {
             window->flags |= SDL_WINDOW_MAXIMIZED;
-        } else {
+        } else
+#endif
+        {
             window->flags &= ~SDL_WINDOW_MAXIMIZED;
         }
+#ifdef WS_MINIMIZE
         if (style & WS_MINIMIZE) {
             window->flags |= SDL_WINDOW_MINIMIZED;
-        } else {
+        } else
+#endif
+        {
             window->flags &= ~SDL_WINDOW_MINIMIZED;
         }
     }
@@ -225,7 +243,7 @@
         DestroyWindow(hwnd);
         return -1;
     }
-#ifdef SDL_VIDEO_OPENGL_WGL
+#if SDL_VIDEO_OPENGL_WGL
     if (window->flags & SDL_WINDOW_OPENGL) {
         if (WIN_GL_SetupWindow(_this, window) < 0) {
             WIN_DestroyWindow(_this, window);
--- a/src/video/x11/SDL_x11events.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/x11/SDL_x11events.c	Tue Feb 01 00:37:02 2011 -0800
@@ -202,7 +202,7 @@
     case KeyPress:{
             KeyCode keycode = xevent.xkey.keycode;
             KeySym keysym = NoSymbol;
-            SDL_scancode scancode;
+            SDL_ScanCode scancode;
             char text[SDL_TEXTINPUTEVENT_TEXT_SIZE];
             Status status = 0;
 
--- a/src/video/x11/SDL_x11keyboard.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/x11/SDL_x11keyboard.c	Tue Feb 01 00:37:02 2011 -0800
@@ -134,7 +134,7 @@
 
 static const struct
 {
-    const SDL_scancode const *table;
+    const SDL_ScanCode const *table;
     int table_size;
 } scancode_set[] = {
     { darwin_scancode_table, SDL_arraysize(darwin_scancode_table) },
@@ -175,7 +175,7 @@
     int i, j;
     int min_keycode, max_keycode;
     struct {
-        SDL_scancode scancode;
+        SDL_ScanCode scancode;
         KeySym keysym;
         int value;
     } fingerprint[] = {
@@ -215,7 +215,7 @@
             printf("Using scancode set %d, min_keycode = %d, max_keycode = %d, table_size = %d\n", i, min_keycode, max_keycode, scancode_set[i].table_size);
 #endif
             SDL_memcpy(&data->key_layout[min_keycode], scancode_set[i].table,
-                       sizeof(SDL_scancode) * scancode_set[i].table_size);
+                       sizeof(SDL_ScanCode) * scancode_set[i].table_size);
             fingerprint_detected = SDL_TRUE;
             break;
         }
@@ -239,7 +239,7 @@
                 key = X11_KeyCodeToSDLKey(data->display, i);
                 for (j = 0; j < SDL_arraysize(keymap); ++j) {
                     if (keymap[j] == key) {
-                        data->key_layout[i] = (SDL_scancode) j;
+                        data->key_layout[i] = (SDL_ScanCode) j;
                         break;
                     }
                 }
@@ -264,7 +264,7 @@
 {
     SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
     int i;
-    SDL_scancode scancode;
+    SDL_ScanCode scancode;
     SDLKey keymap[SDL_NUM_SCANCODES];
 
     SDL_zero(keymap);
--- a/src/video/x11/SDL_x11video.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/x11/SDL_x11video.c	Tue Feb 01 00:37:02 2011 -0800
@@ -209,7 +209,7 @@
     device->shape_driver.CreateShaper = X11_CreateShaper;
     device->shape_driver.SetWindowShape = X11_SetWindowShape;
     device->shape_driver.ResizeWindowShape = X11_ResizeWindowShape;
-#ifdef SDL_VIDEO_OPENGL_GLX
+#if SDL_VIDEO_OPENGL_GLX
     device->GL_LoadLibrary = X11_GL_LoadLibrary;
     device->GL_GetProcAddress = X11_GL_GetProcAddress;
     device->GL_UnloadLibrary = X11_GL_UnloadLibrary;
--- a/src/video/x11/SDL_x11video.h	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/x11/SDL_x11video.h	Tue Feb 01 00:37:02 2011 -0800
@@ -96,7 +96,7 @@
     Atom _NET_WM_ICON;
     Atom UTF8_STRING;
 
-    SDL_scancode key_layout[256];
+    SDL_ScanCode key_layout[256];
     SDL_bool selection_waiting;
 } SDL_VideoData;
 
--- a/src/video/x11/SDL_x11window.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/src/video/x11/SDL_x11window.c	Tue Feb 01 00:37:02 2011 -0800
@@ -288,7 +288,7 @@
     }
 */
 #endif
-#ifdef SDL_VIDEO_OPENGL_GLX
+#if SDL_VIDEO_OPENGL_GLX
     if (window->flags & SDL_WINDOW_OPENGL) {
         XVisualInfo *vinfo;
 
--- a/test/checkkeys.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/checkkeys.c	Tue Feb 01 00:37:02 2011 -0800
@@ -53,7 +53,7 @@
 }
 
 static void
-PrintKey(SDL_keysym * sym, SDL_bool pressed, SDL_bool repeat)
+PrintKey(SDL_KeySym * sym, SDL_bool pressed, SDL_bool repeat)
 {
     /* Print the keycode, name and state */
     if (sym->sym) {
--- a/test/common.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/common.c	Tue Feb 01 00:37:02 2011 -0800
@@ -616,7 +616,7 @@
                 fprintf(stderr, "\n");
             }
         }
-        if (SDL_VideoInit(state->videodriver, 0) < 0) {
+        if (SDL_VideoInit(state->videodriver) < 0) {
             fprintf(stderr, "Couldn't initialize video driver: %s\n",
                     SDL_GetError());
             return SDL_FALSE;
@@ -1038,7 +1038,12 @@
     case SDL_WINDOWEVENT:
         switch (event->window.event) {
         case SDL_WINDOWEVENT_CLOSE:
-            *done = 1;
+			{
+				SDL_Window *pWindow = SDL_GetWindowFromID(event->window.windowID);
+				if ( pWindow ) {
+					SDL_DestroyWindow( pWindow );
+				}
+			}
             break;
         }
         break;
--- a/test/testatomic.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/testatomic.c	Tue Feb 01 00:37:02 2011 -0800
@@ -3,6 +3,7 @@
 #include "SDL.h"
 #include "SDL_atomic.h"
 #include "SDL_assert.h"
+#include "SDL_cpuinfo.h"
 
 /*
   Absolutely basic tests just to see if we get the expected value
@@ -231,10 +232,472 @@
 /* End atomic operation test */
 /**************************************************************************/
 
+/**************************************************************************/
+/* Lock-free FIFO test */
+
+/* This is useful to test the impact of another thread locking the queue
+   entirely for heavy-weight manipulation.
+ */
+#define TEST_SPINLOCK_FIFO
+
+#define NUM_READERS 4
+#define NUM_WRITERS 4
+#define EVENTS_PER_WRITER   1000000
+
+/* The number of entries must be a power of 2 */
+#define MAX_ENTRIES 256
+#define WRAP_MASK   (MAX_ENTRIES-1)
+
+typedef struct
+{
+    SDL_atomic_t sequence;
+    SDL_Event event;
+} SDL_EventQueueEntry;
+
+typedef struct
+{
+    SDL_EventQueueEntry entries[MAX_ENTRIES];
+
+    char cache_pad1[SDL_CACHELINE_SIZE-((sizeof(SDL_EventQueueEntry)*MAX_ENTRIES)%SDL_CACHELINE_SIZE)];
+
+    SDL_atomic_t enqueue_pos;
+
+    char cache_pad2[SDL_CACHELINE_SIZE-sizeof(SDL_atomic_t)];
+
+    SDL_atomic_t dequeue_pos;
+
+    char cache_pad3[SDL_CACHELINE_SIZE-sizeof(SDL_atomic_t)];
+
+#ifdef TEST_SPINLOCK_FIFO
+    SDL_SpinLock lock;
+    SDL_atomic_t rwcount;
+    SDL_atomic_t watcher;
+
+    char cache_pad4[SDL_CACHELINE_SIZE-sizeof(SDL_SpinLock)-2*sizeof(SDL_atomic_t)];
+#endif
+
+    volatile SDL_bool active;
+
+    /* Only needed for the mutex test */
+    SDL_mutex *mutex;
+
+} SDL_EventQueue;
+
+static void InitEventQueue(SDL_EventQueue *queue)
+{
+    int i;
+
+    for (i = 0; i < MAX_ENTRIES; ++i) {
+        SDL_AtomicSet(&queue->entries[i].sequence, i);
+    }
+    SDL_AtomicSet(&queue->enqueue_pos, 0);
+    SDL_AtomicSet(&queue->dequeue_pos, 0);
+#ifdef TEST_SPINLOCK_FIFO
+    queue->lock = 0;
+    SDL_AtomicSet(&queue->rwcount, 0);
+#endif
+    queue->active = SDL_TRUE;
+}
+
+static SDL_bool EnqueueEvent_LockFree(SDL_EventQueue *queue, const SDL_Event *event)
+{
+    SDL_EventQueueEntry *entry;
+    unsigned queue_pos;
+    unsigned entry_seq;
+    int delta;
+    SDL_bool status;
+
+#ifdef TEST_SPINLOCK_FIFO
+    /* This is a gate so an external thread can lock the queue */
+    SDL_AtomicLock(&queue->lock);
+    SDL_assert(SDL_AtomicGet(&queue->watcher) == 0);
+    SDL_AtomicIncRef(&queue->rwcount);
+    SDL_AtomicUnlock(&queue->lock);
+#endif
+
+    queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos);
+    for ( ; ; ) {
+        entry = &queue->entries[queue_pos & WRAP_MASK];
+        entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence);
+
+        delta = (int)(entry_seq - queue_pos);
+        if (delta == 0) {
+            /* The entry and the queue position match, try to increment the queue position */
+            if (SDL_AtomicCAS(&queue->enqueue_pos, (int)queue_pos, (int)(queue_pos+1))) {
+                /* We own the object, fill it! */
+                entry->event = *event;
+                SDL_AtomicSet(&entry->sequence, (int)(queue_pos + 1));
+                status = SDL_TRUE;
+                break;
+            }
+        } else if (delta < 0) {
+            /* We ran into an old queue entry, which means it still needs to be dequeued */
+            status = SDL_FALSE;
+            break;
+        } else {
+            /* We ran into a new queue entry, get the new queue position */
+            queue_pos = (unsigned)SDL_AtomicGet(&queue->enqueue_pos);
+        }
+    }
+
+#ifdef TEST_SPINLOCK_FIFO
+    SDL_AtomicDecRef(&queue->rwcount);
+#endif
+    return status;
+}
+
+static SDL_bool DequeueEvent_LockFree(SDL_EventQueue *queue, SDL_Event *event)
+{
+    SDL_EventQueueEntry *entry;
+    unsigned queue_pos;
+    unsigned entry_seq;
+    int delta;
+    SDL_bool status;
+
+#ifdef TEST_SPINLOCK_FIFO
+    /* This is a gate so an external thread can lock the queue */
+    SDL_AtomicLock(&queue->lock);
+    SDL_assert(SDL_AtomicGet(&queue->watcher) == 0);
+    SDL_AtomicIncRef(&queue->rwcount);
+    SDL_AtomicUnlock(&queue->lock);
+#endif
+
+    queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos);
+    for ( ; ; ) {
+        entry = &queue->entries[queue_pos & WRAP_MASK];
+        entry_seq = (unsigned)SDL_AtomicGet(&entry->sequence);
+
+        delta = (int)(entry_seq - (queue_pos + 1));
+        if (delta == 0) {
+            /* The entry and the queue position match, try to increment the queue position */
+            if (SDL_AtomicCAS(&queue->dequeue_pos, (int)queue_pos, (int)(queue_pos+1))) {
+                /* We own the object, fill it! */
+                *event = entry->event;
+                SDL_AtomicSet(&entry->sequence, (int)(queue_pos+MAX_ENTRIES));
+                status = SDL_TRUE;
+                break;
+            }
+        } else if (delta < 0) {
+            /* We ran into an old queue entry, which means we've hit empty */
+            status = SDL_FALSE;
+            break;
+        } else {
+            /* We ran into a new queue entry, get the new queue position */
+            queue_pos = (unsigned)SDL_AtomicGet(&queue->dequeue_pos);
+        }
+    }
+
+#ifdef TEST_SPINLOCK_FIFO
+    SDL_AtomicDecRef(&queue->rwcount);
+#endif
+    return status;
+}
+
+static SDL_bool EnqueueEvent_Mutex(SDL_EventQueue *queue, const SDL_Event *event)
+{
+    SDL_EventQueueEntry *entry;
+    unsigned queue_pos;
+    unsigned entry_seq;
+    int delta;
+    SDL_bool status = SDL_FALSE;
+
+    SDL_mutexP(queue->mutex);
+
+    queue_pos = (unsigned)queue->enqueue_pos.value;
+    entry = &queue->entries[queue_pos & WRAP_MASK];
+    entry_seq = (unsigned)entry->sequence.value;
+
+    delta = (int)(entry_seq - queue_pos);
+    if (delta == 0) {
+        ++queue->enqueue_pos.value;
+
+        /* We own the object, fill it! */
+        entry->event = *event;
+        entry->sequence.value = (int)(queue_pos + 1);
+        status = SDL_TRUE;
+    } else if (delta < 0) {
+        /* We ran into an old queue entry, which means it still needs to be dequeued */
+    } else {
+        printf("ERROR: mutex failed!\n");
+    }
+
+    SDL_mutexV(queue->mutex);
+
+    return status;
+}
+
+static SDL_bool DequeueEvent_Mutex(SDL_EventQueue *queue, SDL_Event *event)
+{
+    SDL_EventQueueEntry *entry;
+    unsigned queue_pos;
+    unsigned entry_seq;
+    int delta;
+    SDL_bool status = SDL_FALSE;
+
+    SDL_mutexP(queue->mutex);
+
+    queue_pos = (unsigned)queue->dequeue_pos.value;
+    entry = &queue->entries[queue_pos & WRAP_MASK];
+    entry_seq = (unsigned)entry->sequence.value;
+
+    delta = (int)(entry_seq - (queue_pos + 1));
+    if (delta == 0) {
+        ++queue->dequeue_pos.value;
+
+        /* We own the object, fill it! */
+        *event = entry->event;
+        entry->sequence.value = (int)(queue_pos + MAX_ENTRIES);
+        status = SDL_TRUE;
+    } else if (delta < 0) {
+        /* We ran into an old queue entry, which means we've hit empty */
+    } else {
+        printf("ERROR: mutex failed!\n");
+    }
+
+    SDL_mutexV(queue->mutex);
+
+    return status;
+}
+
+static SDL_sem *writersDone;
+static SDL_sem *readersDone;
+static SDL_atomic_t writersRunning;
+static SDL_atomic_t readersRunning;
+
+typedef struct
+{
+    SDL_EventQueue *queue;
+    int index;
+    char padding1[SDL_CACHELINE_SIZE-(sizeof(SDL_EventQueue*)+sizeof(int))%SDL_CACHELINE_SIZE];
+    int waits;
+    SDL_bool lock_free;
+    char padding2[SDL_CACHELINE_SIZE-sizeof(int)-sizeof(SDL_bool)];
+} WriterData;
+
+typedef struct
+{
+    SDL_EventQueue *queue;
+    int counters[NUM_WRITERS];
+    int waits;
+    SDL_bool lock_free;
+    char padding[SDL_CACHELINE_SIZE-(sizeof(SDL_EventQueue*)+sizeof(int)*NUM_WRITERS+sizeof(int)+sizeof(SDL_bool))%SDL_CACHELINE_SIZE];
+} ReaderData;
+
+static int FIFO_Writer(void* _data)
+{
+    WriterData *data = (WriterData *)_data;
+    SDL_EventQueue *queue = data->queue;
+    int index = data->index;
+    int i;
+    SDL_Event event;
+
+    event.type = SDL_USEREVENT;
+    event.user.windowID = 0;
+    event.user.code = 0;
+    event.user.data1 = data;
+    event.user.data2 = NULL;
+
+    if (data->lock_free) {
+        for (i = 0; i < EVENTS_PER_WRITER; ++i) {
+            event.user.code = i;
+            while (!EnqueueEvent_LockFree(queue, &event)) {
+                ++data->waits;
+                SDL_Delay(0);
+            }
+        }
+    } else {
+        for (i = 0; i < EVENTS_PER_WRITER; ++i) {
+            event.user.code = i;
+            while (!EnqueueEvent_Mutex(queue, &event)) {
+                ++data->waits;
+                SDL_Delay(0);
+            }
+        }
+    }
+    SDL_AtomicAdd(&writersRunning, -1);
+    SDL_SemPost(writersDone);
+    return 0;
+}
+
+static int FIFO_Reader(void* _data)
+{
+    ReaderData *data = (ReaderData *)_data;
+    SDL_EventQueue *queue = data->queue;
+    SDL_Event event;
+
+    if (data->lock_free) {
+        for ( ; ; ) {
+            if (DequeueEvent_LockFree(queue, &event)) {
+                WriterData *writer = (WriterData*)event.user.data1;
+                ++data->counters[writer->index];
+            } else if (queue->active) {
+                ++data->waits;
+                SDL_Delay(0);
+            } else {
+                /* We drained the queue, we're done! */
+                break;
+            }
+        }
+    } else {
+        for ( ; ; ) {
+            if (DequeueEvent_Mutex(queue, &event)) {
+                WriterData *writer = (WriterData*)event.user.data1;
+                ++data->counters[writer->index];
+            } else if (queue->active) {
+                ++data->waits;
+                SDL_Delay(0);
+            } else {
+                /* We drained the queue, we're done! */
+                break;
+            }
+        }
+    }
+    SDL_AtomicAdd(&readersRunning, -1);
+    SDL_SemPost(readersDone);
+    return 0;
+}
+
+#ifdef TEST_SPINLOCK_FIFO
+/* This thread periodically locks the queue for no particular reason */
+static int FIFO_Watcher(void* _data)
+{
+    SDL_EventQueue *queue = (SDL_EventQueue *)_data;
+
+    while (queue->active) {
+        SDL_AtomicLock(&queue->lock);
+        SDL_AtomicIncRef(&queue->watcher);
+        while (SDL_AtomicGet(&queue->rwcount) > 0) {
+            SDL_Delay(0);
+        }
+        /* Do queue manipulation here... */
+        SDL_AtomicDecRef(&queue->watcher);
+        SDL_AtomicUnlock(&queue->lock);
+
+        /* Wait a bit... */
+        SDL_Delay(1);
+    }
+    return 0;
+}
+#endif /* TEST_SPINLOCK_FIFO */
+
+static void RunFIFOTest(SDL_bool lock_free)
+{
+    SDL_EventQueue queue;
+    WriterData writerData[NUM_WRITERS];
+    ReaderData readerData[NUM_READERS];
+    Uint32 start, end;
+    int i, j;
+    int grand_total;
+ 
+    printf("\nFIFO test---------------------------------------\n\n");
+    printf("Mode: %s\n", lock_free ? "LockFree" : "Mutex");
+
+    readersDone = SDL_CreateSemaphore(0);
+    writersDone = SDL_CreateSemaphore(0);
+
+    SDL_memset(&queue, 0xff, sizeof(queue));
+
+    InitEventQueue(&queue);
+    if (!lock_free) {
+        queue.mutex = SDL_CreateMutex();
+    }
+
+    start = SDL_GetTicks();
+ 
+#ifdef TEST_SPINLOCK_FIFO
+    /* Start a monitoring thread */
+    if (lock_free) {
+        SDL_CreateThread(FIFO_Watcher, &queue);
+    }
+#endif
+
+    /* Start the readers first */
+    printf("Starting %d readers\n", NUM_READERS);
+    SDL_zero(readerData);
+    SDL_AtomicSet(&readersRunning, NUM_READERS);
+    for (i = 0; i < NUM_READERS; ++i) {
+        readerData[i].queue = &queue;
+        readerData[i].lock_free = lock_free;
+        SDL_CreateThread(FIFO_Reader, &readerData[i]);
+    }
+
+    /* Start up the writers */
+    printf("Starting %d writers\n", NUM_WRITERS);
+    SDL_zero(writerData);
+    SDL_AtomicSet(&writersRunning, NUM_WRITERS);
+    for (i = 0; i < NUM_WRITERS; ++i) {
+        writerData[i].queue = &queue;
+        writerData[i].index = i;
+        writerData[i].lock_free = lock_free;
+        SDL_CreateThread(FIFO_Writer, &writerData[i]);
+    }
+ 
+    /* Wait for the writers */
+    while (SDL_AtomicGet(&writersRunning) > 0) {
+        SDL_SemWait(writersDone);
+    }
+ 
+    /* Shut down the queue so readers exit */
+    queue.active = SDL_FALSE;
+
+    /* Wait for the readers */
+    while (SDL_AtomicGet(&readersRunning) > 0) {
+        SDL_SemWait(readersDone);
+    }
+
+    end = SDL_GetTicks();
+ 
+    SDL_DestroySemaphore(readersDone);
+    SDL_DestroySemaphore(writersDone);
+
+    if (!lock_free) {
+        SDL_DestroyMutex(queue.mutex);
+    }
+ 
+    printf("Finished in %f sec\n", (end - start) / 1000.f);
+
+    printf("\n");
+    for (i = 0; i < NUM_WRITERS; ++i) {
+        printf("Writer %d wrote %d events, had %d waits\n", i, EVENTS_PER_WRITER, writerData[i].waits);
+    }
+    printf("Writers wrote %d total events\n", NUM_WRITERS*EVENTS_PER_WRITER);
+
+    /* Print a breakdown of which readers read messages from which writer */
+    printf("\n");
+    grand_total = 0;
+    for (i = 0; i < NUM_READERS; ++i) {
+        int total = 0;
+        for (j = 0; j < NUM_WRITERS; ++j) {
+            total += readerData[i].counters[j];
+        }
+        grand_total += total;
+        printf("Reader %d read %d events, had %d waits\n", i, total, readerData[i].waits);
+        printf("  { ");
+        for (j = 0; j < NUM_WRITERS; ++j) {
+            if (j > 0) {
+                printf(", ");
+            }
+            printf("%d", readerData[i].counters[j]);
+        }
+        printf(" }\n");
+    }
+    printf("Readers read %d total events\n", grand_total);
+}
+
+/* End FIFO test */
+/**************************************************************************/
+
 int
 main(int argc, char *argv[])
 {
     RunBasicTest();
     RunEpicTest();
+/* This test is really slow, so don't run it by default */
+#if 0
+    RunFIFOTest(SDL_FALSE);
+#endif
+    RunFIFOTest(SDL_TRUE);
     return 0;
 }
+
+/* vi: set ts=4 sw=4 expandtab: */
--- a/test/testgesture.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/testgesture.c	Tue Feb 01 00:37:02 2011 -0800
@@ -19,14 +19,14 @@
 #define PRIu32 "u"
 #endif
 #ifndef PRIs64
-#ifdef __WINDOWS__
+#ifdef __WIN32__
 #define PRIs64 "I64"
 #else
 #define PRIs64 "lld"
 #endif
 #endif
 #ifndef PRIu64
-#ifdef __WINDOWS__
+#ifdef __WIN32__
 #define PRIu64 "I64u"
 #else
 #define PRIu64 "llu"
--- a/test/testkeys.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/testkeys.c	Tue Feb 01 00:37:02 2011 -0800
@@ -11,7 +11,7 @@
 int
 main(int argc, char *argv[])
 {
-    SDL_scancode scancode;
+    SDL_ScanCode scancode;
 
     if (SDL_Init(SDL_INIT_VIDEO) < 0) {
         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
--- a/test/testplatform.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/testplatform.c	Tue Feb 01 00:37:02 2011 -0800
@@ -140,6 +140,7 @@
 {
     if (verbose) {
         printf("CPU count: %d\n", SDL_GetCPUCount());
+	printf("CPU cache line size: %d\n", SDL_GetCPUCacheLineSize());
         printf("RDTSC %s\n", SDL_HasRDTSC()? "detected" : "not detected");
         printf("MMX %s\n", SDL_HasMMX()? "detected" : "not detected");
         printf("MMX Ext %s\n", SDL_HasMMXExt()? "detected" : "not detected");
@@ -168,7 +169,6 @@
     SDL_assert_release(5 < 4);
     SDL_assert_release(0 && "This is a test");
 #endif
-    SDL_assert_release(0 && "This is a test");
 
     return (0);
 }
--- a/test/testsem.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/testsem.c	Tue Feb 01 00:37:02 2011 -0800
@@ -39,6 +39,29 @@
     alive = 0;
 }
 
+static void
+TestWaitTimeout(void)
+{
+    Uint32 start_ticks;
+    Uint32 end_ticks;
+    Uint32 duration;
+
+    sem = SDL_CreateSemaphore(0);
+    printf("Waiting 2 seconds on semaphore\n");
+
+    start_ticks = SDL_GetTicks();
+    SDL_SemWaitTimeout(sem, 2000);
+    end_ticks = SDL_GetTicks();
+
+    duration = end_ticks - start_ticks;
+
+    /* Accept a little offset in the effective wait */
+    if (duration > 1900 && duration < 2050)
+        printf("Wait done.\n");
+    else
+        fprintf(stderr, "Wait took %d milliseconds\n", duration);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -81,6 +104,9 @@
     printf("Finished waiting for threads\n");
 
     SDL_DestroySemaphore(sem);
+
+    TestWaitTimeout();
+
     SDL_Quit();
     return (0);
 }
--- a/test/testshape.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/testshape.c	Tue Feb 01 00:37:02 2011 -0800
@@ -60,7 +60,7 @@
     	exit(-1);
     }
 	
-	if(SDL_VideoInit(NULL,0) == -1) {
+	if(SDL_VideoInit(NULL) == -1) {
 		printf("Could not initialize SDL video.\n");
 		exit(-2);
 	}
--- a/test/testwm.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/testwm.c	Tue Feb 01 00:37:02 2011 -0800
@@ -210,7 +210,7 @@
         printf(" MODE");
 }
 
-static void PrintKey(const SDL_keysym *sym, int pressed)
+static void PrintKey(const SDL_KeySym *sym, int pressed)
 {
     /* Print the keycode, name and state */
     if ( sym->sym ) {
--- a/test/threadwin.c	Mon Jan 31 07:36:12 2011 -0800
+++ b/test/threadwin.c	Tue Feb 01 00:37:02 2011 -0800
@@ -241,16 +241,7 @@
     video_flags = SDL_SWSURFACE;
     parsed = 1;
     while (parsed) {
-        /* If the threaded option is enabled, and the SDL library hasn't
-           been compiled with threaded events enabled, then the mouse and
-           keyboard won't respond.
-         */
-        if ((argc >= 2) && (strcmp(argv[1], "-threaded") == 0)) {
-            init_flags |= SDL_INIT_EVENTTHREAD;
-            argc -= 1;
-            argv += 1;
-            printf("Running with threaded events\n");
-        } else if ((argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0)) {
+        if ((argc >= 2) && (strcmp(argv[1], "-fullscreen") == 0)) {
             video_flags |= SDL_FULLSCREEN;
             argc -= 1;
             argv += 1;
@@ -320,9 +311,8 @@
 
     /* Loop, waiting for QUIT */
     while (!done) {
-        if (!(init_flags & SDL_INIT_EVENTTHREAD)) {
-            SDL_PumpEvents();   /* Needed when event thread is off */
-        }
+        SDL_PumpEvents();
+
         if (SDL_PeepEvents(NULL, 0, SDL_PEEKEVENT, SDL_QUIT, SDL_QUIT)) {
             done = 1;
         }