Blob Blame History Raw
diff -urN SDL-1.2.9/aclocal.m4 /root/Desktop/gp2xdev/libs/SDL-1.2.9/aclocal.m4
--- SDL-1.2.9/aclocal.m4	2005-08-28 08:31:27.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/aclocal.m4	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# generated automatically by aclocal 1.9.6 -*- Autoconf -*-
+# generated automatically by aclocal 1.9.5 -*- Autoconf -*-
 
 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
 # 2005  Free Software Foundation, Inc.
@@ -28,7 +28,7 @@
 # Call AM_AUTOMAKE_VERSION so it can be traced.
 # This function is AC_REQUIREd by AC_INIT_AUTOMAKE.
 AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
-	 [AM_AUTOMAKE_VERSION([1.9.6])])
+	 [AM_AUTOMAKE_VERSION([1.9.5])])
 
 # AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
 
diff -urN SDL-1.2.9/config.sub /root/Desktop/gp2xdev/libs/SDL-1.2.9/config.sub
--- SDL-1.2.9/config.sub	2004-05-06 17:55:06.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/config.sub	2006-05-19 09:11:11.000000000 +0200
@@ -3,7 +3,7 @@
 #   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
 #   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
 
-timestamp='2003-02-22'
+timestamp='2006-04-10'
 
 # This file is (in principle) common to ALL GNU software.
 # The presence of a machine in this file suggests that SOME GNU software
@@ -497,6 +497,10 @@
 		basic_machine=i386-pc
 		os=-go32
 		;;
+	gp2x)
+		basic_machine=arm-gp2x
+		os=-linux-gnu
+		;;
 	h3050r* | hiux*)
 		basic_machine=hppa1.1-hitachi
 		os=-hiuxwe2
diff -urN SDL-1.2.9/configure /root/Desktop/gp2xdev/libs/SDL-1.2.9/configure
--- SDL-1.2.9/configure	2005-08-28 08:32:11.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/configure	2006-05-19 09:11:11.000000000 +0200
@@ -1043,7 +1043,7 @@
   --enable-video          Enable the video subsystem default=yes
   --enable-events         Enable the events subsystem default=yes
   --enable-joystick       Enable the joystick subsystem default=yes
-  --enable-cdrom          Enable the cdrom subsystem default=yes
+  --enable-cdrom          Enable the cdrom subsystem default=no
   --enable-threads        Enable the threading subsystem default=yes
   --enable-timers         Enable the timer subsystem default=yes
   --enable-endian         Enable the endian subsystem default=yes
@@ -1053,39 +1053,40 @@
   --enable-alsa           support the ALSA audio API default=yes
   --disable-alsatest      Do not try to compile and run a test Alsa program
   --enable-alsa-shared     dynamically load ALSA audio support default=yes
-  --enable-esd            support the Enlightened Sound Daemon default=yes
+  --enable-esd            support the Enlightened Sound Daemon default=no
   --disable-esdtest       Do not try to compile and run a test ESD program
-  --enable-esd-shared     dynamically load ESD audio support default=yes
-  --enable-arts           support the Analog Real Time Synthesizer default=yes
+  --enable-esd-shared     dynamically load ESD audio support default=no
+  --enable-arts           support the Analog Real Time Synthesizer default=no
   --enable-arts-shared    dynamically load aRts audio support default=yes
-  --enable-nas            support the NAS audio API default=yes
-  --enable-diskaudio      support the disk writer audio driver default=yes
-  --enable-mintaudio      support Atari audio driver default=yes
+  --enable-nas            support the NAS audio API default=no
+  --enable-diskaudio      support the disk writer audio driver default=no
+  --enable-mintaudio      support Atari audio driver default=no
   --enable-nasm           use nasm assembly blitters on x86 default=yes
   --enable-video-nanox use nanox video driver default=no
   --enable-nanox-debug print debug messages default=no
   --enable-nanox-share-memory use share memory default=no
   --enable-nanox-direct-fb use direct framebuffer access default=no
-  --enable-video-x11      use X11 video driver default=yes
+  --enable-video-x11      use X11 video driver default=no
   --enable-video-x11-vm   use X11 VM extension for fullscreen default=yes
-  --enable-dga            allow use of X11 DGA code default=yes
-  --enable-video-x11-dgamouse  use X11 DGA for mouse events default=yes
-  --enable-video-x11-xv   use X11 XvImage extension for video default=yes
+  --enable-dga            allow use of X11 DGA code default=no
+  --enable-video-x11-dgamouse  use X11 DGA for mouse events default=no
+  --enable-video-x11-xv   use X11 XvImage extension for video default=no
   --enable-video-x11-xinerama   enable X11 Xinerama support default=yes
   --enable-video-x11-xme  enable Xi Graphics XME for fullscreen default=yes
-  --enable-video-dga      use DGA 2.0 video driver default=yes
-  --enable-video-photon   use QNX Photon video driver default=yes
-  --enable-video-fbcon    use framebuffer console video driver default=yes
+  --enable-video-dga      use DGA 2.0 video driver default=no
+  --enable-video-photon   use QNX Photon video driver default=no
+  --enable-video-fbcon    use framebuffer console video driver default=no
   --enable-video-directfb use DirectFB video driver default=no
-  --enable-video-ps2gs    use PlayStation 2 GS video driver default=yes
+  --enable-video-ps2gs    use PlayStation 2 GS video driver default=no
   --enable-video-ggi      use GGI video driver default=no
   --enable-video-svga     use SVGAlib video driver default=no
   --enable-video-vgl      use VGL video driver default=no
   --enable-video-aalib    use AAlib video driver default=no
-  --enable-video-xbios    use Atari Xbios video driver default=yes
-  --enable-video-gem      use Atari Gem video driver default=yes
+  --enable-video-xbios    use Atari Xbios video driver default=no
+  --enable-video-gem      use Atari Gem video driver default=no
+  --enable-video-gp2x    use gp2x video driver default=yes
   --enable-video-dummy    use dummy video driver default=yes
-  --enable-video-opengl   include OpenGL context creation default=yes
+  --enable-video-opengl   include OpenGL context creation default=no
   --enable-osmesa-shared  dynamically load OSMesa OpenGL support default=yes
   --enable-input-events   use Linux 2.4 unified input interface default=yes
   --enable-pth            use GNU pth library for multi-threading default=yes
@@ -1093,11 +1094,11 @@
   --enable-pthread-sem    use pthread semaphores default=yes
   --enable-sigaction      use sigaction instead of signal default=yes
   --enable-stdio-redirect Redirect STDIO to files on Win32 default=yes
-  --enable-directx        use DirectX for Win32 audio/video default=yes
+  --enable-directx        use DirectX for Win32 audio/video default=no
   --enable-video-qtopia   use Qtopia video driver default=no
   --enable-video-picogui  use PicoGUI video driver default=no
   --enable-sdl-dlopen     use dlopen for shared object loading default=yes
-  --enable-atari-ldg      use Atari LDG for shared object loading default=yes
+  --enable-atari-ldg      use Atari LDG for shared object loading default=no
   --enable-rpath          use an rpath when linking SDL default=yes
 
 Optional Packages:
@@ -1567,6 +1568,7 @@
 
 
 
+
 #
 # Making releases:
 # Edit include/SDL/SDL_version.h and change the version, then:
@@ -3793,7 +3795,7 @@
   ;;
 *-*-irix6*)
   # Find out which ABI we are using.
-  echo '#line 3796 "configure"' > conftest.$ac_ext
+  echo '#line 3798 "configure"' > conftest.$ac_ext
   if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5
   (eval $ac_compile) 2>&5
   ac_status=$?
@@ -5607,7 +5609,7 @@
 
 
 # Provide some information about the compiler.
-echo "$as_me:5610:" \
+echo "$as_me:5612:" \
      "checking for Fortran 77 compiler version" >&5
 ac_compiler=`set X $ac_compile; echo $2`
 { (eval echo "$as_me:$LINENO: \"$ac_compiler --version </dev/null >&5\"") >&5
@@ -6661,11 +6663,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6664: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6666: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6668: \$? = $ac_status" >&5
+   echo "$as_me:6670: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -6904,11 +6906,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6907: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6909: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:6911: \$? = $ac_status" >&5
+   echo "$as_me:6913: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -6964,11 +6966,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:6967: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:6969: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:6971: \$? = $ac_status" >&5
+   echo "$as_me:6973: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -9159,7 +9161,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9162 "configure"
+#line 9164 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -9257,7 +9259,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 9260 "configure"
+#line 9262 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11458,11 +11460,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11461: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11463: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:11465: \$? = $ac_status" >&5
+   echo "$as_me:11467: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -11518,11 +11520,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:11521: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:11523: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:11525: \$? = $ac_status" >&5
+   echo "$as_me:11527: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -12881,7 +12883,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12884 "configure"
+#line 12886 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -12979,7 +12981,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 12982 "configure"
+#line 12984 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -13816,11 +13818,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13819: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13821: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:13823: \$? = $ac_status" >&5
+   echo "$as_me:13825: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -13876,11 +13878,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:13879: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:13881: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:13883: \$? = $ac_status" >&5
+   echo "$as_me:13885: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -15925,11 +15927,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:15928: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:15930: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:15932: \$? = $ac_status" >&5
+   echo "$as_me:15934: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -16168,11 +16170,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16171: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16173: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>conftest.err)
    ac_status=$?
    cat conftest.err >&5
-   echo "$as_me:16175: \$? = $ac_status" >&5
+   echo "$as_me:16177: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s "$ac_outfile"; then
      # The compiler can only warn and ignore the option if not recognized
      # So say no if there are warnings
@@ -16228,11 +16230,11 @@
    -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \
    -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
    -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:16231: $lt_compile\"" >&5)
+   (eval echo "\"\$as_me:16233: $lt_compile\"" >&5)
    (eval "$lt_compile" 2>out/conftest.err)
    ac_status=$?
    cat out/conftest.err >&5
-   echo "$as_me:16235: \$? = $ac_status" >&5
+   echo "$as_me:16237: \$? = $ac_status" >&5
    if (exit $ac_status) && test -s out/conftest2.$ac_objext
    then
      # The compiler can only warn and ignore the option if not recognized
@@ -18423,7 +18425,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18426 "configure"
+#line 18428 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -18521,7 +18523,7 @@
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<EOF
-#line 18524 "configure"
+#line 18526 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -22412,7 +22414,7 @@
   enableval="$enable_esd"
 
 else
-  enable_esd=yes
+  enable_esd=no
 fi;
     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
 
@@ -22702,7 +22704,7 @@
   enableval="$enable_esd_shared"
 
 else
-  enable_esd_shared=yes
+  enable_esd_shared=no
 fi;
             esd_lib_spec=`echo $ESD_LIBS | sed 's/.*-L\([^ ]*\).*/\1\/libesd.so.*/'`
             esd_lib=`ls $esd_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
@@ -22734,7 +22736,7 @@
   enableval="$enable_arts"
 
 else
-  enable_arts=yes
+  enable_arts=no
 fi;
     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
         # Extract the first word of "artsc-config", so it can be a program name with args.
@@ -22879,7 +22881,7 @@
   enableval="$enable_nas"
 
 else
-  enable_nas=yes
+  enable_nas=no
 fi;
     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
         echo "$as_me:$LINENO: checking for NAS audio support" >&5
@@ -22912,7 +22914,7 @@
   enableval="$enable_diskaudio"
 
 else
-  enable_diskaudio=yes
+  enable_diskaudio=no
 fi;
     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
         CFLAGS="$CFLAGS -DDISKAUD_SUPPORT"
@@ -22928,7 +22930,7 @@
   enableval="$enable_mintaudio"
 
 else
-  enable_mintaudio=yes
+  enable_mintaudio=no
 fi;
     if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
         mintaudio=no
@@ -23231,7 +23233,7 @@
   enableval="$enable_video_x11"
 
 else
-  enable_video_x11=yes
+  enable_video_x11=no
 fi;
     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
         echo "$as_me:$LINENO: checking for X" >&5
@@ -24764,14 +24766,14 @@
   enableval="$enable_dga"
 
 else
-  enable_dga=yes
+  enable_dga=no
 fi;
             # Check whether --enable-video-x11-dgamouse or --disable-video-x11-dgamouse was given.
 if test "${enable_video_x11_dgamouse+set}" = set; then
   enableval="$enable_video_x11_dgamouse"
 
 else
-  enable_video_x11_dgamouse=yes
+  enable_video_x11_dgamouse=no
 fi;
             if test x$enable_dga = xyes; then
                 echo "$as_me:$LINENO: checking for XFree86 DGA 1.0 support" >&5
@@ -24843,7 +24845,7 @@
   enableval="$enable_video_x11_xv"
 
 else
-  enable_video_x11_xv=yes
+  enable_video_x11_xv=no
 fi;
             if test x$enable_video_x11_xv = xyes; then
                 echo "$as_me:$LINENO: checking for XFree86 XvImage support" >&5
@@ -25061,7 +25063,7 @@
   enableval="$enable_video_dga"
 
 else
-  enable_video_dga=yes
+  enable_video_dga=no
 fi;
     if test x$video_x11_dga = xyes -a x$enable_video_dga = xyes; then
         save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS -Isrc/video"
@@ -25136,7 +25138,7 @@
   enableval="$enable_video_photon"
 
 else
-  enable_video_photon=yes
+  enable_video_photon=no
 fi;
     if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
         echo "$as_me:$LINENO: checking for QNX Photon support" >&5
@@ -25214,7 +25216,7 @@
   enableval="$enable_video_fbcon"
 
 else
-  enable_video_fbcon=yes
+  enable_video_fbcon=no
 fi;
     if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
         echo "$as_me:$LINENO: checking for framebuffer console support" >&5
@@ -25375,7 +25377,7 @@
   enableval="$enable_video_ps2gs"
 
 else
-  enable_video_ps2gs=yes
+  enable_video_ps2gs=no
 fi;
     if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
         echo "$as_me:$LINENO: checking for PlayStation 2 GS support" >&5
@@ -25755,7 +25757,7 @@
   enableval="$enable_xbios"
 
 else
-  enable_video_xbios=yes
+  enable_video_xbios=no
 fi;
     video_xbios=no
     if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
@@ -25773,7 +25775,7 @@
   enableval="$enable_gem"
 
 else
-  enable_video_gem=yes
+  enable_video_gem=no
 fi;
     if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
         video_gem=no
@@ -26004,6 +26006,22 @@
     VIDEO_DRIVERS="$VIDEO_DRIVERS ataricommon/libvideo_ataricommon.la"
 }
 
+CheckGP2XVideo()
+{
+    # Check whether --enable-video-gp2x or --disable-video-gp2x was given.
+if test "${enable_video_gp2x+set}" = set; then
+  enableval="$enable_video_gp2x"
+
+else
+  enable_video_gp2x=yes
+fi;
+    if test x$enable_video_gp2x = xyes; then
+      CFLAGS="$CFLAGS -DENABLE_GP2XVIDEO"
+      VIDEO_SUBDIRS="$VIDEO_SUBDIRS gp2x"
+      VIDEO_DRIVERS="$VIDEO_DRIVERS gp2x/libvideo_gp2x.la"
+    fi
+}
+
 CheckDummyVideo()
 {
     # Check whether --enable-video-dummy or --disable-video-dummy was given.
@@ -26025,7 +26043,7 @@
   enableval="$enable_video_opengl"
 
 else
-  enable_video_opengl=yes
+  enable_video_opengl=no
 fi;
 
 CheckOpenGL()
@@ -27797,7 +27815,7 @@
   enableval="$enable_directx"
 
 else
-  enable_directx=yes
+  enable_directx=no
 fi;
     if test x$enable_directx = xyes; then
         echo "$as_me:$LINENO: checking for DirectX headers and libraries" >&5
@@ -28382,7 +28400,7 @@
   enableval="$enable_atari_ldg"
 
 else
-  enable_atari_ldg=yes
+  enable_atari_ldg=no
 fi;
     if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
         if test "${ac_cv_header_ldg_h+set}" = set; then
@@ -29801,6 +29819,7 @@
         CheckNANOX
         CheckDGA
         CheckFBCON
+	CheckGP2XVideo
         CheckDirectFB
         CheckPS2GS
         CheckGGI
@@ -31773,8 +31792,10 @@
 esac
 
 # Finally create all the generated files
-                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                ac_config_files="$ac_config_files Makefile docs/Makefile docs/html/Makefile docs/man3/Makefile include/Makefile src/Makefile src/main/Makefile src/main/macosx/Makefile src/main/macosx/Info.plist src/audio/Makefile src/audio/alsa/Makefile src/audio/arts/Makefile src/audio/baudio/Makefile src/audio/dc/Makefile src/audio/disk/Makefile src/audio/dma/Makefile src/audio/dmedia/Makefile src/audio/dsp/Makefile src/audio/esd/Makefile src/audio/macosx/Makefile src/audio/macrom/Makefile src/audio/mint/Makefile src/audio/mme/Makefile src/audio/nas/Makefile src/audio/nto/Makefile src/audio/openbsd/Makefile src/audio/paudio/Makefile src/audio/sun/Makefile src/audio/ums/Makefile src/audio/windib/Makefile src/audio/windx5/Makefile src/video/Makefile src/video/aalib/Makefile src/video/ataricommon/Makefile src/video/bwindow/Makefile src/video/cybergfx/Makefile src/video/dc/Makefile src/video/dga/Makefile src/video/directfb/Makefile src/video/dummy/Makefile src/video/epoc/Makefile src/video/fbcon/Makefile src/video/gem/Makefile src/video/ggi/Makefile src/video/maccommon/Makefile src/video/macdsp/Makefile src/video/macrom/Makefile src/video/nanox/Makefile src/video/photon/Makefile src/video/picogui/Makefile src/video/ps2gs/Makefile src/video/qtopia/Makefile src/video/quartz/Makefile src/video/riscos/Makefile src/video/svga/Makefile src/video/vgl/Makefile src/video/wincommon/Makefile src/video/windib/Makefile src/video/windx5/Makefile src/video/x11/Makefile src/video/xbios/Makefile src/video/XFree86/Makefile src/video/XFree86/extensions/Makefile src/video/XFree86/Xinerama/Makefile src/video/XFree86/Xv/Makefile src/video/XFree86/Xxf86dga/Makefile src/video/XFree86/Xxf86vm/Makefile src/events/Makefile src/joystick/Makefile src/joystick/amigaos/Makefile src/joystick/beos/Makefile src/joystick/bsd/Makefile src/joystick/darwin/Makefile src/joystick/dc/Makefile src/joystick/dummy/Makefile src/joystick/linux/Makefile src/joystick/macos/Makefile src/joystick/mint/Makefile src/joystick/riscos/Makefile src/joystick/win32/Makefile src/cdrom/Makefile src/cdrom/aix/Makefile src/cdrom/beos/Makefile src/cdrom/dc/Makefile src/cdrom/dummy/Makefile src/cdrom/bsdi/Makefile src/cdrom/freebsd/Makefile src/cdrom/linux/Makefile src/cdrom/macos/Makefile src/cdrom/macosx/Makefile src/cdrom/mint/Makefile src/cdrom/openbsd/Makefile src/cdrom/osf/Makefile src/cdrom/qnx/Makefile src/cdrom/win32/Makefile src/thread/Makefile src/timer/Makefile src/endian/Makefile src/file/Makefile src/cpuinfo/Makefile src/hermes/Makefile sdl-config SDL.spec SDL.qpg"
+                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          ac_config_files="$ac_config_files Makefile docs/Makefile docs/html/Makefile docs/man3/Makefile include/Makefile src/Makefile src/main/Makefile src/main/macosx/Makefile src/main/macosx/Info.plist src/audio/Makefile src/audio/alsa/Makefile src/audio/arts/Makefile src/audio/baudio/Makefile src/audio/dc/Makefile src/audio/disk/Makefile src/audio/dma/Makefile src/audio/dmedia/Makefile src/audio/dsp/Makefile src/audio/esd/Makefile src/audio/macosx/Makefile src/audio/macrom/Makefile src/audio/mint/Makefile src/audio/mme/Makefile src/audio/nas/Makefile src/audio/nto/Makefile src/audio/openbsd/Makefile src/audio/paudio/Makefile src/audio/sun/Makefile src/audio/ums/Makefile src/audio/windib/Makefile src/audio/windx5/Makefile src/video/Makefile src/video/aalib/Makefile src/video/ataricommon/Makefile src/video/bwindow/Makefile src/video/cybergfx/Makefile src/video/dc/Makefile src/video/dga/Makefile src/video/directfb/Makefile src/video/dummy/Makefile src/video/epoc/Makefile src/video/fbcon/Makefile src/video/gem/Makefile src/video/ggi/Makefile src/video/gp2x/Makefile src/video/maccommon/Makefile src/video/macdsp/Makefile src/video/macrom/Makefile src/video/nanox/Makefile src/video/photon/Makefile src/video/picogui/Makefile src/video/ps2gs/Makefile src/video/qtopia/Makefile src/video/quartz/Makefile src/video/riscos/Makefile src/video/svga/Makefile src/video/vgl/Makefile src/video/wincommon/Makefile src/video/windib/Makefile src/video/windx5/Makefile src/video/x11/Makefile src/video/xbios/Makefile src/video/XFree86/Makefile src/video/XFree86/extensions/Makefile src/video/XFree86/Xinerama/Makefile src/video/XFree86/Xv/Makefile src/video/XFree86/Xxf86dga/Makefile src/video/XFree86/Xxf86vm/Makefile src/events/Makefile src/joystick/Makefile src/joystick/amigaos/Makefile src/joystick/beos/Makefile src/joystick/bsd/Makefile src/joystick/darwin/Makefile src/joystick/dc/Makefile src/joystick/dummy/Makefile src/joystick/linux/Makefile src/joystick/macos/Makefile src/joystick/mint/Makefile src/joystick/riscos/Makefile src/joystick/win32/Makefile src/cdrom/Makefile src/cdrom/aix/Makefile src/cdrom/beos/Makefile src/cdrom/dc/Makefile src/cdrom/dummy/Makefile src/cdrom/bsdi/Makefile src/cdrom/freebsd/Makefile src/cdrom/linux/Makefile src/cdrom/macos/Makefile src/cdrom/macosx/Makefile src/cdrom/mint/Makefile src/cdrom/openbsd/Makefile src/cdrom/osf/Makefile src/cdrom/qnx/Makefile src/cdrom/win32/Makefile src/thread/Makefile src/timer/Makefile src/endian/Makefile src/file/Makefile src/cpuinfo/Makefile src/hermes/Makefile sdl-config SDL.spec SDL.qpg"
+
           ac_config_commands="$ac_config_commands default"
+
 cat >confcache <<\_ACEOF
 # This file is a shell script that caches the results of configure
 # tests run on this system so they can be shared between configure
@@ -32509,6 +32530,7 @@
 
 AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
 
+
 _ACEOF
 
 
@@ -32562,6 +32584,7 @@
   "src/video/fbcon/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/video/fbcon/Makefile" ;;
   "src/video/gem/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/video/gem/Makefile" ;;
   "src/video/ggi/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/video/ggi/Makefile" ;;
+  "src/video/gp2x/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/video/gp2x/Makefile" ;;
   "src/video/maccommon/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/video/maccommon/Makefile" ;;
   "src/video/macdsp/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/video/macdsp/Makefile" ;;
   "src/video/macrom/Makefile" ) CONFIG_FILES="$CONFIG_FILES src/video/macrom/Makefile" ;;
diff -urN SDL-1.2.9/configure.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/configure.in
--- SDL-1.2.9/configure.in	2005-08-28 08:31:18.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/configure.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,5 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(README)
+AC_INIT
+AC_CONFIG_SRCDIR([README])
 
 dnl Set various version strings - taken gratefully from the GTk sources
 #
@@ -38,7 +39,7 @@
 AC_SUBST(LT_AGE)
 
 dnl Detect the canonical host and target build environment
-AC_CANONICAL_SYSTEM
+AC_CANONICAL_TARGET([])
 
 dnl Setup for automake
 AM_INIT_AUTOMAKE(SDL, $SDL_VERSION)
@@ -65,7 +66,7 @@
 dnl The alpha architecture needs special flags for binary portability
 case "$target" in
     alpha*-*-linux*)
-        if test x$ac_cv_prog_gcc = xyes; then
+        if test x$ac_cv_c_compiler_gnu = xyes; then
             CFLAGS="$CFLAGS -mcpu=ev4 -Wa,-mall"
         fi
         ;;
@@ -78,24 +79,24 @@
 [  --enable-debug          Disable aggressive optimizations [default=yes]],
               , enable_debug=yes)
 if test x$enable_debug != xyes; then
-    if test x$ac_cv_prog_gcc = xyes; then
+    if test x$ac_cv_c_compiler_gnu = xyes; then
         CFLAGS="$CFLAGS -fexpensive-optimizations"
         # Ack! This breaks the MMX YV12 conversion on gcc 2.95.2
         # CFLAGS="$CFLAGS -fomit-frame-pointer"
     fi
     case "$target" in
         i486-*-*)
-            if test x$ac_cv_prog_gcc = xyes; then
+            if test x$ac_cv_c_compiler_gnu = xyes; then
                 CFLAGS="$CFLAGS -march=i486"
             fi
             ;;
         i?86-*-*)
-            if test x$ac_cv_prog_gcc = xyes; then
+            if test x$ac_cv_c_compiler_gnu = xyes; then
                 CFLAGS="$CFLAGS -march=pentium -mcpu=pentiumpro"
             fi
             ;;
         *-*-osf*)
-            if test x$ac_cv_prog_gcc != xyes; then
+            if test x$ac_cv_c_compiler_gnu != xyes; then
                 CFLAGS="-g3 -fast -arch host"
             fi
             ;;
@@ -106,7 +107,7 @@
 AC_ARG_ENABLE(strict-ansi,
 [  --enable-strict-ansi    Enable strict ANSI compliance build [default=no]],
               , enable_strict_ansi=no)
-if test x$ac_cv_prog_gcc = xyes; then
+if test x$ac_cv_c_compiler_gnu = xyes; then
     CFLAGS="$CFLAGS -Wall"
     if test x$enable_strict_ansi = xyes; then
         CFLAGS="$CFLAGS -ansi -pedantic -D_XOPEN_SOURCE"
@@ -175,7 +176,7 @@
     CFLAGS="$CFLAGS -DDISABLE_JOYSTICK"
 fi
 AC_ARG_ENABLE(cdrom,
-[  --enable-cdrom          Enable the cdrom subsystem [default=yes]],
+[  --enable-cdrom          Enable the cdrom subsystem [default=no]],
               , enable_cdrom=yes)
 if test x$enable_cdrom = xyes; then
     SDL_EXTRADIRS="$SDL_EXTRADIRS cdrom"
@@ -246,23 +247,23 @@
         AC_MSG_CHECKING(for OSS audio support)
         have_oss=no
         if test x$have_oss != xyes; then
-            AC_TRY_COMPILE([
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
               #include <sys/soundcard.h>
-            ],[
+            ]], [[
               int arg = SNDCTL_DSP_SETFRAGMENT;
-            ],[
+            ]])],[
             have_oss=yes
-            ])
+            ],[])
         fi
         if test x$have_oss != xyes; then
-            AC_TRY_COMPILE([
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
               #include <soundcard.h>
-            ],[
+            ]], [[
               int arg = SNDCTL_DSP_SETFRAGMENT;
-            ],[
+            ]])],[
             have_oss=yes
             CFLAGS="$CFLAGS -DOSS_USE_SOUNDCARD_H"
-            ])
+            ],[])
         fi
         AC_MSG_RESULT($have_oss)
         if test x$have_oss = xyes; then
@@ -315,15 +316,15 @@
 
                 AC_MSG_CHECKING(for dlvsym)
                 use_dlvsym=no
-                AC_TRY_COMPILE([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                   #include <stdio.h>
                   #define __USE_GNU
                   #include <dlfcn.h>
-                ],[
+                ]], [[
                   dlvsym(NULL,"","");
-                ],[
+                ]])],[
                 use_dlvsym=yes
-                ])
+                ],[])
                 AC_MSG_RESULT($use_dlvsym);
                 if test x$use_dlvsym = xyes; then
                     CFLAGS="$CFLAGS -DUSE_DLVSYM"
@@ -344,13 +345,13 @@
     if test x$enable_audio = xyes; then
         AC_MSG_CHECKING(for dmedia audio support)
         have_dmedia=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
           #include <dmedia/audio.h>
-        ],[
+        ]], [[
           ALport audio_port;
-        ],[
+        ]])],[
         have_dmedia=yes
-        ])
+        ],[])
         AC_MSG_RESULT($have_dmedia)
         # Set up files for the audio library
         if test x$have_dmedia = xyes; then
@@ -366,14 +367,14 @@
 CheckESD()
 {
     AC_ARG_ENABLE(esd,
-[  --enable-esd            support the Enlightened Sound Daemon [default=yes]],
-                  , enable_esd=yes)
+[  --enable-esd            support the Enlightened Sound Daemon [default=no]],
+                  , enable_esd=no)
     if test x$enable_audio = xyes -a x$enable_esd = xyes; then
         AM_PATH_ESD(0.2.8, have_esd=yes, have_esd=no)
         if test x$have_esd = xyes; then
             AC_ARG_ENABLE(esd-shared,
-[  --enable-esd-shared     dynamically load ESD audio support [default=yes]],
-                          , enable_esd_shared=yes)
+[  --enable-esd-shared     dynamically load ESD audio support [default=no]],
+                          , enable_esd_shared=no)
             esd_lib_spec=`echo $ESD_LIBS | sed 's/.*-L\([[^ ]]*\).*/\1\/libesd.so.*/'`
             esd_lib=`ls $esd_lib_spec | sed 's/.*\/\(.*\)/\1/; q'`
             echo "-- $esd_lib_spec -> $esd_lib"
@@ -398,8 +399,8 @@
 CheckARTSC()
 {
     AC_ARG_ENABLE(arts,
-[  --enable-arts           support the Analog Real Time Synthesizer [default=yes]],
-                  , enable_arts=yes)
+[  --enable-arts           support the Analog Real Time Synthesizer [default=no]],
+                  , enable_arts=no)
     if test x$enable_audio = xyes -a x$enable_arts = xyes; then
         AC_PATH_PROG(ARTSCCONFIG, artsc-config)
         if test x$ARTSCCONFIG = x -o x$ARTSCCONFIG = x'"$ARTSCCONFIG"'; then
@@ -412,13 +413,13 @@
             audio_arts=no
             save_CFLAGS="$CFLAGS"
             CFLAGS="$CFLAGS $ARTSC_CFLAGS"
-            AC_TRY_COMPILE([
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
              #include <artsc.h>
-            ],[
+            ]], [[
              arts_stream_t stream;
-            ],[
+            ]])],[
             audio_arts=yes
-            ])
+            ],[])
             CFLAGS="$save_CFLAGS"
             AC_MSG_RESULT($audio_arts)
             if test x$audio_arts = xyes; then
@@ -451,8 +452,8 @@
 CheckNAS()
 {
     AC_ARG_ENABLE(nas,
-[  --enable-nas            support the NAS audio API [default=yes]],
-                  , enable_nas=yes)
+[  --enable-nas            support the NAS audio API [default=no]],
+                  , enable_nas=no)
     if test x$enable_audio = xyes -a x$enable_nas = xyes; then
         AC_MSG_CHECKING(for NAS audio support)
         have_nas=no
@@ -481,8 +482,8 @@
 CheckDiskAudio()
 {
     AC_ARG_ENABLE(diskaudio,
-[  --enable-diskaudio      support the disk writer audio driver [default=yes]],
-                  , enable_diskaudio=yes)
+[  --enable-diskaudio      support the disk writer audio driver [default=no]],
+                  , enable_diskaudio=no)
     if test x$enable_audio = xyes -a x$enable_diskaudio = xyes; then
         CFLAGS="$CFLAGS -DDISKAUD_SUPPORT"
         AUDIO_SUBDIRS="$AUDIO_SUBDIRS disk"
@@ -494,8 +495,8 @@
 CheckAtariAudio()
 {
     AC_ARG_ENABLE(mintaudio,
-[  --enable-mintaudio      support Atari audio driver [default=yes]],
-                  , enable_mintaudio=yes)
+[  --enable-mintaudio      support Atari audio driver [default=no]],
+                  , enable_mintaudio=no)
     if test x$enable_audio = xyes -a x$enable_mintaudio = xyes; then
         mintaudio=no
         AC_CHECK_HEADER(mint/falcon.h, have_mint_falcon_hdr=yes)
@@ -599,8 +600,8 @@
 CheckX11()
 {
     AC_ARG_ENABLE(video-x11,
-[  --enable-video-x11      use X11 video driver [default=yes]],
-                  , enable_video_x11=yes)
+[  --enable-video-x11      use X11 video driver [default=no]],
+                  , enable_video_x11=no)
     if test x$enable_video = xyes -a x$enable_video_x11 = xyes; then
         AC_PATH_X
         AC_PATH_XTRA
@@ -619,13 +620,13 @@
             if test x$enable_video_x11_vm = xyes; then
                 AC_MSG_CHECKING(for XFree86 VidMode 1.0 support)
                 video_x11_vm=no
-                AC_TRY_COMPILE([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                  #include <X11/Xlib.h>
                  #include <XFree86/extensions/xf86vmode.h>
-                ],[
-                ],[
+                ]], [[
+                ]])],[
                 video_x11_vm=yes
-                ])
+                ],[])
                 AC_MSG_RESULT($video_x11_vm)
                 if test x$video_x11_vm = xyes; then
                     CFLAGS="$CFLAGS -DXFREE86_VM"
@@ -633,14 +634,14 @@
                     VIDEO_DRIVERS="$VIDEO_DRIVERS XFree86/Xxf86vm/libXFree86_Xxf86vm.la"
                     AC_MSG_CHECKING(for XFree86 VidMode gamma support)
                     video_x11_vmgamma=no
-                    AC_TRY_COMPILE([
+                    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                      #include <X11/Xlib.h>
                      #include <XFree86/extensions/xf86vmode.h>
-                    ],[
+                    ]], [[
                      SDL_NAME(XF86VidModeGamma) gamma;
-                    ],[
+                    ]])],[
                     video_x11_vmgamma=yes
-                    ])
+                    ],[])
                     AC_MSG_RESULT($video_x11_vmgamma)
                     if test x$video_x11_vmgamma = xyes; then
                         CFLAGS="$CFLAGS -DXFREE86_VMGAMMA"
@@ -648,21 +649,21 @@
                 fi
             fi
             AC_ARG_ENABLE(dga,
-[  --enable-dga            allow use of X11 DGA code [default=yes]],
-                          , enable_dga=yes)
+[  --enable-dga            allow use of X11 DGA code [default=no]],
+                          , enable_dga=no)
             AC_ARG_ENABLE(video-x11-dgamouse,
-[  --enable-video-x11-dgamouse  use X11 DGA for mouse events [default=yes]],
-                          , enable_video_x11_dgamouse=yes)
+[  --enable-video-x11-dgamouse  use X11 DGA for mouse events [default=no]],
+                          , enable_video_x11_dgamouse=no)
             if test x$enable_dga = xyes; then
                 AC_MSG_CHECKING(for XFree86 DGA 1.0 support)
                 video_x11_dga=no
-                AC_TRY_COMPILE([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                  #include <X11/Xlib.h>
                  #include <XFree86/extensions/xf86dga.h>
-                ],[
-                ],[
+                ]], [[
+                ]])],[
                 video_x11_dga=yes
-                ])
+                ],[])
                 AC_MSG_RESULT($video_x11_dga)
                 if test x$video_x11_dga = xyes; then
                     CFLAGS="$CFLAGS -DXFREE86_DGAMOUSE"
@@ -674,22 +675,22 @@
                 fi
             fi
             AC_ARG_ENABLE(video-x11-xv,
-[  --enable-video-x11-xv   use X11 XvImage extension for video [default=yes]],
-                          , enable_video_x11_xv=yes)
+[  --enable-video-x11-xv   use X11 XvImage extension for video [default=no]],
+                          , enable_video_x11_xv=no)
             if test x$enable_video_x11_xv = xyes; then
                 AC_MSG_CHECKING(for XFree86 XvImage support)
                 video_x11_xv=no
-                AC_TRY_COMPILE([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                  #include <X11/Xlib.h>
                  #include <sys/ipc.h>
                  #include <sys/shm.h>
                  #include <X11/extensions/XShm.h>
                  #include <XFree86/extensions/Xvlib.h>
-                ],[
+                ]], [[
                  SDL_NAME(XvImage) *image;
-                ],[
+                ]])],[
                 video_x11_xv=yes
-                ])
+                ],[])
                 AC_MSG_RESULT($video_x11_xv)
                 if test x$video_x11_xv = xyes; then
                     CFLAGS="$CFLAGS -DXFREE86_XV"
@@ -703,14 +704,14 @@
             if test x$enable_video_x11_xinerama = xyes; then
                 AC_MSG_CHECKING(for X11 Xinerama support)
                 video_x11_xinerama=no
-                AC_TRY_COMPILE([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                  #include <X11/Xlib.h>
                  #include <XFree86/extensions/Xinerama.h>
-                ],[
+                ]], [[
                  SDL_NAME(XineramaScreenInfo) *xinerama;
-                ],[
+                ]])],[
                 video_x11_xinerama=yes
-                ])
+                ],[])
                 AC_MSG_RESULT($video_x11_xinerama)
                 if test x$video_x11_xinerama = xyes; then
                     CFLAGS="$CFLAGS -DHAVE_XINERAMA"
@@ -724,14 +725,14 @@
             if test x$enable_video_x11_xme = xyes; then
                 AC_MSG_CHECKING(for Xi Graphics XiGMiscExtension support)
                 video_x11_xme=no
-                AC_TRY_COMPILE([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                  #include <X11/Xlib.h>
                  #include <X11/extensions/xme.h>
-                ],[
+                ]], [[
                  XiGMiscResolutionInfo *resolutions;
-                ],[
+                ]])],[
                 video_x11_xme=yes
-                ])
+                ],[])
                 AC_MSG_RESULT($video_x11_xme)
                 if test x$video_x11_xme = xyes; then
                     CFLAGS="$CFLAGS -DHAVE_XIGXME"
@@ -746,20 +747,20 @@
 CheckDGA()
 {
     AC_ARG_ENABLE(video-dga,
-[  --enable-video-dga      use DGA 2.0 video driver [default=yes]],
-                  , enable_video_dga=yes)
+[  --enable-video-dga      use DGA 2.0 video driver [default=no]],
+                  , enable_video_dga=no)
     if test x$video_x11_dga = xyes -a x$enable_video_dga = xyes; then
         save_CFLAGS="$CFLAGS"; CFLAGS="$CFLAGS -Isrc/video"
         AC_MSG_CHECKING(for XFree86 DGA 2.0 support)
         video_x11_dga2=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <X11/Xlib.h>
          #include <XFree86/extensions/xf86dga.h>
-        ],[
+        ]], [[
          SDL_NAME(XDGAEvent) xevent;
-        ],[
+        ]])],[
         video_x11_dga2=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_x11_dga2)
         if test x$video_x11_dga2 = xyes; then
             CFLAGS="$CFLAGS -DENABLE_DGA"
@@ -772,21 +773,21 @@
 CheckPHOTON()
 {
     AC_ARG_ENABLE(video-photon,
-[  --enable-video-photon   use QNX Photon video driver [default=yes]],
-                  , enable_video_photon=yes)
+[  --enable-video-photon   use QNX Photon video driver [default=no]],
+                  , enable_video_photon=no)
     if test x$enable_video = xyes -a x$enable_video_photon = xyes; then
         AC_MSG_CHECKING(for QNX Photon support)
         video_photon=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
           #include <Ph.h>
           #include <Pt.h>
           #include <photon/Pg.h>
           #include <photon/PdDirect.h>
-        ],[
+        ]], [[
          PgDisplaySettings_t *visual;
-        ],[
+        ]])],[
         video_photon=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_photon)
         if test x$video_photon = xyes; then
             CFLAGS="$CFLAGS -DENABLE_PHOTON"
@@ -802,19 +803,19 @@
 CheckFBCON()
 {
     AC_ARG_ENABLE(video-fbcon,
-[  --enable-video-fbcon    use framebuffer console video driver [default=yes]],
-                  , enable_video_fbcon=yes)
+[  --enable-video-fbcon    use framebuffer console video driver [default=no]],
+                  , enable_video_fbcon=no)
     if test x$enable_video = xyes -a x$enable_video_fbcon = xyes; then
         AC_MSG_CHECKING(for framebuffer console support)
         video_fbcon=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <linux/fb.h>
          #include <linux/kd.h>
          #include <linux/keyboard.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_fbcon=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_fbcon)
         if test x$video_fbcon = xyes; then
             CFLAGS="$CFLAGS -DENABLE_FBCON"
@@ -868,18 +869,18 @@
 CheckPS2GS()
 {
     AC_ARG_ENABLE(video-ps2gs,
-[  --enable-video-ps2gs    use PlayStation 2 GS video driver [default=yes]],
-                  , enable_video_ps2gs=yes)
+[  --enable-video-ps2gs    use PlayStation 2 GS video driver [default=no]],
+                  , enable_video_ps2gs=no)
     if test x$enable_video = xyes -a x$enable_video_ps2gs = xyes; then
         AC_MSG_CHECKING(for PlayStation 2 GS support)
         video_ps2gs=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <linux/ps2/dev.h>
          #include <linux/ps2/gs.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_ps2gs=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_ps2gs)
         if test x$video_ps2gs = xyes; then
             CFLAGS="$CFLAGS -DENABLE_PS2GS"
@@ -898,13 +899,13 @@
     if test x$enable_video = xyes -a x$enable_video_ggi = xyes; then
         AC_MSG_CHECKING(for GGI support)
         video_ggi=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <ggi/ggi.h>
          #include <ggi/gii.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_ggi=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_ggi)
         if test x$video_ggi = xyes; then
             CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_GGI"
@@ -925,17 +926,17 @@
     if test x$enable_video = xyes -a x$enable_video_svga = xyes; then
         AC_MSG_CHECKING(for SVGAlib (1.4.0+) support)
         video_svga=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <vga.h>
          #include <vgamouse.h>
          #include <vgakeyboard.h>
-        ],[
+        ]], [[
          if ( SCANCODE_RIGHTWIN && SCANCODE_LEFTWIN ) {
              exit(0);
          }
-        ],[
+        ]])],[
         video_svga=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_svga)
         if test x$video_svga = xyes; then
             CFLAGS="$CFLAGS -DENABLE_SVGALIB"
@@ -956,17 +957,17 @@
     if test x$enable_video = xyes -a x$enable_video_vgl = xyes; then
         AC_MSG_CHECKING(for libVGL support)
         video_vgl=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <sys/fbio.h>
          #include <sys/consio.h>
          #include <sys/kbio.h>
          #include <vgl.h>
-        ],[
+        ]], [[
          VGLBitmap bitmap;
          exit(bitmap.Bitmap);
-        ],[
+        ]])],[
         video_vgl=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_vgl)
         if test x$video_vgl = xyes; then
             CFLAGS="$CFLAGS -DENABLE_VGL"
@@ -987,12 +988,12 @@
     if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
         AC_MSG_CHECKING(for AAlib support)
         video_aalib=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <aalib.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_aalib=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_aalib)
         if test x$video_aalib = xyes; then
             CFLAGS="$CFLAGS -DENABLE_AALIB"
@@ -1008,8 +1009,8 @@
 CheckAtariXbiosVideo()
 {
     AC_ARG_ENABLE(xbios,
-[  --enable-video-xbios    use Atari Xbios video driver [default=yes]],
-                  , enable_video_xbios=yes)
+[  --enable-video-xbios    use Atari Xbios video driver [default=no]],
+                  , enable_video_xbios=no)
     video_xbios=no
     if test x$enable_video = xyes -a x$enable_video_xbios = xyes; then
         video_xbios=yes
@@ -1023,8 +1024,8 @@
 CheckAtariGemVideo()
 {
     AC_ARG_ENABLE(gem,
-[  --enable-video-gem      use Atari Gem video driver [default=yes]],
-                  , enable_video_gem=yes)
+[  --enable-video-gem      use Atari Gem video driver [default=no]],
+                  , enable_video_gem=no)
     if test x$enable_video = xyes -a x$enable_video_gem = xyes; then
         video_gem=no
         AC_CHECK_HEADER(gem.h, have_gem_hdr=yes)
@@ -1047,6 +1048,19 @@
     VIDEO_DRIVERS="$VIDEO_DRIVERS ataricommon/libvideo_ataricommon.la"
 }
 
+dnl paeryn 04012006 Set up the GP2X video driver.
+CheckGP2XVideo()
+{
+    AC_ARG_ENABLE(video-gp2x,
+[  --enable-video-gp2x    use gp2x video driver [default=yes]],
+                  , enable_video_gp2x=yes)
+    if test x$enable_video_gp2x = xyes; then
+      CFLAGS="$CFLAGS -DENABLE_GP2XVIDEO"
+      VIDEO_SUBDIRS="$VIDEO_SUBDIRS gp2x"
+      VIDEO_DRIVERS="$VIDEO_DRIVERS gp2x/libvideo_gp2x.la"
+    fi
+}
+
 dnl rcg04172001 Set up the Null video driver.
 CheckDummyVideo()
 {
@@ -1062,8 +1076,8 @@
 
 dnl Check to see if OpenGL support is desired
 AC_ARG_ENABLE(video-opengl,
-[  --enable-video-opengl   include OpenGL context creation [default=yes]],
-              , enable_video_opengl=yes)
+[  --enable-video-opengl   include OpenGL context creation [default=no]],
+              , enable_video_opengl=no)
 
 dnl Find OpenGL
 CheckOpenGL()
@@ -1071,14 +1085,14 @@
     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
         AC_MSG_CHECKING(for OpenGL (GLX) support)
         video_opengl=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <GL/gl.h>
          #include <GL/glx.h>
          #include <dlfcn.h> /* For loading extensions */
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_opengl=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_opengl)
         if test x$video_opengl = xyes; then
             CFLAGS="$CFLAGS -DHAVE_OPENGL"
@@ -1095,12 +1109,12 @@
     if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
         AC_MSG_CHECKING(for OpenGL (Photon) support)
         video_opengl=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <GL/gl.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_opengl=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_opengl)
         if test x$video_opengl = xyes; then
             CFLAGS="$CFLAGS -DHAVE_OPENGL"
@@ -1178,15 +1192,15 @@
     if test x$enable_input_events = xyes; then
         AC_MSG_CHECKING(for Linux 2.4 unified input interface)
         use_input_events=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
           #include <linux/input.h>
-        ],[
+        ]], [[
           #ifndef EVIOCGNAME
           #error EVIOCGNAME() ioctl not available
           #endif
-        ],[
+        ]])],[
         use_input_events=yes
-        ])
+        ],[])
         AC_MSG_RESULT($use_input_events)
         if test x$use_input_events = xyes; then
             CFLAGS="$CFLAGS -DUSE_INPUT_EVENTS"
@@ -1281,7 +1295,7 @@
             ;;
         *-*-osf*)
             pthread_cflags="-D_REENTRANT"
-            if test x$ac_cv_prog_gcc = xyes; then
+            if test x$ac_cv_c_compiler_gnu = xyes; then
                 pthread_lib="-lpthread -lrt"
             else
                 pthread_lib="-lpthread -lexc -lrt"
@@ -1300,14 +1314,14 @@
         # Check to see if we have pthread support on this system
         AC_MSG_CHECKING(for pthreads)
         use_pthreads=no
-        AC_TRY_LINK([
+        AC_LINK_IFELSE([AC_LANG_PROGRAM([[
          #include <pthread.h>
-        ],[
+        ]], [[
          pthread_attr_t type;
          pthread_attr_init(&type);
-        ],[
+        ]])],[
         use_pthreads=yes
-        ])
+        ],[])
         AC_MSG_RESULT($use_pthreads)
         # Restore the compiler flags and libraries
         CFLAGS="$ac_save_cflags"; LIBS="$ac_save_libs"
@@ -1321,18 +1335,18 @@
             # Check to see if recursive mutexes are available
             AC_MSG_CHECKING(for recursive mutexes)
             has_recursive_mutexes=no
-            AC_TRY_LINK([
+            AC_LINK_IFELSE([AC_LANG_PROGRAM([[
               #include <pthread.h>
-            ],[
+            ]], [[
               pthread_mutexattr_t attr;
               #if defined(linux) && !(defined(__arm__) && defined(QWS))
               pthread_mutexattr_setkind_np(&attr, PTHREAD_MUTEX_RECURSIVE_NP);
               #else
               pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
               #endif
-            ],[
+            ]])],[
             has_recursive_mutexes=yes
-            ])
+            ],[])
             # Some systems have broken recursive mutex implementations
             case "$target" in
                 *-*-darwin*)
@@ -1351,13 +1365,13 @@
             if test x$enable_pthread_sem = xyes; then
                 AC_MSG_CHECKING(for pthread semaphores)
                 have_pthread_sem=no
-                AC_TRY_COMPILE([
+                AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                   #include <pthread.h>
                   #include <semaphore.h>
-                ],[
-                ],[
+                ]], [[
+                ]])],[
                 have_pthread_sem=yes
-                ])
+                ],[])
                 AC_MSG_RESULT($have_pthread_sem)
             fi
 
@@ -1366,17 +1380,17 @@
                 *-*-linux*)
                     AC_MSG_CHECKING(for broken glibc 2.0 pthreads)
                     glibc20_pthreads=no
-                    AC_TRY_COMPILE([
+                    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
                       #include <features.h>
                       #if (__GLIBC__ == 2) && (__GLIBC_MINOR__ == 0)
                       #warning Working around a bug in glibc 2.0 pthreads
                       #else
                       #error pthread implementation okay
                       #endif /* glibc 2.0 */
-                    ],[
-                    ],[
+                    ]], [[
+                    ]])],[
                     glibc20_pthreads=yes
-                    ])
+                    ],[])
                     AC_MSG_RESULT($glibc20_pthreads)
             esac
         fi
@@ -1384,14 +1398,14 @@
 
     AC_MSG_CHECKING(whether semun is defined in /usr/include/sys/sem.h)
     have_semun=no
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
       #include <sys/types.h>
       #include <sys/sem.h>
-    ],[
+    ]], [[
       union semun t;
-    ],[
+    ]])],[
     have_semun=yes
-    ])
+    ],[])
     AC_MSG_RESULT($have_semun)
     if test x$have_semun = xyes; then
         CFLAGS="$CFLAGS -DHAVE_SEMUN"
@@ -1483,14 +1497,14 @@
     if test x$enable_sigaction = xyes; then
         AC_MSG_CHECKING(sigaction)
         have_sigaction=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <signal.h>
-        ],[
+        ]], [[
          struct sigaction junk;
          sigaction(0, &junk, &junk);
-        ],[
+        ]])],[
         have_sigaction=yes
-        ])
+        ],[])
         AC_MSG_RESULT($have_sigaction)
         if test x$have_sigaction = xyes; then
             CFLAGS="$CFLAGS -DHAVE_SIGACTION"
@@ -1503,12 +1517,12 @@
 {
     AC_MSG_CHECKING(Win32 compiler)
     have_win32_gcc=no
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
      #include <windows.h>
-    ],[
-    ],[
+    ]], [[
+    ]])],[
     have_win32_gcc=yes
-    ])
+    ],[])
     AC_MSG_RESULT($have_win32_gcc)
     if test x$have_win32_gcc != xyes; then
        AC_MSG_ERROR([
@@ -1529,19 +1543,19 @@
 CheckDIRECTX()
 {
     AC_ARG_ENABLE(directx,
-[  --enable-directx        use DirectX for Win32 audio/video [default=yes]],
-                  , enable_directx=yes)
+[  --enable-directx        use DirectX for Win32 audio/video [default=no]],
+                  , enable_directx=no)
     if test x$enable_directx = xyes; then
         AC_MSG_CHECKING(for DirectX headers and libraries)
         use_directx=no
         tmp_cflags=$CFLAGS
         CFLAGS="$CFLAGS -I$srcdir"
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include "src/video/windx5/directx.h"
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         use_directx=yes
-        ])
+        ],[])
         CFLAGS=$tmp_cflags
         AC_MSG_RESULT($use_directx)
     fi
@@ -1580,15 +1594,15 @@
     if test x$enable_video = xyes -a x$enable_video_qtopia = xyes; then
         AC_MSG_CHECKING(for Qtopia support)
         video_qtopia=no
-        AC_LANG_CPLUSPLUS
+        AC_LANG([C++])
         OLD_CXX="$CXXFLAGS"
         CXXFLAGS="-DQT_QWS_EBX -fno-rtti -fno-exceptions -DQT_QWS_CUSTOM -DQWS -I${QPEDIR}/include -I${QTDIR}/include/ -DNO_DEBUG"
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <qpe/qpeapplication.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_qtopia=yes
-        ])
+        ],[])
         CXXFLAGS="$OLD_CXX"
         AC_MSG_RESULT($video_qtopia)
         if test x$video_qtopia = xyes; then
@@ -1602,7 +1616,7 @@
 *** Failed to find Qtopia includes. Make sure that the QTDIR and QPEDIR
 *** environment variables are set correctly.])
         fi
-        AC_LANG_C
+        AC_LANG([C])
     fi
 }
 
@@ -1615,12 +1629,12 @@
     if test x$enable_video = xyes -a x$enable_video_picogui = xyes; then
         AC_MSG_CHECKING(for PicoGUI support)
         video_picogui=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <picogui.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         video_picogui=yes
-        ])
+        ],[])
         AC_MSG_RESULT($video_picogui)
         if test x$video_picogui = xyes; then
 	    SDL_LIBS="$SDL_LIBS -lpgui"
@@ -1628,7 +1642,7 @@
             VIDEO_SUBDIRS="$VIDEO_SUBDIRS picogui"
             VIDEO_DRIVERS="$VIDEO_DRIVERS picogui/libvideo_picogui.la"
         fi
-        AC_LANG_C
+        AC_LANG([C])
     fi
 }
 
@@ -1683,12 +1697,12 @@
     if test x$enable_sdl_dlopen = xyes; then
         AC_MSG_CHECKING(for dlopen)
         use_dlopen=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
          #include <dlfcn.h>
-        ],[
-        ],[
+        ]], [[
+        ]])],[
         use_dlopen=yes
-        ])
+        ],[])
         AC_MSG_RESULT($use_dlopen)
 
         if test x$use_dlopen = xyes; then
@@ -1704,8 +1718,8 @@
 CheckAtariLdg()
 {
     AC_ARG_ENABLE(atari-ldg,
-[  --enable-atari-ldg      use Atari LDG for shared object loading [default=yes]],
-                  , enable_atari_ldg=yes)
+[  --enable-atari-ldg      use Atari LDG for shared object loading [default=no]],
+                  , enable_atari_ldg=no)
     if test x$video_gem = xyes -a x$enable_atari_ldg = xyes; then
         AC_CHECK_HEADER(ldg.h, have_ldg_hdr=yes)
         AC_CHECK_LIB(ldg, ldg_open, have_ldg_lib=yes, have_ldg_lib=no, -lgem)
@@ -1750,7 +1764,7 @@
 
         AC_MSG_CHECKING(for usbhid)
         have_usbhid=no
-        AC_TRY_COMPILE([
+        AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
           #include <sys/types.h>
           #if defined(HAVE_USB_H)
           #include <usb.h>
@@ -1764,19 +1778,19 @@
           #elif defined(HAVE_LIBUSBHID_H)
           #include <libusbhid.h>
           #endif
-        ],[
+        ]], [[
           struct report_desc *repdesc;
           struct usb_ctl_report *repbuf;
           hid_kind_t hidkind;
-        ],[
+        ]])],[
         have_usbhid=yes
-        ])
+        ],[])
         AC_MSG_RESULT($have_usbhid)
 
         if test x$have_usbhid = xyes; then
             AC_MSG_CHECKING(for ucr_data member of usb_ctl_report)
             have_usbhid_ucr_data=no
-            AC_TRY_COMPILE([
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
               #include <sys/types.h>
               #if defined(HAVE_USB_H)
               #include <usb.h>
@@ -1790,12 +1804,12 @@
               #elif defined(HAVE_LIBUSBHID_H)
               #include <libusbhid.h>
               #endif
-            ],[
+            ]], [[
               struct usb_ctl_report buf;
               if (buf.ucr_data) { }
-            ],[
+            ]])],[
             have_usbhid_ucr_data=yes
-            ])
+            ],[])
             if test x$have_usbhid_ucr_data = xyes; then
                 CFLAGS="$CFLAGS -DUSBHID_UCR_DATA"
             fi
@@ -1803,7 +1817,7 @@
             
 	    AC_MSG_CHECKING(for new usbhid API)
             have_usbhid_new=no
-            AC_TRY_COMPILE([
+            AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
               #include <sys/types.h>
               #if defined(HAVE_USB_H)
               #include <usb.h>
@@ -1817,12 +1831,12 @@
               #elif defined(HAVE_LIBUSBHID_H)
               #include <libusbhid.h>
               #endif
-            ],[
+            ]], [[
               report_desc_t d;
 	      hid_start_parse(d, 1, 1);
-            ],[
+            ]])],[
             have_usbhid_new=yes
-            ])
+            ],[])
             if test x$have_usbhid_new = xyes; then
                 CFLAGS="$CFLAGS -DUSBHID_NEW"
             fi
@@ -1841,14 +1855,14 @@
     have_gcc_altivec=no
     save_CFLAGS="${CFLAGS}"
     CFLAGS="${CFLAGS} -DGCC_ALTIVEC -DUSE_ALTIVEC_BLITTERS -faltivec"
-    AC_TRY_COMPILE([
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
     vector unsigned int vzero() {
         return vec_splat_u32(0);
     }
-    ],[
-    ],[
+    ]], [[
+    ]])],[
     have_gcc_altivec=yes
-    ])
+    ],[])
     if test x$have_gcc_altivec = xno; then
         CFLAGS="${save_CFLAGS}"
     fi
@@ -1894,6 +1908,7 @@
         CheckNANOX
         CheckDGA
         CheckFBCON
+	CheckGP2XVideo
         CheckDirectFB
         CheckPS2GS
         CheckGGI
@@ -2866,7 +2881,7 @@
 dnl Important: Any directory that you want to be in the distcheck should
 dnl            have a file listed here, so that configure generates the
 dnl            subdirectories on the build target.
-AC_OUTPUT([
+AC_CONFIG_FILES([
 Makefile
 docs/Makefile
 docs/html/Makefile
@@ -2911,6 +2926,7 @@
 src/video/fbcon/Makefile
 src/video/gem/Makefile
 src/video/ggi/Makefile
+src/video/gp2x/Makefile
 src/video/maccommon/Makefile
 src/video/macdsp/Makefile
 src/video/macrom/Makefile
@@ -2971,4 +2987,6 @@
 sdl-config
 SDL.spec
 SDL.qpg
-], [chmod +x sdl-config])
+])
+AC_CONFIG_COMMANDS([default],[[chmod +x sdl-config]],[[]])
+AC_OUTPUT
diff -urN SDL-1.2.9/docs/html/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/docs/html/Makefile.in
--- SDL-1.2.9/docs/html/Makefile.in	2005-08-28 08:31:36.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/docs/html/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/docs/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/docs/Makefile.in
--- SDL-1.2.9/docs/Makefile.in	2005-08-28 08:31:36.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/docs/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/docs/man3/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/docs/man3/Makefile.in
--- SDL-1.2.9/docs/man3/Makefile.in	2005-08-28 08:31:36.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/docs/man3/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/include/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/include/Makefile.in
--- SDL-1.2.9/include/Makefile.in	2005-08-28 08:31:37.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/include/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/include/SDL_gp2x.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/include/SDL_gp2x.h
--- SDL-1.2.9/include/SDL_gp2x.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/include/SDL_gp2x.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,30 @@
+/*
+ * Non-standard SDL header.
+ *
+ * This header gives access to a few extra features of the GP2X hardware
+ * that I added to the video driver.
+ */
+
+#ifndef SDL_GP2X__H
+#define SDL_GP2X__H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+  
+void SDL_GP2X_SetMonoColours(int background, int foreground);
+int  SDL_GP2X_GetPhysicalScreenSize(SDL_Rect *size);
+void SDL_GP2X_Display(SDL_Rect *area);
+void SDL_GP2X_InitializeCursor();
+void SDL_GP2X_SetCursorColour(WMcursor *wcursor,
+			      int bred, int bgreen, int bblue, int balpha,
+			      int fred, int fgreen, int fblue, int falpha);
+void SDL_GP2X_DefineRegion(int region, SDL_Rect *area);
+void SDL_GP2X_ActivateRegion(int region, int activate);
+void SDL_GP2X_MiniDisplay(int x, int y);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff -urN SDL-1.2.9/include/SDL_keysym.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/include/SDL_keysym.h
--- SDL-1.2.9/include/SDL_keysym.h	2004-01-04 17:49:07.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/include/SDL_keysym.h	2006-05-19 09:11:11.000000000 +0200
@@ -38,6 +38,7 @@
 	/* The keyboard syms have been cleverly chosen to map to ASCII */
 	SDLK_UNKNOWN		= 0,
 	SDLK_FIRST		= 0,
+	SDLK_CTRL_C		= 3,
 	SDLK_BACKSPACE		= 8,
 	SDLK_TAB		= 9,
 	SDLK_CLEAR		= 12,
diff -urN SDL-1.2.9/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/Makefile.in
--- SDL-1.2.9/Makefile.in	2005-08-28 08:32:09.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/README.GP2X /root/Desktop/gp2xdev/libs/SDL-1.2.9/README.GP2X
--- SDL-1.2.9/README.GP2X	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/README.GP2X	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,166 @@
+$Header: /home/fedora/jkeating/pkgs/rpms/arm-gp2x-linux-SDL/devel/gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $
+
+SDL for the GP2X (1.2.9)
+________________________
+
+Using the official http://www.libsdl.org/ 1.2.9 release as a basis this
+release aims to add advanced support for the GP2X handheld console/computer.
+
+Taken from The Open2x libs-gp2x project.
+(Software development libraries patched and optimised for the GP2X development)
+
+Added hardware support, made as a seperate video driver rather than
+extending fbcon driver.
+Added ability to scale display surface to full-screen.
+Fixed X & Y buttons.
+Added Hardware cursor support
+Added regions - user-definable areas of the physical display to show.
+Added support for non-scaled displays that are smaller than native resolution.
+Disabled cursor support initially - details below.
+
+TODO: 
+
+Clean GPH changes to source (Please: Modularise it)
+More (anybody) ;-)
+
+BUILDING:
+
+Build using a configure flag something like what is shown below.
+
+./configure --prefix=$LIB_ROOT --host=$HOST --disable-shared
+
+USING:
+
+This is SDL and can be used just like any other SDL build.
+
+****
+** Limitations of GP2X video driver
+****
+
+The primary surface (as set by SDL_SetVideoMode) is limited to 8 or 16 bit.
+24 and 32 bit modes are NOT supported, driver will use 16bit instead.
+SetVideoMode also forces SDL_HWSURFACE
+
+Screen sizes can be between 64x64 and 1024x768 inclusive, but the width must
+be a multiple of 8 (legacy), width will be rounded up if need be.
+The primary surface will be visually expanded or shrunk to fill either the
+LCD or TV. The scaler is coarse only, no nice bilinear filtering.
+
+HWSURFACE to HWSURFACE blits are accelerated and ASYNCHRONOUS, SDL_BlitSurface
+will return as soon as it has set the blit up, you MUST lock the surface if
+you want to be sure the blit has taken place.
+
+====
+== SWSURFACE to HWSURFACE blits have moderate acceleration and SDL_BlitSurface
+== will return when the blit is finished, although locking the surface is still
+== required to ensure the blitter flushes its cache.
+===
+== NOTE: My driver supports it, but SDL seems to not call my blit routine if
+== the source surface is SWSURFACE. Will look into it later.
+====
+
+The harware cursor is capable of colour (although only 2), but is 24bit
+regardless of the display surface. It can also alpha-blend it's fore- and
+background colours at different levels, each ranging from 0=transparent to
+15=opaque.
+
+The cursor isn't shown by default on HWSURFACE. If you want to use it you
+need to call SDL_ShowCursor(SDL_ENABLE); This is contary to the standard SDL
+behaviour which defaults to showing it.
+
+
+****
+** Additional non-standard SDL functions, GP2X specific.
+**
+** These are defined in the non-standard SDL_gp2x.h
+****
+
+////
+int SDL_GP2X_GetPhysicalScreenSize(SDL_Rect *size);
+
+  Fills size->w and size->h with dimensions of the current screen,
+    LCD  : 320x240
+    NTSC : 720x480
+    PAL  : 720x576
+  Returns
+    0 for progressive (LCD)
+    1 for interlaced (NTSC & PAL)
+   -1 if SDL_Init hasn't been called yet
+
+////
+void SDL_GP2X_Display(SDL_Rect *area);
+
+  Sets the hardware scaler to show requested area of primary surface as
+  fullscreen. The scaler does not physically alter the surface, it just
+  affects how the surface will appear on-screen. This allows you to pan
+  around a surface larger than the screen, and/or zoom in/out.
+  You cannot zoom out further than having the full surface on-screen.
+
+  area->x and area->y set which pixel of the primary surface will appear at
+  the top-left corner of the display,
+  area->w and area->h set the width and height of the area to fill the display.
+
+////
+void SDL_GP2X_MiniDisplay(int x, int y);
+
+  Similar to the above function, but does not scale and blanks the borders.
+  Only really useful if your videomode is less than 320x240. Gives rise to
+  possible small speed increase as the display hardware doesn't access
+  memory in the borders. Region 1 (see SDL_GP2X_DefineRegion below) area is
+  set to {x, y, x+videomode_width-1, y+videomodeheight-1}.
+  The x & y values are where the top-left corner of you screen will placed
+  on the display. e.g. for a 200x200 videomode centred in the middle of the
+  display you'd use x=60 y=20
+  NO checking is done to make sure your screen fits!
+
+////
+void SDL_GP2X_SetCursorColour(SDL_Cursor *cursor
+                              int b_red, b_green, b_blue, b_alpha,
+                              int f_red, f_green, f_blue, f_alpha);
+
+  Sets the background and foreground colours of the hardware cursor.
+  SDL assumes black and white for all cursors, this lets you choose
+  your own colours for each cursor. Cursor colours are full 24bit, each
+  component wraps instead of clamping (so if you try setting red to 257
+  you'll actually get 1 etc.)
+  Also, the background and foreground colours have seperate levels of
+  alpha-blending (0=transparent -> 15=opaque). Again, the values wrap.
+
+////
+void SDL_GP2X_DefineRegion(int region, SDL_Rect *area);
+
+  Allows you to define regions (1-4) that will be visible.
+  By default region 1 is set to fullscreen (apart from when using MiniDisplay).
+  Regions work by defining rectangles of the display that the video hardware
+  will show. Think of it like painting your LCD black and for each region
+  you use, scrape the paint off for that rectangle.
+  Region areas are in hardware coordinates, 0x0 is the top-left,
+  319x239 is bottom-right regardless of size and position of your surface.
+
+////
+void SDL_GP2X_ActivateRegion(int region, int activate);
+
+  After defining regions above, use this to switch individual regions
+  on (activate = 1) or off (activate=0).
+  By default only region 1 is active.
+  There is a fifth region, region 5, but this is fullscreen only and hence
+  not available to SDL_GP2X_DefineRegion().
+
+
+*************************************************************
+** The following functions are implemented, but not tested **
+*************************************************************
+
+////
+void SDL_GP2X_SetMonoColours(int background, int foreground);
+  ****
+  ** untested function
+  ****
+  When blitting a 1bpp surface, this sets what colour the 0s and 1s will
+  be translated into. Useful for drawing fonts. 
+  This is a global setting, not per-surface.
+
+-------------------------------------
+
+The Open2x Project
+
diff -urN SDL-1.2.9/src/audio/alsa/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/alsa/Makefile.in
--- SDL-1.2.9/src/audio/alsa/Makefile.in	2005-08-28 08:31:38.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/alsa/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_alsa_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/arts/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/arts/Makefile.in
--- SDL-1.2.9/src/audio/arts/Makefile.in	2005-08-28 08:31:38.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/arts/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_arts_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/baudio/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/baudio/Makefile.in
--- SDL-1.2.9/src/audio/baudio/Makefile.in	2005-08-28 08:31:38.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/baudio/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_baudio_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/dc/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dc/Makefile.in
--- SDL-1.2.9/src/audio/dc/Makefile.in	2005-08-28 08:31:39.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dc/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_dc_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/disk/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/disk/Makefile.in
--- SDL-1.2.9/src/audio/disk/Makefile.in	2005-08-28 08:31:39.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/disk/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_disk_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/dma/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dma/Makefile.in
--- SDL-1.2.9/src/audio/dma/Makefile.in	2005-08-28 08:31:39.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dma/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_dma_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/dmedia/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dmedia/Makefile.in
--- SDL-1.2.9/src/audio/dmedia/Makefile.in	2005-08-28 08:31:40.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dmedia/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_dmedia_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/dsp/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dsp/Makefile.in
--- SDL-1.2.9/src/audio/dsp/Makefile.in	2005-08-28 08:31:40.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dsp/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_dsp_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/dsp/SDL_dspaudio.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dsp/SDL_dspaudio.c
--- SDL-1.2.9/src/audio/dsp/SDL_dspaudio.c	2005-02-12 20:39:08.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/dsp/SDL_dspaudio.c	2006-05-19 09:11:11.000000000 +0200
@@ -299,7 +299,8 @@
 		DSP_CloseAudio(this);
 		return(-1);
 	}
-	frag_spec |= 0x00020000;	/* two fragments, for low latency */
+	//frag_spec |= 0x00020000;	/* two fragments, for low latency */
+	frag_spec |= 0x00100000; /* GPH Patch ??? */
 
 	/* Set the audio buffering parameters */
 #ifdef DEBUG_AUDIO
diff -urN SDL-1.2.9/src/audio/esd/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/esd/Makefile.in
--- SDL-1.2.9/src/audio/esd/Makefile.in	2005-08-28 08:31:40.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/esd/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_esd_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/macosx/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/macosx/Makefile.in
--- SDL-1.2.9/src/audio/macosx/Makefile.in	2005-08-28 08:31:40.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/macosx/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_macosx_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/macrom/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/macrom/Makefile.in
--- SDL-1.2.9/src/audio/macrom/Makefile.in	2005-08-28 08:31:41.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/macrom/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_macrom_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/Makefile.in
--- SDL-1.2.9/src/audio/Makefile.in	2005-08-28 08:31:37.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/mint/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/mint/Makefile.in
--- SDL-1.2.9/src/audio/mint/Makefile.in	2005-08-28 08:31:41.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/mint/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_mintaudio_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/mme/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/mme/Makefile.in
--- SDL-1.2.9/src/audio/mme/Makefile.in	2005-08-28 08:31:41.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/mme/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_mme_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/nas/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/nas/Makefile.in
--- SDL-1.2.9/src/audio/nas/Makefile.in	2005-08-28 08:31:42.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/nas/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_nas_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/nto/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/nto/Makefile.in
--- SDL-1.2.9/src/audio/nto/Makefile.in	2005-08-28 08:31:42.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/nto/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_nto_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/openbsd/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/openbsd/Makefile.in
--- SDL-1.2.9/src/audio/openbsd/Makefile.in	2005-08-28 08:31:42.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/openbsd/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_openbsd_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/paudio/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/paudio/Makefile.in
--- SDL-1.2.9/src/audio/paudio/Makefile.in	2005-08-28 08:31:43.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/paudio/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_paudio_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/sun/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/sun/Makefile.in
--- SDL-1.2.9/src/audio/sun/Makefile.in	2005-08-28 08:31:43.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/sun/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_sun_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/ums/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/ums/Makefile.in
--- SDL-1.2.9/src/audio/ums/Makefile.in	2005-08-28 08:31:43.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/ums/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_ums_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/windib/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/windib/Makefile.in
--- SDL-1.2.9/src/audio/windib/Makefile.in	2005-08-28 08:31:44.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/windib/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_windib_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/audio/windx5/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/windx5/Makefile.in
--- SDL-1.2.9/src/audio/windx5/Makefile.in	2005-08-28 08:31:44.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/audio/windx5/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libaudio_windx5_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/aix/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/aix/Makefile.in
--- SDL-1.2.9/src/cdrom/aix/Makefile.in	2005-08-28 08:31:45.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/aix/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_aix_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/beos/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/beos/Makefile.in
--- SDL-1.2.9/src/cdrom/beos/Makefile.in	2005-08-28 08:31:45.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/beos/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_beos_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/bsdi/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/bsdi/Makefile.in
--- SDL-1.2.9/src/cdrom/bsdi/Makefile.in	2005-08-28 08:31:45.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/bsdi/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_bsdi_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/dc/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/dc/Makefile.in
--- SDL-1.2.9/src/cdrom/dc/Makefile.in	2005-08-28 08:31:46.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/dc/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_dc_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/dummy/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/dummy/Makefile.in
--- SDL-1.2.9/src/cdrom/dummy/Makefile.in	2005-08-28 08:31:46.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/dummy/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_dummy_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/freebsd/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/freebsd/Makefile.in
--- SDL-1.2.9/src/cdrom/freebsd/Makefile.in	2005-08-28 08:31:46.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/freebsd/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_freebsd_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/linux/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/linux/Makefile.in
--- SDL-1.2.9/src/cdrom/linux/Makefile.in	2005-08-28 08:31:47.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/linux/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_linux_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/macos/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/macos/Makefile.in
--- SDL-1.2.9/src/cdrom/macos/Makefile.in	2005-08-28 08:31:47.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/macos/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_macos_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/macosx/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/macosx/Makefile.in
--- SDL-1.2.9/src/cdrom/macosx/Makefile.in	2005-08-28 08:31:47.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/macosx/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_macosx_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/Makefile.in
--- SDL-1.2.9/src/cdrom/Makefile.in	2005-08-28 08:31:44.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/mint/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/mint/Makefile.in
--- SDL-1.2.9/src/cdrom/mint/Makefile.in	2005-08-28 08:31:48.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/mint/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_mint_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/openbsd/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/openbsd/Makefile.in
--- SDL-1.2.9/src/cdrom/openbsd/Makefile.in	2005-08-28 08:31:48.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/openbsd/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_openbsd_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/osf/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/osf/Makefile.in
--- SDL-1.2.9/src/cdrom/osf/Makefile.in	2005-08-28 08:31:48.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/osf/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_osf_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/qnx/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/qnx/Makefile.in
--- SDL-1.2.9/src/cdrom/qnx/Makefile.in	2005-08-28 08:31:48.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/qnx/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_qnx_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cdrom/win32/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/win32/Makefile.in
--- SDL-1.2.9/src/cdrom/win32/Makefile.in	2005-08-28 08:31:49.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cdrom/win32/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcdrom_win32_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/cpuinfo/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cpuinfo/Makefile.in
--- SDL-1.2.9/src/cpuinfo/Makefile.in	2005-08-28 08:31:49.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/cpuinfo/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libcpuinfo_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/endian/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/endian/Makefile.in
--- SDL-1.2.9/src/endian/Makefile.in	2005-08-28 08:31:49.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/endian/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libendian_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/events/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/events/Makefile.in
--- SDL-1.2.9/src/events/Makefile.in	2005-08-28 08:31:50.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/events/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libevents_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/events/SDL_keyboard.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/events/SDL_keyboard.c
--- SDL-1.2.9/src/events/SDL_keyboard.c	2005-08-21 08:18:54.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/events/SDL_keyboard.c	2006-05-19 09:11:11.000000000 +0200
@@ -79,6 +79,7 @@
 	SDL_EnableKeyRepeat(0, 0);
 
 	/* Fill in the blanks in keynames */
+	keynames[SDLK_CTRL_C] = "ctrl+c";
 	keynames[SDLK_BACKSPACE] = "backspace";
 	keynames[SDLK_TAB] = "tab";
 	keynames[SDLK_CLEAR] = "clear";
diff -urN SDL-1.2.9/src/file/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/file/Makefile.in
--- SDL-1.2.9/src/file/Makefile.in	2005-08-28 08:31:50.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/file/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libfile_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/hermes/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/hermes/Makefile.in
--- SDL-1.2.9/src/hermes/Makefile.in	2005-08-28 08:31:50.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/hermes/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -18,6 +18,8 @@
 #
 # Some consistent rules for building asm files:
 
+SOURCES = $(libhermes_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/amigaos/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/amigaos/Makefile.in
--- SDL-1.2.9/src/joystick/amigaos/Makefile.in	2005-08-28 08:31:51.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/amigaos/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_amiga_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/beos/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/beos/Makefile.in
--- SDL-1.2.9/src/joystick/beos/Makefile.in	2005-08-28 08:31:51.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/beos/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_beos_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/bsd/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/bsd/Makefile.in
--- SDL-1.2.9/src/joystick/bsd/Makefile.in	2005-08-28 08:31:52.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/bsd/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_bsd_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/darwin/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/darwin/Makefile.in
--- SDL-1.2.9/src/joystick/darwin/Makefile.in	2005-08-28 08:31:52.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/darwin/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_darwin_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/dc/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/dc/Makefile.in
--- SDL-1.2.9/src/joystick/dc/Makefile.in	2005-08-28 08:31:52.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/dc/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_dc_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/dummy/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/dummy/Makefile.in
--- SDL-1.2.9/src/joystick/dummy/Makefile.in	2005-08-28 08:31:53.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/dummy/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_dummy_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/linux/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/linux/Makefile.in
--- SDL-1.2.9/src/joystick/linux/Makefile.in	2005-08-28 08:31:53.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/linux/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_linux_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/linux/SDL_sysjoystick.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/linux/SDL_sysjoystick.c
--- SDL-1.2.9/src/joystick/linux/SDL_sysjoystick.c	2004-09-11 19:48:41.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/linux/SDL_sysjoystick.c	2006-05-19 09:11:11.000000000 +0200
@@ -1,3 +1,4 @@
+//[*]------------------------------------------------------------------------------------------[*]
 /*
     SDL - Simple DirectMedia Layer
     Copyright (C) 1997-2004 Sam Lantinga
@@ -19,653 +20,104 @@
     Sam Lantinga
     slouken@libsdl.org
 */
-
+//[*]------------------------------------------------------------------------------------------[*]
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
 #endif
-
-/* This is the system specific header for the SDL joystick API */
-
+//[*]------------------------------------------------------------------------------------------[*]
+#include <stdlib.h>
 #include <stdio.h>		/* For the definition of NULL */
-#include <stdlib.h>		/* For getenv() prototype */
-#include <string.h>
+#include <sys/types.h>	// For Device open
 #include <sys/stat.h>
-#include <unistd.h>
 #include <fcntl.h>
-#include <sys/ioctl.h>
-#include <limits.h>		/* For the definition of PATH_MAX */
-#ifdef __arm__
-#include <linux/limits.h> /* Arm cross-compiler needs this */
-#endif
-#include <linux/joystick.h>
-#ifdef USE_INPUT_EVENTS
-#include <linux/input.h>
-#endif
+#include <unistd.h>		// For Device read
+
 
 #include "SDL_error.h"
 #include "SDL_joystick.h"
 #include "SDL_sysjoystick.h"
 #include "SDL_joystick_c.h"
+//[*]------------------------------------------------------------------------------------------[*]
+#define MAX_JOYSTICKS	18		/* only 2 are supported in the multimedia API */
+#define MAX_AXES		0		/* each joystick can have up to 2 axes */
+#define MAX_BUTTONS		19		/* and 6 buttons                      */
+#define	MAX_HATS		0
+
+#define	JOYNAMELEN		7
+
+#if 0
+typedef enum {
+	PEPC_VK_UP,				// 0	
+	PEPC_VK_UP_LEFT,		// 1
+	PEPC_VK_UP_RIGHT,		// 2
+	PEPC_VK_DOWN,			// 3
+	PEPC_VK_DOWN_LEFT,		// 4
+	PEPC_VK_DOWN_RIGHT,		// 5
+	PEPC_VK_LEFT,			// 6
+	PEPC_VK_RIGHT,			// 7
+	PEPC_VK_FA,				// 8
+	PEPC_VK_FB,				// 9
+	PEPC_VK_FX,				// 10
+	PEPC_VK_FY,				// 11
+	PEPC_VK_FL,				// 12
+	PEPC_VK_FR,				// 13	
+	PEPC_VK_SELECT,			// 14		
+	PEPC_VK_START,			// 15
+	PEPC_VK_VOL_UP,			// 16
+	PEPC_VK_VOL_DOWN		// 17	
+	PEPC_VK_STICK_PUSH // 18
+}MAP_KEY;	
+#endif	
+
+#if 1
+#define	PEPC_VK_UP				(1<<0)	
+#define	PEPC_VK_UP_LEFT			(1<<1)	
+#define	PEPC_VK_UP_RIGHT		(1<<2)	
+#define	PEPC_VK_DOWN			(1<<3)	
+#define	PEPC_VK_DOWN_LEFT		(1<<4)	
+#define	PEPC_VK_DOWN_RIGHT		(1<<5)	
+#define	PEPC_VK_LEFT			(1<<6)	
+#define	PEPC_VK_RIGHT			(1<<7)	
+#define	PEPC_VK_FA				(1<<8)	
+#define	PEPC_VK_FB				(1<<9)	
+#define	PEPC_VK_FY				(1<<10)	
+#define	PEPC_VK_FX				(1<<11)	
+#define	PEPC_VK_FL				(1<<12)	
+#define	PEPC_VK_FR				(1<<13)	
+#define	PEPC_VK_SELECT			(1<<14)	
+#define	PEPC_VK_START			(1<<15)	
+#define	PEPC_VK_VOL_UP			(1<<16)	
+#define	PEPC_VK_VOL_DOWN		(1<<17)	
+#define	PEPC_VK_STICK_PUSH		(1<<18)	
+#endif
 
-/* Special joystick configurations */
-static struct {
-	const char *name;
-	int naxes;
-	int nhats;
-	int nballs;
-} special_joysticks[] = {
-	{ "MadCatz Panther XL", 3, 2, 1 }, /* We don't handle rudder (axis 8) */
-	{ "SideWinder Precision Pro", 4, 1, 0 },
-	{ "SideWinder 3D Pro", 4, 1, 0 },
-	{ "Microsoft SideWinder 3D Pro", 4, 1, 0 },
-	{ "Microsoft SideWinder Dual Strike USB version 1.0", 2, 1, 0 },
-	{ "WingMan Interceptor", 3, 3, 0 },
-	{ "WingMan Extreme Digital 3D", 4, 1, 0 },
-	{ "Microsoft SideWinder Precision 2 Joystick", 4, 1, 0 },
-	{ "Logitech Inc. WingMan Extreme Digital 3D", 4, 1, 0 },
-	{ "Saitek Saitek X45", 6, 1, 0 }
-};
-
-#ifndef NO_LOGICAL_JOYSTICKS
-
-static struct joystick_logical_values {
-        int njoy;
-        int nthing;
-} joystick_logical_values[] = {
-
-/* +0 */
-   /* MP-8800 axes map - map to {logical joystick #, logical axis #} */
-   {0,0},{0,1},{0,2},{1,0},{1,1},{0,3},{1,2},{1,3},{2,0},{2,1},{2,2},{2,3},
-   {3,0},{3,1},{3,2},{3,3},{0,4},{1,4},{2,4},
-
-/* +19 */
-   /* MP-8800 hat map - map to {logical joystick #, logical hat #} */
-   {0,0},{1,0},{2,0},{3,0},
-
-/* +23 */
-   /* MP-8800 button map - map to {logical joystick #, logical button #} */
-   {0,0},{0,1},{0,2},{0,3},{0,4},{0,5},{0,6},{0,7},{0,8},{0,9},{0,10},{0,11},
-   {1,0},{1,1},{1,2},{1,3},{1,4},{1,5},{1,6},{1,7},{1,8},{1,9},{1,10},{1,11},
-   {2,0},{2,1},{2,2},{2,3},{2,4},{2,5},{2,6},{2,7},{2,8},{2,9},{2,10},{2,11},
-   {3,0},{3,1},{3,2},{3,3},{3,4},{3,5},{3,6},{3,7},{3,8},{3,9},{3,10},{3,11}
-};
-
-static struct joystick_logical_layout {
-        int naxes;
-        int nhats;
-        int nballs;
-        int nbuttons;
-} joystick_logical_layout[] = {
-        /* MP-8800 logical layout */
-        {5, 1, 0, 12},
-        {5, 1, 0, 12},
-        {5, 1, 0, 12},
-        {4, 1, 0, 12}
-};
-
-/*
-   Some USB HIDs show up as a single joystick even though they actually
-   control 2 or more joysticks.  This array sets up a means of mapping
-   a single physical joystick to multiple logical joysticks. (djm)
-                                                                                
-   njoys
-        the number of logical joysticks
-                                                                                
-   layouts
-        an array of layout structures, one to describe each logical joystick
-                                                                                
-   axes, hats, balls, buttons
-        arrays that map a physical thingy to a logical thingy
- */
-static struct joystick_logicalmap {
-        const char *name;
-        int njoys;
-        struct joystick_logical_layout *layouts;
-        struct joystick_logical_values *axes;
-        struct joystick_logical_values *hats;
-        struct joystick_logical_values *balls;
-        struct joystick_logical_values *buttons;
-
-} joystick_logicalmap[] = {
-        {"WiseGroup.,Ltd MP-8800 Quad USB Joypad", 4, joystick_logical_layout,
-         joystick_logical_values, joystick_logical_values+19, NULL,
-         joystick_logical_values+23}
-};
-
-/* find the head of a linked list, given a point in it
- */
-#define SDL_joylist_head(i, start)\
-        for(i = start; SDL_joylist[i].fname == NULL;) i = SDL_joylist[i].prev;
-
-#define SDL_logical_joydecl(d) d
-
-
-#else
-
-#define SDL_logical_joydecl(d)
-
-#endif /* USE_LOGICAL_JOYSTICKS */
-
-/* The maximum number of joysticks we'll detect */
-#define MAX_JOYSTICKS	32
+static char *dev_name = "/dev/GPIO";
 
-/* A list of available joysticks */
-static struct
+//[*]------------------------------------------------------------------------------------------[*]
+struct joystick_hwdata
 {
-        char* fname;
-#ifndef NO_LOGICAL_JOYSTICKS
-        SDL_Joystick* joy;
-        struct joystick_logicalmap* map;
-        int prev;
-        int next;
-        int logicalno;
-#endif /* USE_LOGICAL_JOYSTICKS */
-} SDL_joylist[MAX_JOYSTICKS];
-
-
-/* The private structure used to keep track of a joystick */
-struct joystick_hwdata {
 	int fd;
-	/* The current linux joystick driver maps hats to two axes */
-	struct hwdata_hat {
-		int axis[2];
-	} *hats;
-	/* The current linux joystick driver maps balls to two axes */
-	struct hwdata_ball {
-		int axis[2];
-	} *balls;
-
-	/* Support for the Linux 2.4 unified input interface */
-#ifdef USE_INPUT_EVENTS
-	SDL_bool is_hid;
-	Uint8 key_map[KEY_MAX-BTN_MISC];
-	Uint8 abs_map[ABS_MAX];
-	struct axis_correct {
-		int used;
-		int coef[3];
-	} abs_correct[ABS_MAX];
-#endif
+	int prev_buttons;
 };
-
-static char *mystrdup(const char *string)
-{
-	char *newstring;
-
-	newstring = (char *)malloc(strlen(string)+1);
-	if ( newstring ) {
-		strcpy(newstring, string);
-	}
-	return(newstring);
-}
-
-
-#ifndef NO_LOGICAL_JOYSTICKS
-
-static int CountLogicalJoysticks(int max)
-{
-   register int i, j, k, ret, prev;
-   const char* name;
-
-   ret = 0;
-
-   for(i = 0; i < max; i++) {
-      name = SDL_SYS_JoystickName(i);
-
-      if (name) {
-         for(j = 0; j < SDL_TABLESIZE(joystick_logicalmap); j++) {
-            if (!strcmp(name, joystick_logicalmap[j].name)) {
-
-               prev = i;
-               SDL_joylist[prev].map = joystick_logicalmap+j;
-
-               for(k = 1; k < joystick_logicalmap[j].njoys; k++) {
-                  SDL_joylist[prev].next = max + ret;
-
-                  if (prev != i)
-                     SDL_joylist[max+ret].prev = prev;
-
-                  prev = max + ret;
-                  SDL_joylist[prev].logicalno = k;
-                  SDL_joylist[prev].map = joystick_logicalmap+j;
-                  ret++;
-               }
-
-               break;
-            }
-         }
-      }
-   }
-
-   return ret;
-}
-
-static void LogicalSuffix(int logicalno, char* namebuf, int len)
-{
-   register int slen;
-   const static char suffixs[] =
-      "01020304050607080910111213141516171819"
-      "20212223242526272829303132";
-   const char* suffix;
-
-   slen = strlen(namebuf);
-
-   suffix = NULL;
-
-   if (logicalno*2<sizeof(suffixs))
-      suffix = suffixs + (logicalno*2);
-
-   if (slen + 4 < len && suffix) {
-      namebuf[slen++] = ' ';
-      namebuf[slen++] = '#';
-      namebuf[slen++] = suffix[0];
-      namebuf[slen++] = suffix[1];
-      namebuf[slen++] = 0;
-   }
-}
-
-#endif /* USE_LOGICAL_JOYSTICKS */
-
-#ifdef USE_INPUT_EVENTS
-#define test_bit(nr, addr) \
-	(((1UL << ((nr) & 31)) & (((const unsigned int *) addr)[(nr) >> 5])) != 0)
-
-static int EV_IsJoystick(int fd)
-{
-	unsigned long evbit[40];
-	unsigned long keybit[40];
-	unsigned long absbit[40];
-
-	if ( (ioctl(fd, EVIOCGBIT(0, sizeof(evbit)), evbit) < 0) ||
-	     (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) < 0) ||
-	     (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) < 0) ) {
-		return(0);
-	}
-	if (!(test_bit(EV_KEY, evbit) && test_bit(EV_ABS, evbit) &&
-	      test_bit(ABS_X, absbit) && test_bit(ABS_Y, absbit) &&
-	     (test_bit(BTN_TRIGGER, keybit) || test_bit(BTN_A, keybit) || test_bit(BTN_1, keybit)))) return 0;
-	return(1);
-}
-
-#endif /* USE_INPUT_EVENTS */
-
-/* Function to scan the system for joysticks */
+//[*]------------------------------------------------------------------------------------------[*]
+/* 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 0, or -1 on an unrecoverable fatal error.
+ */
 int SDL_SYS_JoystickInit(void)
 {
-	/* The base path of the joystick devices */
-	const char *joydev_pattern[] = {
-#ifdef USE_INPUT_EVENTS
-		"/dev/input/event%d",
-#endif
-		"/dev/input/js%d",
-		"/dev/js%d"
-	};
-	int numjoysticks;
-	int i, j;
-	int fd;
-	char path[PATH_MAX];
-	dev_t dev_nums[MAX_JOYSTICKS];  /* major/minor device numbers */
-	struct stat sb;
-	int n, duplicate;
-
-	numjoysticks = 0;
-
-	/* First see if the user specified a joystick to use */
-	if ( getenv("SDL_JOYSTICK_DEVICE") != NULL ) {
-		strncpy(path, getenv("SDL_JOYSTICK_DEVICE"), sizeof(path));
-		path[sizeof(path)-1] = '\0';
-		if ( stat(path, &sb) == 0 ) {
-			fd = open(path, O_RDONLY, 0);
-			if ( fd >= 0 ) {
-				/* Assume the user knows what they're doing. */
-				SDL_joylist[numjoysticks].fname =mystrdup(path);
-				if ( SDL_joylist[numjoysticks].fname ) {
-					dev_nums[numjoysticks] = sb.st_rdev;
-					++numjoysticks;
-				}
-				close(fd);
-			}
-		}
-	}
-
-	for ( i=0; i<SDL_TABLESIZE(joydev_pattern); ++i ) {
-		for ( j=0; j < MAX_JOYSTICKS; ++j ) {
-			sprintf(path, joydev_pattern[i], j);
-
-			/* rcg06302000 replaced access(F_OK) call with stat().
-			 * stat() will fail if the file doesn't exist, so it's
-			 * equivalent behaviour.
-			 */
-			if ( stat(path, &sb) == 0 ) {
-				/* Check to make sure it's not already in list.
-				 * This happens when we see a stick via symlink.
-				 */
-				duplicate = 0;
-				for (n=0; (n<numjoysticks) && !duplicate; ++n) {
-					if ( sb.st_rdev == dev_nums[n] ) {
-						duplicate = 1;
-					}
-				}
-				if (duplicate) {
-					continue;
-				}
-
-				fd = open(path, O_RDONLY, 0);
-				if ( fd < 0 ) {
-					continue;
-				}
-#ifdef USE_INPUT_EVENTS
-#ifdef DEBUG_INPUT_EVENTS
-				printf("Checking %s\n", path);
-#endif
-				if ( (i == 0) && ! EV_IsJoystick(fd) ) {
-					close(fd);
-					continue;
-				}
-#endif
-				close(fd);
-
-				/* We're fine, add this joystick */
-				SDL_joylist[numjoysticks].fname =mystrdup(path);
-				if ( SDL_joylist[numjoysticks].fname ) {
-					dev_nums[numjoysticks] = sb.st_rdev;
-					++numjoysticks;
-				}
-			} else
-				break;
-		}
-
-#ifdef USE_INPUT_EVENTS
-		/* This is a special case...
-		   If the event devices are valid then the joystick devices
-		   will be duplicates but without extra information about their
-		   hats or balls. Unfortunately, the event devices can't
-		   currently be calibrated, so it's a win-lose situation.
-		   So : /dev/input/eventX = /dev/input/jsY = /dev/jsY
-		*/
-		if ( (i == 0) && (numjoysticks > 0) )
-			break;
-#endif
-	}
-#ifndef NO_LOGICAL_JOYSTICKS
-	numjoysticks += CountLogicalJoysticks(numjoysticks);
-#endif
-
-	return(numjoysticks);
+	printf("SDL_SYS_JoystickInit\n");
+	return 1;
 }
-
+//[*]------------------------------------------------------------------------------------------[*]
 /* Function to get the device-dependent name of a joystick */
 const char *SDL_SYS_JoystickName(int index)
 {
-	int fd;
-	static char namebuf[128];
-	char *name;
-	SDL_logical_joydecl(int oindex = index);
-
-#ifndef NO_LOGICAL_JOYSTICKS
-	SDL_joylist_head(index, index);
-#endif
-	name = NULL;
-	fd = open(SDL_joylist[index].fname, O_RDONLY, 0);
-	if ( fd >= 0 ) {
-		if ( 
-#ifdef USE_INPUT_EVENTS
-		     (ioctl(fd, EVIOCGNAME(sizeof(namebuf)), namebuf) <= 0) &&
-#endif
-		     (ioctl(fd, JSIOCGNAME(sizeof(namebuf)), namebuf) <= 0) ) {
-			name = SDL_joylist[index].fname;
-		} else {
-			name = namebuf;
-		}
-		close(fd);
-
-#ifndef NO_LOGICAL_JOYSTICKS
-		if (SDL_joylist[oindex].prev || SDL_joylist[oindex].next)
-       		   LogicalSuffix(SDL_joylist[oindex].logicalno, namebuf, 128);
-#endif
-	}
-	return name;
-}
-
-static int allocate_hatdata(SDL_Joystick *joystick)
-{
-	int i;
-
-	joystick->hwdata->hats = (struct hwdata_hat *)malloc(
-		joystick->nhats * sizeof(struct hwdata_hat));
-	if ( joystick->hwdata->hats == NULL ) {
-		return(-1);
-	}
-	for ( i=0; i<joystick->nhats; ++i ) {
-		joystick->hwdata->hats[i].axis[0] = 1;
-		joystick->hwdata->hats[i].axis[1] = 1;
-	}
-	return(0);
-}
-
-static int allocate_balldata(SDL_Joystick *joystick)
-{
-	int i;
-
-	joystick->hwdata->balls = (struct hwdata_ball *)malloc(
-		joystick->nballs * sizeof(struct hwdata_ball));
-	if ( joystick->hwdata->balls == NULL ) {
-		return(-1);
-	}
-	for ( i=0; i<joystick->nballs; ++i ) {
-		joystick->hwdata->balls[i].axis[0] = 0;
-		joystick->hwdata->balls[i].axis[1] = 0;
-	}
-	return(0);
-}
-
-static SDL_bool JS_ConfigJoystick(SDL_Joystick *joystick, int fd)
-{
-	SDL_bool handled;
-	unsigned char n;
-	int old_axes, tmp_naxes, tmp_nhats, tmp_nballs;
-	const char *name;
-	char *env, env_name[128];
-	int i;
-
-	handled = SDL_FALSE;
-
-	/* Default joystick device settings */
-	if ( ioctl(fd, JSIOCGAXES, &n) < 0 ) {
-		joystick->naxes = 2;
-	} else {
-		joystick->naxes = n;
-	}
-	if ( ioctl(fd, JSIOCGBUTTONS, &n) < 0 ) {
-		joystick->nbuttons = 2;
-	} else {
-		joystick->nbuttons = n;
-	}
-
-	name = SDL_SYS_JoystickName(joystick->index);
-	old_axes = joystick->naxes;
-
-	/* Generic analog joystick support */
-	if ( strstr(name, "Analog") == name && strstr(name, "-hat") ) {
-		if ( sscanf(name,"Analog %d-axis %*d-button %d-hat",
-			&tmp_naxes, &tmp_nhats) == 2 ) {
-
-			joystick->naxes = tmp_naxes;
-			joystick->nhats = tmp_nhats;
-
-			handled = SDL_TRUE;
-		}
-	}
-
-	/* Special joystick support */
-	for ( i=0; i < SDL_TABLESIZE(special_joysticks); ++i ) {
-		if ( strcmp(name, special_joysticks[i].name) == 0 ) {
-
-			joystick->naxes = special_joysticks[i].naxes;
-			joystick->nhats = special_joysticks[i].nhats;
-			joystick->nballs = special_joysticks[i].nballs;
-
-			handled = SDL_TRUE;
-			break;
-		}
-	}
-
-	/* User environment joystick support */
-	if ( (env = getenv("SDL_LINUX_JOYSTICK")) ) {
-		strcpy(env_name, "");
-		if ( *env == '\'' && sscanf(env, "'%[^']s'", env_name) == 1 )
-			env += strlen(env_name)+2;
-		else if ( sscanf(env, "%s", env_name) == 1 )
-			env += strlen(env_name);
-
-		if ( strcmp(name, env_name) == 0 ) {
-
-			if ( sscanf(env, "%d %d %d", &tmp_naxes, &tmp_nhats,
-				&tmp_nballs) == 3 ) {
-
-				joystick->naxes = tmp_naxes;
-				joystick->nhats = tmp_nhats;
-				joystick->nballs = tmp_nballs;
-
-				handled = SDL_TRUE;
-			}
-		}
-	}
-
-	/* Remap hats and balls */
-	if (handled) {
-		if ( joystick->nhats > 0 ) {
-			if ( allocate_hatdata(joystick) < 0 ) {
-				joystick->nhats = 0;
-			}
-		}
-		if ( joystick->nballs > 0 ) {
-			if ( allocate_balldata(joystick) < 0 ) {
-				joystick->nballs = 0;
-			}
-		}
-	}
-
-	return(handled);
-}
-
-#ifdef USE_INPUT_EVENTS
-
-static SDL_bool EV_ConfigJoystick(SDL_Joystick *joystick, int fd)
-{
-	int i, t;
-	unsigned long keybit[40];
-	unsigned long absbit[40];
-	unsigned long relbit[40];
-
-	/* See if this device uses the new unified event API */
-	if ( (ioctl(fd, EVIOCGBIT(EV_KEY, sizeof(keybit)), keybit) >= 0) &&
-	     (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absbit)), absbit) >= 0) &&
-	     (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relbit)), relbit) >= 0) ) {
-		joystick->hwdata->is_hid = SDL_TRUE;
-
-		/* Get the number of buttons, axes, and other thingamajigs */
-		for ( i=BTN_JOYSTICK; i < KEY_MAX; ++i ) {
-			if ( test_bit(i, keybit) ) {
-#ifdef DEBUG_INPUT_EVENTS
-				printf("Joystick has button: 0x%x\n", i);
-#endif
-				joystick->hwdata->key_map[i-BTN_MISC] =
-						joystick->nbuttons;
-				++joystick->nbuttons;
-			}
-		}
-		for ( i=BTN_MISC; i < BTN_JOYSTICK; ++i ) {
-			if ( test_bit(i, keybit) ) {
-#ifdef DEBUG_INPUT_EVENTS
-				printf("Joystick has button: 0x%x\n", i);
-#endif
-				joystick->hwdata->key_map[i-BTN_MISC] =
-						joystick->nbuttons;
-				++joystick->nbuttons;
-			}
-		}
-		for ( i=0; i<ABS_MAX; ++i ) {
-			/* Skip hats */
-			if ( i == ABS_HAT0X ) {
-				i = ABS_HAT3Y;
-				continue;
-			}
-			if ( test_bit(i, absbit) ) {
-				int values[5];
-
-				if ( ioctl(fd, EVIOCGABS(i), values) < 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]);
-#endif /* DEBUG_INPUT_EVENTS */
-				joystick->hwdata->abs_map[i] = joystick->naxes;
-				if ( values[1] == values[2] ) {
-				    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];
-				    joystick->hwdata->abs_correct[i].coef[1] =
-					(values[2] + values[1]) / 2 + values[4];
-				    t = ((values[2] - values[1]) / 2 - 2 * values[4]);
-				    if ( t != 0 ) {
-					joystick->hwdata->abs_correct[i].coef[2] = (1 << 29) / t;
-				    } else {
-					joystick->hwdata->abs_correct[i].coef[2] = 0;
-				    }
-				}
-				++joystick->naxes;
-			}
-		}
-		for ( i=ABS_HAT0X; i <= ABS_HAT3Y; i += 2 ) {
-			if ( test_bit(i, absbit) || test_bit(i+1, absbit) ) {
-#ifdef DEBUG_INPUT_EVENTS
-				printf("Joystick has hat %d\n",(i-ABS_HAT0X)/2);
-#endif
-				++joystick->nhats;
-			}
-		}
-		if ( test_bit(REL_X, relbit) || test_bit(REL_Y, relbit) ) {
-			++joystick->nballs;
-		}
-
-		/* Allocate data to keep track of these thingamajigs */
-		if ( joystick->nhats > 0 ) {
-			if ( allocate_hatdata(joystick) < 0 ) {
-				joystick->nhats = 0;
-			}
-		}
-		if ( joystick->nballs > 0 ) {
-			if ( allocate_balldata(joystick) < 0 ) {
-				joystick->nballs = 0;
-			}
-		}
-	}
-	return(joystick->hwdata->is_hid);
+	return "PEP Joy";
 }
-
-#endif /* USE_INPUT_EVENTS */
-
-#ifndef NO_LOGICAL_JOYSTICKS
-static void ConfigLogicalJoystick(SDL_Joystick *joystick)
-{
-        struct joystick_logical_layout* layout;
-                                                                                
-        layout = SDL_joylist[joystick->index].map->layouts +
-                SDL_joylist[joystick->index].logicalno;
-                                                                                
-        joystick->nbuttons = layout->nbuttons;
-        joystick->nhats = layout->nhats;
-        joystick->naxes = layout->naxes;
-        joystick->nballs = layout->nballs;
-}
-#endif
-
-
+//[*]------------------------------------------------------------------------------------------[*]
 /* 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.
@@ -673,420 +125,129 @@
  */
 int SDL_SYS_JoystickOpen(SDL_Joystick *joystick)
 {
-	int fd;
-	SDL_logical_joydecl(int realindex);
-	SDL_logical_joydecl(SDL_Joystick *realjoy = NULL);
-
-	/* Open the joystick and set the joystick file descriptor */
-#ifndef NO_LOGICAL_JOYSTICKS
-	if (SDL_joylist[joystick->index].fname == NULL) {
-		SDL_joylist_head(realindex, joystick->index);
-		realjoy = SDL_JoystickOpen(realindex);
+	int fd = 0;
 
-		if (realjoy == NULL)
-			return(-1);
-                                                                                
-		fd = realjoy->hwdata->fd;
-
-	} else {
-		fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0);
-	}
-	SDL_joylist[joystick->index].joy = joystick;
-#else
-	fd = open(SDL_joylist[joystick->index].fname, O_RDONLY, 0);
-#endif
-
-	if ( fd < 0 ) {
-		SDL_SetError("Unable to open %s\n",
-		             SDL_joylist[joystick->index]);
-		return(-1);
+	fd = open(dev_name, O_RDWR | O_NDELAY );
+	if(fd < 0){      	
+        printf( "GPIO OPEN FAIL\n"); 
+        return -1;
 	}
-	joystick->hwdata = (struct joystick_hwdata *)
-	                   malloc(sizeof(*joystick->hwdata));
-	if ( joystick->hwdata == NULL ) {
+	
+	joystick->hwdata = (struct joystick_hwdata *) malloc(sizeof(*joystick->hwdata));
+	if (joystick->hwdata == NULL)
+	{
 		SDL_OutOfMemory();
-		close(fd);
-		return(-1);
+		return -1;
 	}
-	memset(joystick->hwdata, 0, sizeof(*joystick->hwdata));
-	joystick->hwdata->fd = fd;
+	joystick->hwdata->prev_buttons=0;
 
-	/* Set the joystick to non-blocking read mode */
-	fcntl(fd, F_SETFL, O_NONBLOCK);
-
-	/* Get the number of buttons and axes on the joystick */
-#ifndef NO_LOGICAL_JOYSTICKS
-	if (realjoy)
-		ConfigLogicalJoystick(joystick);
-	else
-#endif
-#ifdef USE_INPUT_EVENTS
-	if ( ! EV_ConfigJoystick(joystick, fd) )
-#endif
-		JS_ConfigJoystick(joystick, fd);
+	// fill nbuttons, naxes, and nhats fields
+	joystick->nbuttons = MAX_BUTTONS;
+	joystick->naxes = MAX_AXES;
+	joystick->nhats = MAX_HATS;
+	
+	joystick->hwdata->fd = fd;
+	joystick->hwdata->prev_buttons = 0;
 
 	return(0);
 }
-
-#ifndef NO_LOGICAL_JOYSTICKS
-
-static SDL_Joystick* FindLogicalJoystick(
-   SDL_Joystick *joystick, struct joystick_logical_values* v)
-{
-        SDL_Joystick *logicaljoy;
-        register int i;
-
-        i = joystick->index;
-        logicaljoy = NULL;
-
-        /* get the fake joystick that will receive the event
-         */
-        for(;;) {
-
-           if (SDL_joylist[i].logicalno == v->njoy) {
-              logicaljoy = SDL_joylist[i].joy;
-              break;
-           }
-
-           if (SDL_joylist[i].next == 0)
-              break;
-
-           i = SDL_joylist[i].next;
-
-        }
-
-        return logicaljoy;
-}
-
-static int LogicalJoystickButton(
-   SDL_Joystick *joystick, Uint8 button, Uint8 state){
-        struct joystick_logical_values* buttons;
-        SDL_Joystick *logicaljoy = NULL;
-
-        /* if there's no map then this is just a regular joystick
-         */
-        if (SDL_joylist[joystick->index].map == NULL)
-           return 0;
-
-        /* get the logical joystick that will receive the event
-         */
-        buttons = SDL_joylist[joystick->index].map->buttons+button;
-        logicaljoy = FindLogicalJoystick(joystick, buttons);
-
-        if (logicaljoy == NULL)
-           return 1;
-
-        SDL_PrivateJoystickButton(logicaljoy, buttons->nthing, state);
-
-        return 1;
-}
-
-static int LogicalJoystickAxis(
-	SDL_Joystick *joystick, Uint8 axis, Sint16 value)
-{
-        struct joystick_logical_values* axes;
-        SDL_Joystick *logicaljoy = NULL;
-
-        /* if there's no map then this is just a regular joystick
-         */
-        if (SDL_joylist[joystick->index].map == NULL)
-           return 0;
-
-        /* get the logical joystick that will receive the event
-         */
-        axes = SDL_joylist[joystick->index].map->axes+axis;
-        logicaljoy = FindLogicalJoystick(joystick, axes);
-
-        if (logicaljoy == NULL)
-           return 1;
-
-        SDL_PrivateJoystickAxis(logicaljoy, axes->nthing, value);
-
-        return 1;
-}
-#endif /* USE_LOGICAL_JOYSTICKS */
-
-static __inline__
-void HandleHat(SDL_Joystick *stick, Uint8 hat, int axis, int value)
-{
-	struct hwdata_hat *the_hat;
-	const Uint8 position_map[3][3] = {
-		{ SDL_HAT_LEFTUP, SDL_HAT_UP, SDL_HAT_RIGHTUP },
-		{ SDL_HAT_LEFT, SDL_HAT_CENTERED, SDL_HAT_RIGHT },
-		{ SDL_HAT_LEFTDOWN, SDL_HAT_DOWN, SDL_HAT_RIGHTDOWN }
-	};
-	SDL_logical_joydecl(SDL_Joystick *logicaljoy = NULL);
-	SDL_logical_joydecl(struct joystick_logical_values* hats = NULL);
-
-	the_hat = &stick->hwdata->hats[hat];
-	if ( value < 0 ) {
-		value = 0;
-	} else
-	if ( value == 0 ) {
-		value = 1;
-	} else
-	if ( value > 0 ) {
-		value = 2;
-	}
-	if ( value != the_hat->axis[axis] ) {
-		the_hat->axis[axis] = value;
-
-#ifndef NO_LOGICAL_JOYSTICKS
-		/* if there's no map then this is just a regular joystick
-		*/
-		if (SDL_joylist[stick->index].map != NULL) {
-
-			/* get the fake joystick that will receive the event
-			*/
-			hats = SDL_joylist[stick->index].map->hats+hat;
-			logicaljoy = FindLogicalJoystick(stick, hats);
-		}
-
-		if (logicaljoy) {
-			stick = logicaljoy;
-			hat = hats->nthing;
-		}
-#endif /* USE_LOGICAL_JOYSTICKS */
-
-		SDL_PrivateJoystickHat(stick, hat,
-			position_map[the_hat->axis[1]][the_hat->axis[0]]);
-	}
-}
-
-static __inline__
-void HandleBall(SDL_Joystick *stick, Uint8 ball, int axis, int value)
-{
-	stick->hwdata->balls[ball].axis[axis] += value;
-}
-
+//[*]------------------------------------------------------------------------------------------[*]
 /* 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.
  */
-static __inline__ void JS_HandleEvents(SDL_Joystick *joystick)
-{
-	struct js_event events[32];
-	int i, len;
-	Uint8 other_axis;
-
-#ifndef NO_LOGICAL_JOYSTICKS
-	if (SDL_joylist[joystick->index].fname == NULL) {
-		SDL_joylist_head(i, joystick->index);
-		return JS_HandleEvents(SDL_joylist[i].joy);
-	}
-#endif
-
-	while ((len=read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
-		len /= sizeof(events[0]);
-		for ( i=0; i<len; ++i ) {
-			switch (events[i].type & ~JS_EVENT_INIT) {
-			    case JS_EVENT_AXIS:
-				if ( events[i].number < joystick->naxes ) {
-#ifndef NO_LOGICAL_JOYSTICKS
-					if (!LogicalJoystickAxis(joystick,
-				           events[i].number, events[i].value))
-#endif
-					SDL_PrivateJoystickAxis(joystick,
-				           events[i].number, events[i].value);
-					break;
-				}
-				events[i].number -= joystick->naxes;
-				other_axis = (events[i].number / 2);
-				if ( other_axis < joystick->nhats ) {
-					HandleHat(joystick, other_axis,
-						events[i].number%2,
-						events[i].value);
-					break;
-				}
-				events[i].number -= joystick->nhats*2;
-				other_axis = (events[i].number / 2);
-				if ( other_axis < joystick->nballs ) {
-					HandleBall(joystick, other_axis,
-						events[i].number%2,
-						events[i].value);
-					break;
-				}
-				break;
-			    case JS_EVENT_BUTTON:
-#ifndef NO_LOGICAL_JOYSTICKS
-				if (!LogicalJoystickButton(joystick,
-				           events[i].number, events[i].value))
-#endif
-				SDL_PrivateJoystickButton(joystick,
-				           events[i].number, events[i].value);
-				break;
-			    default:
-				/* ?? */
-				break;
-			}
-		}
-	}
-}
-#ifdef USE_INPUT_EVENTS
-static __inline__ int EV_AxisCorrect(SDL_Joystick *joystick, int which, int value)
-{
-	struct axis_correct *correct;
-
-	correct = &joystick->hwdata->abs_correct[which];
-	if ( correct->used ) {
-		if ( value > correct->coef[0] ) {
-			if ( value < correct->coef[1] ) {
-				return 0;
-			}
-			value -= correct->coef[1];
-		} else {
-			value -= correct->coef[0];
-		}
-		value *= correct->coef[2];
-		value >>= 14;
-	}
-
-	/* Clamp and return */
-	if ( value < -32767 ) return -32767;
-	if ( value >  32767 ) return  32767;
-
-	return value;
-}
-
-static __inline__ void EV_HandleEvents(SDL_Joystick *joystick)
-{
-	struct input_event events[32];
-	int i, len;
-	int code;
-
-#ifndef NO_LOGICAL_JOYSTICKS
-	if (SDL_joylist[joystick->index].fname == NULL) {
-		SDL_joylist_head(i, joystick->index);
-		return EV_HandleEvents(SDL_joylist[i].joy);
-	}
-#endif
-
-	while ((len=read(joystick->hwdata->fd, events, (sizeof events))) > 0) {
-		len /= sizeof(events[0]);
-		for ( i=0; i<len; ++i ) {
-			code = events[i].code;
-			switch (events[i].type) {
-			    case EV_KEY:
-				if ( code >= BTN_MISC ) {
-					code -= BTN_MISC;
-#ifndef NO_LOGICAL_JOYSTICKS
-					if (!LogicalJoystickButton(joystick,
-				           joystick->hwdata->key_map[code],
-					   events[i].value))
-#endif
-					SDL_PrivateJoystickButton(joystick,
-				           joystick->hwdata->key_map[code],
-					   events[i].value);
-				}
-				break;
-			    case EV_ABS:
-				switch (code) {
-				    case ABS_HAT0X:
-				    case ABS_HAT0Y:
-				    case ABS_HAT1X:
-				    case ABS_HAT1Y:
-				    case ABS_HAT2X:
-				    case ABS_HAT2Y:
-				    case ABS_HAT3X:
-				    case ABS_HAT3Y:
-					code -= ABS_HAT0X;
-					HandleHat(joystick, code/2, code%2,
-							events[i].value);
-					break;
-				    default:
-					events[i].value = EV_AxisCorrect(joystick, code, events[i].value);
-#ifndef NO_LOGICAL_JOYSTICKS
-					if (!LogicalJoystickAxis(joystick,
-				           joystick->hwdata->abs_map[code],
-					   events[i].value))
-#endif
-					SDL_PrivateJoystickAxis(joystick,
-				           joystick->hwdata->abs_map[code],
-					   events[i].value);
-					break;
-				}
-				break;
-			    case EV_REL:
-				switch (code) {
-				    case REL_X:
-				    case REL_Y:
-					code -= REL_X;
-					HandleBall(joystick, code/2, code%2,
-							events[i].value);
-					break;
-				    default:
-					break;
-				}
-				break;
-			    default:
-				break;
-			}
-		}
-	}
-}
-#endif /* USE_INPUT_EVENTS */
-
 void SDL_SYS_JoystickUpdate(SDL_Joystick *joystick)
 {
-	int i;
+	int ret=0;
+	unsigned long buff=0,prev_buttons=0, changed=0,buttons=0;
 	
-#ifdef USE_INPUT_EVENTS
-	if ( joystick->hwdata->is_hid )
-		EV_HandleEvents(joystick);
-	else
-#endif
-		JS_HandleEvents(joystick);
+	ret = read(joystick->hwdata->fd, &buff, 4); 
 
-	/* Deliver ball motion updates */
-	for ( i=0; i<joystick->nballs; ++i ) {
-		int xrel, yrel;
+	prev_buttons 	= joystick->hwdata->prev_buttons;
+	changed 		= buff^prev_buttons; 
+		
+	if(changed & PEPC_VK_UP			) SDL_PrivateJoystickButton(joystick, 0, 
+												(buff & PEPC_VK_UP			) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_UP_LEFT	) SDL_PrivateJoystickButton(joystick, 1, 
+												(buff & PEPC_VK_UP_LEFT		) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_UP_RIGHT	) SDL_PrivateJoystickButton(joystick, 2, 
+												(buff & PEPC_VK_UP_RIGHT	) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_DOWN		) SDL_PrivateJoystickButton(joystick, 3, 
+												(buff & PEPC_VK_DOWN		) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_DOWN_LEFT	) SDL_PrivateJoystickButton(joystick, 4, 
+												(buff & PEPC_VK_DOWN_LEFT	) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_DOWN_RIGHT	) SDL_PrivateJoystickButton(joystick, 5, 
+												(buff & PEPC_VK_DOWN_RIGHT	) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_LEFT		) SDL_PrivateJoystickButton(joystick, 6, 
+												(buff & PEPC_VK_LEFT		) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_RIGHT		) SDL_PrivateJoystickButton(joystick, 7, 
+												(buff & PEPC_VK_RIGHT		) ? SDL_PRESSED : SDL_RELEASED);
+	
+	if(changed & PEPC_VK_FA			) SDL_PrivateJoystickButton(joystick, 8, 
+												(buff & PEPC_VK_FA			) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_FB			) SDL_PrivateJoystickButton(joystick, 9, 
+												(buff & PEPC_VK_FB			) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_FX			) SDL_PrivateJoystickButton(joystick, 10, 
+												(buff & PEPC_VK_FX			) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_FY			) SDL_PrivateJoystickButton(joystick, 11, 
+												(buff & PEPC_VK_FY			) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_FL			) SDL_PrivateJoystickButton(joystick, 12, 
+												(buff & PEPC_VK_FL			) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_FR			) SDL_PrivateJoystickButton(joystick, 13, 
+												(buff & PEPC_VK_FR			) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_START		) SDL_PrivateJoystickButton(joystick, 14, 
+												(buff & PEPC_VK_START		) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_SELECT		) SDL_PrivateJoystickButton(joystick, 15, 
+												(buff & PEPC_VK_SELECT		) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_VOL_UP		) SDL_PrivateJoystickButton(joystick, 16, 
+												(buff & PEPC_VK_VOL_UP		) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_VOL_DOWN	) SDL_PrivateJoystickButton(joystick, 17, 
+												(buff & PEPC_VK_VOL_DOWN		) ? SDL_PRESSED : SDL_RELEASED);
+	if(changed & PEPC_VK_STICK_PUSH	) SDL_PrivateJoystickButton(joystick, 18, 
+												(buff & PEPC_VK_STICK_PUSH		) ? SDL_PRESSED : SDL_RELEASED);
+	
 
-		xrel = joystick->hwdata->balls[i].axis[0];
-		yrel = joystick->hwdata->balls[i].axis[1];
-		if ( xrel || yrel ) {
-			joystick->hwdata->balls[i].axis[0] = 0;
-			joystick->hwdata->balls[i].axis[1] = 0;
-			SDL_PrivateJoystickBall(joystick, (Uint8)i, xrel, yrel);
-		}
-	}
+#if 0
+	if(changed == PEPC_VK_UP			) SDL_PrivateJoystickButton(joystick, 0,  SDL_PRESSED);
+	if(changed == PEPC_VK_UP_LEFT		) SDL_PrivateJoystickButton(joystick, 1,  SDL_PRESSED);
+	if(changed == PEPC_VK_UP_RIGHT		) SDL_PrivateJoystickButton(joystick, 2,  SDL_PRESSED);
+	if(changed == PEPC_VK_DOWN			) SDL_PrivateJoystickButton(joystick, 3,  SDL_PRESSED);
+	if(changed == PEPC_VK_DOWN_LEFT		) SDL_PrivateJoystickButton(joystick, 4,  SDL_PRESSED);
+	if(changed == PEPC_VK_DOWN_RIGHT	) SDL_PrivateJoystickButton(joystick, 5,  SDL_PRESSED);
+	if(changed == PEPC_VK_LEFT			) SDL_PrivateJoystickButton(joystick, 6,  SDL_PRESSED);
+	if(changed == PEPC_VK_RIGHT			) SDL_PrivateJoystickButton(joystick, 7,  SDL_PRESSED);
+												
+	if(changed == PEPC_VK_FA			) SDL_PrivateJoystickButton(joystick, 8,  SDL_PRESSED);
+	if(changed == PEPC_VK_FB			) SDL_PrivateJoystickButton(joystick, 9,  SDL_PRESSED);
+	if(changed == PEPC_VK_FX			) SDL_PrivateJoystickButton(joystick, 10, SDL_PRESSED);
+	if(changed == PEPC_VK_FY			) SDL_PrivateJoystickButton(joystick, 11, SDL_PRESSED);
+	if(changed == PEPC_VK_FL			) SDL_PrivateJoystickButton(joystick, 12, SDL_PRESSED);
+	if(changed == PEPC_VK_FR			) SDL_PrivateJoystickButton(joystick, 13, SDL_PRESSED);
+	if(changed == PEPC_VK_START			) SDL_PrivateJoystickButton(joystick, 14, SDL_PRESSED);
+	if(changed == PEPC_VK_SELECT		) SDL_PrivateJoystickButton(joystick, 15, SDL_PRESSED);
+	if(changed == PEPC_VK_VOL_UP		) SDL_PrivateJoystickButton(joystick, 16, SDL_PRESSED);
+	if(changed == PEPC_VK_VOL_DOWN		) SDL_PrivateJoystickButton(joystick, 17, SDL_PRESSED);
+#endif	
+	
+	/*joystick->hwdata->prev_buttons = buttons;*/
+	joystick->hwdata->prev_buttons = buff;
 }
-
+//[*]------------------------------------------------------------------------------------------[*]
 /* Function to close a joystick after use */
 void SDL_SYS_JoystickClose(SDL_Joystick *joystick)
 {
-#ifndef NO_LOGICAL_JOYSTICKS
-	register int i;
-	if (SDL_joylist[joystick->index].fname == NULL) {
-		SDL_joylist_head(i, joystick->index);
-		SDL_JoystickClose(SDL_joylist[i].joy);
-	}
-#endif
-
-	if ( joystick->hwdata ) {
-#ifndef NO_LOGICAL_JOYSTICKS
-		if (SDL_joylist[joystick->index].fname != NULL)
-#endif
+	if (joystick->hwdata != NULL) 
+	{
 		close(joystick->hwdata->fd);
-		if ( joystick->hwdata->hats ) {
-			free(joystick->hwdata->hats);
-		}
-		if ( joystick->hwdata->balls ) {
-			free(joystick->hwdata->balls);
-		}
+		// free system specific hardware data
 		free(joystick->hwdata);
-		joystick->hwdata = NULL;
 	}
 }
-
+//[*]------------------------------------------------------------------------------------------[*]
 /* Function to perform any system-specific joystick related cleanup */
 void SDL_SYS_JoystickQuit(void)
 {
-	int i;
-
-	for ( i=0; SDL_joylist[i].fname; ++i ) {
-		free(SDL_joylist[i].fname);
-	}
-	SDL_joylist[0].fname = NULL;
+	return;
 }
-
+//[*]------------------------------------------------------------------------------------------[*]
diff -urN SDL-1.2.9/src/joystick/macos/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/macos/Makefile.in
--- SDL-1.2.9/src/joystick/macos/Makefile.in	2005-08-28 08:31:54.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/macos/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_macos_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/Makefile.in
--- SDL-1.2.9/src/joystick/Makefile.in	2005-08-28 08:31:51.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/mint/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/mint/Makefile.in
--- SDL-1.2.9/src/joystick/mint/Makefile.in	2005-08-28 08:31:54.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/mint/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_mint_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/riscos/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/riscos/Makefile.in
--- SDL-1.2.9/src/joystick/riscos/Makefile.in	2005-08-28 08:31:54.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/riscos/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_riscos_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/joystick/SDL_joystick.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/SDL_joystick.c
--- SDL-1.2.9/src/joystick/SDL_joystick.c	2004-01-04 17:49:17.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/SDL_joystick.c	2006-05-19 09:11:11.000000000 +0200
@@ -76,7 +76,8 @@
  */
 int SDL_NumJoysticks(void)
 {
-	return SDL_numjoysticks;
+	//return SDL_numjoysticks;
+	return 1;
 }
 
 /*
diff -urN SDL-1.2.9/src/joystick/win32/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/win32/Makefile.in
--- SDL-1.2.9/src/joystick/win32/Makefile.in	2005-08-28 08:31:54.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/joystick/win32/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libjoystick_winmm_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/main/macosx/Makefile /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/main/macosx/Makefile
--- SDL-1.2.9/src/main/macosx/Makefile	2005-08-28 08:33:11.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/main/macosx/Makefile	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # src/main/macosx/Makefile.  Generated from Makefile.in by configure.
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -27,7 +27,7 @@
 pkgincludedir = $(includedir)/SDL
 top_builddir = ../../..
 am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
-INSTALL = /usr/bin/ginstall -c
+INSTALL = /usr/bin/install -c
 install_sh_DATA = $(install_sh) -c -m 644
 install_sh_PROGRAM = $(install_sh) -c
 install_sh_SCRIPT = $(install_sh) -c
@@ -39,9 +39,9 @@
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-build_triplet = i686-pc-linux-gnu
-host_triplet = i686-pc-linux-gnu
-target_triplet = i686-pc-linux-gnu
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = arm-unknown-linux-gnu
+target_triplet = arm-unknown-linux-gnu
 subdir = src/main/macosx
 DIST_COMMON = $(srcdir)/Info.plist.in $(srcdir)/Makefile.am \
 	$(srcdir)/Makefile.in
@@ -66,39 +66,39 @@
 nibdataDATA_INSTALL = $(INSTALL_DATA)
 DATA = $(hackhacknibdata_DATA) $(nibdata_DATA)
 DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
-ACLOCAL = ${SHELL} /usr/src/SDL12/missing --run aclocal-1.9
+ACLOCAL = ${SHELL} /home/darius/gp2x/sdl/SDL-1.2.9/missing --run aclocal-1.9
 ALLOCA = 
 ALSA_CFLAGS = 
-ALSA_LIBS = -L/usr/lib  -lasound -lm -ldl -lpthread
+ALSA_LIBS = 
 AMDEP_FALSE = #
 AMDEP_TRUE = 
-AMTAR = ${SHELL} /usr/src/SDL12/missing --run tar
-AR = ar
+AMTAR = ${SHELL} /home/darius/gp2x/sdl/SDL-1.2.9/missing --run tar
+AR = arm-linux-ar
 ARCH = linux
-ARTSCCONFIG = /usr/local/bin/artsc-config
+ARTSCCONFIG = 
 AS = as
 ASFLAGS = 
-AUDIO_DRIVERS =  disk/libaudio_disk.la dsp/libaudio_dsp.la dma/libaudio_dma.la alsa/libaudio_alsa.la arts/libaudio_arts.la esd/libaudio_esd.la
-AUDIO_SUBDIRS =  disk dsp dma alsa arts esd
-AUTOCONF = ${SHELL} /usr/src/SDL12/missing --run autoconf
-AUTOHEADER = ${SHELL} /usr/src/SDL12/missing --run autoheader
-AUTOMAKE = ${SHELL} /usr/src/SDL12/missing --run automake-1.9
+AUDIO_DRIVERS =  dsp/libaudio_dsp.la dma/libaudio_dma.la
+AUDIO_SUBDIRS =  dsp dma
+AUTOCONF = ${SHELL} /home/darius/gp2x/sdl/SDL-1.2.9/missing --run autoconf
+AUTOHEADER = ${SHELL} /home/darius/gp2x/sdl/SDL-1.2.9/missing --run autoheader
+AUTOMAKE = ${SHELL} /home/darius/gp2x/sdl/SDL-1.2.9/missing --run automake-1.9
 AWK = gawk
-CC = gcc
-CCAS = gcc
+CC = arm-linux-gcc
+CCAS = arm-linux-gcc
 CCASFLAGS = 
 CCDEPMODE = depmode=gcc3
 CDROM_DRIVERS =  linux/libcdrom_linux.la
 CDROM_SUBDIRS =  linux
-CFLAGS = -g -O2 -Wall -DENABLE_DUMMYVIDEO -DDISKAUD_SUPPORT -DUSE_DLOPEN -DUSE_ASMBLIT -I./hermes -I$(top_srcdir)/src/hermes -DOSS_SUPPORT -DALSA_SUPPORT -DALSA_DYNAMIC=$(alsa_lib)  -DUSE_DLVSYM -DARTSC_SUPPORT -DARTSC_DYNAMIC=$(arts_lib) -I/usr/local/include/artsc -DESD_SUPPORT -DESD_DYNAMIC=$(esd_lib)   -I/usr/X11R6/include -DENABLE_X11 -DXTHREADS -I./include -I./src/video -DXFREE86_VM -DXFREE86_VMGAMMA -DXFREE86_DGAMOUSE -DDEFAULT_DGAMOUSE -DXFREE86_XV -DHAVE_XINERAMA -Isrc/video -DENABLE_DGA -DENABLE_FBCON -DHAVE_OPENGL -DUSE_INPUT_EVENTS -D_REENTRANT -DSDL_USE_PTHREADS -DHAVE_SIGACTION -DHAVE_LINUX_VERSION_H -I$(top_srcdir)/include -I$(top_srcdir)/include/SDL -I$(top_srcdir)/src -I$(top_srcdir)/src/main/linux -I$(top_srcdir)/src/audio -I$(top_srcdir)/src/video -I$(top_srcdir)/src/video/XFree86/extensions -I$(top_srcdir)/src/events -I$(top_srcdir)/src/joystick -I$(top_srcdir)/src/cdrom -I$(top_srcdir)/src/thread -I$(top_srcdir)/src/timer -I$(top_srcdir)/src/endian -I$(top_srcdir)/src/file -I$(top_builddir)/src/thread
-CPP = gcc -E
+CFLAGS = -g -O2 -Wall -DENABLE_DUMMYVIDEO -DUSE_DLOPEN -DOSS_SUPPORT -DENABLE_GP2XVIDEO -DUSE_INPUT_EVENTS -D_REENTRANT -DSDL_USE_PTHREADS -DHAVE_SIGACTION -DHAVE_LINUX_VERSION_H -I$(top_srcdir)/include -I$(top_srcdir)/include/SDL -I$(top_srcdir)/src -I$(top_srcdir)/src/main/linux -I$(top_srcdir)/src/audio -I$(top_srcdir)/src/video -I$(top_srcdir)/src/video/XFree86/extensions -I$(top_srcdir)/src/events -I$(top_srcdir)/src/joystick -I$(top_srcdir)/src/cdrom -I$(top_srcdir)/src/thread -I$(top_srcdir)/src/timer -I$(top_srcdir)/src/endian -I$(top_srcdir)/src/file -I$(top_builddir)/src/thread
+CPP = arm-linux-gcc -E
 CPPFLAGS = 
-CXX = g++
-CXXCPP = g++ -E
+CXX = arm-linux-g++
+CXXCPP = arm-linux-g++ -E
 CXXDEPMODE = depmode=gcc3
-CXXFLAGS = -g -O2 -Wall -DENABLE_DUMMYVIDEO -DDISKAUD_SUPPORT -DUSE_DLOPEN -DUSE_ASMBLIT -I./hermes -I$(top_srcdir)/src/hermes -DOSS_SUPPORT -DALSA_SUPPORT -DALSA_DYNAMIC=$(alsa_lib)  -DUSE_DLVSYM -DARTSC_SUPPORT -DARTSC_DYNAMIC=$(arts_lib) -I/usr/local/include/artsc -DESD_SUPPORT -DESD_DYNAMIC=$(esd_lib)   -I/usr/X11R6/include -DENABLE_X11 -DXTHREADS -I./include -I./src/video -DXFREE86_VM -DXFREE86_VMGAMMA -DXFREE86_DGAMOUSE -DDEFAULT_DGAMOUSE -DXFREE86_XV -DHAVE_XINERAMA -Isrc/video -DENABLE_DGA -DENABLE_FBCON -DHAVE_OPENGL -DUSE_INPUT_EVENTS -D_REENTRANT -DSDL_USE_PTHREADS -DHAVE_SIGACTION -DHAVE_LINUX_VERSION_H -I$(top_srcdir)/include -I$(top_srcdir)/include/SDL -I$(top_srcdir)/src -I$(top_srcdir)/src/main/linux -I$(top_srcdir)/src/audio -I$(top_srcdir)/src/video -I$(top_srcdir)/src/video/XFree86/extensions -I$(top_srcdir)/src/events -I$(top_srcdir)/src/joystick -I$(top_srcdir)/src/cdrom -I$(top_srcdir)/src/thread -I$(top_srcdir)/src/timer -I$(top_srcdir)/src/endian -I$(top_srcdir)/src/file -I$(top_builddir)/src/thread
+CXXFLAGS = -g -O2 -Wall -DENABLE_DUMMYVIDEO -DUSE_DLOPEN -DOSS_SUPPORT -DENABLE_GP2XVIDEO -DUSE_INPUT_EVENTS -D_REENTRANT -DSDL_USE_PTHREADS -DHAVE_SIGACTION -DHAVE_LINUX_VERSION_H -I$(top_srcdir)/include -I$(top_srcdir)/include/SDL -I$(top_srcdir)/src -I$(top_srcdir)/src/main/linux -I$(top_srcdir)/src/audio -I$(top_srcdir)/src/video -I$(top_srcdir)/src/video/XFree86/extensions -I$(top_srcdir)/src/events -I$(top_srcdir)/src/joystick -I$(top_srcdir)/src/cdrom -I$(top_srcdir)/src/thread -I$(top_srcdir)/src/timer -I$(top_srcdir)/src/endian -I$(top_srcdir)/src/file -I$(top_builddir)/src/thread
 CYGPATH_W = echo
-DEFS = -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"SDL\" -DVERSION=\"1.2.9\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 -DHAVE_LIBASOUND=1 
+DEFS = -DPACKAGE_NAME=\"\" -DPACKAGE_TARNAME=\"\" -DPACKAGE_VERSION=\"\" -DPACKAGE_STRING=\"\" -DPACKAGE_BUGREPORT=\"\" -DPACKAGE=\"SDL\" -DVERSION=\"1.2.9\" -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DHAVE_ALLOCA_H=1 -DHAVE_ALLOCA=1 
 DEPDIR = .deps
 DIRECTFB_CFLAGS = 
 DIRECTFB_LIBS = 
@@ -113,13 +113,13 @@
 ENABLE_STATIC_FALSE = #
 ENABLE_STATIC_TRUE = 
 ESD_CFLAGS = 
-ESD_CONFIG = /usr/bin/esd-config
-ESD_LIBS = -L/usr/lib -lesd -laudiofile -lm
+ESD_CONFIG = 
+ESD_LIBS = 
 EXEEXT = 
-F77 = g77
+F77 = f95
 FFLAGS = -g -O2
-HAVE_NASM_FALSE = #
-HAVE_NASM_TRUE = 
+HAVE_NASM_FALSE = 
+HAVE_NASM_TRUE = #
 INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
@@ -136,9 +136,9 @@
 LT_CURRENT = 7
 LT_RELEASE = 1.2
 LT_REVISION = 2
-MAKEINFO = ${SHELL} /usr/src/SDL12/missing --run makeinfo
-NASM = /usr/local/bin/nasm
-NASMFLAGS = -f elf
+MAKEINFO = ${SHELL} /home/darius/gp2x/sdl/SDL-1.2.9/missing --run makeinfo
+NASM = 
+NASMFLAGS = 
 OBJC = 
 OBJCDEPMODE = 
 OBJCFLAGS = 
@@ -154,11 +154,11 @@
 PATH_SEPARATOR = :
 PKG_CONFIG = 
 PTH_CONFIG = 
-RANLIB = ranlib
+RANLIB = arm-linux-ranlib
 SDL_BINARY_AGE = 9
 SDL_CFLAGS =  -D_REENTRANT
-SDL_EXTRADIRS =  audio video events joystick cdrom thread timer endian file cpuinfo hermes
-SDL_EXTRALIBS =  audio/libaudio.la video/libvideo.la events/libevents.la joystick/libjoystick.la cdrom/libcdrom.la thread/libthread.la timer/libtimer.la endian/libendian.la file/libfile.la cpuinfo/libcpuinfo.la hermes/libhermes.la
+SDL_EXTRADIRS =  audio video events joystick cdrom thread timer endian file cpuinfo
+SDL_EXTRALIBS =  audio/libaudio.la video/libvideo.la events/libevents.la joystick/libjoystick.la cdrom/libcdrom.la thread/libthread.la timer/libtimer.la endian/libendian.la file/libfile.la cpuinfo/libcpuinfo.la
 SDL_INTERFACE_AGE = 2
 SDL_LIBS = -lSDL -lpthread
 SDL_MAJOR_VERSION = 1
@@ -170,9 +170,9 @@
 SET_MAKE = 
 SHARED_SYSTEM_LIBS = 
 SHELL = /bin/sh
-STATIC_SYSTEM_LIBS =  -lm -ldl  -L/usr/X11R6/lib -lX11 -lXext
-STRIP = strip
-SYSTEM_LIBS =  -lm -ldl  -L/usr/X11R6/lib -lX11 -lXext
+STATIC_SYSTEM_LIBS =  -lm -ldl
+STRIP = arm-linux-strip
+SYSTEM_LIBS =  -lm -ldl
 TARGET_AIX_FALSE = 
 TARGET_AIX_TRUE = #
 TARGET_BEOS_FALSE = 
@@ -208,22 +208,22 @@
 USE_DIRECTX_FALSE = 
 USE_DIRECTX_TRUE = #
 VERSION = 1.2.9
-VIDEO_DRIVERS =  dummy/libvideo_null.la x11/libvideo_x11.la XFree86/Xxf86vm/libXFree86_Xxf86vm.la XFree86/Xxf86dga/libXFree86_Xxf86dga.la XFree86/Xv/libXFree86_Xv.la XFree86/Xinerama/libXFree86_Xinerama.la dga/libvideo_dga.la fbcon/libvideo_fbcon.la
-VIDEO_SUBDIRS =  dummy x11 XFree86/Xxf86vm XFree86/Xxf86dga XFree86/Xv XFree86/Xinerama dga fbcon
-X_CFLAGS =  -I/usr/X11R6/include
+VIDEO_DRIVERS =  dummy/libvideo_null.la gp2x/libvideo_gp2x.la
+VIDEO_SUBDIRS =  dummy gp2x
+X_CFLAGS = 
 X_EXTRA_LIBS = 
-X_LIBS =  -L/usr/X11R6/lib
-X_PRE_LIBS =  -lSM -lICE
-ac_ct_AR = ar
+X_LIBS = 
+X_PRE_LIBS = 
+ac_ct_AR = 
 ac_ct_AS = 
-ac_ct_CC = gcc
-ac_ct_CXX = g++
+ac_ct_CC = 
+ac_ct_CXX = 
 ac_ct_DLLTOOL = 
-ac_ct_F77 = g77
+ac_ct_F77 = f95
 ac_ct_OBJDUMP = 
-ac_ct_RANLIB = ranlib
-ac_ct_STRIP = strip
-alsa_lib = libasound.so.2
+ac_ct_RANLIB = 
+ac_ct_STRIP = 
+alsa_lib = 
 am__fastdepCC_FALSE = #
 am__fastdepCC_TRUE = 
 am__fastdepCXX_FALSE = #
@@ -235,40 +235,40 @@
 am__quote = 
 am__tar = ${AMTAR} chof - "$$tardir"
 am__untar = ${AMTAR} xf -
-arts_lib = libartsc.so.0
+arts_lib = 
 bindir = ${exec_prefix}/bin
-build = i686-pc-linux-gnu
+build = x86_64-unknown-linux-gnu
 build_alias = 
-build_cpu = i686
+build_cpu = x86_64
 build_os = linux-gnu
-build_vendor = pc
+build_vendor = unknown
 datadir = ${prefix}/share
-esd_lib = libesd.so.0
+esd_lib = 
 exec_prefix = ${prefix}
-host = i686-pc-linux-gnu
-host_alias = 
-host_cpu = i686
+host = arm-unknown-linux-gnu
+host_alias = arm-linux
+host_cpu = arm
 host_os = linux-gnu
-host_vendor = pc
+host_vendor = unknown
 includedir = ${prefix}/include
 infodir = ${prefix}/info
-install_sh = /usr/src/SDL12/install-sh
+install_sh = /home/darius/gp2x/sdl/SDL-1.2.9/install-sh
 libdir = ${exec_prefix}/lib
 libexecdir = ${exec_prefix}/libexec
 localstatedir = ${prefix}/var
 mandir = ${prefix}/man
 mkdir_p = mkdir -p --
 oldincludedir = /usr/include
-prefix = /usr/local
+prefix = /usr/local/gp2x/arm-linux/
 program_transform_name = s,x,x,
 sbindir = ${exec_prefix}/sbin
 sharedstatedir = ${prefix}/com
 sysconfdir = ${prefix}/etc
-target = i686-pc-linux-gnu
+target = arm-unknown-linux-gnu
 target_alias = 
-target_cpu = i686
+target_cpu = arm
 target_os = linux-gnu
-target_vendor = pc
+target_vendor = unknown
 #hackhacknibdatadir = $(nibdatadir)/SDLMain.nib
 #hackhacknibdata_DATA = info.nib
 #nibdatadir = $(datadir)/sdl
diff -urN SDL-1.2.9/src/main/macosx/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/main/macosx/Makefile.in
--- SDL-1.2.9/src/main/macosx/Makefile.in	2005-08-28 08:31:55.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/main/macosx/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/src/main/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/main/Makefile.in
--- SDL-1.2.9/src/main/Makefile.in	2005-08-28 08:31:55.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/main/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -19,6 +19,8 @@
 # entry points, which require special application initialization.
 
 
+SOURCES = $(libSDLmain_a_SOURCES) $(libarch_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/Makefile.in
--- SDL-1.2.9/src/Makefile.in	2005-08-28 08:31:37.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libSDL_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/thread/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/thread/Makefile.in
--- SDL-1.2.9/src/thread/Makefile.in	2005-08-28 08:31:56.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/thread/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libthread_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/timer/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/timer/Makefile.in
--- SDL-1.2.9/src/timer/Makefile.in	2005-08-28 08:31:56.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/timer/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libtimer_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/aalib/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/aalib/Makefile.in
--- SDL-1.2.9/src/video/aalib/Makefile.in	2005-08-28 08:31:59.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/aalib/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_aa_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/ataricommon/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/ataricommon/Makefile.in
--- SDL-1.2.9/src/video/ataricommon/Makefile.in	2005-08-28 08:31:59.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/ataricommon/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_ataricommon_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/bwindow/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/bwindow/Makefile.in
--- SDL-1.2.9/src/video/bwindow/Makefile.in	2005-08-28 08:31:59.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/bwindow/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_bwindow_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/cybergfx/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/cybergfx/Makefile.in
--- SDL-1.2.9/src/video/cybergfx/Makefile.in	2005-08-28 08:32:00.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/cybergfx/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_cgx_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/dc/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/dc/Makefile.in
--- SDL-1.2.9/src/video/dc/Makefile.in	2005-08-28 08:32:00.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/dc/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_dc_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/dga/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/dga/Makefile.in
--- SDL-1.2.9/src/video/dga/Makefile.in	2005-08-28 08:32:00.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/dga/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_dga_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/directfb/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/directfb/Makefile.in
--- SDL-1.2.9/src/video/directfb/Makefile.in	2005-08-28 08:32:01.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/directfb/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_directfb_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/dummy/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/dummy/Makefile.in
--- SDL-1.2.9/src/video/dummy/Makefile.in	2005-08-28 08:32:01.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/dummy/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_null_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/epoc/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/epoc/Makefile.in
--- SDL-1.2.9/src/video/epoc/Makefile.in	2005-08-28 08:32:01.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/epoc/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_epoc_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/fbcon/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/Makefile.in
--- SDL-1.2.9/src/video/fbcon/Makefile.in	2005-08-28 08:32:02.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_fbcon_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/fbcon/mmsp2_mmio.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/mmsp2_mmio.h
--- SDL-1.2.9/src/video/fbcon/mmsp2_mmio.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/mmsp2_mmio.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,46 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+// MMSP2 register definitions
+
+#include "mmsp2_regs.h"
+#define NOFBACCEL_DEBUG 1
+
+// Wait for fifo space
+#define mmsp2_wait(space)						\
+{									\
+  do {} while (mmsp2_blit_regs[MESGFIFOSTATUS] & MESG_FULL);		\
+}
+
+// Wait for idle accelerator
+#define mmsp2_waitidle()						\
+{									\
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);		\
+}
+
+// Convert virtual address to physical (fbmem only)
+#define mmsp2_addr(addr) (((Uint32)addr)-((Uint32)mapped_mem)+0x3101000)
diff -urN SDL-1.2.9/src/video/fbcon/mmsp2_regs.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/mmsp2_regs.h
--- SDL-1.2.9/src/video/fbcon/mmsp2_regs.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/mmsp2_regs.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,125 @@
+/*
+ * MMSP2 (MP2520F) Registers
+ *  Only listed needed registers for HW blit stuff
+ *
+ * 2005-12-20 Paeryn
+ */
+static char rcsid=
+  "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+  
+
+#ifndef _MMSP2_REG_H_
+#define _MMSP2_REG_H_
+
+// Debugging defines
+#define FBCON_DEBUG 1
+#define FBACCEL_DEBUG 1
+
+////
+// Blitter registers
+
+#define MESGDSTCTRL      0x0000>>2
+#define MESG_DSTENB    1<<6
+#define MESG_BSTBPP    0x60
+#define MESG_DSTBPP_8  0<<5
+#define MESG_DSTBPP_16 1<<5
+
+#define MESGDSTADDR      0x0004>>2
+
+#define MESGDSTSTRIDE    0x0008>>2
+
+#define MESGSRCCTRL      0x000c>>2
+#define MESG_INVIDEO   1<<8
+#define MESG_SRCENB    1<<7
+#define MESG_SRCBPP    0x60
+#define MESG_SRCBPP_8  0<<5
+#define MESG_SRCBPP_16 1<<5
+#define MESG_SRCBPP_1  1<<6
+
+#define MESGSRCADDR      0x0010>>2
+
+#define MESGSRCSTRIDE    0x0014>>2
+
+#define MESGSRCFORCOLOR  0x0018>>2
+
+#define MESGSRCBACKCOLOR 0x001c>>2
+
+#define MESGPATCTRL      0x0020>>2
+#define MESG_PATMONO   1<<6
+#define MESG_PATENB    1<<5
+#define MESG_PATBPP    0x18
+#define MESG_PATBPP_8  0<<3
+#define MESG_PATBPP_16 1<<3
+#define MESG_PATBPP_1  1<<4
+#define MESG_YOFFSET   0x07
+
+#define MESGFORCOLOR     0x0024>>2
+
+#define MESGBACKCOLOR    0x0028>>2
+
+#define MESGSIZE         0x002c>>2
+#define MESG_HEIGHT 16
+#define MESG_WIDTH  0
+
+#define MESGCTRL         0x0030>>2
+#define MESG_TRANSPCOLOR 16
+#define MESG_TRANSPEN    1<<11
+#define MESG_FFCLR       1<<10
+#define MESG_YDIR        1<<9
+#define MESG_YDIR_NEG    0<<9
+#define MESG_YDIR_POS    1<<9
+#define MESG_XDIR        1<<8
+#define MESG_XDIR_NEG    0<<8
+#define MESG_XDIR_POS    1<<8
+#define MESG_ROP         0xff
+
+#define MESGSTATUS       0x0034>>2
+#define MESG_BUSY 1<<0
+
+#define MESGFIFOSTATUS   0x0038>>2
+#define MESG_FULL    1<<31
+#define MESG_REMAIN  0x1f
+
+#define MESGFIFO         0x003c>>2
+#define MESGPAT          0x0080>>2
+
+////
+// Basic ROPs
+#define MMSP2_ROP_SRC 0xCC
+#define MMSP2_ROP_PAT 0xF0
+
+////
+// Control registers
+#define SYSCLKENREG   0x0904>>1
+#define FASTIOCLK 1<<10
+
+#define VCLKENREG     0x090a>>1
+#define GRPCLK 1<<2
+
+#define MLC_STL_OADRL 0x290e>>1
+#define MLC_STL_OADRH 0x2910>>1
+#define MLC_STL_EADRL 0x2912>>1
+#define MLC_STL_EADRH 0x2914>>1
+
+// GPIOB[4] is vsync
+#define GPIOB_PINLVL 0x1182>>1
+#define GPIOB_VSYNC 1<<4
+
+////
+// A few macros,
+
+// mmsp2_wait()
+//   Waits until the blitter is ready to accept next command
+void mmsp2_blit_wait(void)
+{
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+}
+
+// Uint32 mmsp2_virt2phys(void *addr)
+//   Convert virtual address to physical
+Uint32 mmsp2_virt2phys(void *)
+{
+  return (Uint32)addr - (Uint32)mapped_mem + 0x3101000;
+}
+
+#endif
diff -urN SDL-1.2.9/src/video/fbcon/SDL_fbevents.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbevents.c
--- SDL-1.2.9/src/video/fbcon/SDL_fbevents.c	2005-01-04 20:04:14.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbevents.c	2006-05-19 09:11:11.000000000 +0200
@@ -22,7 +22,7 @@
 
 #ifdef SAVE_RCSID
 static char rcsid =
- "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
 #endif
 
 /* Handle the event stream, converting console events into SDL events */
@@ -54,6 +54,7 @@
 #include "SDL_fbvideo.h"
 #include "SDL_fbevents_c.h"
 #include "SDL_fbkeys.h"
+#include "SDL_keysym.h"
 
 #include "SDL_fbelo.h"
 
@@ -61,6 +62,8 @@
 #define GPM_NODE_FIFO	"/dev/gpmdata"
 #endif
 
+#define FB_VT_OPEN 0 // ghcstop add
+
 
 /* The translation tables from a console scancode to a SDL keysym */
 #define NUM_VGAKEYMAPS	(1<<KG_CAPSSHIFT)
@@ -87,6 +90,7 @@
 	/* Load all the keysym mappings */
 	for ( map=0; map<NUM_VGAKEYMAPS; ++map ) {
 		memset(vga_keymap[map], 0, NR_KEYS*sizeof(Uint16));
+		
 		for ( i=0; i<NR_KEYS; ++i ) {
 			entry.kb_table = map;
 			entry.kb_index = i;
@@ -115,25 +119,25 @@
 						vga_keymap[map][i]=entry.kb_value;
 						vga_keymap[map][i]+= '0';
 						break;
-										case K_PPLUS:
+					case K_PPLUS:
 						vga_keymap[map][i]=K(KT_ASCII,'+');
 						break;
-										case K_PMINUS:
+					case K_PMINUS:
 						vga_keymap[map][i]=K(KT_ASCII,'-');
 						break;
-										case K_PSTAR:
+					case K_PSTAR:
 						vga_keymap[map][i]=K(KT_ASCII,'*');
 						break;
-										case K_PSLASH:
+					case K_PSLASH:
 						vga_keymap[map][i]=K(KT_ASCII,'/');
 						break;
-										case K_PENTER:
+					case K_PENTER:
 						vga_keymap[map][i]=K(KT_ASCII,'\r');
 						break;
-										case K_PCOMMA:
+					case K_PCOMMA:
 						vga_keymap[map][i]=K(KT_ASCII,',');
 						break;
-										case K_PDOT:
+					case K_PDOT:
 						vga_keymap[map][i]=K(KT_ASCII,'.');
 						break;
 					default:
@@ -163,18 +167,6 @@
 	/* Set medium-raw keyboard mode */
 	if ( (keyboard_fd >= 0) && !FB_InGraphicsMode(this) ) {
 
-		/* Switch to the correct virtual terminal */
-		if ( current_vt > 0 ) {
-			struct vt_stat vtstate;
-
-			if ( ioctl(keyboard_fd, VT_GETSTATE, &vtstate) == 0 ) {
-				saved_vt = vtstate.v_active;
-			}
-			if ( ioctl(keyboard_fd, VT_ACTIVATE, current_vt) == 0 ) {
-				ioctl(keyboard_fd, VT_WAITACTIVE, current_vt);
-			}
-		}
-
 		/* Set the terminal input mode */
 		if ( tcgetattr(keyboard_fd, &saved_kbd_termios) < 0 ) {
 			SDL_SetError("Unable to get terminal attributes");
@@ -184,52 +176,31 @@
 			keyboard_fd = -1;
 			return(-1);
 		}
-		if ( ioctl(keyboard_fd, KDGKBMODE, &saved_kbd_mode) < 0 ) {
-			SDL_SetError("Unable to get current keyboard mode");
-			if ( keyboard_fd > 0 ) {
-				close(keyboard_fd);
-			}
-			keyboard_fd = -1;
-			return(-1);
-		}
 		keyboard_termios = saved_kbd_termios;
-		keyboard_termios.c_lflag &= ~(ICANON | ECHO | ISIG);
+		
+   		keyboard_termios.c_lflag = 0;
 		keyboard_termios.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
-		keyboard_termios.c_cc[VMIN] = 0;
-		keyboard_termios.c_cc[VTIME] = 0;
+
+   		keyboard_termios.c_cc[VTIME]    = 0;   // 문자 사이의 timer를 disable
+   		keyboard_termios.c_cc[VMIN]     = 1;   // 최소 5 문자 받을 때까진 blocking
+
+   		tcflush(keyboard_fd, TCIFLUSH);
+		
 		if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) {
 			FB_CloseKeyboard(this);
 			SDL_SetError("Unable to set terminal attributes");
 			return(-1);
 		}
-		/* This will fail if we aren't root or this isn't our tty */
-		if ( ioctl(keyboard_fd, KDSKBMODE, K_MEDIUMRAW) < 0 ) {
-			FB_CloseKeyboard(this);
-			SDL_SetError("Unable to set keyboard in raw mode");
-			return(-1);
-		}
-		if ( ioctl(keyboard_fd, KDSETMODE, KD_GRAPHICS) < 0 ) {
-			FB_CloseKeyboard(this);
-			SDL_SetError("Unable to set keyboard in graphics mode");
-			return(-1);
-		}
+		
+
 	}
 	return(keyboard_fd);
 }
 
 void FB_LeaveGraphicsMode(_THIS)
 {
-	if ( FB_InGraphicsMode(this) ) {
-		ioctl(keyboard_fd, KDSETMODE, KD_TEXT);
-		ioctl(keyboard_fd, KDSKBMODE, saved_kbd_mode);
-		tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
-		saved_kbd_mode = -1;
-
-		/* Head back over to the original virtual terminal */
-		if ( saved_vt > 0 ) {
-			ioctl(keyboard_fd, VT_ACTIVATE, saved_vt);
-		}
-	}
+	tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
+	saved_kbd_mode = -1;
 }
 
 void FB_CloseKeyboard(_THIS)
@@ -256,34 +227,7 @@
 		for ( i=0; tty0[i] && (tty0_fd < 0); ++i ) {
 			tty0_fd = open(tty0[i], O_WRONLY, 0);
 		}
-		if ( tty0_fd < 0 ) {
-			tty0_fd = dup(0); /* Maybe stdin is a VT? */
-		}
-		ioctl(tty0_fd, VT_OPENQRY, &current_vt);
-		close(tty0_fd);
-		if ( (geteuid() == 0) && (current_vt > 0) ) {
-			for ( i=0; vcs[i] && (keyboard_fd < 0); ++i ) {
-				char vtpath[12];
-
-				sprintf(vtpath, vcs[i], current_vt);
-				keyboard_fd = open(vtpath, O_RDWR, 0);
-#ifdef DEBUG_KEYBOARD
-				fprintf(stderr, "vtpath = %s, fd = %d\n",
-					vtpath, keyboard_fd);
-#endif /* DEBUG_KEYBOARD */
-
-				/* This needs to be our controlling tty
-				   so that the kernel ioctl() calls work
-				*/
-				if ( keyboard_fd >= 0 ) {
-					tty0_fd = open("/dev/tty", O_RDWR, 0);
-					if ( tty0_fd >= 0 ) {
-						ioctl(tty0_fd, TIOCNOTTY, 0);
-						close(tty0_fd);
-					}
-				}
-			}
-		}
+		
  		if ( keyboard_fd < 0 ) {
 			/* Last resort, maybe our tty is a usable VT */
 			current_vt = 0;
@@ -293,18 +237,7 @@
 		fprintf(stderr, "Current VT: %d\n", current_vt);
 #endif
  		saved_kbd_mode = -1;
-
-		/* Make sure that our input is a console terminal */
-		{ int dummy;
-		  if ( ioctl(keyboard_fd, KDGKBMODE, &dummy) < 0 ) {
-			close(keyboard_fd);
-			keyboard_fd = -1;
-			SDL_SetError("Unable to open a console terminal");
-		  }
-		}
-
-		/* Set up keymap */
-		FB_vgainitkeymaps(keyboard_fd);
+		
  	}
  	return(keyboard_fd);
 }
@@ -835,7 +768,7 @@
 static void switch_vt(_THIS, unsigned short which)
 {
 	struct vt_stat vtstate;
-	unsigned short v_active;
+	unsigned short current;
 	SDL_Surface *screen;
 	__u16 saved_pal[3*256];
 	Uint32 screen_arealen;
@@ -846,7 +779,7 @@
 	     (which == vtstate.v_active) ) {
 		return;
 	}
-	v_active = vtstate.v_active;
+	current = vtstate.v_active;
 
 	/* Save the contents of the screen, and go to text mode */
 	SDL_mutexP(hw_lock);
@@ -864,7 +797,7 @@
 	if ( ioctl(keyboard_fd, VT_ACTIVATE, which) == 0 ) {
 		/* Wait for our console to be activated again */
 		ioctl(keyboard_fd, VT_WAITACTIVE, which);
-		while ( ioctl(keyboard_fd, VT_WAITACTIVE, v_active) < 0 ) {
+		while ( ioctl(keyboard_fd, VT_WAITACTIVE, current) < 0 ) {
 			if ( (errno != EINTR) && (errno != EAGAIN) ) {
 				/* Unknown VT error - cancel this */
 				break;
@@ -892,14 +825,26 @@
 	SDL_keysym keysym;
 
 	nread = read(keyboard_fd, keybuf, BUFSIZ);
+	
+	// ghcstop add: 041206  확장키의 경우는 처리를 하지 않는다.
+	if(nread >= 3 ) return; 
+
 	for ( i=0; i<nread; ++i ) {
-		scancode = keybuf[i] & 0x7F;
+		scancode = keybuf[i] & 0x7F; // ascii code로 제한 
+		
+		
+		#if 0 // 041206 ghcstop change
 		if ( keybuf[i] & 0x80 ) {
 			pressed = SDL_RELEASED;
 		} else {
 			pressed = SDL_PRESSED;
 		}
+		#else
+			pressed = SDL_PRESSED; // 무조건 pressed로 처리한다.
+		#endif
 		TranslateKey(scancode, &keysym);
+		
+		
 		/* Handle Alt-FN for vt switch */
 		switch (keysym.sym) {
 		    case SDLK_F1:
@@ -922,7 +867,7 @@
 			}
 			/* Fall through to normal processing */
 		    default:
-			posted += SDL_PrivateKeyboard(pressed, &keysym);
+			posted += SDL_PrivateKeyboard(pressed, &keysym); // ghcstop 041206 SDL_keyboard.c로 가서 event처리가 된다. 잘볼 것
 			break;
 		}
 	}
@@ -934,12 +879,14 @@
 	int max_fd;
 	static struct timeval zero;
 
+
 	do {
 		posted = 0;
 
 		FD_ZERO(&fdset);
 		max_fd = 0;
 		if ( keyboard_fd >= 0 ) {
+			
 			FD_SET(keyboard_fd, &fdset);
 			if ( max_fd < keyboard_fd ) {
 				max_fd = keyboard_fd;
@@ -966,6 +913,8 @@
 	} while ( posted );
 }
 
+
+#if 0 // 041206: ghcstop delete 왜냐? 아예 keymap을 내맘대로 serial console용으로 변화시켰기 때문
 void FB_InitOSKeymap(_THIS)
 {
 	int i;
@@ -1082,6 +1031,46 @@
 	  }
 	}
 }
+#else
+
+void FB_InitOSKeymap(_THIS)
+{
+	int i;
+
+	/* Initialize the Linux key translation table */
+
+	/* First get the ascii keys and others not well handled */
+	for (i=0; i<SDL_TABLESIZE(keymap); ++i)  // 128개 까정 
+	{
+		keymap[i] = 0; // all key map clear ==> 몽땅 SDLK_UNKNOWN로 일단 세팅
+	}
+	
+	keymap[0] =  SDLK_UNKNOWN	;
+	keymap[3] =  SDLK_CTRL_C	;
+	keymap[8] =  SDLK_BACKSPACE	;
+	keymap[9] =  SDLK_TAB		;
+	keymap[12] = SDLK_CLEAR		;
+	keymap[13] = SDLK_RETURN	;	
+	keymap[19] = SDLK_PAUSE		;
+	keymap[27] = SDLK_ESCAPE    ;
+	
+	
+	for (i=32; i<=64; ++i)  // ' ' 에서부터 '@'까지의 32개 
+	{
+		keymap[i] = i; // all key map clear ==> 몽땅 SDLK_UNKNOWN로 일단 세팅
+	}
+	
+	for (i=91; i<=122; ++i)  // '[' 에서부터 'z'까지의 32개 
+	{
+		keymap[i] = i; // all key map clear ==> 몽땅 SDLK_UNKNOWN로 일단 세팅
+	}
+
+	keymap[127] = SDLK_DELETE    ;	
+       
+	
+}
+
+#endif
 
 static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
 {
@@ -1092,6 +1081,7 @@
 
 	/* If UNICODE is on, get the UNICODE value for the key */
 	keysym->unicode = 0;
+	#if 0 // 041206: ghcstop delete 왜냐? 아예 keymap을 내맘대로 serial console용으로 변화시켰기 때문
 	if ( SDL_TranslateUNICODE ) {
 		int map;
 		SDLMod modstate;
@@ -1123,5 +1113,6 @@
 			keysym->unicode = KVAL(vga_keymap[map][scancode]);
 		}
 	}
+	#endif 
 	return(keysym);
 }
diff -urN SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.c
--- SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.c	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.c	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,301 @@
+/*
+	SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+/*
+ * Hardware accelerated framebuffer for the GP2X.
+ *   Liberties are taken as the current /dev/fb is restrictive.
+ *   /dev/fb is only used to determine base fb memory, after that
+ *   all graphics hardware is accessed directly.
+ */
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_fbgp2x.h"
+#include "mmsp2_regs.h"
+
+Uint16 volatile *mmsp2_regs;
+Uint32 volatile *mmsp2_blit_regs;
+
+
+/* Set video addr */
+void MMSP2_SetScreen(Uint32 addr)
+{
+  mmsp2_regs[MLC_STL_OADRL] = addr & 0xffff;
+  mmsp2_regs[MLC_STL_OADRH] = addr >> 16;
+  addr += 640;
+  mmsp2_regs[MLC_STL_EADRL] = addr & 0xffff;
+  mmsp2_regs[MLC_STL_EADRH] = addr >> 16;
+}
+
+////
+// dummy blit to force MMSP2's blitter to flush it's cache
+static void dummy_blit(void)
+{
+#ifdef FBACCEL_DEBUG
+  fputs("SDL: dummy_blit\n", stderr);
+#endif
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+  mmsp2_blit_regs[MESGDSTCTRL] = MESG_DSTBPP_16 | MESG_DSTENB;
+  mmsp2_blit_regs[MESGDSTADDR] = 0x3101000;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = 0;
+  mmsp2_blit_regs[MESGSRCCTRL] = 0;
+  mmsp2_blit_regs[MESGPATCTRL] = 0;
+  mmsp2_blit_regs[MESGSIZE] = (1 << MESG_HEIGHT) | 1;
+  mmsp2_blit_regs[MESGCTRL] = (MESG_XDIR_POS) | (MESG_YDIR_POS) | 0xaa;
+  asm volatile ("" ::: "memory");
+  mmsp2_blit_regs[MESGSTATUS] = 1;
+}
+
+////
+// Wait for vertical retrace
+static void WaitVBL(_THIS)
+{
+  // Make sure the blitter has finished
+  dummy_blit();
+  // Now wait for vsync to start
+  do {} while (!(mmsp2_regs[GPIOB_PINLVL] & GPIOB_VSYNC));
+  // Wait for it to stop
+  do {} while ((mmsp2_regs[GPIOB_PINLVL] & GPIOB_VSYNC));
+}
+
+////
+// Sets video mem colorkey and accelerated blit function */
+static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
+{
+  surface->format->colorkey = key;
+  return 0;
+}
+
+////
+// Sets per surface hardware alpha value
+//  Alpha-blending is only available between layers
+static int SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
+{
+  surface->format->alpha = value;
+  return 0;
+}
+
+////
+// Hardware accelerated RectFill
+static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 colour)
+{
+  Uint32 dstctrl;
+  Uint32 dest;
+
+  // Don't blit to the display surface when switched away (legacy)
+  if ( dst == this->screen ) {
+    SDL_mutexP(hw_lock);
+  }
+
+  switch (dst->format->BytesPerPixel) {
+  case 1:
+    dstctrl = MESG_DSTBPP_8 | ((rect->x & 0x3) << 3);
+    dest = mmsp2_addr(dst->pixels) + (rect->y * dst->pitch) + rect->x;
+    break;
+  case 2:
+    dstctrl = MESG_DSTBPP_16 | (rect->x & 0x1) << 4;
+    dest = mmsp2_addr(dst->pixels) + (rect->y * dst->pitch) + (rect->x << 1);
+    break;
+  default:
+#ifdef FBACCEL_DEBUG
+    fprintf(stderr, "HW_Fill attempted on surface with %d bpp\n",
+	    dst->format->BitsPerPixel);
+#endif
+    return -1;
+    break;
+  }
+#ifdef FBACCEL_DEBUG
+  fprintf(stderr, "dstctrl = 0x%X, dest = 0x%X, stride =%d, colour = %4X\n",
+	  dstctrl, dest, dst->pitch, colour);
+#endif
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+  mmsp2_blit_regs[MESGDSTCTRL] = dstctrl;
+  mmsp2_blit_regs[MESGDSTADDR] = dest & 0xfffffffc;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = dst->pitch;
+  mmsp2_blit_regs[MESGPATCTRL] = MESG_PATENB | MESG_PATBPP_1;
+  mmsp2_blit_regs[MESGFORCOLOR] = colour;
+  mmsp2_blit_regs[MESGBACKCOLOR] = colour;
+  mmsp2_blit_regs[MESGSIZE] = (rect->h << MESG_HEIGHT) | rect->w;
+  mmsp2_blit_regs[MESGCTRL] = (MESG_XDIR_POS) | (MESG_YDIR_POS) | 0xf0;
+  asm volatile ("":::"memory"); // Imperative that MESGSTATUS is written last
+  mmsp2_blit_regs[MESGSTATUS] = 0x01;
+ 
+  FB_AddBusySurface(dst);
+
+  if ( dst == this->screen ) {
+    SDL_mutexV(hw_lock);
+  }
+  
+  return 0;
+}
+
+////
+// Hardware accelerated blit. Only 1->8, 1->16, 8->8, 16->16
+static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                       SDL_Surface *dst, SDL_Rect *dstrect)
+{
+  SDL_VideoDevice *this = current_video;
+  int w, h;
+  int srcX, srcY;
+  int srcstride, dststride;
+  int dstX, dstY;
+  Uint32 control;
+  Uint32 srcstart, dststart;
+  Uint32 srcctrl, dstctrl;
+
+  // Don't blit to the display surface when switched away
+  if (dst == this->screen) {
+    SDL_mutexP(hw_lock);
+  }
+  
+  // generate blitting parameters
+  srcX = srcrect->x;
+  srcY = srcrect->y;
+  dstX = dstrect->x;
+  dstY = dstrect->y;
+  w = srcrect->w;
+  h = srcrect->h;
+  srcstride = src->pitch;
+  dststride = dst->pitch;
+
+  // set ROP & colourkey
+  control = MESG_ROP_SRC;
+  if (src->flags & SDL_SRCCOLORKEY)
+    control |= MESG_TRANSPEN | (src->format->colorkey << MESG_TRANSPCOLOR);
+
+  // Set up the blit direction (in control) flags */
+  //  if x-pos of src is before x-pos of dst then blit right to left
+  if (srcX >= dstX)
+    control |= MESG_XDIR_POS;
+  else {
+    srcX += (w - 1);
+    dstX += (w - 1);
+  }
+  //  likewise, with y-pos. This is to cater for overlapping blits
+  if (srcY >= dstY)
+    control |= MESG_YDIR_POS;
+  else {
+    srcY += (h - 1);
+    dstY += (h - 1);
+    srcstride = -srcstride;
+    dststride = -dststride;
+  }
+  
+  // Set up the blit addresses, and control (32-bit alignment pixels)
+  if (src->format->BitsPerPixel == 8) {
+    srcstart = mmsp2_addr(src->pixels) + (srcY * src->pitch) + srcX;
+    srcctrl = MESG_SRCBPP_8 | (srcX & 0x3) << 3;
+  } else {
+    srcstart = mmsp2_addr(src->pixels) + (srcY * src->pitch) + (srcX << 1);
+    srcctrl = MESG_SRCBPP_16 | (srcX & 0x1) << 4;
+  }
+  if (dst->format->BitsPerPixel == 8) {
+    dststart = mmsp2_addr(dst->pixels) + (dstY * dst->pitch) + dstX;
+    dstctrl = MESG_DSTBPP_8 | (dstX & 0x3) << 3;
+  } else {
+    dststart = mmsp2_addr(dst->pixels) + (dstY * dst->pitch) + (dstX << 1);
+    dstctrl = MESG_DSTBPP_16 | (dstX & 0x1) << 4;
+  }
+#ifdef FBACCEL_DEBUG
+  fprintf(stderr, "srcctrl = 0x%X, (%d,%d) x (%d,%d)\n",
+	  srcctrl, srcX, srcY, w, h);
+  fprintf(stderr, "dstctrl = 0x%X, (%d,%d) x (%d,%d)\n",
+	  dstctrl, dstX, dstY, dstrect->w, dstrect->h);
+  fprintf(stderr, "control = %X\n", control);
+#endif
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+  mmsp2_blit_regs[MESGDSTCTRL] = dstctrl;
+  mmsp2_blit_regs[MESGDSTADDR] = dststart & 0xfffffffc;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = dststride;
+  mmsp2_blit_regs[MESGSRCCTRL] = MESG_SRCENB | MESG_INVIDEO | srcctrl;
+  mmsp2_blit_regs[MESGSRCADDR] = srcstart & 0xfffffffc;
+  mmsp2_blit_regs[MESGSRCSTRIDE] = srcstride;
+  mmsp2_blit_regs[MESGPATCTRL] = 0;
+  mmsp2_blit_regs[MESGSIZE] = (h << MESG_HEIGHT) | w;
+  mmsp2_blit_regs[MESGCTRL] = control;
+  asm volatile ("":::"memory");
+  mmsp2_blit_regs[MESGSTATUS] = 0x01;
+  
+  FB_AddBusySurface(src);
+  FB_AddBusySurface(dst);
+  
+  if (dst == this->screen) {
+    SDL_mutexV(hw_lock);
+  }
+  return(0);
+}
+
+////
+// Check that blit can be accelerated
+static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+  int accelerated;
+
+  /* Set initial acceleration on */
+  src->flags |= SDL_HWACCEL;
+  
+  /* Set the surface attributes */
+  if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
+    if (!this->info.blit_hw_A) {
+      src->flags &= ~SDL_HWACCEL;
+    }
+  }
+  if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
+    if (!this->info.blit_hw_CC) {
+      src->flags &= ~SDL_HWACCEL;
+    }
+  }
+  
+  /* Check to see if final surface blit is accelerated */
+  accelerated = !!(src->flags & SDL_HWACCEL);
+  if (accelerated) {
+    src->map->hw_blit = HWAccelBlit;
+  }
+  return accelerated;
+}
+
+void FB_GP2XAccel(_THIS, __u32 card)
+{
+  // We have hardware accelerated surface functions
+  this->CheckHWBlit = CheckHWBlit;
+  wait_vbl = WaitVBL;
+  wait_idle = WaitIdle;
+  
+  /* The MMSP2 has an accelerated color fill */
+  this->info.blit_fill = 1;
+  this->FillHWRect = FillHWRect;
+  
+  /* The MMSP2 has accelerated normal and colorkey blits. */
+  this->info.blit_hw = 1;
+  this->info.blit_hw_CC = 1;
+  this->SetHWColorKey = SetHWColorKey;
+
+  /* The MMSP2 doesn't have an accelerated alpha blit */
+  //  this->info.blit_hw_A = 1;
+  //  this->SetHWAlpha = SetHWAlpha;
+}
diff -urN SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.h
--- SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbgp2x.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,38 @@
+/*
+	SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+/* MMSP2 hardware acceleration for the SDL framebuffer console driver */
+
+#include "SDL_fbvideo.h"
+
+/* base for mmsp io registers */
+extern Uint16 volatile *mmsp2_regs;
+extern Uint32 volatile *mmsp2_blit_regs;
+
+/* Set up the driver for MMSP2 acceleration */
+extern void FB_GP2XAccel(_THIS, __u32 card);
+extern void GP2X_SetScreen(Uint32 addr);
diff -urN SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.c
--- SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.c	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.c	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,301 @@
+/*
+	SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+/*
+ * Hardware accelerated framebuffer for the GP2X.
+ *   Liberties are taken as the current /dev/fb is restrictive.
+ *   /dev/fb is only used to determine base fb memory, after that
+ *   all graphics hardware is accessed directly.
+ */
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_fbgp2x.h"
+#include "mmsp2_regs.h"
+
+Uint16 volatile *mmsp2_regs;
+Uint32 volatile *mmsp2_blit_regs;
+
+
+/* Set video addr */
+void MMSP2_SetScreen(Uint32 addr)
+{
+  mmsp2_regs[MLC_STL_OADRL] = addr & 0xffff;
+  mmsp2_regs[MLC_STL_OADRH] = addr >> 16;
+  addr += 640;
+  mmsp2_regs[MLC_STL_EADRL] = addr & 0xffff;
+  mmsp2_regs[MLC_STL_EADRH] = addr >> 16;
+}
+
+////
+// dummy blit to force MMSP2's blitter to flush it's cache
+static void dummy_blit(void)
+{
+#ifdef FBACCEL_DEBUG
+  fputs("SDL: dummy_blit\n", stderr);
+#endif
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+  mmsp2_blit_regs[MESGDSTCTRL] = MESG_DSTBPP_16 | MESG_DSTENB;
+  mmsp2_blit_regs[MESGDSTADDR] = 0x3101000;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = 0;
+  mmsp2_blit_regs[MESGSRCCTRL] = 0;
+  mmsp2_blit_regs[MESGPATCTRL] = 0;
+  mmsp2_blit_regs[MESGSIZE] = (1 << MESG_HEIGHT) | 1;
+  mmsp2_blit_regs[MESGCTRL] = (MESG_XDIR_POS) | (MESG_YDIR_POS) | 0xaa;
+  asm volatile ("" ::: "memory");
+  mmsp2_blit_regs[MESGSTATUS] = 1;
+}
+
+////
+// Wait for vertical retrace
+static void WaitVBL(_THIS)
+{
+  // Make sure the blitter has finished
+  dummy_blit();
+  // Now wait for vsync to start
+  do {} while (!(mmsp2_regs[GPIOB_PINLVL] & GPIOB_VSYNC));
+  // Wait for it to stop
+  do {} while ((mmsp2_regs[GPIOB_PINLVL] & GPIOB_VSYNC));
+}
+
+////
+// Sets video mem colorkey and accelerated blit function */
+static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
+{
+  surface->format->colorkey = key;
+  return 0;
+}
+
+////
+// Sets per surface hardware alpha value
+//  Alpha-blending is only available between layers
+static int SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
+{
+  surface->format->alpha = value;
+  return 0;
+}
+
+////
+// Hardware accelerated RectFill
+static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 colour)
+{
+  Uint32 dstctrl;
+  Uint32 dest;
+
+  // Don't blit to the display surface when switched away (legacy)
+  if ( dst == this->screen ) {
+    SDL_mutexP(hw_lock);
+  }
+
+  switch (dst->format->BytesPerPixel) {
+  case 1:
+    dstctrl = MESG_DSTBPP_8 | ((rect->x & 0x3) << 3);
+    dest = mmsp2_addr(dst->pixels) + (rect->y * dst->pitch) + rect->x;
+    break;
+  case 2:
+    dstctrl = MESG_DSTBPP_16 | (rect->x & 0x1) << 4;
+    dest = mmsp2_addr(dst->pixels) + (rect->y * dst->pitch) + (rect->x << 1);
+    break;
+  default:
+#ifdef FBACCEL_DEBUG
+    fprintf(stderr, "HW_Fill attempted on surface with %d bpp\n",
+	    dst->format->BitsPerPixel);
+#endif
+    return -1;
+    break;
+  }
+#ifdef FBACCEL_DEBUG
+  fprintf(stderr, "dstctrl = 0x%X, dest = 0x%X, stride =%d, colour = %4X\n",
+	  dstctrl, dest, dst->pitch, colour);
+#endif
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+  mmsp2_blit_regs[MESGDSTCTRL] = dstctrl;
+  mmsp2_blit_regs[MESGDSTADDR] = dest & 0xfffffffc;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = dst->pitch;
+  mmsp2_blit_regs[MESGPATCTRL] = MESG_PATENB | MESG_PATBPP_1;
+  mmsp2_blit_regs[MESGFORCOLOR] = colour;
+  mmsp2_blit_regs[MESGBACKCOLOR] = colour;
+  mmsp2_blit_regs[MESGSIZE] = (rect->h << MESG_HEIGHT) | rect->w;
+  mmsp2_blit_regs[MESGCTRL] = (MESG_XDIR_POS) | (MESG_YDIR_POS) | 0xf0;
+  asm volatile ("":::"memory"); // Imperative that MESGSTATUS is written last
+  mmsp2_blit_regs[MESGSTATUS] = 0x01;
+ 
+  FB_AddBusySurface(dst);
+
+  if ( dst == this->screen ) {
+    SDL_mutexV(hw_lock);
+  }
+  
+  return 0;
+}
+
+////
+// Hardware accelerated blit. Only 1->8, 1->16, 8->8, 16->16
+static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                       SDL_Surface *dst, SDL_Rect *dstrect)
+{
+  SDL_VideoDevice *this = current_video;
+  int w, h;
+  int srcX, srcY;
+  int srcstride, dststride;
+  int dstX, dstY;
+  Uint32 control;
+  Uint32 srcstart, dststart;
+  Uint32 srcctrl, dstctrl;
+
+  // Don't blit to the display surface when switched away
+  if (dst == this->screen) {
+    SDL_mutexP(hw_lock);
+  }
+  
+  // generate blitting parameters
+  srcX = srcrect->x;
+  srcY = srcrect->y;
+  dstX = dstrect->x;
+  dstY = dstrect->y;
+  w = srcrect->w;
+  h = srcrect->h;
+  srcstride = src->pitch;
+  dststride = dst->pitch;
+
+  // set ROP & colourkey
+  control = MESG_ROP_SRC;
+  if (src->flags & SDL_SRCCOLORKEY)
+    control |= MESG_TRANSPEN | (src->format->colorkey << MESG_TRANSPCOLOR);
+
+  // Set up the blit direction (in control) flags */
+  //  if x-pos of src is before x-pos of dst then blit right to left
+  if (srcX >= dstX)
+    control |= MESG_XDIR_POS;
+  else {
+    srcX += (w - 1);
+    dstX += (w - 1);
+  }
+  //  likewise, with y-pos. This is to cater for overlapping blits
+  if (srcY >= dstY)
+    control |= MESG_YDIR_POS;
+  else {
+    srcY += (h - 1);
+    dstY += (h - 1);
+    srcstride = -srcstride;
+    dststride = -dststride;
+  }
+  
+  // Set up the blit addresses, and control (32-bit alignment pixels)
+  if (src->format->BitsPerPixel == 8) {
+    srcstart = mmsp2_addr(src->pixels) + (srcY * src->pitch) + srcX;
+    srcctrl = MESG_SRCBPP_8 | (srcX & 0x3) << 3;
+  } else {
+    srcstart = mmsp2_addr(src->pixels) + (srcY * src->pitch) + (srcX << 1);
+    srcctrl = MESG_SRCBPP_16 | (srcX & 0x1) << 4;
+  }
+  if (dst->format->BitsPerPixel == 8) {
+    dststart = mmsp2_addr(dst->pixels) + (dstY * dst->pitch) + dstX;
+    dstctrl = MESG_DSTBPP_8 | (dstX & 0x3) << 3;
+  } else {
+    dststart = mmsp2_addr(dst->pixels) + (dstY * dst->pitch) + (dstX << 1);
+    dstctrl = MESG_DSTBPP_16 | (dstX & 0x1) << 4;
+  }
+#ifdef FBACCEL_DEBUG
+  fprintf(stderr, "srcctrl = 0x%X, (%d,%d) x (%d,%d)\n",
+	  srcctrl, srcX, srcY, w, h);
+  fprintf(stderr, "dstctrl = 0x%X, (%d,%d) x (%d,%d)\n",
+	  dstctrl, dstX, dstY, dstrect->w, dstrect->h);
+  fprintf(stderr, "control = %X\n", control);
+#endif
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+  mmsp2_blit_regs[MESGDSTCTRL] = dstctrl;
+  mmsp2_blit_regs[MESGDSTADDR] = dststart & 0xfffffffc;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = dststride;
+  mmsp2_blit_regs[MESGSRCCTRL] = MESG_SRCENB | MESG_INVIDEO | srcctrl;
+  mmsp2_blit_regs[MESGSRCADDR] = srcstart & 0xfffffffc;
+  mmsp2_blit_regs[MESGSRCSTRIDE] = srcstride;
+  mmsp2_blit_regs[MESGPATCTRL] = 0;
+  mmsp2_blit_regs[MESGSIZE] = (h << MESG_HEIGHT) | w;
+  mmsp2_blit_regs[MESGCTRL] = control;
+  asm volatile ("":::"memory");
+  mmsp2_blit_regs[MESGSTATUS] = 0x01;
+  
+  FB_AddBusySurface(src);
+  FB_AddBusySurface(dst);
+  
+  if (dst == this->screen) {
+    SDL_mutexV(hw_lock);
+  }
+  return(0);
+}
+
+////
+// Check that blit can be accelerated
+static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+  int accelerated;
+
+  /* Set initial acceleration on */
+  src->flags |= SDL_HWACCEL;
+  
+  /* Set the surface attributes */
+  if ((src->flags & SDL_SRCALPHA) == SDL_SRCALPHA) {
+    if (!this->info.blit_hw_A) {
+      src->flags &= ~SDL_HWACCEL;
+    }
+  }
+  if ((src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY) {
+    if (!this->info.blit_hw_CC) {
+      src->flags &= ~SDL_HWACCEL;
+    }
+  }
+  
+  /* Check to see if final surface blit is accelerated */
+  accelerated = !!(src->flags & SDL_HWACCEL);
+  if (accelerated) {
+    src->map->hw_blit = HWAccelBlit;
+  }
+  return accelerated;
+}
+
+void FB_GP2XAccel(_THIS, __u32 card)
+{
+  // We have hardware accelerated surface functions
+  this->CheckHWBlit = CheckHWBlit;
+  wait_vbl = WaitVBL;
+  wait_idle = WaitIdle;
+  
+  /* The MMSP2 has an accelerated color fill */
+  this->info.blit_fill = 1;
+  this->FillHWRect = FillHWRect;
+  
+  /* The MMSP2 has accelerated normal and colorkey blits. */
+  this->info.blit_hw = 1;
+  this->info.blit_hw_CC = 1;
+  this->SetHWColorKey = SetHWColorKey;
+
+  /* The MMSP2 doesn't have an accelerated alpha blit */
+  //  this->info.blit_hw_A = 1;
+  //  this->SetHWAlpha = SetHWAlpha;
+}
diff -urN SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.h
--- SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,38 @@
+/*
+	SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+/* MMSP2 hardware acceleration for the SDL framebuffer console driver */
+
+#include "SDL_fbvideo.h"
+
+/* base for mmsp io registers */
+extern Uint16 volatile *mmsp2_regs;
+extern Uint32 volatile *mmsp2_blit_regs;
+
+/* Set up the driver for MMSP2 acceleration */
+extern void FB_MMSP2Accel(_THIS, __u32 card);
+extern void MMSP2_SetScreen(Uint32 addr);
diff -urN SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.s /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.s
--- SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.s	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbmmsp2.s	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,3 @@
+	.file	"SDL_fbmmsp2.c"
+	.ident	"GCC: (GNU) 4.0.2 20051125 (Red Hat 4.0.2-8)"
+	.section	.note.GNU-stack,"",@progbits
diff -urN SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c
--- SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c	2005-02-12 19:03:54.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c	2006-05-19 09:11:11.000000000 +0200
@@ -50,7 +50,7 @@
 #include "SDL_fb3dfx.h"
 #include "SDL_fbmatrox.h"
 #include "SDL_fbriva.h"
-
+#include "SDL_fbgp2x.h"
 
 #if defined(i386) && defined(FB_TYPE_VGA_PLANES)
 #define VGA16_FBCON_SUPPORT
@@ -394,7 +394,7 @@
 			FB_VideoQuit(this);
 			return(-1);
 	}
-
+#if 0
 	/* Check if the user wants to disable hardware acceleration */
 	{ const char *fb_accel;
 		fb_accel = getenv("SDL_FBACCEL");
@@ -402,7 +402,7 @@
 			finfo.accel = atoi(fb_accel);
 		}
 	}
-
+#endif
 	/* Memory map the device, compensating for buggy PPC mmap() */
 	mapped_offset = (((long)finfo.smem_start) -
 	                (((long)finfo.smem_start)&~(PAGE_SIZE-1)));
@@ -440,10 +440,10 @@
 		vformat->Bmask |= (0x00000001<<vinfo.blue.offset);
 	}
 	saved_vinfo = vinfo;
-
+#if 0
 	/* Save hardware palette, if needed */
 	FB_SavePalette(this, &finfo, &vinfo);
-
+#endif
 	/* If the I/O registers are available, memory map them so we
 	   can take advantage of any supported hardware acceleration.
 	 */
@@ -493,6 +493,7 @@
 	this->info.wm_available = 0;
 	this->info.hw_available = 1;
 	this->info.video_mem = finfo.smem_len/1024;
+#if 0
 	if ( mapped_io ) {
 		switch (finfo.accel) {
 		    case FB_ACCEL_MATROX_MGA2064W:
@@ -527,12 +528,14 @@
 			break;
 		}
 	}
+#endif
 
 	/* Enable mouse and keyboard support */
 	if ( FB_OpenKeyboard(this) < 0 ) {
 		FB_VideoQuit(this);
 		return(-1);
 	}
+#if 0
 	if ( FB_OpenMouse(this) < 0 ) {
 		const char *sdl_nomouse;
 
@@ -543,7 +546,7 @@
 			return(-1);
 		}
 	}
-
+#endif
 	/* We're done! */
 	return(0);
 }
@@ -695,10 +698,10 @@
 	fprintf(stderr, "Printing actual finfo:\n");
 	print_finfo(&finfo);
 #endif
-
+#if 0
 	/* Save hardware palette, if needed */
 	FB_SavePalette(this, &finfo, &vinfo);
-
+#endif
 	/* Set up the new mode framebuffer */
 	current->flags = SDL_FULLSCREEN;
 	current->w = vinfo.xres;
@@ -730,10 +733,10 @@
 	if ( FB_EnterGraphicsMode(this) < 0 ) {
 		return(NULL);
 	}
-
+#if 0
 	/* Restore the original palette */
 	FB_RestorePalette(this);
-
+#endif
 	/* Set the video mode and get the final screen format */
 	if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
 		SDL_SetError("Couldn't get console screen info");
@@ -821,10 +824,10 @@
 		SDL_SetError("Couldn't get console hardware info");
 		return(NULL);
 	}
-
+#if 0
 	/* Save hardware palette, if needed */
 	FB_SavePalette(this, &finfo, &vinfo);
-
+#endif
 	/* Set up the new mode framebuffer */
 	current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
 	current->w = vinfo.xres;
@@ -1422,7 +1425,7 @@
 
 	if ( this->screen ) {
 		/* Clear screen and tell SDL not to free the pixels */
-		if ( this->screen->pixels && FB_InGraphicsMode(this) ) {
+		if ( this->screen->pixels ) {
 #if defined(__powerpc__) || defined(__ia64__)	/* SIGBUS when using memset() ?? */
 			Uint8 *rowp = (Uint8 *)this->screen->pixels;
 			int left = this->screen->pitch*this->screen->h;
@@ -1469,17 +1472,19 @@
 			munmap(mapped_io, mapped_iolen);
 			mapped_io = NULL;
 		}
-
+#if 0
 		/* Restore the original video mode and palette */
 		if ( FB_InGraphicsMode(this) ) {
 			FB_RestorePalette(this);
 			ioctl(console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo);
 		}
-
+#endif
 		/* We're all done with the framebuffer */
 		close(console_fd);
 		console_fd = -1;
 	}
+#if 0
 	FB_CloseMouse(this);
+#endif
 	FB_CloseKeyboard(this);
 }
diff -urN SDL-1.2.9/src/video/gem/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gem/Makefile.in
--- SDL-1.2.9/src/video/gem/Makefile.in	2005-08-28 08:32:02.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gem/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_gem_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/ggi/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/ggi/Makefile.in
--- SDL-1.2.9/src/video/ggi/Makefile.in	2005-08-28 08:32:02.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/ggi/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_ggi_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
Binary files SDL-1.2.9/src/video/gp2x/.libs/libvideo_gp2x.a and /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/.libs/libvideo_gp2x.a differ
diff -urN SDL-1.2.9/src/video/gp2x/Makefile.am /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/Makefile.am
--- SDL-1.2.9/src/video/gp2x/Makefile.am	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/Makefile.am	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,15 @@
+
+## Makefile.am for SDL using the gp2x video driver
+
+noinst_LTLIBRARIES = libvideo_gp2x.la
+libvideo_gp2x_la_SOURCES = $(gp2x_SRCS)
+
+# The SDL gp2x video driver sources
+gp2x_SRCS = 			\
+	SDL_gp2xvideo.h		\
+	SDL_gp2xevents.c	\
+	SDL_gp2xevents_c.h	\
+	SDL_gp2xmouse.c		\
+	SDL_gp2xmouse_c.h	\
+	SDL_gp2xvideo.c
+
diff -urN SDL-1.2.9/src/video/gp2x/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/Makefile.in
--- SDL-1.2.9/src/video/gp2x/Makefile.in	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,541 @@
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
+# @configure_input@
+
+# Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
+# 2003, 2004, 2005  Free Software Foundation, Inc.
+# This Makefile.in is free software; the Free Software Foundation
+# gives unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+SOURCES = $(libvideo_gp2x_la_SOURCES)
+
+srcdir = @srcdir@
+top_srcdir = @top_srcdir@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+top_builddir = ../../..
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+INSTALL = @INSTALL@
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+target_triplet = @target@
+subdir = src/video/gp2x
+DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/acinclude.m4 \
+	$(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+	$(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+LTLIBRARIES = $(noinst_LTLIBRARIES)
+libvideo_gp2x_la_LIBADD =
+am__objects_1 = SDL_gp2xevents.lo SDL_gp2xmouse.lo SDL_gp2xvideo.lo
+am_libvideo_gp2x_la_OBJECTS = $(am__objects_1)
+libvideo_gp2x_la_OBJECTS = $(am_libvideo_gp2x_la_OBJECTS)
+DEFAULT_INCLUDES = -I. -I$(srcdir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+	$(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+LTCOMPILE = $(LIBTOOL) --tag=CC --mode=compile $(CC) $(DEFS) \
+	$(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) \
+	$(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+	$(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libvideo_gp2x_la_SOURCES)
+DIST_SOURCES = $(libvideo_gp2x_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+ALLOCA = @ALLOCA@
+ALSA_CFLAGS = @ALSA_CFLAGS@
+ALSA_LIBS = @ALSA_LIBS@
+AMDEP_FALSE = @AMDEP_FALSE@
+AMDEP_TRUE = @AMDEP_TRUE@
+AMTAR = @AMTAR@
+AR = @AR@
+ARCH = @ARCH@
+ARTSCCONFIG = @ARTSCCONFIG@
+AS = @AS@
+ASFLAGS = @ASFLAGS@
+AUDIO_DRIVERS = @AUDIO_DRIVERS@
+AUDIO_SUBDIRS = @AUDIO_SUBDIRS@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCAS = @CCAS@
+CCASFLAGS = @CCASFLAGS@
+CCDEPMODE = @CCDEPMODE@
+CDROM_DRIVERS = @CDROM_DRIVERS@
+CDROM_SUBDIRS = @CDROM_SUBDIRS@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CXX = @CXX@
+CXXCPP = @CXXCPP@
+CXXDEPMODE = @CXXDEPMODE@
+CXXFLAGS = @CXXFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+DIRECTFB_CFLAGS = @DIRECTFB_CFLAGS@
+DIRECTFB_LIBS = @DIRECTFB_LIBS@
+DLLTOOL = @DLLTOOL@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+ENABLE_SHARED_FALSE = @ENABLE_SHARED_FALSE@
+ENABLE_SHARED_TRUE = @ENABLE_SHARED_TRUE@
+ENABLE_STATIC_FALSE = @ENABLE_STATIC_FALSE@
+ENABLE_STATIC_TRUE = @ENABLE_STATIC_TRUE@
+ESD_CFLAGS = @ESD_CFLAGS@
+ESD_CONFIG = @ESD_CONFIG@
+ESD_LIBS = @ESD_LIBS@
+EXEEXT = @EXEEXT@
+F77 = @F77@
+FFLAGS = @FFLAGS@
+HAVE_NASM_FALSE = @HAVE_NASM_FALSE@
+HAVE_NASM_TRUE = @HAVE_NASM_TRUE@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+JOYSTICK_DRIVERS = @JOYSTICK_DRIVERS@
+JOYSTICK_SUBDIRS = @JOYSTICK_SUBDIRS@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+LT_AGE = @LT_AGE@
+LT_CURRENT = @LT_CURRENT@
+LT_RELEASE = @LT_RELEASE@
+LT_REVISION = @LT_REVISION@
+MAKEINFO = @MAKEINFO@
+NASM = @NASM@
+NASMFLAGS = @NASMFLAGS@
+OBJC = @OBJC@
+OBJCDEPMODE = @OBJCDEPMODE@
+OBJCFLAGS = @OBJCFLAGS@
+OBJDUMP = @OBJDUMP@
+OBJEXT = @OBJEXT@
+OSMESA_CONFIG = @OSMESA_CONFIG@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PKG_CONFIG = @PKG_CONFIG@
+PTH_CONFIG = @PTH_CONFIG@
+RANLIB = @RANLIB@
+SDL_BINARY_AGE = @SDL_BINARY_AGE@
+SDL_CFLAGS = @SDL_CFLAGS@
+SDL_EXTRADIRS = @SDL_EXTRADIRS@
+SDL_EXTRALIBS = @SDL_EXTRALIBS@
+SDL_INTERFACE_AGE = @SDL_INTERFACE_AGE@
+SDL_LIBS = @SDL_LIBS@
+SDL_MAJOR_VERSION = @SDL_MAJOR_VERSION@
+SDL_MICRO_VERSION = @SDL_MICRO_VERSION@
+SDL_MINOR_VERSION = @SDL_MINOR_VERSION@
+SDL_RLD_FLAGS = @SDL_RLD_FLAGS@
+SDL_STATIC_LIBS = @SDL_STATIC_LIBS@
+SDL_VERSION = @SDL_VERSION@
+SET_MAKE = @SET_MAKE@
+SHARED_SYSTEM_LIBS = @SHARED_SYSTEM_LIBS@
+SHELL = @SHELL@
+STATIC_SYSTEM_LIBS = @STATIC_SYSTEM_LIBS@
+STRIP = @STRIP@
+SYSTEM_LIBS = @SYSTEM_LIBS@
+TARGET_AIX_FALSE = @TARGET_AIX_FALSE@
+TARGET_AIX_TRUE = @TARGET_AIX_TRUE@
+TARGET_BEOS_FALSE = @TARGET_BEOS_FALSE@
+TARGET_BEOS_TRUE = @TARGET_BEOS_TRUE@
+TARGET_BSDI_FALSE = @TARGET_BSDI_FALSE@
+TARGET_BSDI_TRUE = @TARGET_BSDI_TRUE@
+TARGET_FREEBSD_FALSE = @TARGET_FREEBSD_FALSE@
+TARGET_FREEBSD_TRUE = @TARGET_FREEBSD_TRUE@
+TARGET_IRIX_FALSE = @TARGET_IRIX_FALSE@
+TARGET_IRIX_TRUE = @TARGET_IRIX_TRUE@
+TARGET_LINUX_FALSE = @TARGET_LINUX_FALSE@
+TARGET_LINUX_TRUE = @TARGET_LINUX_TRUE@
+TARGET_MACOSX_FALSE = @TARGET_MACOSX_FALSE@
+TARGET_MACOSX_TRUE = @TARGET_MACOSX_TRUE@
+TARGET_MACOS_FALSE = @TARGET_MACOS_FALSE@
+TARGET_MACOS_TRUE = @TARGET_MACOS_TRUE@
+TARGET_MINT_FALSE = @TARGET_MINT_FALSE@
+TARGET_MINT_TRUE = @TARGET_MINT_TRUE@
+TARGET_NETBSD_FALSE = @TARGET_NETBSD_FALSE@
+TARGET_NETBSD_TRUE = @TARGET_NETBSD_TRUE@
+TARGET_OPENBSD_FALSE = @TARGET_OPENBSD_FALSE@
+TARGET_OPENBSD_TRUE = @TARGET_OPENBSD_TRUE@
+TARGET_QNX_FALSE = @TARGET_QNX_FALSE@
+TARGET_QNX_TRUE = @TARGET_QNX_TRUE@
+TARGET_QTOPIA_FALSE = @TARGET_QTOPIA_FALSE@
+TARGET_QTOPIA_TRUE = @TARGET_QTOPIA_TRUE@
+TARGET_SOLARIS_FALSE = @TARGET_SOLARIS_FALSE@
+TARGET_SOLARIS_TRUE = @TARGET_SOLARIS_TRUE@
+TARGET_WIN32_FALSE = @TARGET_WIN32_FALSE@
+TARGET_WIN32_TRUE = @TARGET_WIN32_TRUE@
+USE_CLONE_FALSE = @USE_CLONE_FALSE@
+USE_CLONE_TRUE = @USE_CLONE_TRUE@
+USE_DIRECTX_FALSE = @USE_DIRECTX_FALSE@
+USE_DIRECTX_TRUE = @USE_DIRECTX_TRUE@
+VERSION = @VERSION@
+VIDEO_DRIVERS = @VIDEO_DRIVERS@
+VIDEO_SUBDIRS = @VIDEO_SUBDIRS@
+X_CFLAGS = @X_CFLAGS@
+X_EXTRA_LIBS = @X_EXTRA_LIBS@
+X_LIBS = @X_LIBS@
+X_PRE_LIBS = @X_PRE_LIBS@
+ac_ct_AR = @ac_ct_AR@
+ac_ct_AS = @ac_ct_AS@
+ac_ct_CC = @ac_ct_CC@
+ac_ct_CXX = @ac_ct_CXX@
+ac_ct_DLLTOOL = @ac_ct_DLLTOOL@
+ac_ct_F77 = @ac_ct_F77@
+ac_ct_OBJDUMP = @ac_ct_OBJDUMP@
+ac_ct_RANLIB = @ac_ct_RANLIB@
+ac_ct_STRIP = @ac_ct_STRIP@
+alsa_lib = @alsa_lib@
+am__fastdepCC_FALSE = @am__fastdepCC_FALSE@
+am__fastdepCC_TRUE = @am__fastdepCC_TRUE@
+am__fastdepCXX_FALSE = @am__fastdepCXX_FALSE@
+am__fastdepCXX_TRUE = @am__fastdepCXX_TRUE@
+am__fastdepOBJC_FALSE = @am__fastdepOBJC_FALSE@
+am__fastdepOBJC_TRUE = @am__fastdepOBJC_TRUE@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+arts_lib = @arts_lib@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+datadir = @datadir@
+esd_lib = @esd_lib@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+sysconfdir = @sysconfdir@
+target = @target@
+target_alias = @target_alias@
+target_cpu = @target_cpu@
+target_os = @target_os@
+target_vendor = @target_vendor@
+noinst_LTLIBRARIES = libvideo_gp2x.la
+libvideo_gp2x_la_SOURCES = $(gp2x_SRCS)
+
+# The SDL gp2x video driver sources
+gp2x_SRCS = \
+	SDL_gp2xvideo.h		\
+	SDL_gp2xevents.c	\
+	SDL_gp2xevents_c.h	\
+	SDL_gp2xmouse.c		\
+	SDL_gp2xmouse_c.h	\
+	SDL_gp2xvideo.c
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+	@for dep in $?; do \
+	  case '$(am__configure_deps)' in \
+	    *$$dep*) \
+	      cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh \
+		&& exit 0; \
+	      exit 1;; \
+	  esac; \
+	done; \
+	echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign  src/video/gp2x/Makefile'; \
+	cd $(top_srcdir) && \
+	  $(AUTOMAKE) --foreign  src/video/gp2x/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+	@case '$?' in \
+	  *config.status*) \
+	    cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+	  *) \
+	    echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+	    cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+	esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+	cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+clean-noinstLTLIBRARIES:
+	-test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+	@list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+	  dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+	  test "$$dir" != "$$p" || dir=.; \
+	  echo "rm -f \"$${dir}/so_locations\""; \
+	  rm -f "$${dir}/so_locations"; \
+	done
+libvideo_gp2x.la: $(libvideo_gp2x_la_OBJECTS) $(libvideo_gp2x_la_DEPENDENCIES) 
+	$(LINK)  $(libvideo_gp2x_la_LDFLAGS) $(libvideo_gp2x_la_OBJECTS) $(libvideo_gp2x_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+	-rm -f *.$(OBJEXT)
+
+distclean-compile:
+	-rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SDL_gp2xevents.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SDL_gp2xmouse.Plo@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/SDL_gp2xvideo.Plo@am__quote@
+
+.c.o:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c $<
+
+.c.obj:
+@am__fastdepCC_TRUE@	if $(COMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ `$(CYGPATH_W) '$<'`; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Po"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=no @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+.c.lo:
+@am__fastdepCC_TRUE@	if $(LTCOMPILE) -MT $@ -MD -MP -MF "$(DEPDIR)/$*.Tpo" -c -o $@ $<; \
+@am__fastdepCC_TRUE@	then mv -f "$(DEPDIR)/$*.Tpo" "$(DEPDIR)/$*.Plo"; else rm -f "$(DEPDIR)/$*.Tpo"; exit 1; fi
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	source='$<' object='$@' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@	$(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+	-rm -f *.lo
+
+clean-libtool:
+	-rm -rf .libs _libs
+
+distclean-libtool:
+	-rm -f libtool
+uninstall-info-am:
+
+ID: $(HEADERS) $(SOURCES) $(LISP) $(TAGS_FILES)
+	list='$(SOURCES) $(HEADERS) $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	mkid -fID $$unique
+tags: TAGS
+
+TAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	if test -z "$(ETAGS_ARGS)$$tags$$unique"; then :; else \
+	  test -n "$$unique" || unique=$$empty_fix; \
+	  $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+	    $$tags $$unique; \
+	fi
+ctags: CTAGS
+CTAGS:  $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+		$(TAGS_FILES) $(LISP)
+	tags=; \
+	here=`pwd`; \
+	list='$(SOURCES) $(HEADERS)  $(LISP) $(TAGS_FILES)'; \
+	unique=`for i in $$list; do \
+	    if test -f "$$i"; then echo $$i; else echo $(srcdir)/$$i; fi; \
+	  done | \
+	  $(AWK) '    { files[$$0] = 1; } \
+	       END { for (i in files) print i; }'`; \
+	test -z "$(CTAGS_ARGS)$$tags$$unique" \
+	  || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+	     $$tags $$unique
+
+GTAGS:
+	here=`$(am__cd) $(top_builddir) && pwd` \
+	  && cd $(top_srcdir) \
+	  && gtags -i $(GTAGS_ARGS) $$here
+
+distclean-tags:
+	-rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+	@srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; \
+	topsrcdirstrip=`echo "$(top_srcdir)" | sed 's|.|.|g'`; \
+	list='$(DISTFILES)'; for file in $$list; do \
+	  case $$file in \
+	    $(srcdir)/*) file=`echo "$$file" | sed "s|^$$srcdirstrip/||"`;; \
+	    $(top_srcdir)/*) file=`echo "$$file" | sed "s|^$$topsrcdirstrip/|$(top_builddir)/|"`;; \
+	  esac; \
+	  if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+	  dir=`echo "$$file" | sed -e 's,/[^/]*$$,,'`; \
+	  if test "$$dir" != "$$file" && test "$$dir" != "."; then \
+	    dir="/$$dir"; \
+	    $(mkdir_p) "$(distdir)$$dir"; \
+	  else \
+	    dir=''; \
+	  fi; \
+	  if test -d $$d/$$file; then \
+	    if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+	      cp -pR $(srcdir)/$$file $(distdir)$$dir || exit 1; \
+	    fi; \
+	    cp -pR $$d/$$file $(distdir)$$dir || exit 1; \
+	  else \
+	    test -f $(distdir)/$$file \
+	    || cp -p $$d/$$file $(distdir)/$$file \
+	    || exit 1; \
+	  fi; \
+	done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+	@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-am
+install-strip:
+	$(MAKE) $(AM_MAKEFLAGS) INSTALL_PROGRAM="$(INSTALL_STRIP_PROGRAM)" \
+	  install_sh_PROGRAM="$(INSTALL_STRIP_PROGRAM)" INSTALL_STRIP_FLAG=-s \
+	  `test -z '$(STRIP)' || \
+	    echo "INSTALL_PROGRAM_ENV=STRIPPROG='$(STRIP)'"` install
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+	-test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+
+maintainer-clean-generic:
+	@echo "This command is intended for maintainers to use"
+	@echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLTLIBRARIES \
+	mostlyclean-am
+
+distclean: distclean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+	distclean-libtool distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-exec-am:
+
+install-info: install-info-am
+
+install-man:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+	-rm -rf ./$(DEPDIR)
+	-rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+	mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-info-am
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+	clean-libtool clean-noinstLTLIBRARIES ctags distclean \
+	distclean-compile distclean-generic distclean-libtool \
+	distclean-tags distdir dvi dvi-am html html-am info info-am \
+	install install-am install-data install-data-am install-exec \
+	install-exec-am install-info install-info-am install-man \
+	install-strip installcheck installcheck-am installdirs \
+	maintainer-clean maintainer-clean-generic mostlyclean \
+	mostlyclean-compile mostlyclean-generic mostlyclean-libtool \
+	pdf pdf-am ps ps-am tags uninstall uninstall-am \
+	uninstall-info-am
+
+# Tell versions [3.59,3.63) of GNU make to not export all variables.
+# Otherwise a system limit (for SysV at least) may be exceeded.
+.NOEXPORT:
diff -urN SDL-1.2.9/src/video/gp2x/mmsp2_regs.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/mmsp2_regs.h
--- SDL-1.2.9/src/video/gp2x/mmsp2_regs.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/mmsp2_regs.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,191 @@
+/*
+ * MMSP2 (MP2520F) Registers
+ *  Only listed needed regs for HW blit stuff
+ *
+ * 2005-12-20 Paeryn
+ */
+  
+
+#ifndef _MMSP2_REG_H_
+#define _MMSP2_REG_H_
+
+/*
+ * Blitter registers
+ */
+
+#define MESGDSTCTRL      (0x0000>>2)
+#define MESG_DSTENB    (1<<6)
+#define MESG_BSTBPP    0x60
+#define MESG_DSTBPP_8  (0<<5)
+#define MESG_DSTBPP_16 (1<<5)
+
+#define MESGDSTADDR      (0x0004>>2)
+#define MESGDSTSTRIDE    (0x0008>>2)
+#define MESGSRCCTRL      (0x000c>>2)
+#define MESG_INVIDEO   (1<<8)
+#define MESG_SRCENB    (1<<7)
+#define MESG_SRCBPP    0x60
+#define MESG_SRCBPP_8  (0<<5)
+#define MESG_SRCBPP_16 (1<<5)
+#define MESG_SRCBPP_1  (1<<6)
+
+#define MESGSRCADDR      (0x0010>>2)
+#define MESGSRCSTRIDE    (0x0014>>2)
+#define MESGSRCFORCOLOR  (0x0018>>2)
+#define MESGSRCBACKCOLOR (0x001c>>2)
+#define MESGPATCTRL      (0x0020>>2)
+#define MESG_PATMONO   (1<<6)
+#define MESG_PATENB    (1<<5)
+#define MESG_PATBPP    0x18
+#define MESG_PATBPP_8  (0<<3)
+#define MESG_PATBPP_16 (1<<3)
+#define MESG_PATBPP_1  (1<<4)
+#define MESG_YOFFSET   0x07
+
+#define MESGFORCOLOR     (0x0024>>2)
+#define MESGBACKCOLOR    (0x0028>>2)
+#define MESGSIZE         (0x002c>>2)
+#define MESG_HEIGHT 16
+#define MESG_WIDTH  0
+
+#define MESGCTRL         (0x0030>>2)
+#define MESG_TRANSPCOLOR 16
+#define MESG_TRANSPEN    (1<<11)
+#define MESG_FFCLR       (1<<10)
+#define MESG_YDIR        (1<<9)
+#define MESG_YDIR_NEG    (0<<9)
+#define MESG_YDIR_POS    (1<<9)
+#define MESG_XDIR        (1<<8)
+#define MESG_XDIR_NEG    (0<<8)
+#define MESG_XDIR_POS    (1<<8)
+#define MESG_ROP         0xff
+
+#define MESGSTATUS       (0x0034>>2)
+#define MESG_BUSY (1<<0)
+
+#define MESGFIFOSTATUS   (0x0038>>2)
+#define MESG_FULL    (1<<31)
+#define MESG_REMAIN  0x1f
+
+#define MESGFIFO         (0x003c>>2)
+#define MESGPAT          (0x0080>>2)
+
+/*
+ * Basic ROPs
+ */
+#define MESG_ROP_NULL 0xAA
+#define MESG_ROP_COPY 0xCC
+#define MESG_ROP_PAT  0xF0
+
+
+/*
+ * Control registers
+ */
+#define SYSCLKENREG   (0x0904>>1)
+#define FASTIOCLK (1<<10)
+
+#define VCLKENREG     (0x090a>>1)
+#define GRPCLK (1<<2)
+
+#define SC_STATUS     (0x1802>>1)
+#define SC_DISP_FIELD (1<<7)
+
+#define GPIOB_PINLVL (0x1182>>1)
+#define GPIOB_VSYNC (1<<4)
+
+#define DPC_CNTL      (0x2800>>1)
+#define DPC_INTERLACE (1<<5)
+#define DPC_X_MAX     (0x2816>>1)
+#define DPC_Y_MAX     (0x2818>>1)
+#define DPC_CLKCNTL   (0x2848>>1)
+
+#define MLC_OVLAY_CNTR (0x2880>>1)
+#define DISP_BOTH_PATH   (1<<15)
+#define DISP_OVLY2SCALE  (1<<14)
+#define DISP_FLD_POL     (1<<13)
+#define DISP_GAMM_BYPATH (1<<12)
+#define DISP_SWAP        (1<<11)
+#define DISP_CURSOR      (1<<9)
+#define DISP_SUBPICTURE  (1<<8)
+#define DISP_OSD         (1<<7)
+#define DISP_STL5EN      (1<<6)
+#define DISP_STL4EN      (1<<5)
+#define DISP_STL3EN      (1<<4)
+#define DISP_STL2EN      (1<<3)
+#define DISP_STL1EN      (1<<2)
+#define DISP_VLBON       (1<<1)
+#define DISP_VLAON       (1<<0)
+
+#define MLC_STL_CNTL  (0x28da>>1)
+#define MLC_STL_BPP 9
+#define MLC_STL_BPP_4 0x00aa
+#define MLC_STL_BPP_8 0x02aa
+#define MLC_STL_BPP_16 0x04aa
+#define MLC_STL_BPP_24 0x06aa
+#define MLC_STL5ACT (1<<8)
+#define MLC_STL4ACT (1<<6)
+#define MLC_STL3ACT (1<<6)
+#define MLC_STL2ACT (1<<4)
+#define MLC_STL1ACT (1<<0)
+#define MLC_STL_DEFAULT 0xaa
+
+#define MLC_STL_MIXMUX    (0x28dc>>1)
+#define MLC_STL5_MIXMUX 8
+#define MLC_STL4_MIXMUX 6
+#define MLC_STL3_MIXMUX 4
+#define MLC_STL2_MIXMUX 2
+#define MLC_STL1_MIXMUX 0
+
+#define MLC_STL_ALPHAL (0x28de>>1)
+#define MLC_STL3_ALPHA 8
+#define MLC_STL2_ALPHA 4
+#define MLC_STL1_ALPHA 0
+
+#define MLC_STL_ALPHAH (0x28e0>>1)
+#define MLC_STL5_ALPHA 4;
+#define MLC_STL4_ALPHA 0;
+
+#define MLC_STL1_STX    (0x28e2>>1)
+#define MLC_STL1_ENDX   (0x28e4>>1)
+#define MLC_STL1_STY    (0x28e6>>1)
+#define MLC_STL1_ENDY   (0x28e8>>1)
+#define MLC_STL2_STX    (0x28ea>>1)
+#define MLC_STL2_ENDX   (0x28ec>>1)
+#define MLC_STL2_STY    (0x28ee>>1)
+#define MLC_STL2_ENDY   (0x28f0>>1)
+#define MLC_STL3_STX    (0x28f2>>1)
+#define MLC_STL3_ENDX   (0x28f4>>1)
+#define MLC_STL3_STY    (0x28f6>>1)
+#define MLC_STL3_ENDY   (0x28f8>>1)
+#define MLC_STL4_STX    (0x28fa>>1)
+#define MLC_STL4_ENDX   (0x28fc>>1)
+#define MLC_STL4_STY    (0x28fe>>1)
+#define MLC_STL4_ENDY   (0x2900>>1)
+#define MLC_STL_CKEY_GB (0x2902>>1)
+#define MLC_STL_CKEYG 8
+#define MLC_STL_CKEYB 0
+#define MLC_STL_CKEY_R  (0x2904>>1)
+#define MLC_STL_HSC     (0x2906>>1)
+#define MLC_STL_VSCL    (0x2908>>1)
+#define MLC_STL_VSCH    (0x290a>>1)
+#define MLC_STL_HW      (0x290c>>1)
+#define MLC_STL_OADRL   (0x290e>>1)
+#define MLC_STL_OADRH   (0x2910>>1)
+#define MLC_STL_EADRL   (0x2912>>1)
+#define MLC_STL_EADRH   (0x2914>>1)
+#define MLC_STL_PALLT_A (0x2958>>1)
+#define MLC_STL_PALLT_D (0x295a>>1)
+
+#define MLC_HWC_CNTL  (0x291e>>1)
+#define MLC_HWC_STX   (0x2920>>1)
+#define MLC_HWC_STY   (0x2922>>1)
+#define MLC_HWC_FGR   (0x2924>>1)
+#define MLC_HWC_FB    (0x2926>>1)
+#define MLC_HWC_BGR   (0x2928>>1)
+#define MLC_HWC_BB    (0x292a>>1)
+#define MLC_HWC_OADRL (0x292c>>1)
+#define MLC_HWC_OADRH (0x292e>>1)
+#define MLC_HWC_EADRL (0x2930>>1)
+#define MLC_HWC_EADRH (0x2932>>1)
+
+#endif
diff -urN SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.c
--- SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.c	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.c	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,289 @@
+/*
+	SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+#include "SDL_types.h"
+#include "SDL_video.h"
+#include "SDL_blit.h"
+#include "SDL_fbmmsp2.h"
+#include "mmsp2_mmio.h"
+#include "mmsp2_regs.h"
+
+Uint16 volatile *mmsp2_regs;
+Uint32 volatile *mmsp2_blit_regs;
+
+
+/* Set video addr */
+void MMSP2_SetScreen(Uint32 addr)
+{
+  mmsp2_regs[MLC_STL_OADRL] = addr & 0xffff;
+  mmsp2_regs[MLC_STL_OADRH] = addr >> 16;
+  addr += 640;
+  mmsp2_regs[MLC_STL_EADRL] = addr & 0xffff;
+  mmsp2_regs[MLC_STL_EADRH] = addr >> 16;
+}
+
+// dummy blit to force MMSP2's blitter to flush it's cache
+static void dummy_blit(void)
+{
+  mmsp2_blit_regs[MESGDSTCTRL] = MESG_DSTBPP_16 | MESG_DSTENB;
+  mmsp2_blit_regs[MESGDSTADDR] = 0x3101000;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = 0;
+  mmsp2_blit_regs[MESGSRCCTRL] = 0;
+  mmsp2_blit_regs[MESGPATCTRL] = 0;
+  mmsp2_blit_regs[MESGSIZE] = (1 << MESG_HEIGHT) | 1;
+  mmsp2_blit_regs[MESGCTRL] = (MESG_XDIR_POS) | (MESG_YDIR_POS) | 0xaa;
+  do {} while (mmsp2_blit_regs[MESGSTATUS] & MESG_BUSY);
+  asm volatile ("" ::: "memory");
+  mmsp2_blit_regs[MESGSTATUS] = 1;
+}
+
+/* Wait for vertical retrace */
+static void WaitVBL(_THIS)
+{
+  dummy_blit();
+  // Now wait for vsync to start
+  do {} while (!(mmsp2_regs[GPIOB_PINLVL] & GPIOB_VSYNC));
+  // Wait for it to stop
+  do {} while ((mmsp2_regs[GPIOB_PINLVL] & GPIOB_VSYNC));
+}
+
+/* Wait for blitter to be free */
+static void WaitIdle(_THIS)
+{
+  mmsp2_waitidle();
+}
+
+/* Sets video mem colorkey and accelerated blit function */
+static int SetHWColorKey(_THIS, SDL_Surface *surface, Uint32 key)
+{
+  surface->format->colorkey = key;
+  return(0);
+}
+
+/* Sets per surface hardware alpha value */
+static int SetHWAlpha(_THIS, SDL_Surface *surface, Uint8 value)
+{
+  surface->format->alpha = value;
+  return(0);
+}
+
+// RectFill via hardware
+static int FillHWRect(_THIS, SDL_Surface *dst, SDL_Rect *rect, Uint32 colour)
+{
+  Uint32 dstctrl;
+  Uint32 dest;
+
+  /* Don't blit to the display surface when switched away */
+  if ( dst == this->screen ) {
+    SDL_mutexP(hw_lock);
+  }
+  switch (dst->format->BytesPerPixel) {
+  case 1:
+    dstctrl = MESG_DSTBPP_8 | ((rect->x & 0x3) << 3);
+    dest = mmsp2_addr(dst->pixels) + (rect->y * dst->pitch) + rect->x;
+#ifdef FBACCEL_DEBUG
+    fputs("8bit fill not yet implemented\n", stderr);
+#endif
+    break;
+  case 2:
+    dstctrl = MESG_DSTBPP_16 | (rect->x & 0x1) << 4;
+    dest = mmsp2_addr(dst->pixels) + (rect->y * dst->pitch) + (rect->x << 1);
+#ifdef FBACCEL_DEBUG
+    fprintf(stderr, "dstctrl = 0x%X, dest = 0x%X, stride =%d, colour = %4X\n",
+	    dstctrl, dest, dst->pitch, colour);
+#endif
+    mmsp2_blit_regs[MESGDSTCTRL] = dstctrl;
+    mmsp2_blit_regs[MESGDSTADDR] = dest & 0xfffffffc;
+    mmsp2_blit_regs[MESGDSTSTRIDE] = dst->pitch;
+    mmsp2_blit_regs[MESGPATCTRL] = MESG_PATENB | MESG_PATBPP_1;
+    mmsp2_blit_regs[MESGFORCOLOR] = colour;
+    mmsp2_blit_regs[MESGBACKCOLOR] = colour;
+    mmsp2_blit_regs[MESGSIZE] = (rect->h << MESG_HEIGHT) | rect->w;
+    mmsp2_blit_regs[MESGCTRL] = (MESG_XDIR_POS) | (MESG_YDIR_POS) | 0xf0;
+
+    // Wait for blitter to be free, then start it.
+    wait_idle(this);
+    asm volatile ("":::"memory");  // Imperative that next line comes last
+    mmsp2_blit_regs[MESGSTATUS] = 0x01;
+    break;
+  default:
+#ifdef FBACCEL_DEBUG
+    fprintf(stderr, "HW_Fill attempted on surface with %d bpp\n",
+	    dst->format->BitsPerPixel);
+#endif
+    break;
+  }
+  
+  FB_AddBusySurface(dst);
+  
+  if ( dst == this->screen ) {
+    SDL_mutexV(hw_lock);
+  }
+
+  return(0);
+}
+
+static int HWAccelBlit(SDL_Surface *src, SDL_Rect *srcrect,
+                       SDL_Surface *dst, SDL_Rect *dstrect)
+{
+  SDL_VideoDevice *this = current_video;
+  int w, h;
+  int srcX, srcY;
+  int srcstride, dststride;
+  int dstX, dstY;
+  Uint32 control;
+  Uint32 srcstart, dststart;
+  Uint32 srcctrl, dstctrl;
+
+  /* Don't blit to the display surface when switched away */
+  if ( dst == this->screen ) {
+    SDL_mutexP(hw_lock);
+  }
+  
+  /* Adjust for the current blit rectangles */
+  srcX = srcrect->x;
+  srcY = srcrect->y;
+  dstX = dstrect->x;
+  dstY = dstrect->y;
+  w = srcrect->w;
+  h = srcrect->h;
+  srcstride = src->pitch;
+  dststride = dst->pitch;
+
+  // set ROP & colourkey
+  control = 0xcc;
+  if (src->flags & SDL_SRCCOLORKEY)
+    control |= MESG_TRANSPEN | (src->format->colorkey << MESG_TRANSPCOLOR);
+  /* Set up the blit direction (in control) flags */
+  if ( srcX >= dstX )
+    control |= MESG_XDIR_POS;
+  else {
+    srcX += (w - 1);
+    dstX += (w - 1);
+  }
+  if ( srcY >= dstY )
+    control |= MESG_YDIR_POS;
+  else {
+    srcY += (h - 1);
+    dstY += (h - 1);
+    srcstride = -srcstride;
+    dststride = -dststride;
+  }
+  
+  /* Set up the blit addresses, and control (32-bit alignment pixels) */
+  if (src->format->BitsPerPixel == 8) {
+    srcstart = mmsp2_addr(src->pixels) + (srcY * src->pitch) + srcX;
+    srcctrl = MESG_SRCBPP_8 | (srcX & 0x3) << 3;
+  } else {
+    srcstart = mmsp2_addr(src->pixels) + (srcY * src->pitch) + (srcX << 1);
+    srcctrl = MESG_SRCBPP_16 | (srcX & 0x1) << 4;
+  }
+  if (dst->format->BitsPerPixel == 8) {
+    dststart = mmsp2_addr(dst->pixels) + (dstY * dst->pitch) + dstX;
+    dstctrl = MESG_DSTBPP_8 | (dstX & 0x3) << 3;
+  } else {
+    dststart = mmsp2_addr(dst->pixels) + (dstY * dst->pitch) + (dstX << 1);
+    dstctrl = MESG_DSTBPP_16 | (dstX & 0x1) << 4;
+  }
+#ifdef FBACCEL_DEBUG
+  fprintf(stderr, "srcctrl = 0x%X, (%d,%d) x (%d,%d)\n",
+	  srcctrl, srcX, srcY, w, h);
+  fprintf(stderr, "dstctrl = 0x%X, (%d,%d) x (%d,%d)\n",
+	  dstctrl, dstX, dstY, dstrect->w, dstrect->h);
+  fprintf(stderr, "control = %X\n", control);
+#endif
+  mmsp2_blit_regs[MESGDSTCTRL] = dstctrl;
+  mmsp2_blit_regs[MESGDSTADDR] = dststart & 0xfffffffc;
+  mmsp2_blit_regs[MESGDSTSTRIDE] = dststride;
+  mmsp2_blit_regs[MESGSRCCTRL] = MESG_SRCENB | MESG_INVIDEO | srcctrl;
+  mmsp2_blit_regs[MESGSRCADDR] = srcstart & 0xfffffffc;
+  mmsp2_blit_regs[MESGSRCSTRIDE] = srcstride;
+  mmsp2_blit_regs[MESGPATCTRL] = 0;
+  mmsp2_blit_regs[MESGSIZE] = (h << MESG_HEIGHT) | w;
+  mmsp2_blit_regs[MESGCTRL] = control;
+  
+  // Wait for blitter to be free, then start it.
+  wait_idle(this);
+  asm volatile ("":::"memory");  // Imperative that next line comes last
+  mmsp2_blit_regs[MESGSTATUS] = 0x01;
+  
+  FB_AddBusySurface(src);
+  FB_AddBusySurface(dst);
+  
+  if ( dst == this->screen ) {
+    SDL_mutexV(hw_lock);
+  }
+  return(0);
+}
+
+static int CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+  int accelerated;
+
+  /* Set initial acceleration on */
+  src->flags |= SDL_HWACCEL;
+  
+  /* Set the surface attributes */
+  if ( (src->flags & SDL_SRCALPHA) == SDL_SRCALPHA ) {
+    if ( ! this->info.blit_hw_A ) {
+      src->flags &= ~SDL_HWACCEL;
+    }
+  }
+  if ( (src->flags & SDL_SRCCOLORKEY) == SDL_SRCCOLORKEY ) {
+    if ( ! this->info.blit_hw_CC ) {
+      src->flags &= ~SDL_HWACCEL;
+    }
+  }
+  
+  /* Check to see if final surface blit is accelerated */
+  accelerated = !!(src->flags & SDL_HWACCEL);
+  if (accelerated) {
+    src->map->hw_blit = HWAccelBlit;
+  }
+  return(accelerated);
+}
+
+void FB_MMSP2Accel(_THIS, __u32 card)
+{
+  /* We have hardware accelerated surface functions */
+  this->CheckHWBlit = CheckHWBlit;
+  wait_vbl = WaitVBL;
+  wait_idle = WaitIdle;
+  
+  /* The MMSP2 has an accelerated color fill */
+  this->info.blit_fill = 1;
+  this->FillHWRect = FillHWRect;
+  
+  /* The MMSP2 has accelerated normal and colorkey blits. */
+  this->info.blit_hw = 1;
+  this->info.blit_hw_CC = 1;
+  this->SetHWColorKey = SetHWColorKey;
+
+  /* The MMSP2 doesn't have an accelerated alpha blit */
+  //  this->info.blit_hw_A = 1;
+  //  this->SetHWAlpha = SetHWAlpha;
+}
diff -urN SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.h
--- SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_fbmmsp2.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,38 @@
+/*
+	SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+/* MMSP2 hardware acceleration for the SDL framebuffer console driver */
+
+#include "SDL_fbvideo.h"
+
+/* base for mmsp io registers */
+extern Uint16 volatile *mmsp2_regs;
+extern Uint32 volatile *mmsp2_blit_regs;
+
+/* Set up the driver for MMSP2 acceleration */
+extern void FB_MMSP2Accel(_THIS, __u32 card);
+extern void MMSP2_SetScreen(Uint32 addr);
diff -urN SDL-1.2.9/src/video/gp2x/SDL_fbvideo.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_fbvideo.c
--- SDL-1.2.9/src/video/gp2x/SDL_fbvideo.c	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_fbvideo.c	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,1618 @@
+/*
+	SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+/* Framebuffer console based SDL video driver implementation.
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/mman.h>
+#include <asm/page.h>		/* For definition of PAGE_SIZE */
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+#include "SDL_fbvideo.h"
+#include "SDL_fbmouse_c.h"
+#include "SDL_fbevents_c.h"
+#if 0 // ghcstop_041123 delete
+#include "SDL_fb3dfx.h"
+#include "SDL_fbmatrox.h"
+#include "SDL_fbriva.h"
+#endif
+
+#define SDL_MMSP2  // Paeryn, unofficial HW accel
+#include "SDL_fbmmsp2.h"
+#include "mmsp2_regs.h"
+int memory_fd;
+
+
+// ghcstop,  SDL_sysideo.h:  #define _THIS        SDL_VideoDevice *_this
+
+/* ghcstop_041124 add
+ *
+ * keyboard, mouse input을 없애는 define, 1이면 enable, 0이면 disable
+ *
+ * mplayer의 20041123이전의 버전에서는 이부분을 0으로 하고 사용할 것
+ * 그 이후버전은 이부분을 1로 하고 SDL_fbevents.c의 #define FB_VT_OPEN 1 // ghcstop add를
+ * 0으로 하고 테스트 하고 있으나 문제점이 발견되네....키 이벤트가 안먹어잉....(test program에서는
+ * - testbitmap.c 잘된다...--;, 20041124) 
+ */
+#define FB_INPUT_DEVICE_ENABLE 1 
+
+
+// ghcstop: 나중에 video setting쪽을 볼때는 SDL_SetError를 printf로 치환해서 볼 것(1.2.5에서는 이렇게 테스트했음)
+#define FBCON_DEBUG 1// ghcstop delete
+
+#if defined(i386) && defined(FB_TYPE_VGA_PLANES)
+#define VGA16_FBCON_SUPPORT
+#ifndef FB_AUX_VGA_PLANES_VGA4
+#define FB_AUX_VGA_PLANES_VGA4	0
+#endif
+static inline void outb (unsigned char value, unsigned short port)
+{
+  __asm__ __volatile__ ("outb %b0,%w1"::"a" (value), "Nd" (port));
+} 
+#endif /* FB_TYPE_VGA_PLANES */
+
+/* A list of video resolutions that we query for (sorted largest to smallest) */
+static const SDL_Rect checkres[] = {
+	{  0, 0, 1600, 1200 },		/* 16 bpp: 0x11E, or 286 */
+	{  0, 0, 1408, 1056 },		/* 16 bpp: 0x19A, or 410 */
+	{  0, 0, 1280, 1024 },		/* 16 bpp: 0x11A, or 282 */
+	{  0, 0, 1152,  864 },		/* 16 bpp: 0x192, or 402 */
+	{  0, 0, 1024,  768 },		/* 16 bpp: 0x117, or 279 */
+	{  0, 0,  960,  720 },		/* 16 bpp: 0x18A, or 394 */
+	{  0, 0,  800,  600 },		/* 16 bpp: 0x114, or 276 */
+	{  0, 0,  768,  576 },		/* 16 bpp: 0x182, or 386 */
+	{  0, 0,  720,  576 },		/* PAL */
+	{  0, 0,  720,  480 },		/* NTSC */
+	{  0, 0,  640,  480 },		/* 16 bpp: 0x111, or 273 */
+	{  0, 0,  640,  400 },		/*  8 bpp: 0x100, or 256 */
+	{  0, 0,  512,  384 },
+	{  0, 0,  320,  240 },
+	{  0, 0,  320,  200 },
+	{  0, 0,  240,  320 }          // ghcstop add
+
+};
+static const struct {
+	int xres;
+	int yres;
+	int pixclock;
+	int left;
+	int right;
+	int upper;
+	int lower;
+	int hslen;
+	int vslen;
+	int sync;
+	int vmode;
+} vesa_timings[] = {
+#ifdef USE_VESA_TIMINGS	/* Only tested on Matrox Millenium I */
+	{  640,  400, 39771,  48, 16, 39,  8,  96, 2, 2, 0 },	/* 70 Hz */
+	{  640,  480, 39683,  48, 16, 33, 10,  96, 2, 0, 0 },	/* 60 Hz */
+	{  768,  576, 26101, 144, 16, 28,  6, 112, 4, 0, 0 },	/* 60 Hz */
+	{  800,  600, 24038, 144, 24, 28,  8, 112, 6, 0, 0 },	/* 60 Hz */
+	{  960,  720, 17686, 144, 24, 28,  8, 112, 4, 0, 0 },	/* 60 Hz */
+	{ 1024,  768, 15386, 160, 32, 30,  4, 128, 4, 0, 0 },	/* 60 Hz */
+	{ 1152,  864, 12286, 192, 32, 30,  4, 128, 4, 0, 0 },	/* 60 Hz */
+	{ 1280, 1024,  9369, 224, 32, 32,  4, 136, 4, 0, 0 },	/* 60 Hz */
+	{ 1408, 1056,  8214, 256, 40, 32,  5, 144, 5, 0, 0 },	/* 60 Hz */
+	{ 1600, 1200,/*?*/0, 272, 48, 32,  5, 152, 5, 0, 0 },	/* 60 Hz */
+#else
+	/* You can generate these timings from your XF86Config file using
+	   the 'modeline2fb' perl script included with the fbset package.
+	   These timings were generated for Matrox Millenium I, 15" monitor.
+	*/
+	{  240,  320, 63492,  16, 16, 16,  4,  48, 2, 0, 2 },	/* 72 Hz */ // ghcstop add
+	{  320,  200, 79440,  16, 16, 20,  4,  48, 1, 0, 2 },	/* 70 Hz */
+	{  320,  240, 63492,  16, 16, 16,  4,  48, 2, 0, 2 },	/* 72 Hz */
+	{  512,  384, 49603,  48, 16, 16,  1,  64, 3, 0, 0 },	/* 78 Hz */
+	{  640,  400, 31746,  96, 32, 41,  1,  64, 3, 2, 0 },	/* 85 Hz */
+	{  640,  480, 31746, 120, 16, 16,  1,  64, 3, 0, 0 },	/* 75 Hz */
+	{  768,  576, 26101, 144, 16, 28,  6, 112, 4, 0, 0 },	/* 60 Hz */
+	{  800,  600, 20000,  64, 56, 23, 37, 120, 6, 3, 0 },	/* 72 Hz */
+	{  960,  720, 17686, 144, 24, 28,  8, 112, 4, 0, 0 },	/* 60 Hz */
+	{ 1024,  768, 13333, 144, 24, 29,  3, 136, 6, 0, 0 },	/* 70 Hz */
+	{ 1152,  864, 12286, 192, 32, 30,  4, 128, 4, 0, 0 },	/* 60 Hz */
+	{ 1280, 1024,  9369, 224, 32, 32,  4, 136, 4, 0, 0 },	/* 60 Hz */
+	{ 1408, 1056,  8214, 256, 40, 32,  5, 144, 5, 0, 0 },	/* 60 Hz */
+	{ 1600, 1200,/*?*/0, 272, 48, 32,  5, 152, 5, 0, 0 },	/* 60 Hz */
+#endif
+};
+
+int SDL_videofd; // Dark add 20050510
+
+/* Initialization/Query functions */
+static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+#ifdef VGA16_FBCON_SUPPORT
+static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
+#endif
+static int FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors);
+static void FB_VideoQuit(_THIS);
+
+/* Hardware surface functions */
+static int FB_InitHWSurfaces(_THIS, SDL_Surface *screen, char *base, int size);
+static void FB_FreeHWSurfaces(_THIS);
+static int FB_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int FB_LockHWSurface(_THIS, SDL_Surface *surface);
+static void FB_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void FB_FreeHWSurface(_THIS, SDL_Surface *surface);
+static void FB_WaitVBL(_THIS);
+static void FB_WaitIdle(_THIS);
+static int FB_FlipHWSurface(_THIS, SDL_Surface *surface);
+
+/* Internal palette functions */
+static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
+                                  struct fb_var_screeninfo *vinfo);
+static void FB_RestorePalette(_THIS);
+
+/* FB driver bootstrap functions */
+
+static int FB_Available(void)
+{
+	int console;
+	const char *SDL_fbdev;
+
+	SDL_fbdev = getenv("SDL_FBDEV");
+	if ( SDL_fbdev == NULL ) {
+		SDL_fbdev = "/dev/fb0";
+	}
+	console = open(SDL_fbdev, O_RDWR, 0);
+	SDL_videofd = console; // Dark add 20050510
+	if ( console >= 0 ) {
+		close(console);
+	}
+	return(console >= 0);
+}
+
+static void FB_DeleteDevice(SDL_VideoDevice *device)
+{
+	free(device->hidden);
+	free(device);
+}
+
+static SDL_VideoDevice *FB_CreateDevice(int devindex)
+{
+	SDL_VideoDevice *this;
+
+    ghcd(("FB_CreateDevice\n"));        
+	/* Initialize all variables that we clean on shutdown */
+	this = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+	if ( this ) {
+		memset(this, 0, (sizeof *this));
+		this->hidden = (struct SDL_PrivateVideoData *)
+				malloc((sizeof *this->hidden));
+	}
+	if ( (this == NULL) || (this->hidden == NULL) ) {
+		SDL_OutOfMemory();
+		if ( this ) {
+			free(this);
+		}
+		return(0);
+	}
+	memset(this->hidden, 0, (sizeof *this->hidden));
+	wait_vbl = FB_WaitVBL;
+	wait_idle = FB_WaitIdle;
+	mouse_fd = -1;
+	keyboard_fd = -1;
+
+	/* Set the function pointers */
+	this->VideoInit = FB_VideoInit;
+	this->ListModes = FB_ListModes;
+	this->SetVideoMode = FB_SetVideoMode;
+	this->SetColors = FB_SetColors;
+	this->UpdateRects = NULL;
+	this->VideoQuit = FB_VideoQuit;
+	this->AllocHWSurface = FB_AllocHWSurface;
+	this->CheckHWBlit = NULL;
+	this->FillHWRect = NULL;
+	this->SetHWColorKey = NULL;
+	this->SetHWAlpha = NULL;
+	this->LockHWSurface = FB_LockHWSurface;
+	this->UnlockHWSurface = FB_UnlockHWSurface;
+	this->FlipHWSurface = FB_FlipHWSurface;
+	this->FreeHWSurface = FB_FreeHWSurface;
+	this->SetCaption = NULL;
+	this->SetIcon = NULL;
+	this->IconifyWindow = NULL;
+	this->GrabInput = NULL;
+	this->GetWMInfo = NULL;
+	this->InitOSKeymap = FB_InitOSKeymap;
+	this->PumpEvents = FB_PumpEvents;
+
+	this->free = FB_DeleteDevice;
+
+	return this;
+}
+
+VideoBootStrap FBCON_bootstrap = {
+	"fbcon", "Linux Framebuffer Console",
+	FB_Available, FB_CreateDevice
+};
+
+static int FB_CheckMode(_THIS, struct fb_var_screeninfo *vinfo,
+                        int index, unsigned int *w, unsigned int *h)
+{
+	int mode_okay;
+
+	mode_okay = 0;
+	vinfo->bits_per_pixel = (index+1)*8;
+	vinfo->xres = *w;
+	vinfo->xres_virtual = *w;
+	vinfo->yres = *h;
+	vinfo->yres_virtual = *h;
+	vinfo->activate = FB_ACTIVATE_TEST;
+	if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, vinfo) == 0 ) {
+#ifdef FBCON_DEBUG
+		fprintf(stderr, "Checked mode %dx%d at %d bpp, got mode %dx%d at %d bpp\n", *w, *h, (index+1)*8, vinfo->xres, vinfo->yres, vinfo->bits_per_pixel);
+#endif
+		if ( (((vinfo->bits_per_pixel+7)/8)-1) == index ) {
+			*w = vinfo->xres;
+			*h = vinfo->yres;
+			mode_okay = 1;
+		}
+	}
+	return mode_okay;
+}
+
+static int FB_AddMode(_THIS, int index, unsigned int w, unsigned int h)
+{
+	SDL_Rect *mode;
+	int i;
+	int next_mode;
+
+	/* Check to see if we already have this mode */
+	if ( SDL_nummodes[index] > 0 ) {
+		mode = SDL_modelist[index][SDL_nummodes[index]-1];
+		if ( (mode->w == w) && (mode->h == h) ) {
+#ifdef FBCON_DEBUG
+			fprintf(stderr, "We already have mode %dx%d at %d bytes per pixel\n", w, h, index+1);
+#endif
+			return(0);
+		}
+	}
+
+	/* Only allow a mode if we have a valid timing for it */
+	next_mode = -1;
+	for ( i=0; i<(sizeof(vesa_timings)/sizeof(vesa_timings[0])); ++i ) {
+		if ( (w == vesa_timings[i].xres) &&
+		     (h == vesa_timings[i].yres) && vesa_timings[i].pixclock ) {
+			next_mode = i;
+			break;
+		}
+	}
+	if ( next_mode == -1 ) {
+#ifdef FBCON_DEBUG
+		fprintf(stderr, "No valid timing line for mode %dx%d\n", w, h);
+#endif
+		return(0);
+	}
+
+	/* Set up the new video mode rectangle */
+	mode = (SDL_Rect *)malloc(sizeof *mode);
+	if ( mode == NULL ) {
+		SDL_OutOfMemory();
+		return(-1);
+	}
+	mode->x = 0;
+	mode->y = 0;
+	mode->w = w;
+	mode->h = h;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Adding mode %dx%d at %d bytes per pixel\n", w, h, index+1);
+#endif
+
+	/* Allocate the new list of modes, and fill in the new mode */
+	next_mode = SDL_nummodes[index];
+	SDL_modelist[index] = (SDL_Rect **)
+	       realloc(SDL_modelist[index], (1+next_mode+1)*sizeof(SDL_Rect *));
+	if ( SDL_modelist[index] == NULL ) {
+		SDL_OutOfMemory();
+		SDL_nummodes[index] = 0;
+		free(mode);
+		return(-1);
+	}
+	SDL_modelist[index][next_mode] = mode;
+	SDL_modelist[index][next_mode+1] = NULL;
+	SDL_nummodes[index]++;
+
+	return(0);
+}
+
+static int FB_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+	struct fb_fix_screeninfo finfo;
+	struct fb_var_screeninfo vinfo;
+	int i, j;
+	int current_index;
+	unsigned int current_w;
+	unsigned int current_h;
+	const char *SDL_fbdev;
+
+	/* Initialize the library */
+	SDL_fbdev = getenv("SDL_FBDEV");
+	if ( SDL_fbdev == NULL ) {
+		SDL_fbdev = "/dev/fb0";
+	}
+	console_fd = open(SDL_fbdev, O_RDWR, 0);
+	if ( console_fd < 0 ) {
+		SDL_SetError("Unable to open %s", SDL_fbdev);
+		return(-1);
+	}
+#ifdef SDL_MMSP2 // needed to get at HW registers
+	memory_fd = open("/dev/mem", O_RDWR, 0);
+	if (memory_fd <0) {
+	  SDL_SetError("Unable to open /dev/mem");
+	  return(-1);
+	}
+#endif
+
+#ifndef DISABLE_THREADS
+	/* Create the hardware surface lock mutex */
+	hw_lock = SDL_CreateMutex();
+	if ( hw_lock == NULL ) {
+		SDL_SetError("Unable to create lock mutex");
+		FB_VideoQuit(this);
+		return(-1);
+	}
+#endif
+
+	/* Get the type of video hardware */
+	if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
+		SDL_SetError("Couldn't get console hardware info");
+		FB_VideoQuit(this);
+		return(-1);
+	}
+	switch (finfo.type) {
+		case FB_TYPE_PACKED_PIXELS:
+			/* Supported, no worries.. */
+			break;
+#ifdef VGA16_FBCON_SUPPORT
+		case FB_TYPE_VGA_PLANES:
+			/* VGA16 is supported, but that's it */
+			if ( finfo.type_aux == FB_AUX_VGA_PLANES_VGA4 ) {
+				if ( ioperm(0x3b4, 0x3df - 0x3b4 + 1, 1) < 0 ) {
+					SDL_SetError("No I/O port permissions");
+					FB_VideoQuit(this);
+					return(-1);
+				}
+				this->SetVideoMode = FB_SetVGA16Mode;
+				break;
+			}
+			/* Fall through to unsupported case */
+#endif /* VGA16_FBCON_SUPPORT */
+		default:
+			SDL_SetError("Unsupported console hardware");
+			FB_VideoQuit(this);
+			return(-1);
+	}
+	switch (finfo.visual) {
+		case FB_VISUAL_TRUECOLOR:
+		case FB_VISUAL_PSEUDOCOLOR:
+		case FB_VISUAL_STATIC_PSEUDOCOLOR:
+		case FB_VISUAL_DIRECTCOLOR:
+			break;
+		default:
+			SDL_SetError("Unsupported console hardware");
+			FB_VideoQuit(this);
+			return(-1);
+	}
+
+	/* Check if the user wants to disable hardware acceleration */
+	{ const char *fb_accel;
+		fb_accel = getenv("SDL_FBACCEL");
+		if ( fb_accel ) {
+			finfo.accel = atoi(fb_accel);
+		}
+	}
+
+	/* Memory map the device, compensating for buggy PPC mmap() */
+	mapped_offset = (((long)finfo.smem_start) -
+	                (((long)finfo.smem_start)&~(PAGE_SIZE-1)));
+	mapped_memlen = finfo.smem_len+mapped_offset;
+#ifdef SDL_MMSP2
+	// gp2x fbcon doesn't alloc any surface memory but reserves space
+	// for 2 1280x1024x16 frame buffers. Need to go via /dev/mem 
+	if (finfo.smem_start == 0x3101000) {
+	  mapped_memlen = 0x500000;  // gp2x has space for 2 1280x1024 16bit
+	  mapped_mem = mmap(NULL, mapped_memlen, PROT_READ|PROT_WRITE,
+			    MAP_SHARED, memory_fd, 0x3101000);
+	} else
+#endif
+	mapped_mem = mmap(NULL, mapped_memlen,
+	                  PROT_READ|PROT_WRITE, MAP_SHARED, console_fd, 0);
+	if ( mapped_mem == (char *)-1 ) {
+		SDL_SetError("Unable to memory map the video hardware");
+		mapped_mem = NULL;
+		FB_VideoQuit(this);
+		return(-1);
+	}
+
+	/* Determine the current screen depth */
+	if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
+		SDL_SetError("Couldn't get console pixel format");
+		FB_VideoQuit(this);
+		return(-1);
+	}
+	vformat->BitsPerPixel = vinfo.bits_per_pixel;
+	if ( vformat->BitsPerPixel < 8 ) {
+		/* Assuming VGA16, we handle this via a shadow framebuffer */
+		vformat->BitsPerPixel = 8;
+	}
+	for ( i=0; i<vinfo.red.length; ++i ) {
+		vformat->Rmask <<= 1;
+		vformat->Rmask |= (0x00000001<<vinfo.red.offset);
+	}
+	for ( i=0; i<vinfo.green.length; ++i ) {
+		vformat->Gmask <<= 1;
+		vformat->Gmask |= (0x00000001<<vinfo.green.offset);
+	}
+	for ( i=0; i<vinfo.blue.length; ++i ) {
+		vformat->Bmask <<= 1;
+		vformat->Bmask |= (0x00000001<<vinfo.blue.offset);
+	}
+	saved_vinfo = vinfo;
+	
+	
+	#if 0 // ghcstop_041123
+	/* Save hardware palette, if needed */
+	FB_SavePalette(this, &finfo, &vinfo);
+	#endif
+
+	/* If the I/O registers are available, memory map them so we
+	   can take advantage of any supported hardware acceleration.
+	 */
+	vinfo.accel_flags = 0;	/* Temporarily reserve registers */
+	ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo);
+#ifdef SDL_MMSP2  // gp2x HW io not available through fbcon
+	mmsp2_regs = mmap(NULL, 0x10000, PROT_READ|PROT_WRITE,
+			  MAP_SHARED, memory_fd, 0xc0000000);
+	mmsp2_blit_regs = mmap(NULL, 0x100, PROT_READ|PROT_WRITE,
+			       MAP_SHARED, memory_fd, 0xe0020000);
+#endif
+	if ( finfo.accel && finfo.mmio_len ) {
+		mapped_iolen = finfo.mmio_len;
+		mapped_io = mmap(NULL, mapped_iolen, PROT_READ|PROT_WRITE,
+		                 MAP_SHARED, console_fd, mapped_memlen);
+		if ( mapped_io == (char *)-1 ) {
+			/* Hmm, failed to memory map I/O registers */
+			mapped_io = NULL;
+		}
+	}
+
+	/* Query for the list of available video modes */
+	current_w = vinfo.xres;
+	current_h = vinfo.yres;
+
+        ghcd(("current_w = %d, current_h = %d\n", current_w, current_h));
+
+	current_index = ((vinfo.bits_per_pixel+7)/8)-1;
+#ifdef BROKEN_MODES
+	FB_AddMode(this, current_index, current_w, current_h);
+#else
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		SDL_nummodes[i] = 0;
+		SDL_modelist[i] = NULL;
+		for ( j=0; j<(sizeof(checkres)/sizeof(checkres[0])); ++j ) {
+			unsigned int w, h;
+
+			/* See if we are querying for the current mode */
+			w = checkres[j].w;
+			h = checkres[j].h;
+			if ( i == current_index ) {
+				if ( (current_w > w) || (current_h > h) ) {
+					/* Only check once */
+                                        ghcd(("width: %d, height: %d\n"));
+					FB_AddMode(this, i, current_w, current_h);
+					current_index = -1;
+				}
+			}
+			if ( FB_CheckMode(this, &vinfo, i, &w, &h) ) {
+                        ghcd(("FB_CehckMode\n"));
+				FB_AddMode(this, i, w, h);
+			}
+		}
+	}
+#endif /* BROKEN_MODES */
+
+	/* Fill in our hardware acceleration capabilities */
+	this->info.wm_available = 0;
+	this->info.hw_available = 1;
+	this->info.video_mem = finfo.smem_len/1024;
+#ifdef SDL_MMSP2
+#ifdef FBACCEL_DEBUG
+	printf("MMSP2 hardware accelerator!\n");
+#endif
+	this->info.video_mem = 5*1024;  // gp2x reserves 5M video mem
+	FB_MMSP2Accel(this, finfo.accel);
+	mmsp2_regs[SYSCLKENREG] |= FASTIOCLK;
+	mmsp2_regs[VCLKENREG] = 0xffff;
+#endif
+#if 0 // ghcstop_041123 delete			
+	if ( mapped_io ) {
+		switch (finfo.accel) {
+		    case FB_ACCEL_MATROX_MGA2064W:
+		    case FB_ACCEL_MATROX_MGA1064SG:
+		    case FB_ACCEL_MATROX_MGA2164W:
+		    case FB_ACCEL_MATROX_MGA2164W_AGP:
+		    case FB_ACCEL_MATROX_MGAG100:
+		    /*case FB_ACCEL_MATROX_MGAG200: G200 acceleration broken! */
+		    case FB_ACCEL_MATROX_MGAG400:
+#ifdef FBACCEL_DEBUG
+			printf("Matrox hardware accelerator!\n");
+#endif
+			FB_MatroxAccel(this, finfo.accel);
+			break;
+		    case FB_ACCEL_3DFX_BANSHEE:
+#ifdef FBACCEL_DEBUG
+			printf("3DFX hardware accelerator!\n");
+#endif
+			FB_3DfxAccel(this, finfo.accel);
+			break;
+		    case FB_ACCEL_NV3:
+		    case FB_ACCEL_NV4:
+#ifdef FBACCEL_DEBUG
+			printf("NVidia hardware accelerator!\n");
+#endif
+			FB_RivaAccel(this, finfo.accel);
+			break;
+
+		    default:
+#ifdef FBACCEL_DEBUG
+			printf("Unknown hardware accelerator.\n");
+#endif
+			break;
+		}
+	}
+#endif // no accelation, comment	
+
+
+#if FB_INPUT_DEVICE_ENABLE // ghcstop
+        /* Enable mouse and keyboard support */
+	if ( FB_OpenKeyboard(this) < 0 ) {
+		FB_VideoQuit(this);
+		return(-1);
+	}
+	
+	#if 0 // ghcstop delete, no keyboard, no mouse in s3c2410
+	// ghcstop_041123: SDL_fbevents.c, 아직은 마우스 살리지 말고나중에 살려야겠군...
+	if ( FB_OpenMouse(this) < 0 ) { 
+		const char *sdl_nomouse;
+
+		sdl_nomouse = getenv("SDL_NOMOUSE");
+		if ( ! sdl_nomouse ) {
+			SDL_SetError("Unable to open mouse");
+			FB_VideoQuit(this);
+			return(-1);
+		}
+	}
+    #endif
+#endif    
+
+	/* We're done! */
+	return(0);
+}
+
+static SDL_Rect **FB_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+	return(SDL_modelist[((format->BitsPerPixel+7)/8)-1]);
+}
+
+/* Various screen update functions available */
+static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
+#ifdef VGA16_FBCON_SUPPORT
+static void FB_VGA16Update(_THIS, int numrects, SDL_Rect *rects);
+#endif
+
+#ifdef FBCON_DEBUG
+static void print_vinfo(struct fb_var_screeninfo *vinfo)
+{
+	fprintf(stderr, "Printing vinfo:\n");
+	fprintf(stderr, "\txres: %d\n", vinfo->xres);
+	fprintf(stderr, "\tyres: %d\n", vinfo->yres);
+	fprintf(stderr, "\txres_virtual: %d\n", vinfo->xres_virtual);
+	fprintf(stderr, "\tyres_virtual: %d\n", vinfo->yres_virtual);
+	fprintf(stderr, "\txoffset: %d\n", vinfo->xoffset);
+	fprintf(stderr, "\tyoffset: %d\n", vinfo->yoffset);
+	fprintf(stderr, "\tbits_per_pixel: %d\n", vinfo->bits_per_pixel);
+	fprintf(stderr, "\tgrayscale: %d\n", vinfo->grayscale);
+	fprintf(stderr, "\tnonstd: %d\n", vinfo->nonstd);
+	fprintf(stderr, "\tactivate: %d\n", vinfo->activate);
+	fprintf(stderr, "\theight: %d\n", vinfo->height);
+	fprintf(stderr, "\twidth: %d\n", vinfo->width);
+	fprintf(stderr, "\taccel_flags: %d\n", vinfo->accel_flags);
+	fprintf(stderr, "\tpixclock: %d\n", vinfo->pixclock);
+	fprintf(stderr, "\tleft_margin: %d\n", vinfo->left_margin);
+	fprintf(stderr, "\tright_margin: %d\n", vinfo->right_margin);
+	fprintf(stderr, "\tupper_margin: %d\n", vinfo->upper_margin);
+	fprintf(stderr, "\tlower_margin: %d\n", vinfo->lower_margin);
+	fprintf(stderr, "\thsync_len: %d\n", vinfo->hsync_len);
+	fprintf(stderr, "\tvsync_len: %d\n", vinfo->vsync_len);
+	fprintf(stderr, "\tsync: %d\n", vinfo->sync);
+	fprintf(stderr, "\tvmode: %d\n", vinfo->vmode);
+	fprintf(stderr, "\tred: %d/%d\n", vinfo->red.length, vinfo->red.offset);
+	fprintf(stderr, "\tgreen: %d/%d\n", vinfo->green.length, vinfo->green.offset);
+	fprintf(stderr, "\tblue: %d/%d\n", vinfo->blue.length, vinfo->blue.offset);
+	fprintf(stderr, "\talpha: %d/%d\n", vinfo->transp.length, vinfo->transp.offset);
+}
+static void print_finfo(struct fb_fix_screeninfo *finfo)
+{
+	fprintf(stderr, "Printing finfo:\n");
+	fprintf(stderr, "\tsmem_start = %p\n", (char *)finfo->smem_start);
+	fprintf(stderr, "\tsmem_len = %d\n", finfo->smem_len);
+	fprintf(stderr, "\ttype = %d\n", finfo->type);
+	fprintf(stderr, "\ttype_aux = %d\n", finfo->type_aux);
+	fprintf(stderr, "\tvisual = %d\n", finfo->visual);
+	fprintf(stderr, "\txpanstep = %d\n", finfo->xpanstep);
+	fprintf(stderr, "\typanstep = %d\n", finfo->ypanstep);
+	fprintf(stderr, "\tywrapstep = %d\n", finfo->ywrapstep);
+	fprintf(stderr, "\tline_length = %d\n", finfo->line_length);
+	fprintf(stderr, "\tmmio_start = %p\n", (char *)finfo->mmio_start);
+	fprintf(stderr, "\tmmio_len = %d\n", finfo->mmio_len);
+	fprintf(stderr, "\taccel = %d\n", finfo->accel);
+}
+#endif
+
+static int choose_fbmodes_mode(struct fb_var_screeninfo *vinfo)
+{
+	int matched;
+	FILE *fbmodes;
+
+	matched = 0;
+	fbmodes = fopen("/etc/fb.modes", "r");
+	if ( fbmodes ) {
+		/* FIXME: Parse the mode definition file */
+		fclose(fbmodes);
+	}
+	return(matched);
+}
+
+static int choose_vesa_mode(struct fb_var_screeninfo *vinfo)
+{
+	int matched;
+	int i;
+
+	/* Check for VESA timings */
+	matched = 0;
+	for ( i=0; i<(sizeof(vesa_timings)/sizeof(vesa_timings[0])); ++i ) {
+		if ( (vinfo->xres == vesa_timings[i].xres) &&
+		     (vinfo->yres == vesa_timings[i].yres) ) {
+#ifdef FBCON_DEBUG
+			fprintf(stderr, "Using VESA timings for %dx%d\n",
+						vinfo->xres, vinfo->yres);
+#endif
+			if ( vesa_timings[i].pixclock ) {
+				vinfo->pixclock = vesa_timings[i].pixclock;
+			}
+			vinfo->left_margin = vesa_timings[i].left;
+			vinfo->right_margin = vesa_timings[i].right;
+			vinfo->upper_margin = vesa_timings[i].upper;
+			vinfo->lower_margin = vesa_timings[i].lower;
+			vinfo->hsync_len = vesa_timings[i].hslen;
+			vinfo->vsync_len = vesa_timings[i].vslen;
+			vinfo->sync = vesa_timings[i].sync;
+			vinfo->vmode = vesa_timings[i].vmode;
+			matched = 1;
+			break;
+		}
+	}
+	return(matched);
+}
+
+#ifdef VGA16_FBCON_SUPPORT
+static SDL_Surface *FB_SetVGA16Mode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	struct fb_fix_screeninfo finfo;
+	struct fb_var_screeninfo vinfo;
+
+#if FB_INPUT_DEVICE_ENABLE // ghcstop
+	/* Set the terminal into graphics mode */
+	if ( FB_EnterGraphicsMode(this) < 0 ) {
+		return(NULL);
+	}
+#endif
+
+	#if 0 // ghcstop_041123 delete
+	/* Restore the original palette */
+	FB_RestorePalette(this);
+	#endif
+
+	/* Set the video mode and get the final screen format */
+	if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
+		SDL_SetError("Couldn't get console screen info");
+		return(NULL);
+	}
+	cache_vinfo = vinfo;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing actual vinfo:\n");
+	print_vinfo(&vinfo);
+#endif
+	if ( ! SDL_ReallocFormat(current, bpp, 0, 0, 0, 0) ) {
+		return(NULL);
+	}
+	current->format->palette->ncolors = 16;
+
+	/* Get the fixed information about the console hardware.
+	   This is necessary since finfo.line_length changes.
+	 */
+	if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
+		SDL_SetError("Couldn't get console hardware info");
+		return(NULL);
+	}
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing actual finfo:\n");
+	print_finfo(&finfo);
+#endif
+
+	#if 0 // ghcstop_041123 delete
+	/* Save hardware palette, if needed */
+	FB_SavePalette(this, &finfo, &vinfo);
+	#endif
+
+	/* Set up the new mode framebuffer */
+	current->flags = SDL_FULLSCREEN;
+	current->w = vinfo.xres;
+	current->h = vinfo.yres;
+	current->pitch = current->w;
+	current->pixels = malloc(current->h*current->pitch);
+
+	/* Set the update rectangle function */
+	this->UpdateRects = FB_VGA16Update;
+
+	/* We're done */
+	return(current);
+}
+#endif /* VGA16_FBCON_SUPPORT */
+
+static SDL_Surface *FB_SetVideoMode(_THIS, SDL_Surface *current,
+				int width, int height, int bpp, Uint32 flags)
+{
+	struct fb_fix_screeninfo finfo;
+	struct fb_var_screeninfo vinfo;
+	int i;
+	Uint32 Rmask;
+	Uint32 Gmask;
+	Uint32 Bmask;
+	char *surfaces_mem;
+	int surfaces_len;
+
+ghcd(("fbs-0\n"));
+#if FB_INPUT_DEVICE_ENABLE // ghcstop_041123 alive
+	/* Set the terminal into graphics mode */
+	if ( FB_EnterGraphicsMode(this) < 0 ) {
+		return(NULL);
+	}
+#endif
+
+ghcd(("fbs-1\n"));        
+	#if 0 // ghcstop_041123 delete
+	/* Restore the original palette */
+	FB_RestorePalette(this);
+	#endif
+
+	/* Set the video mode and get the final screen format */
+	if ( ioctl(console_fd, FBIOGET_VSCREENINFO, &vinfo) < 0 ) {
+		SDL_SetError("Couldn't get console screen info");
+		return(NULL);
+	}
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing original vinfo: (want bpp %d)\n", bpp);
+	print_vinfo(&vinfo);
+#endif
+	if ( (vinfo.xres != width) || (vinfo.yres != height) ||
+	     (vinfo.bits_per_pixel != bpp) || (flags & SDL_DOUBLEBUF) ) {
+		vinfo.activate = FB_ACTIVATE_NOW;
+		vinfo.accel_flags = 0;
+		vinfo.bits_per_pixel = bpp;
+		vinfo.xres = width;
+		vinfo.xres_virtual = width;
+		vinfo.yres = height;
+		if ( flags & SDL_DOUBLEBUF ) {
+			vinfo.yres_virtual = height*2;
+		} else {
+			vinfo.yres_virtual = height;
+		}
+		vinfo.xoffset = 0;
+		vinfo.yoffset = 0;
+		vinfo.red.length = vinfo.red.offset = 0;
+		vinfo.green.length = vinfo.green.offset = 0;
+		vinfo.blue.length = vinfo.blue.offset = 0;
+		vinfo.transp.length = vinfo.transp.offset = 0;
+		if ( ! choose_fbmodes_mode(&vinfo) ) {
+		  choose_vesa_mode(&vinfo);
+		}
+#ifdef FBCON_DEBUG
+		fprintf(stderr, "Printing wanted vinfo: (%d)\n", vinfo.bits_per_pixel);
+		print_vinfo(&vinfo);
+#endif
+		if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) {
+			vinfo.yres_virtual = height;
+			if ( ioctl(console_fd, FBIOPUT_VSCREENINFO, &vinfo) < 0 ) {
+				SDL_SetError("Couldn't set console screen info");
+				return(NULL);
+			}
+		}
+	} else {
+		int maxheight;
+
+		/* Figure out how much video memory is available */
+		if ( flags & SDL_DOUBLEBUF ) {
+			maxheight = height*2;
+		} else {
+			maxheight = height;
+		}
+		if ( vinfo.yres_virtual > maxheight ) {
+			vinfo.yres_virtual = maxheight;
+		}
+	}
+	cache_vinfo = vinfo;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing actual vinfo:\n");
+	print_vinfo(&vinfo);
+#endif
+	Rmask = 0;
+	for ( i=0; i<vinfo.red.length; ++i ) {
+		Rmask <<= 1;
+		Rmask |= (0x00000001<<vinfo.red.offset);
+	}
+	Gmask = 0;
+	for ( i=0; i<vinfo.green.length; ++i ) {
+		Gmask <<= 1;
+		Gmask |= (0x00000001<<vinfo.green.offset);
+	}
+	Bmask = 0;
+	for ( i=0; i<vinfo.blue.length; ++i ) {
+		Bmask <<= 1;
+		Bmask |= (0x00000001<<vinfo.blue.offset);
+	}
+	if ( ! SDL_ReallocFormat(current, vinfo.bits_per_pixel,
+	                                  Rmask, Gmask, Bmask, 0) ) {
+		return(NULL);
+	}
+
+	/* Get the fixed information about the console hardware.
+	   This is necessary since finfo.line_length changes.
+	 */
+	if ( ioctl(console_fd, FBIOGET_FSCREENINFO, &finfo) < 0 ) {
+		SDL_SetError("Couldn't get console hardware info");
+		return(NULL);
+	}
+
+	#if 0 // ghcstop_041123 delete
+	/* Save hardware palette, if needed */
+	FB_SavePalette(this, &finfo, &vinfo);
+	#endif
+
+	/* Set up the new mode framebuffer */
+	current->flags = (SDL_FULLSCREEN|SDL_HWSURFACE);
+	current->w = vinfo.xres;
+	current->h = vinfo.yres;
+	current->pitch = finfo.line_length;
+	current->pixels = mapped_mem+mapped_offset;
+
+	/* Set up the information for hardware surfaces */
+	surfaces_mem = (char *)current->pixels +
+	                        vinfo.yres_virtual*current->pitch;
+	surfaces_len = (mapped_memlen-(surfaces_mem-mapped_mem));
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "surface mem= 0x%8X, length = 0x%X\n",
+		(unsigned int)surfaces_mem, surfaces_len);
+#endif
+	FB_FreeHWSurfaces(this);
+	FB_InitHWSurfaces(this, current, surfaces_mem, surfaces_len);
+
+	/* Let the application know we have a hardware palette */
+	switch (finfo.visual) {
+	    case FB_VISUAL_PSEUDOCOLOR:
+		current->flags |= SDL_HWPALETTE;
+		break;
+	    default:
+		break;
+	}
+
+	/* Update for double-buffering, if we can */
+	if ( flags & SDL_DOUBLEBUF ) {
+		if ( vinfo.yres_virtual == (height*2) ) {
+			current->flags |= SDL_DOUBLEBUF;
+			flip_page = 1;
+			flip_address[0] = (char *)current->pixels;
+			flip_address[1] = (char *)current->pixels+
+			                          current->h*current->pitch;
+			this->screen = current;
+			FB_FlipHWSurface(this, current);
+			this->screen = NULL;
+		}
+	}
+
+	/* Set the update rectangle function */
+	this->UpdateRects = FB_DirectUpdate;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Printing finfo:\n");
+	print_finfo(&finfo);
+#endif
+	/* We're done */
+	return(current);
+}
+
+#ifdef FBCON_DEBUG
+void FB_DumpHWSurfaces(_THIS)
+{
+	vidmem_bucket *bucket;
+
+	printf("Memory left: %d (%d total)\n", surfaces_memleft, surfaces_memtotal);
+	printf("\n");
+	printf("         Base  Size\n");
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		printf("Bucket:  %p, %d (%s)\n", bucket->base, bucket->size, bucket->used ? "used" : "free");
+		if ( bucket->prev ) {
+			if ( bucket->base != bucket->prev->base+bucket->prev->size ) {
+				printf("Warning, corrupt bucket list! (prev)\n");
+			}
+		} else {
+			if ( bucket != &surfaces ) {
+				printf("Warning, corrupt bucket list! (!prev)\n");
+			}
+		}
+		if ( bucket->next ) {
+			if ( bucket->next->base != bucket->base+bucket->size ) {
+				printf("Warning, corrupt bucket list! (next)\n");
+			}
+		}
+	}
+	printf("\n");
+}
+#endif
+
+static int FB_InitHWSurfaces(_THIS, SDL_Surface *screen, char *base, int size)
+{
+	vidmem_bucket *bucket;
+
+	surfaces_memtotal = size;
+	surfaces_memleft = size;
+
+	if ( surfaces_memleft > 0 ) {
+		bucket = (vidmem_bucket *)malloc(sizeof(*bucket));
+		if ( bucket == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		bucket->prev = &surfaces;
+		bucket->used = 0;
+		bucket->dirty = 0;
+		bucket->base = base;
+		bucket->size = size;
+		bucket->next = NULL;
+	} else {
+		bucket = NULL;
+	}
+
+	surfaces.prev = NULL;
+	surfaces.used = 1;
+	surfaces.dirty = 0;
+	surfaces.base = screen->pixels;
+	surfaces.size = (unsigned int)((long)base - (long)surfaces.base);
+	surfaces.next = bucket;
+	screen->hwdata = (struct private_hwdata *)&surfaces;
+	return(0);
+}
+static void FB_FreeHWSurfaces(_THIS)
+{
+	vidmem_bucket *bucket, *freeable;
+
+	bucket = surfaces.next;
+	while ( bucket ) {
+		freeable = bucket;
+		bucket = bucket->next;
+		free(freeable);
+	}
+	surfaces.next = NULL;
+}
+
+static int FB_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+	vidmem_bucket *bucket;
+	int size;
+	int extra;
+
+#ifdef SDL_MMSP2
+	// gp2x speccific: surface any width, pitch 32bit
+	surface->pitch = ((surface->format->BytesPerPixel * surface->w) + 3) & 0xfffc;
+#else
+/* Temporarily, we only allow surfaces the same width as display.
+   Some blitters require the pitch between two hardware surfaces
+   to be the same.  Others have interesting alignment restrictions.
+   Until someone who knows these details looks at the code...
+*/
+	if ( surface->pitch > SDL_VideoSurface->pitch ) {
+	  SDL_SetError("Surface requested wider than screen");
+	  return(-1);
+	}
+	surface->pitch = SDL_VideoSurface->pitch;
+#endif
+	size = surface->h * surface->pitch;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Allocating bucket of %d bytes\n", size);
+#endif
+
+	/* Quick check for available mem */
+	if ( size > surfaces_memleft ) {
+		SDL_SetError("Not enough video memory");
+		return(-1);
+	}
+
+	/* Search for an empty bucket big enough */
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		if ( ! bucket->used && (size <= bucket->size) ) {
+			break;
+		}
+	}
+	if ( bucket == NULL ) {
+		SDL_SetError("Video memory too fragmented");
+		return(-1);
+	}
+
+	/* Create a new bucket for left-over memory */
+	extra = (bucket->size - size);
+	if ( extra ) {
+		vidmem_bucket *newbucket;
+
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Adding new free bucket of %d bytes\n", extra);
+#endif
+		newbucket = (vidmem_bucket *)malloc(sizeof(*newbucket));
+		if ( newbucket == NULL ) {
+			SDL_OutOfMemory();
+			return(-1);
+		}
+		newbucket->prev = bucket;
+		newbucket->used = 0;
+		newbucket->base = bucket->base+size;
+		newbucket->size = extra;
+		newbucket->next = bucket->next;
+		if ( bucket->next ) {
+			bucket->next->prev = newbucket;
+		}
+		bucket->next = newbucket;
+	}
+
+	/* Set the current bucket values and return it! */
+	bucket->used = 1;
+	bucket->size = size;
+	bucket->dirty = 0;
+#ifdef FBCON_DEBUG
+	fprintf(stderr, "Allocated %d bytes at %p\n", bucket->size, bucket->base);
+#endif
+	surfaces_memleft -= size;
+	surface->flags |= SDL_HWSURFACE;
+	surface->pixels = bucket->base;
+	surface->hwdata = (struct private_hwdata *)bucket;
+	return(0);
+}
+static void FB_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+	vidmem_bucket *bucket, *freeable;
+
+	/* Look for the bucket in the current list */
+	for ( bucket=&surfaces; bucket; bucket=bucket->next ) {
+		if ( bucket == (vidmem_bucket *)surface->hwdata ) {
+			break;
+		}
+	}
+	if ( bucket && bucket->used ) {
+		/* Add the memory back to the total */
+#ifdef DGA_DEBUG
+	printf("Freeing bucket of %d bytes\n", bucket->size);
+#endif
+		surfaces_memleft += bucket->size;
+
+		/* Can we merge the space with surrounding buckets? */
+		bucket->used = 0;
+		if ( bucket->next && ! bucket->next->used ) {
+#ifdef DGA_DEBUG
+	printf("Merging with next bucket, for %d total bytes\n", bucket->size+bucket->next->size);
+#endif
+			freeable = bucket->next;
+			bucket->size += bucket->next->size;
+			bucket->next = bucket->next->next;
+			if ( bucket->next ) {
+				bucket->next->prev = bucket;
+			}
+			free(freeable);
+		}
+		if ( bucket->prev && ! bucket->prev->used ) {
+#ifdef DGA_DEBUG
+	printf("Merging with previous bucket, for %d total bytes\n", bucket->prev->size+bucket->size);
+#endif
+			freeable = bucket;
+			bucket->prev->size += bucket->size;
+			bucket->prev->next = bucket->next;
+			if ( bucket->next ) {
+				bucket->next->prev = bucket->prev;
+			}
+			free(freeable);
+		}
+	}
+	surface->pixels = NULL;
+	surface->hwdata = NULL;
+}
+static int FB_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == this->screen ) {
+		SDL_mutexP(hw_lock);
+		if ( FB_IsSurfaceBusy(surface) ) {
+			FB_WaitBusySurfaces(this);
+		}
+	} else {
+		if ( FB_IsSurfaceBusy(surface) ) {
+			FB_WaitBusySurfaces(this);
+		}
+	}
+	return(0);
+}
+static void FB_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+	if ( surface == this->screen ) {
+		SDL_mutexV(hw_lock);
+	}
+}
+
+static void FB_WaitVBL(_THIS)
+{
+#ifdef FBIOWAITRETRACE /* Heheh, this didn't make it into the main kernel */
+	ioctl(console_fd, FBIOWAITRETRACE, 0);
+#endif
+	return;
+}
+
+static void FB_WaitIdle(_THIS)
+{
+	return;
+}
+
+static int FB_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+	/* Wait for vertical retrace and then flip display */
+	cache_vinfo.yoffset = flip_page*surface->h;
+	if ( FB_IsSurfaceBusy(this->screen) ) {
+		FB_WaitBusySurfaces(this);
+	}
+	wait_vbl(this);
+#ifdef SDL_MMSP2    // gp2x fbcon doesn't support PAN (yet?)
+	MMSP2_SetScreen((Uint32)(flip_address[flip_page] - mapped_mem) +
+			0x3101000);
+#else
+	if ( ioctl(console_fd, FBIOPAN_DISPLAY, &cache_vinfo) < 0 ) {
+	        SDL_SetError("ioctl(FBIOPAN_DISPLAY) failed");
+		return(-1);
+	}
+#endif
+	flip_page = !flip_page;
+	surface->pixels = flip_address[flip_page];
+	return(0);
+}
+
+static void FB_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
+{
+	/* The application is already updating the visible video memory */
+	return;
+}
+
+#ifdef VGA16_FBCON_SUPPORT
+/* Code adapted with thanks from the XFree86 VGA16 driver! :) */
+#define writeGr(index, value) \
+outb(index, 0x3CE);           \
+outb(value, 0x3CF);
+#define writeSeq(index, value) \
+outb(index, 0x3C4);            \
+outb(value, 0x3C5);
+
+static void FB_VGA16Update(_THIS, int numrects, SDL_Rect *rects)
+{
+    SDL_Surface *screen;
+    int width, height, FBPitch, left, i, j, SRCPitch, phase;
+    register Uint32 m;
+    Uint8  s1, s2, s3, s4;
+    Uint32 *src, *srcPtr;
+    Uint8  *dst, *dstPtr;
+
+    screen = this->screen;
+    FBPitch = screen->w >> 3;
+    SRCPitch = screen->pitch >> 2;
+
+    writeGr(0x03, 0x00);
+    writeGr(0x05, 0x00);
+    writeGr(0x01, 0x00);
+    writeGr(0x08, 0xFF);
+
+    while(numrects--) {
+	left = rects->x & ~7;
+        width = (rects->w + 7) >> 3;
+        height = rects->h;
+        src = (Uint32*)screen->pixels + (rects->y * SRCPitch) + (left >> 2); 
+        dst = (Uint8*)mapped_mem + (rects->y * FBPitch) + (left >> 3);
+
+	if((phase = (long)dst & 3L)) {
+	    phase = 4 - phase;
+	    if(phase > width) phase = width;
+	    width -= phase;
+	}
+
+        while(height--) {
+	    writeSeq(0x02, 1 << 0);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
+ 		*dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
+ 		s1 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		m = (srcPtr[3] & 0x01010101) | ((srcPtr[2] & 0x01010101) << 4);
+ 		s2 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		m = (srcPtr[5] & 0x01010101) | ((srcPtr[4] & 0x01010101) << 4);
+ 		s3 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		m = (srcPtr[7] & 0x01010101) | ((srcPtr[6] & 0x01010101) << 4);
+ 		s4 = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x01010101) | ((srcPtr[0] & 0x01010101) << 4);
+ 		*dstPtr++ = (m >> 24) | (m >> 15) | (m >> 6) | (m << 3);
+		srcPtr += 2;
+	    }
+
+	    writeSeq(0x02, 1 << 1);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) << 4);
+ 		*dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) << 4);
+ 		s1 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		m = (srcPtr[3] & 0x02020202) | ((srcPtr[2] & 0x02020202) << 4);
+ 		s2 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		m = (srcPtr[5] & 0x02020202) | ((srcPtr[4] & 0x02020202) << 4);
+ 		s3 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		m = (srcPtr[7] & 0x02020202) | ((srcPtr[6] & 0x02020202) << 4);
+ 		s4 = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x02020202) | ((srcPtr[0] & 0x02020202) << 4);
+ 		*dstPtr++ = (m >> 25) | (m >> 16) | (m >> 7) | (m << 2);
+		srcPtr += 2;
+	    }
+
+	    writeSeq(0x02, 1 << 2);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) << 4);
+ 		*dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) << 4);
+ 		s1 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		m = (srcPtr[3] & 0x04040404) | ((srcPtr[2] & 0x04040404) << 4);
+ 		s2 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		m = (srcPtr[5] & 0x04040404) | ((srcPtr[4] & 0x04040404) << 4);
+ 		s3 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		m = (srcPtr[7] & 0x04040404) | ((srcPtr[6] & 0x04040404) << 4);
+ 		s4 = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x04040404) | ((srcPtr[0] & 0x04040404) << 4);
+ 		*dstPtr++ = (m >> 26) | (m >> 17) | (m >> 8) | (m << 1);
+		srcPtr += 2;
+	    }
+	    
+	    writeSeq(0x02, 1 << 3);
+	    dstPtr = dst;
+	    srcPtr = src;
+	    i = width;
+	    j = phase;
+	    while(j--) {
+		m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) << 4);
+ 		*dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		srcPtr += 2;
+	    }
+	    while(i >= 4) {
+		m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) << 4);
+ 		s1 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		m = (srcPtr[3] & 0x08080808) | ((srcPtr[2] & 0x08080808) << 4);
+ 		s2 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		m = (srcPtr[5] & 0x08080808) | ((srcPtr[4] & 0x08080808) << 4);
+ 		s3 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		m = (srcPtr[7] & 0x08080808) | ((srcPtr[6] & 0x08080808) << 4);
+ 		s4 = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		*((Uint32*)dstPtr) = s1 | (s2 << 8) | (s3 << 16) | (s4 << 24);
+		srcPtr += 8;
+		dstPtr += 4;
+		i -= 4;
+	    }
+	    while(i--) {
+		m = (srcPtr[1] & 0x08080808) | ((srcPtr[0] & 0x08080808) << 4);
+ 		*dstPtr++ = (m >> 27) | (m >> 18) | (m >> 9) | m;
+		srcPtr += 2;
+	    }
+
+            dst += FBPitch;
+            src += SRCPitch;
+        }
+        rects++;
+    }
+}
+#endif /* VGA16_FBCON_SUPPORT */
+
+void FB_SavePaletteTo(_THIS, int palette_len, __u16 *area)
+{
+	struct fb_cmap cmap;
+
+	cmap.start = 0;
+	cmap.len = palette_len;
+	cmap.red = &area[0*palette_len];
+	cmap.green = &area[1*palette_len];
+	cmap.blue = &area[2*palette_len];
+	cmap.transp = NULL;
+	ioctl(console_fd, FBIOGETCMAP, &cmap);
+}
+
+void FB_RestorePaletteFrom(_THIS, int palette_len, __u16 *area)
+{
+	struct fb_cmap cmap;
+
+	cmap.start = 0;
+	cmap.len = palette_len;
+	cmap.red = &area[0*palette_len];
+	cmap.green = &area[1*palette_len];
+	cmap.blue = &area[2*palette_len];
+	cmap.transp = NULL;
+	ioctl(console_fd, FBIOPUTCMAP, &cmap);
+}
+
+static void FB_SavePalette(_THIS, struct fb_fix_screeninfo *finfo,
+                                  struct fb_var_screeninfo *vinfo)
+{
+	int i;
+
+	/* Save hardware palette, if needed */
+	if ( finfo->visual == FB_VISUAL_PSEUDOCOLOR ) {
+		saved_cmaplen = 1<<vinfo->bits_per_pixel;
+		saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap));
+		if ( saved_cmap != NULL ) {
+			FB_SavePaletteTo(this, saved_cmaplen, saved_cmap);
+		}
+	}
+
+	/* Added support for FB_VISUAL_DIRECTCOLOR.
+	   With this mode pixel information is passed through the palette...
+	   Neat fading and gamma correction effects can be had by simply
+	   fooling around with the palette instead of changing the pixel
+	   values themselves... Very neat!
+
+	   Adam Meyerowitz 1/19/2000
+	   ameyerow@optonline.com
+	*/
+	if ( finfo->visual == FB_VISUAL_DIRECTCOLOR ) {
+		__u16 new_entries[3*256];
+
+		/* Save the colormap */
+		saved_cmaplen = 256;
+		saved_cmap=(__u16 *)malloc(3*saved_cmaplen*sizeof(*saved_cmap));
+		if ( saved_cmap != NULL ) {
+			FB_SavePaletteTo(this, saved_cmaplen, saved_cmap);
+		}
+
+		/* Allocate new identity colormap */
+		for ( i=0; i<256; ++i ) {
+	      		new_entries[(0*256)+i] =
+			new_entries[(1*256)+i] =
+			new_entries[(2*256)+i] = (i<<8)|i;
+		}
+		FB_RestorePaletteFrom(this, 256, new_entries);
+	}
+}
+
+static void FB_RestorePalette(_THIS)
+{
+	/* Restore the original palette */
+	if ( saved_cmap ) {
+		FB_RestorePaletteFrom(this, saved_cmaplen, saved_cmap);
+		free(saved_cmap);
+		saved_cmap = NULL;
+	}
+}
+
+static int FB_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color *colors)
+{
+	int i;
+	__u16 r[256];
+	__u16 g[256];
+	__u16 b[256];
+	struct fb_cmap cmap;
+
+	/* Set up the colormap */
+	for (i = 0; i < ncolors; i++) {
+		r[i] = colors[i].r << 8;
+		g[i] = colors[i].g << 8;
+		b[i] = colors[i].b << 8;
+	}
+	cmap.start = firstcolor;
+	cmap.len = ncolors;
+	cmap.red = r;
+	cmap.green = g;
+	cmap.blue = b;
+	cmap.transp = NULL;
+
+	if( (ioctl(console_fd, FBIOPUTCMAP, &cmap) < 0) ||
+	    !(this->screen->flags & SDL_HWPALETTE) ) {
+	        colors = this->screen->format->palette->colors;
+		ncolors = this->screen->format->palette->ncolors;
+		cmap.start = 0;
+		cmap.len = ncolors;
+		memset(r, 0, sizeof(r));
+		memset(g, 0, sizeof(g));
+		memset(b, 0, sizeof(b));
+		if ( ioctl(console_fd, FBIOGETCMAP, &cmap) == 0 ) {
+			for ( i=ncolors-1; i>=0; --i ) {
+				colors[i].r = (r[i]>>8);
+				colors[i].g = (g[i]>>8);
+				colors[i].b = (b[i]>>8);
+			}
+		}
+		return(0);
+	}
+	return(1);
+}
+
+/* Note:  If we are terminated, this could be called in the middle of
+   another SDL video routine -- notably UpdateRects.
+*/
+static void FB_VideoQuit(_THIS)
+{
+	int i, j;
+
+	if ( this->screen ) {
+		/* Clear screen and tell SDL not to free the pixels */
+// ghcstop fix to original: 041123
+#if FB_INPUT_DEVICE_ENABLE
+		if ( this->screen->pixels && FB_InGraphicsMode(this) ) {
+#else			
+		if ( this->screen->pixels  ) {
+#endif
+			
+#ifdef __powerpc__	/* SIGBUS when using memset() ?? */
+			Uint8 *rowp = (Uint8 *)this->screen->pixels;
+			int left = this->screen->pitch*this->screen->h;
+			while ( left-- ) { *rowp++ = 0; }
+#else
+			memset(this->screen->pixels,0,this->screen->h*this->screen->pitch);
+#endif
+		}
+		/* This test fails when using the VGA16 shadow memory */
+		if ( ((char *)this->screen->pixels >= mapped_mem) &&
+		     ((char *)this->screen->pixels < (mapped_mem+mapped_memlen)) ) {
+			this->screen->pixels = NULL;
+		}
+	}
+
+	/* Clear the lock mutex */
+	if ( hw_lock ) {
+		SDL_DestroyMutex(hw_lock);
+		hw_lock = NULL;
+	}
+
+	/* Clean up defined video modes */
+	for ( i=0; i<NUM_MODELISTS; ++i ) {
+		if ( SDL_modelist[i] != NULL ) {
+			for ( j=0; SDL_modelist[i][j]; ++j ) {
+				free(SDL_modelist[i][j]);
+			}
+			free(SDL_modelist[i]);
+			SDL_modelist[i] = NULL;
+		}
+	}
+
+	/* Clean up the memory bucket list */
+	FB_FreeHWSurfaces(this);
+
+	/* Close console and input file descriptors */
+	if ( console_fd > 0 ) {
+		/* Unmap the video framebuffer and I/O registers */
+		if ( mapped_mem ) {
+			munmap(mapped_mem, mapped_memlen);
+			mapped_mem = NULL;
+		}
+		if ( mapped_io ) {
+			munmap(mapped_io, mapped_iolen);
+			mapped_io = NULL;
+		}
+#ifdef SDL_MMSP2
+		mmsp2_regs[SYSCLKENREG] |= ~FASTIOCLK;
+		if (mmsp2_regs) {
+		  munmap(mmsp2_regs, 0x10000);
+		  mmsp2_regs = NULL;
+		}
+		if (mmsp2_blit_regs) {
+		  munmap(mmsp2_blit_regs, 0x100);
+		  mmsp2_blit_regs = NULL;
+		}
+#endif
+        #if 0 // ghcstop delete, palette는 쓰지 않는다.
+		/* Restore the original video mode and palette */
+		if ( FB_InGraphicsMode(this) ) {
+			FB_RestorePalette(this);
+			ioctl(console_fd, FBIOPUT_VSCREENINFO, &saved_vinfo);
+		}
+        #endif
+
+		/* We're all done with the framebuffer */
+		close(console_fd);
+		console_fd = -1;
+	}
+#if FB_INPUT_DEVICE_ENABLE	// ghcstop
+	#if 0 // ghcstop_041123 delete, 이부분은 나중에 원복할 것
+	FB_CloseMouse(this);
+	#endif
+	dprintf("FB_closeKeyboard\n"); // ghcstop
+	FB_CloseKeyboard(this);
+#endif	
+}
diff -urN SDL-1.2.9/src/video/gp2x/SDL_gp2xevents.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xevents.c
--- SDL-1.2.9/src/video/gp2x/SDL_gp2xevents.c	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xevents.c	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,881 @@
+/*
+  SDL - Simple DirectMedia Layer
+  Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+  "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+/* Handle the event stream, converting console events into SDL events */
+
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/ioctl.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <string.h>
+#include <errno.h>
+#include <limits.h>
+
+/* For parsing /proc */
+#include <dirent.h>
+#include <ctype.h>
+
+#include <linux/vt.h>
+#include <linux/kd.h>
+#include <linux/keyboard.h>
+
+#include "SDL.h"
+#include "SDL_mutex.h"
+#include "SDL_sysevents.h"
+#include "SDL_sysvideo.h"
+#include "SDL_events_c.h"
+#include "SDL_gp2xvideo.h"
+#include "SDL_gp2xevents_c.h"
+//#include "SDL_gp2xkeys.h"
+//#include "SDL_keysym.h"
+
+
+/***********
+ *** Mouse stuff
+ **********/
+//=====================================================
+// Temporarily enable mouse debug for open/close
+#define DEBUG_MOUSE 1
+//=====================================================
+
+static enum {
+  MOUSE_NONE = -1,
+  MOUSE_MSC,	/* Note: GPM uses the MSC protocol */
+  MOUSE_PS2,
+  MOUSE_IMPS2,
+  MOUSE_MS,
+  MOUSE_BM,
+  MOUSE_ELO,
+  NUM_MOUSE_DRVS
+} mouse_drv = MOUSE_NONE;
+
+void GP2X_CloseMouse(_THIS)
+{
+  if (this->hidden->mouse_fd > 0) {
+    close(this->hidden->mouse_fd);
+  }
+  this->hidden->mouse_fd = -1;
+}
+
+
+/* rcg06112001 Set up IMPS/2 mode, if possible. This gives
+ *  us access to the mousewheel, etc. Returns zero if
+ *  writes to device failed, but you still need to query the
+ *  device to see which mode it's actually in.
+ */
+static int set_imps2_mode(int fd)
+{
+  /* If you wanted to control the mouse mode (and we do :)  ) ...
+     Set IMPS/2 protocol:
+     {0xf3,200,0xf3,100,0xf3,80}
+     Reset mouse device:
+     {0xFF}
+  */
+  Uint8 set_imps2[] = {0xf3, 200, 0xf3, 100, 0xf3, 80};
+  Uint8 reset = 0xff;
+  fd_set fdset;
+  struct timeval tv;
+  int retval = 0;
+  
+  if (write(fd, &set_imps2, sizeof(set_imps2)) == sizeof(set_imps2)) {
+    if (write(fd, &reset, sizeof (reset)) == sizeof (reset)) {
+      retval = 1;
+    }
+  }
+  
+  /* Get rid of any chatter from the above */
+  FD_ZERO(&fdset);
+  FD_SET(fd, &fdset);
+  tv.tv_sec = 0;
+  tv.tv_usec = 0;
+  while (select(fd+1, &fdset, 0, 0, &tv) > 0) {
+    char temp[32];
+    read(fd, temp, sizeof(temp));
+  }
+  
+  return retval;
+}
+
+
+/* Returns true if the mouse uses the IMPS/2 protocol */
+static int detect_imps2(int fd)
+{
+  int imps2;
+  
+  imps2 = 0;
+  
+  if (getenv("SDL_MOUSEDEV_IMPS2")) {
+    imps2 = 1;
+  }
+  if (!imps2) {
+    Uint8 query_ps2 = 0xF2;
+    fd_set fdset;
+    struct timeval tv;
+    
+    /* Get rid of any mouse motion noise */
+    FD_ZERO(&fdset);
+    FD_SET(fd, &fdset);
+    tv.tv_sec = 0;
+    tv.tv_usec = 0;
+    while (select(fd+1, &fdset, 0, 0, &tv) > 0) {
+      char temp[32];
+      read(fd, temp, sizeof(temp));
+    }
+    
+    /* Query for the type of mouse protocol */
+    if (write(fd, &query_ps2, sizeof (query_ps2)) == sizeof (query_ps2)) {
+      Uint8 ch = 0;
+      
+      /* Get the mouse protocol response */
+      do {
+	FD_ZERO(&fdset);
+	FD_SET(fd, &fdset);
+	tv.tv_sec = 1;
+	tv.tv_usec = 0;
+	if (select(fd+1, &fdset, 0, 0, &tv) < 1) {
+	  break;
+	}
+      } while ((read(fd, &ch, sizeof (ch)) == sizeof (ch)) &&
+	       ((ch == 0xFA) || (ch == 0xAA)) );
+      
+      /* Experimental values (Logitech wheelmouse) */
+#ifdef DEBUG_MOUSE
+      fprintf(stderr, "Last mouse mode: 0x%x\n", ch);
+#endif
+      if ((ch == 3) || (ch == 4)) {
+	imps2 = 1;
+      }
+    }
+  }
+  return imps2;
+}
+
+int GP2X_OpenMouse(_THIS)
+{
+  int i;
+  const char *mousedev;
+  const char *mousedrv;
+  
+  mousedrv = getenv("SDL_MOUSEDRV");
+  mousedev = getenv("SDL_MOUSEDEV");
+  this->hidden->mouse_fd = -1;
+  
+  /* STD MICE */
+#ifdef DEBUG_MOUSE
+  fputs("SDL_GP2X: Looking for a mouse\n", stderr);
+#endif
+  if (mousedev == NULL) {
+    /* FIXME someday... allow multiple mice in this driver */
+    static const char * const ps2mice[] = {
+      "/dev/input/mouse/0", "/dev/usbmouse", "/dev/psaux", NULL
+    };
+    /* Now try to use a modern PS/2 mouse */
+    for (i=0; (this->hidden->mouse_fd < 0) && ps2mice[i]; ++i ) {
+      this->hidden->mouse_fd = open(ps2mice[i], O_RDWR, 0);
+      if (this->hidden->mouse_fd < 0) {
+	this->hidden->mouse_fd = open(ps2mice[i], O_RDONLY, 0);
+      }
+      if (this->hidden->mouse_fd >= 0) {
+	/* rcg06112001 Attempt to set IMPS/2 mode */
+	if (i == 0) {
+	  set_imps2_mode(this->hidden->mouse_fd);
+	}
+	if (detect_imps2(this->hidden->mouse_fd)) {
+#ifdef DEBUG_MOUSE
+	  fprintf(stderr, "Using IMPS2 mouse\n");
+#endif
+	  mouse_drv = MOUSE_IMPS2;
+	} else {
+#ifdef DEBUG_MOUSE
+	  fprintf(stderr, "Using PS2 mouse\n");
+#endif
+	  mouse_drv = MOUSE_PS2;
+	}
+      }
+    }
+  }
+  if (this->hidden->mouse_fd < 0) {
+    mouse_drv = MOUSE_NONE;
+#ifdef DEBUG_MOUSE
+  fputs("SDL_GP2X: No mice found\n", stderr);
+#endif
+  }
+  return this->hidden->mouse_fd;
+}
+
+//============================
+#undef DEBUG_MOUSE
+//============================
+
+static int posted = 0;
+
+void GP2X_vgamousecallback(int button, int relative, int dx, int dy)
+{
+  int button_1, button_3;
+  int button_state;
+  int state_changed;
+  int i;
+  Uint8 state;
+
+  if ( dx || dy ) {
+    posted += SDL_PrivateMouseMotion(0, relative, dx, dy);
+  }
+
+  /* Swap button 1 and 3 */
+  button_1 = (button & 0x04) >> 2;
+  button_3 = (button & 0x01) << 2;
+  button &= ~0x05;
+  button |= (button_1|button_3);
+
+  /* See what changed */
+  button_state = SDL_GetMouseState(NULL, NULL);
+  state_changed = button_state ^ button;
+  for (i=0; i<8; ++i ) {
+    if (state_changed & (1<<i)) {
+      if (button & (1<<i)) {
+	state = SDL_PRESSED;
+      } else {
+	state = SDL_RELEASED;
+      }
+      posted += SDL_PrivateMouseButton(state, i+1, 0, 0);
+    }
+  }
+}
+
+/* For now, use MSC, PS/2, and MS protocols
+   Driver adapted from the SVGAlib mouse driver code (taken from gpm, etc.)
+*/
+static void handle_mouse(_THIS)
+{
+  static int start = 0;
+  static unsigned char mousebuf[BUFSIZ];
+  static int relative = 1;
+
+  int i, nread;
+  int button = 0;
+  int dx = 0, dy = 0;
+  int packetsize = 0;
+  int realx, realy;
+	
+  /* Figure out the mouse packet size */
+  switch (mouse_drv) {
+  case MOUSE_NONE:
+    /* Ack! */
+    read(this->hidden->mouse_fd, mousebuf, BUFSIZ);
+    return;
+  case MOUSE_MSC:
+    packetsize = 5;
+    break;
+  case MOUSE_IMPS2:
+    packetsize = 4;
+    break;
+  case MOUSE_PS2:
+  case MOUSE_MS:
+  case MOUSE_BM:
+    packetsize = 3;
+    break;
+  case MOUSE_ELO:
+  case NUM_MOUSE_DRVS:
+    /* Uh oh.. */
+    packetsize = 0;
+    break;
+  }
+
+  /* Read as many packets as possible */
+  nread = read(this->hidden->mouse_fd, &mousebuf[start], BUFSIZ-start);
+  if (nread < 0) {
+    return;
+  }
+  nread += start;
+#ifdef DEBUG_MOUSE
+  fprintf(stderr, "Read %d bytes from mouse, start = %d\n", nread, start);
+#endif
+  for (i=0; i<(nread-(packetsize-1)); i += packetsize) {
+    switch (mouse_drv) {
+    case MOUSE_NONE:
+      break;
+    case MOUSE_MSC:
+      /* MSC protocol has 0x80 in high byte */
+      if ((mousebuf[i] & 0xF8) != 0x80) {
+	/* Go to next byte */
+	i -= (packetsize-1);
+	continue;
+      }
+      /* Get current mouse state */
+      button = (~mousebuf[i]) & 0x07;
+      dx =   (signed char)(mousebuf[i+1]) +
+	(signed char)(mousebuf[i+3]);
+      dy = -((signed char)(mousebuf[i+2]) +
+	     (signed char)(mousebuf[i+4]));
+      break;
+    case MOUSE_PS2:
+      /* PS/2 protocol has nothing in high byte */
+      if ((mousebuf[i] & 0xC0) != 0) {
+	/* Go to next byte */
+	i -= (packetsize-1);
+	continue;
+      }
+      /* Get current mouse state */
+      button = (mousebuf[i] & 0x04) >> 1 | /*Middle*/
+	(mousebuf[i] & 0x02) >> 1 | /*Right*/
+	(mousebuf[i] & 0x01) << 2;  /*Left*/
+      dx = (mousebuf[i] & 0x10) ?
+	mousebuf[i+1] - 256 : mousebuf[i+1];
+      dy = (mousebuf[i] & 0x20) ?
+	-(mousebuf[i+2] - 256) : -mousebuf[i+2];
+      break;
+    case MOUSE_IMPS2:
+      /* Get current mouse state */
+      button = (mousebuf[i] & 0x04) >> 1 | /*Middle*/
+	(mousebuf[i] & 0x02) >> 1 | /*Right*/
+	(mousebuf[i] & 0x01) << 2 | /*Left*/
+	(mousebuf[i] & 0x40) >> 3 | /* 4 */
+	(mousebuf[i] & 0x80) >> 3;  /* 5 */
+      dx = (mousebuf[i] & 0x10) ?
+	mousebuf[i+1] - 256 : mousebuf[i+1];
+      dy = (mousebuf[i] & 0x20) ?
+	-(mousebuf[i+2] - 256) : -mousebuf[i+2];
+      switch (mousebuf[i+3]&0x0F) {
+      case 0x0E: /* DX = +1 */
+      case 0x02: /* DX = -1 */
+	break;
+      case 0x0F: /* DY = +1 (map button 4) */
+	GP2X_vgamousecallback(button | (1<<3),
+			      1, 0, 0);
+	break;
+      case 0x01: /* DY = -1 (map button 5) */
+	GP2X_vgamousecallback(button | (1<<4),
+			      1, 0, 0);
+	break;
+      }
+      break;
+    case MOUSE_MS:
+    case MOUSE_BM:
+    case MOUSE_ELO:
+    case NUM_MOUSE_DRVS:
+      /* Uh oh.. */
+      dx = 0;
+      dy = 0;
+      break;
+    }
+    GP2X_vgamousecallback(button, relative, dx, dy);
+  }
+  if ( i < nread ) {
+    memcpy(mousebuf, &mousebuf[i], (nread-i));
+    start = (nread-i);
+  } else {
+    start = 0;
+  }
+  return;
+}
+
+
+void GP2X_PumpEvents(_THIS)
+{
+  fd_set fdset;
+  int max_fd;
+  static struct timeval zero;
+
+  do {
+    posted = 0;
+
+    FD_ZERO(&fdset);
+    max_fd = 0;
+    /*** TODO
+    if (this->hidden->keyboard_fd >= 0) {
+			
+      FD_SET(this->hidden->keyboard_fd, &fdset);
+      if (max_fd < this->hidden->keyboard_fd) {
+	max_fd = this->hidden->keyboard_fd;
+      }
+    }
+    ***/
+    if (this->hidden->mouse_fd >= 0) {
+      FD_SET(this->hidden->mouse_fd, &fdset);
+      if (max_fd < this->hidden->mouse_fd) {
+	max_fd = this->hidden->mouse_fd;
+      }
+    }
+    if (select(max_fd+1, &fdset, NULL, NULL, &zero) > 0) {
+      /*** TODO
+      if (this->hidden->keyboard_fd >= 0) {
+	if (FD_ISSET(this->hidden->keyboard_fd, &fdset)) {
+	  handle_keyboard(this);
+	}
+      }
+      ***/
+      if (this->hidden->mouse_fd >= 0) {
+	if (FD_ISSET(this->hidden->mouse_fd, &fdset)) {
+	  handle_mouse(this);
+	}
+      }
+    }
+  } while (posted);
+}
+
+#if 1
+void GP2X_InitOSKeymap(_THIS)
+{
+  /* do nothing. */
+}
+#else
+
+/* The translation tables from a console scancode to a SDL keysym */
+#define NUM_VGAKEYMAPS	(1<<KG_CAPSSHIFT)
+static Uint16 vga_keymap[NUM_VGAKEYMAPS][NR_KEYS];
+static SDLKey keymap[128];
+static Uint16 keymap_temp[128]; /* only used at startup */
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym);
+
+/* Ugh, we have to duplicate the kernel's keysym mapping code...
+   Oh, it's not so bad. :-)
+
+   FIXME: Add keyboard LED handling code
+*/
+static void GP2X_vgainitkeymaps(int fd)
+{
+  struct kbentry entry;
+  int map, i;
+  
+  /* Don't do anything if we are passed a closed keyboard */
+  if (fd < 0) {
+    return;
+  }
+  
+  /* Load all the keysym mappings */
+  for (map=0; map<NUM_VGAKEYMAPS; ++map) {
+    memset(vga_keymap[map], 0, NR_KEYS*sizeof(Uint16));
+    
+    for (i = 0; i < NR_KEYS; ++i) {
+      entry.kb_table = map;
+      entry.kb_index = i;
+      if (ioctl(fd, KDGKBENT, &entry) == 0) {
+	/* fill keytemp. This replaces SDL_fbkeys.h */
+	if ((map == 0) && (i<128)) {
+	  keymap_temp[i] = entry.kb_value;
+	}
+	/* The "Enter" key is a special case */
+	if (entry.kb_value == K_ENTER) {
+	  entry.kb_value = K(KT_ASCII,13);
+	}
+	/* Handle numpad specially as well */
+	if (KTYP(entry.kb_value) == KT_PAD) {
+	  switch (entry.kb_value) {
+	  case K_P0:
+	  case K_P1:
+	  case K_P2:
+	  case K_P3:
+	  case K_P4:
+	  case K_P5:
+	  case K_P6:
+	  case K_P7:
+	  case K_P8:
+	  case K_P9:
+	    vga_keymap[map][i]=entry.kb_value;
+	    vga_keymap[map][i]+= '0';
+	    break;
+	  case K_PPLUS:
+	    vga_keymap[map][i]=K(KT_ASCII,'+');
+	    break;
+	  case K_PMINUS:
+	    vga_keymap[map][i]=K(KT_ASCII,'-');
+	    break;
+	  case K_PSTAR:
+	    vga_keymap[map][i]=K(KT_ASCII,'*');
+	    break;
+	  case K_PSLASH:
+	    vga_keymap[map][i]=K(KT_ASCII,'/');
+	    break;
+	  case K_PENTER:
+	    vga_keymap[map][i]=K(KT_ASCII,'\r');
+	    break;
+	  case K_PCOMMA:
+	    vga_keymap[map][i]=K(KT_ASCII,',');
+	    break;
+	  case K_PDOT:
+	    vga_keymap[map][i]=K(KT_ASCII,'.');
+	    break;
+	  default:
+	    break;
+	  }
+	}
+	/* Do the normal key translation */
+	if ((KTYP(entry.kb_value) == KT_LATIN) ||
+	    (KTYP(entry.kb_value) == KT_ASCII) ||
+	    (KTYP(entry.kb_value) == KT_LETTER)) {
+	  vga_keymap[map][i] = entry.kb_value;
+	}
+      }
+    }
+  }
+}
+
+int GP2X_InGraphicsMode(_THIS)
+{
+  return ((keyboard_fd >= 0) && (saved_kbd_mode >= 0));
+}
+
+int GP2X_EnterGraphicsMode(_THIS)
+{
+  struct termios keyboard_termios;
+  
+  /* Set medium-raw keyboard mode */
+  if ((keyboard_fd >= 0) && !GP2X_InGraphicsMode(this)) {
+    
+    /* Set the terminal input mode */
+    if (tcgetattr(keyboard_fd, &saved_kbd_termios) < 0) {
+      SDL_SetError("Unable to get terminal attributes");
+      if (keyboard_fd > 0) {
+	close(keyboard_fd);
+      }
+      keyboard_fd = -1;
+      return(-1);
+    }
+    keyboard_termios = saved_kbd_termios;
+    
+    keyboard_termios.c_lflag = 0;
+    keyboard_termios.c_iflag &= ~(ISTRIP | IGNCR | ICRNL | INLCR | IXOFF | IXON);
+    
+    keyboard_termios.c_cc[VTIME]    = 0;   // 문자 사이의 timer를 disable
+    keyboard_termios.c_cc[VMIN]     = 1;   // 최소 5 문자 받을 때까진 blocking
+    
+    tcflush(keyboard_fd, TCIFLUSH);
+    
+    if (tcsetattr(keyboard_fd, TCSAFLUSH, &keyboard_termios) < 0) {
+      GP2X_CloseKeyboard(this);
+      SDL_SetError("Unable to set terminal attributes");
+      return(-1);
+    }
+    
+    
+  }
+  return(keyboard_fd);
+}
+
+void GP2X_LeaveGraphicsMode(_THIS)
+{
+  tcsetattr(keyboard_fd, TCSAFLUSH, &saved_kbd_termios);
+  saved_kbd_mode = -1;
+}
+
+void GP2X_CloseKeyboard(_THIS)
+{
+  if (keyboard_fd >= 0) {
+    GP2X_LeaveGraphicsMode(this);
+    if (keyboard_fd > 0) {
+      close(keyboard_fd);
+    }
+  }
+  keyboard_fd = -1;
+}
+
+int GP2X_OpenKeyboard(_THIS)
+{
+  /* Open only if not already opened */
+  if ( keyboard_fd < 0 ) {
+    static const char * const tty0[] = { "/dev/tty0", "/dev/vc/0", NULL };
+    static const char * const vcs[] = { "/dev/vc/%d", "/dev/tty%d", NULL };
+    int i, tty0_fd;
+    
+    /* Try to query for a free virtual terminal */
+    tty0_fd = -1;
+    for (i = 0; tty0[i] && (tty0_fd < 0); ++i) {
+      tty0_fd = open(tty0[i], O_WRONLY, 0);
+    }
+    
+    if ( keyboard_fd < 0 ) {
+      /* Last resort, maybe our tty is a usable VT */
+      current_vt = 0;
+      keyboard_fd = open("/dev/tty", O_RDWR);
+    }
+#ifdef DEBUG_KEYBOARD
+    fprintf(stderr, "Current VT: %d\n", current_vt);
+#endif
+    saved_kbd_mode = -1;
+    
+  }
+  return(keyboard_fd);
+}
+
+static void handle_keyboard(_THIS)
+{
+  unsigned char keybuf[BUFSIZ];
+  int i, nread;
+  int pressed;
+  int scancode;
+  SDL_keysym keysym;
+
+  nread = read(keyboard_fd, keybuf, BUFSIZ);
+	
+  // ghcstop add: 041206  확장키의 경우는 처리를 하지 않는다.
+  if (nread >= 3) return; 
+
+  for (i = 0; i<nread; ++i) {
+    scancode = keybuf[i] & 0x7F;
+    if (keybuf[i] & 0x80) {
+      pressed = SDL_RELEASED;
+    } else {
+      pressed = SDL_PRESSED;
+    }
+    TranslateKey(scancode, &keysym);
+
+    /* Handle Alt-FN for vt switch */
+    switch (keysym.sym) {
+    case SDLK_F1:
+    case SDLK_F2:
+    case SDLK_F3:
+    case SDLK_F4:
+    case SDLK_F5:
+    case SDLK_F6:
+    case SDLK_F7:
+    case SDLK_F8:
+    case SDLK_F9:
+    case SDLK_F10:
+    case SDLK_F11:
+    case SDLK_F12:
+      if (SDL_GetModState() & KMOD_ALT) {
+	if (pressed) {
+	  switch_vt(this, (keysym.sym-SDLK_F1)+1);
+	}
+	break;
+      }
+      /* Fall through to normal processing */
+    default:
+      posted += SDL_PrivateKeyboard(pressed, &keysym);
+      break;
+    }
+  }
+}
+
+#if 0 ****** Why is GP2X different? Needs checking
+void GP2X_InitOSKeymap(_THIS)
+{
+  int i;
+
+  /* Initialize the Linux key translation table */
+
+  /* First get the ascii keys and others not well handled */
+  for (i=0; i<SDL_TABLESIZE(keymap); ++i) {
+    switch(i) {
+      /* These aren't handled by the x86 kernel keymapping (?) */
+    case SCANCODE_PRINTSCREEN:
+      keymap[i] = SDLK_PRINT;
+      break;
+    case SCANCODE_BREAK:
+      keymap[i] = SDLK_BREAK;
+      break;
+    case SCANCODE_BREAK_ALTERNATIVE:
+      keymap[i] = SDLK_PAUSE;
+      break;
+    case SCANCODE_LEFTSHIFT:
+      keymap[i] = SDLK_LSHIFT;
+      break;
+    case SCANCODE_RIGHTSHIFT:
+      keymap[i] = SDLK_RSHIFT;
+      break;
+    case SCANCODE_LEFTCONTROL:
+      keymap[i] = SDLK_LCTRL;
+      break;
+    case SCANCODE_RIGHTCONTROL:
+      keymap[i] = SDLK_RCTRL;
+      break;
+    case SCANCODE_RIGHTWIN:
+      keymap[i] = SDLK_RSUPER;
+      break;
+    case SCANCODE_LEFTWIN:
+      keymap[i] = SDLK_LSUPER;
+      break;
+    case 127:
+      keymap[i] = SDLK_MENU;
+      break;
+      /* this should take care of all standard ascii keys */
+    default:
+      keymap[i] = KVAL(vga_keymap[0][i]);
+      break;
+    }
+  }
+  for (i=0; i<SDL_TABLESIZE(keymap); ++i) {
+    switch(keymap_temp[i]) {
+    case K_F1:  keymap[i] = SDLK_F1;  break;
+    case K_F2:  keymap[i] = SDLK_F2;  break;
+    case K_F3:  keymap[i] = SDLK_F3;  break;
+    case K_F4:  keymap[i] = SDLK_F4;  break;
+    case K_F5:  keymap[i] = SDLK_F5;  break;
+    case K_F6:  keymap[i] = SDLK_F6;  break;
+    case K_F7:  keymap[i] = SDLK_F7;  break;
+    case K_F8:  keymap[i] = SDLK_F8;  break;
+    case K_F9:  keymap[i] = SDLK_F9;  break;
+    case K_F10: keymap[i] = SDLK_F10; break;
+    case K_F11: keymap[i] = SDLK_F11; break;
+    case K_F12: keymap[i] = SDLK_F12; break;
+
+    case K_DOWN:  keymap[i] = SDLK_DOWN;  break;
+    case K_LEFT:  keymap[i] = SDLK_LEFT;  break;
+    case K_RIGHT: keymap[i] = SDLK_RIGHT; break;
+    case K_UP:    keymap[i] = SDLK_UP;    break;
+
+    case K_P0:     keymap[i] = SDLK_KP0; break;
+    case K_P1:     keymap[i] = SDLK_KP1; break;
+    case K_P2:     keymap[i] = SDLK_KP2; break;
+    case K_P3:     keymap[i] = SDLK_KP3; break;
+    case K_P4:     keymap[i] = SDLK_KP4; break;
+    case K_P5:     keymap[i] = SDLK_KP5; break;
+    case K_P6:     keymap[i] = SDLK_KP6; break;
+    case K_P7:     keymap[i] = SDLK_KP7; break;
+    case K_P8:     keymap[i] = SDLK_KP8; break;
+    case K_P9:     keymap[i] = SDLK_KP9; break;
+    case K_PPLUS:  keymap[i] = SDLK_KP_PLUS; break;
+    case K_PMINUS: keymap[i] = SDLK_KP_MINUS; break;
+    case K_PSTAR:  keymap[i] = SDLK_KP_MULTIPLY; break;
+    case K_PSLASH: keymap[i] = SDLK_KP_DIVIDE; break;
+    case K_PENTER: keymap[i] = SDLK_KP_ENTER; break;
+    case K_PDOT:   keymap[i] = SDLK_KP_PERIOD; break;
+
+    case K_SHIFT:  if ( keymap[i] != SDLK_RSHIFT )
+	keymap[i] = SDLK_LSHIFT;
+      break;
+    case K_SHIFTL: keymap[i] = SDLK_LSHIFT; break;
+    case K_SHIFTR: keymap[i] = SDLK_RSHIFT; break;
+    case K_CTRL:  if ( keymap[i] != SDLK_RCTRL )
+	keymap[i] = SDLK_LCTRL;
+      break;
+    case K_CTRLL:  keymap[i] = SDLK_LCTRL;  break;
+    case K_CTRLR:  keymap[i] = SDLK_RCTRL;  break;
+    case K_ALT:    keymap[i] = SDLK_LALT;   break;
+    case K_ALTGR:  keymap[i] = SDLK_RALT;   break;
+
+    case K_INSERT: keymap[i] = SDLK_INSERT;   break;
+    case K_REMOVE: keymap[i] = SDLK_DELETE;   break;
+    case K_PGUP:   keymap[i] = SDLK_PAGEUP;   break;
+    case K_PGDN:   keymap[i] = SDLK_PAGEDOWN; break;
+    case K_FIND:   keymap[i] = SDLK_HOME;     break;
+    case K_SELECT: keymap[i] = SDLK_END;      break;
+
+    case K_NUM:  keymap[i] = SDLK_NUMLOCK;   break;
+    case K_CAPS: keymap[i] = SDLK_CAPSLOCK;  break;
+
+    case K_F13:   keymap[i] = SDLK_PRINT;     break;
+    case K_HOLD:  keymap[i] = SDLK_SCROLLOCK; break;
+    case K_PAUSE: keymap[i] = SDLK_PAUSE;     break;
+
+    case 127: keymap[i] = SDLK_BACKSPACE; break;
+	     
+    default: break;
+    }
+  }
+}
+#else
+
+void GP2X_InitOSKeymap(_THIS)
+{
+  int i;
+
+  /* Initialize the Linux key translation table */
+
+  /* First get the ascii keys and others not well handled */
+  for (i=0; i<SDL_TABLESIZE(keymap); ++i)  // 128개 까정 
+    {
+      keymap[i] = 0; // all key map clear ==> 몽땅 SDLK_UNKNOWN로 일단 세팅
+    }
+	
+  keymap[0] =  SDLK_UNKNOWN	;
+  keymap[3] =  SDLK_CTRL_C	;
+  keymap[8] =  SDLK_BACKSPACE	;
+  keymap[9] =  SDLK_TAB		;
+  keymap[12] = SDLK_CLEAR		;
+  keymap[13] = SDLK_RETURN	;	
+  keymap[19] = SDLK_PAUSE		;
+  keymap[27] = SDLK_ESCAPE    ;
+	
+	
+  for (i=32; i<=64; ++i)  // ' ' 에서부터 '@'까지의 32개 
+    {
+      keymap[i] = i; // all key map clear ==> 몽땅 SDLK_UNKNOWN로 일단 세팅
+    }
+	
+  for (i=91; i<=122; ++i)  // '[' 에서부터 'z'까지의 32개 
+    {
+      keymap[i] = i; // all key map clear ==> 몽땅 SDLK_UNKNOWN로 일단 세팅
+    }
+
+  keymap[127] = SDLK_DELETE    ;	
+       
+	
+}
+
+#endif
+
+static SDL_keysym *TranslateKey(int scancode, SDL_keysym *keysym)
+{
+  /* Set the keysym information */
+  keysym->scancode = scancode;
+  keysym->sym = keymap[scancode];
+  keysym->mod = KMOD_NONE;
+
+  /* If UNICODE is on, get the UNICODE value for the key */
+  keysym->unicode = 0;
+#if 0 // 041206: ghcstop delete 왜냐? 아예 keymap을 내맘대로 serial console용으로 변화시켰기 때문
+  if ( SDL_TranslateUNICODE ) {
+    int map;
+    SDLMod modstate;
+
+    modstate = SDL_GetModState();
+    map = 0;
+    if ( modstate & KMOD_SHIFT ) {
+      map |= (1<<KG_SHIFT);
+    }
+    if ( modstate & KMOD_CTRL ) {
+      map |= (1<<KG_CTRL);
+    }
+    if ( modstate & KMOD_ALT ) {
+      map |= (1<<KG_ALT);
+    }
+    if ( modstate & KMOD_MODE ) {
+      map |= (1<<KG_ALTGR);
+    }
+    if ( KTYP(vga_keymap[map][scancode]) == KT_LETTER ) {
+      if ( modstate & KMOD_CAPS ) {
+	map ^= (1<<KG_SHIFT);
+      }
+    }
+    if ( KTYP(vga_keymap[map][scancode]) == KT_PAD ) {
+      if ( modstate & KMOD_NUM ) {
+	keysym->unicode=KVAL(vga_keymap[map][scancode]);
+      }
+    } else {
+      keysym->unicode = KVAL(vga_keymap[map][scancode]);
+    }
+  }
+#endif 
+  return(keysym);
+}
+
+#endif /* Keyboard support commented out for now */
+
+/* end of SDL_gp2xevents.c ... */
diff -urN SDL-1.2.9/src/video/gp2x/SDL_gp2xevents_c.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xevents_c.h
--- SDL-1.2.9/src/video/gp2x/SDL_gp2xevents_c.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xevents_c.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,39 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+#include "SDL_gp2xvideo.h"
+
+/* Variables and functions exported by SDL_sysevents.c to other parts 
+   of the native video subsystem (SDL_sysvideo.c)
+*/
+extern int GP2X_OpenMouse(_THIS);
+extern void GP2X_CloseMouse(_THIS);
+extern void GP2X_InitOSKeymap(_THIS);
+extern void GP2X_PumpEvents(_THIS);
+
+/* end of SDL_gp2xevents_c.h ... */
+
diff -urN SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse.c
--- SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse.c	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse.c	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,42 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+#include <stdio.h>
+
+#include "SDL_error.h"
+#include "SDL_mouse.h"
+#include "SDL_events_c.h"
+
+#include "SDL_gp2xmouse_c.h"
+
+
+/* The implementation dependent data for the window manager cursor */
+struct WMcursor {
+  video_bucket *bucket;
+  int dimension;
+  unsigned short fgr, fb, bgr, bb, falpha, balpha;
+};
diff -urN SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse_c.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse_c.h
--- SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse_c.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xmouse_c.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,30 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+#include "SDL_gp2xvideo.h"
+
+/* Functions to be exported */
diff -urN SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.c
--- SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.c	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.c	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,1374 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+/*
+ * GP2X SDL video driver implementation,
+ *  Base, dummy.
+ *  Memory routines based on fbcon
+ */
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+#include "SDL.h"
+#include "SDL_error.h"
+#include "SDL_video.h"
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_pixels_c.h"
+#include "SDL_events_c.h"
+
+#include "SDL_gp2xvideo.h"
+#include "SDL_gp2xevents_c.h"
+#include "SDL_gp2xmouse_c.h"
+#include "mmsp2_regs.h"
+
+#define GP2XVID_DRIVER_NAME "GP2X"
+
+
+// Initialization/Query functions
+static int GP2X_VideoInit(_THIS, SDL_PixelFormat *vformat);
+static SDL_Rect **GP2X_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
+static SDL_Surface *GP2X_SetVideoMode(_THIS, SDL_Surface *current,
+				      int width, int height,
+				      int bpp, Uint32 flags);
+static int GP2X_SetColors(_THIS, int firstcolor, int ncolors,
+			  SDL_Color *colors);
+static void GP2X_VideoQuit(_THIS);
+
+// Hardware surface functions
+static void GP2X_SurfaceFree(_THIS, video_bucket *bucket);
+static video_bucket *GP2X_SurfaceAllocate(_THIS, int size);
+
+static int GP2X_InitHWSurfaces(_THIS, SDL_Surface *screen,
+			       char *base, int size);
+static void GP2X_FreeHWSurfaces(_THIS);
+static int GP2X_AllocHWSurface(_THIS, SDL_Surface *surface);
+static int GP2X_LockHWSurface(_THIS, SDL_Surface *surface);
+static void GP2X_UnlockHWSurface(_THIS, SDL_Surface *surface);
+static void GP2X_FreeHWSurface(_THIS, SDL_Surface *surface);
+static void GP2X_DummyBlit(_THIS);
+static int GP2X_FlipHWSurface(_THIS, SDL_Surface *surface);
+// etc.
+static void GP2X_UpdateRects(_THIS, int numrects, SDL_Rect *rects);
+static int GP2X_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst);
+static int GP2X_FillHWRect(_THIS, SDL_Surface *surface,
+			   SDL_Rect *area, Uint32 colour);
+static int GP2X_HWAccelBlit(SDL_Surface *src, SDL_Rect *src_rect,
+			    SDL_Surface *dst, SDL_Rect *dst_rect);
+// cursor
+static WMcursor *GP2X_CreateWMCursor(SDL_VideoDevice *video,
+				     Uint8 *data, Uint8 *mask,
+				     int w, int h,
+				     int hot_x, int hot_y);
+static void GP2X_FreeWMCursor(_THIS, WMcursor *cursor);
+static int GP2X_ShowWMCursor(_THIS, WMcursor *cursor);
+static void GP2X_WarpWMCursor(_THIS, Uint16 x, Uint16 y);
+static void GP2X_MoveWMCursor(_THIS, int x, int y);
+
+////////
+// GP2X driver bootstrap functions
+////////
+
+////
+// Are we available?
+static int GP2X_Available(void)
+{
+  // Of course we are.
+  return 1;
+}
+
+////
+// Cleanup routine
+static void GP2X_DeleteDevice(SDL_VideoDevice *device)
+{
+  SDL_PrivateVideoData *data = device->hidden;
+  int i;
+#ifdef GP2X_DEBUG
+  fputs("SDL_GP2X: DeleteDevice\n", stderr);
+#endif
+
+  if (data->fio)
+    munmap(data->fio, 0x100);
+  if (data->io) {
+    // Clear register bits we clobbered if they weren't on
+    if (data->fastioclk == 0)
+      data->io[SYSCLKENREG] &= ~(FASTIOCLK);
+    if (data->grpclk == 0)
+      data->io[VCLKENREG] &= ~(GRPCLK);
+    // reset display hardware
+    data->io[MLC_STL_CNTL]   = data->stl_cntl;
+    data->io[MLC_STL_MIXMUX] = data->stl_mixmux;
+    data->io[MLC_STL_ALPHAL] = data->stl_alphal;
+    data->io[MLC_STL_ALPHAH] = data->stl_alphah;
+    data->io[MLC_STL_HSC]    = data->stl_hsc;
+    data->io[MLC_STL_VSCL]   = data->stl_vscl;
+    data->io[MLC_STL_VSCH]   = data->stl_vsch;
+    data->io[MLC_STL_HW]     = data->stl_hw;
+    data->io[MLC_STL_OADRL]  = data->stl_oadrl;
+    data->io[MLC_STL_OADRH]  = data->stl_oadrh;
+    data->io[MLC_STL_EADRL]  = data->stl_eadrl;
+    data->io[MLC_STL_EADRH]  = data->stl_eadrh;
+    for (i = 0; i < 16; i++)
+      data->io[MLC_STL1_STX + i] = data->stl_regions[i];
+    data->io[MLC_OVLAY_CNTR] = data->mlc_ovlay_cntr;
+    munmap(data->io, 0x10000);
+  }
+  if (data->vmem)
+    munmap(data->vmem, GP2X_VIDEO_MEM_SIZE);
+
+  if (data->fbcon_fd)
+    close(data->fbcon_fd);
+
+  if (data->memory_fd)
+    close(data->memory_fd);
+  free(device->hidden);
+  free(device);
+}
+
+////
+// Initalize driver
+static SDL_VideoDevice *GP2X_CreateDevice(int devindex)
+{
+  SDL_VideoDevice *device;
+#ifdef GP2X_DEBUG
+  fputs("SDL_GP2X: CreateDevice\n", stderr);
+#endif  
+
+  /* Initialize all variables that we clean on shutdown */
+  device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
+  if (device) {
+    memset(device, 0, (sizeof *device));
+    device->hidden = (struct SDL_PrivateVideoData *)
+      malloc((sizeof *device->hidden));
+  }
+  if ((device == NULL) || (device->hidden == NULL)) {
+    SDL_OutOfMemory();
+    if (device) {
+      free(device);
+    }
+    return 0;
+  }
+  memset(device->hidden, 0, (sizeof *device->hidden));
+
+  device->hidden->mouse_fd = -1;
+  device->hidden->keyboard_fd = -1;
+  
+  // Set the function pointers
+  device->VideoInit = GP2X_VideoInit;
+  device->ListModes = GP2X_ListModes;
+  device->SetVideoMode = GP2X_SetVideoMode;
+  device->CreateYUVOverlay = NULL;
+  device->SetColors = GP2X_SetColors;
+  device->UpdateRects = GP2X_UpdateRects;
+  device->VideoQuit = GP2X_VideoQuit;
+  device->AllocHWSurface = GP2X_AllocHWSurface;
+  device->CheckHWBlit = GP2X_CheckHWBlit;
+  device->FillHWRect = GP2X_FillHWRect;
+  device->SetHWColorKey = NULL;
+  device->SetHWAlpha = NULL;
+  device->LockHWSurface = GP2X_LockHWSurface;
+  device->UnlockHWSurface = GP2X_UnlockHWSurface;
+  device->FlipHWSurface = GP2X_FlipHWSurface;
+  device->FreeHWSurface = GP2X_FreeHWSurface;
+  device->SetCaption = NULL;
+  device->SetIcon = NULL;
+  device->IconifyWindow = NULL;
+  device->GrabInput = NULL;
+  device->GetWMInfo = NULL;
+  device->InitOSKeymap = GP2X_InitOSKeymap;
+  device->PumpEvents = GP2X_PumpEvents;
+  device->CreateWMCursor = GP2X_CreateWMCursor;
+  device->FreeWMCursor = GP2X_FreeWMCursor;
+  device->ShowWMCursor = GP2X_ShowWMCursor;
+  device->WarpWMCursor = GP2X_WarpWMCursor;
+  device->MoveWMCursor = GP2X_MoveWMCursor;
+  device->free = GP2X_DeleteDevice;
+  
+  return device;
+}
+
+////
+// Link info to SDL_video
+VideoBootStrap GP2X_bootstrap = {
+  GP2XVID_DRIVER_NAME, "SDL GP2X video driver",
+  GP2X_Available, GP2X_CreateDevice
+};
+
+////
+// Set up hardware
+static int GP2X_VideoInit(_THIS, SDL_PixelFormat *vformat)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+  int i;
+#ifdef GP2X_DEBUG
+  fputs("SDL_GP2X: VideoInit\n", stderr);
+#endif
+
+#ifndef DISABLE_THREADS
+  // Create hardware surface lock mutex
+  data->hw_lock = SDL_CreateMutex();
+  if (data->hw_lock == NULL) {
+    SDL_SetError("Unable to create lock mutex");
+    GP2X_VideoQuit(this);
+    return -1;
+  }
+#endif
+
+  data->memory_fd = open("/dev/mem", O_RDWR, 0);
+  if (data->memory_fd < 0) {
+    SDL_SetError("Unable to open /dev/mem");
+    return -1;
+  }
+  data->fbcon_fd = open("/dev/fb0", O_RDWR, 0);
+  if (data->fbcon_fd < 0) {
+    SDL_SetError("Unable to open /dev/fb0");
+    return -1;
+  }
+  data->vmem = mmap(NULL, GP2X_VIDEO_MEM_SIZE, PROT_READ|PROT_WRITE,
+		    MAP_SHARED, data->memory_fd, 0x3101000);
+  if (data->vmem == (char *)-1) {
+    SDL_SetError("Unable to get video memory");
+    data->vmem = NULL;
+    GP2X_VideoQuit(this);
+    return -1;
+  }
+  data->io = mmap(NULL, 0x10000, PROT_READ|PROT_WRITE,
+		  MAP_SHARED, data->memory_fd, 0xc0000000);
+  if (data->io == (unsigned short *)-1) {
+    SDL_SetError("Unable to get hardware registers");
+    data->io = NULL;
+    GP2X_VideoQuit(this);
+    return -1;
+  }
+  data->fio = mmap(NULL, 0x100, PROT_READ|PROT_WRITE,
+		  MAP_SHARED, data->memory_fd, 0xe0020000);
+  if (data->fio == (unsigned int *)-1) {
+    SDL_SetError("Unable to get blitter registers");
+    data->fio = NULL;
+    GP2X_VideoQuit(this);
+    return -1;
+  }
+
+  // Determine the screen depth (gp2x defaults to 16-bit depth)
+  // we change this during the SDL_SetVideoMode implementation...
+  vformat->BitsPerPixel = 16;
+  vformat->BytesPerPixel = 2;
+  vformat->Rmask = 0x1f00;
+  vformat->Gmask = 0x07e0;
+  vformat->Bmask = 0x001f;
+  vformat->Amask = 0;
+
+  this->info.wm_available = 0;
+  this->info.hw_available = 1;
+  this->info.video_mem = GP2X_VIDEO_MEM_SIZE / 1024;
+  //  memset(data->vmem, GP2X_VIDEO_MEM_SIZE, 0);
+  // Save hw register data that we clobber
+  data->fastioclk = data->io[SYSCLKENREG] & FASTIOCLK;
+  data->grpclk = data->io[VCLKENREG] & GRPCLK;
+  // Need FastIO for blitter
+  data->io[SYSCLKENREG] |= FASTIOCLK;
+  // and enable graphics clock
+  data->io[VCLKENREG] |= GRPCLK;
+
+  // Save display registers so we can restore screen to original state
+  data->stl_cntl =   data->io[MLC_STL_CNTL];
+  data->stl_mixmux = data->io[MLC_STL_MIXMUX];
+  data->stl_alphal = data->io[MLC_STL_ALPHAL];
+  data->stl_alphah = data->io[MLC_STL_ALPHAH];
+  data->stl_hsc =    data->io[MLC_STL_HSC];
+  data->stl_vscl =   data->io[MLC_STL_VSCL];
+  // HW bug - MLC_STL_VSCH returns VSCL instead
+  data->stl_vsch =   0;//data->io[MLC_STL_VSCH];
+  data->stl_hw =     data->io[MLC_STL_HW];
+  data->stl_oadrl =  data->io[MLC_STL_OADRL];
+  data->stl_oadrh =  data->io[MLC_STL_OADRH];
+  data->stl_eadrl =  data->io[MLC_STL_EADRL];
+  data->stl_eadrh =  data->io[MLC_STL_EADRH];
+  // save the 4 region areas
+  for (i = 0; i < 16; i++)
+    data->stl_regions[i] = data->io[MLC_STL1_STX + i];
+  data->mlc_ovlay_cntr = data->io[MLC_OVLAY_CNTR];
+
+  // Check what video mode we're in (LCD, NTSC or PAL)
+  data->phys_width = data->io[DPC_X_MAX] + 1;
+  data->phys_height = data->io[DPC_Y_MAX] + 1;
+  data->phys_ilace = (data->io[DPC_CNTL] & DPC_INTERLACE) ? 1 : 0;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: Physical screen = %dx%d (ilace = %d)\n",
+	  data->phys_width, data->phys_height, data->phys_ilace);
+#endif
+  for (i = 0; i < SDL_NUMMODES; i++) {
+    data->SDL_modelist[i] = malloc(sizeof(SDL_Rect));
+    data->SDL_modelist[i]->x = data->SDL_modelist[i]->y = 0;
+  }
+  data->SDL_modelist[0]->w =  320; data->SDL_modelist[0]->h = 200; // low-res
+  data->SDL_modelist[1]->w =  320; data->SDL_modelist[1]->h = 240; // lo-res
+  data->SDL_modelist[2]->w =  640; data->SDL_modelist[2]->h = 400; // vga-low
+  data->SDL_modelist[3]->w =  640; data->SDL_modelist[3]->h = 480; // vga
+  data->SDL_modelist[4]->w =  720; data->SDL_modelist[4]->h = 480; // TV NTSC
+  data->SDL_modelist[5]->w =  720; data->SDL_modelist[5]->h = 576; // TV PAL
+  data->SDL_modelist[6]->w =  800; data->SDL_modelist[6]->h = 600; // vga-med
+  data->SDL_modelist[7]->w = 1024; data->SDL_modelist[7]->h = 768; // vga-high
+  data->SDL_modelist[8] = NULL;
+
+  this->info.blit_fill = 1;
+  this->FillHWRect = GP2X_FillHWRect;
+  this->info.blit_hw = 1;
+  this->info.blit_hw_CC = 1;
+
+  // Enable mouse and keyboard support
+  //  GP2X_OpenKeyboard(this);
+  GP2X_OpenMouse(this);
+  return 0;
+}
+
+////
+// Return list of possible screen sizes for given mode
+static SDL_Rect **GP2X_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
+{
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: ListModes\n");
+#endif
+  // Only 8 & 16 bit modes. 4 & 24 are available, but tough.
+  if ((format->BitsPerPixel != 8) && (format->BitsPerPixel != 16))
+    return NULL;
+
+  if (flags & SDL_FULLSCREEN)
+    return this->hidden->SDL_modelist;
+  else
+    return (SDL_Rect **) -1;
+}
+
+////
+// Set hw videomode
+static SDL_Surface *GP2X_SetVideoMode(_THIS, SDL_Surface *current,
+				      int width, int height,
+				      int bpp, Uint32 flags)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+  char *pixelbuffer;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: Setting video mode %dx%d %d bpp, flags=%X\n",
+	  width, height, bpp, flags);
+#endif
+
+  // Set up the new mode framebuffer, making sanity adjustments
+  // 64 <= width <= 1024, multiples of 8 only
+  width = (width + 7) & 0x7f8;
+  if (width < 64) width = 64;
+  if (width > 1024) width = 1024;
+
+  // 64 <= height <= 768
+  if (height < 64) height = 64;
+  if (height > 768) height = 768;
+
+  // 8 or 16 bpp. HW can handle 24, but limited support so not implemented
+  bpp = (bpp <= 8) ? 8 : 16;
+  
+  // Allocate the new pixel format for the screen
+  if (!SDL_ReallocFormat(current, bpp, 0, 0, 0, 0)) {
+    SDL_SetError("Couldn't allocate new pixel format for requested mode");
+    return NULL;
+  }
+  
+  // Screen is always a HWSURFACE and FULLSCREEN
+  current->flags = (flags & SDL_DOUBLEBUF) | SDL_FULLSCREEN |
+    SDL_HWSURFACE | SDL_NOFRAME;
+  if (bpp == 8) current->flags |= SDL_HWPALETTE;
+  data->w = current->w = width;
+  data->h = current->h = height;
+  data->pitch = data->phys_pitch = current->pitch = width * (bpp / 8);
+  if (data->phys_ilace && (width == 720))
+    data->phys_pitch *= 2;
+  this->screen = current;
+  current->pixels = data->vmem;
+
+  data->x_offset = data->y_offset = 0;
+  data->ptr_offset = 0;
+  // gp2x holds x-scale as fixed-point, 1024 == 1:1
+  data->scale_x = (1024 * width) / data->phys_width;
+  // and y-scale is scale * pitch
+  data->scale_y = (height * data->pitch) / data->phys_height;
+  // xscale and yscale are set so that virtual_x * xscale = phys_x
+  data->xscale = (float)data->phys_width / (float)width;
+  data->yscale = (float)data->phys_height / (float)height;
+
+  data->buffer_showing = 0;
+  data->buffer_addr[0] = data->vmem;
+  data->surface_mem = data->vmem + (height * data->pitch);
+  data->memory_max = GP2X_VIDEO_MEM_SIZE - height * data->pitch;
+  if (flags & SDL_DOUBLEBUF) {
+    current->pixels = data->buffer_addr[1] = data->surface_mem;
+    data->surface_mem += height * data->pitch;
+    data->memory_max -= height * data->pitch;
+  }
+  GP2X_FreeHWSurfaces(this);
+  GP2X_InitHWSurfaces(this, current, data->surface_mem, data->memory_max);
+
+  // Load the registers
+  data->io[MLC_STL_HSC] = data->scale_x;
+  data->io[MLC_STL_VSCL] = data->scale_y & 0xffff;
+  data->io[MLC_STL_VSCH] = data->scale_y >> 16;
+  data->io[MLC_STL_HW] = data->phys_pitch;
+  data->io[MLC_STL_CNTL] = (bpp==8 ? MLC_STL_BPP_8 : MLC_STL_BPP_16) |
+    MLC_STL1ACT;
+  data->io[MLC_STL_MIXMUX] = 0;
+  data->io[MLC_STL_ALPHAL] = 255;
+  data->io[MLC_STL_ALPHAH] = 255;
+  data->io[MLC_OVLAY_CNTR] |= DISP_STL1EN;
+
+  pixelbuffer = data->vmem;
+  if (data->phys_ilace) {
+    data->io[MLC_STL_OADRL] = GP2X_PhysL(this, pixelbuffer);
+    data->io[MLC_STL_OADRH] = GP2X_PhysH(this, pixelbuffer);
+    if (data->w == 720) pixelbuffer += data->pitch;
+  }
+  data->io[MLC_STL_EADRL] = GP2X_PhysL(this, pixelbuffer);
+  data->io[MLC_STL_EADRH] = GP2X_PhysH(this, pixelbuffer);
+
+  return current;
+}
+
+////
+// Initialize HW surface list
+static int GP2X_InitHWSurfaces(_THIS, SDL_Surface *screen, char *base, int size)
+{
+  video_bucket *bucket;
+  int cursor_state;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: InitHWSurfaces %p, %d\n", base, size);
+#endif
+
+  this->hidden->memory_left = size;
+  this->hidden->memory_max = size;
+
+  if (this->hidden->memory_left > 0) {
+    bucket = (video_bucket *)malloc(sizeof(*bucket));
+    if (bucket == NULL) {
+      SDL_OutOfMemory();
+      return -1;
+    }
+    bucket->next = NULL;
+    bucket->prev = &this->hidden->video_mem;
+    bucket->used = 0;
+    bucket->dirty = 0;
+    bucket->base = base;
+    bucket->size = size;
+  } else
+    bucket = NULL;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: Screen bucket %p\n", &this->hidden->video_mem);
+  fprintf(stderr, "SDL_GP2X: First free bucket %p (size = %d)\n", bucket, size);
+#endif  
+  this->hidden->video_mem.next = bucket;
+  this->hidden->video_mem.prev = NULL;
+  this->hidden->video_mem.used = 1;
+  this->hidden->video_mem.dirty = 0;
+  this->hidden->video_mem.base = screen->pixels;
+  this->hidden->video_mem.size = (unsigned int)((long)base - (long)screen->pixels);
+  screen->hwdata = (struct private_hwdata *)&this->hidden->video_mem;
+
+  SDL_CursorQuit();
+  SDL_CursorInit(1);
+  //  SDL_{ShowCursor(0);
+
+  return 0;
+}
+
+////
+// Free all surfaces
+static void GP2X_FreeHWSurfaces(_THIS)
+{
+  video_bucket *curr, *next;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: FreeHWSurfaces\n");
+#endif
+
+  next = this->hidden->video_mem.next;
+  while (next) {
+#ifdef GP2X_DEBUG
+    fprintf(stderr, "SDL_GP2X: Freeing bucket %p (size %d)\n", next, next->size);
+#endif
+    curr = next;
+    next = curr->next;
+    free(curr);
+  }
+  this->hidden->video_mem.next = NULL;
+}
+
+//// SURFACE MEMORY MANAGER
+// Allocate memory from free pool
+static video_bucket *GP2X_SurfaceAllocate(_THIS, int size)
+{
+  int left_over;
+  video_bucket *bucket;
+  SDL_PrivateVideoData *data = this->hidden;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: SurfaceManager allocating %d bytes\n", size);
+#endif
+
+  if (size > data->memory_left) {
+    SDL_SetError("Not enough video memory");
+    return NULL;
+  }
+
+  for (bucket = &data->video_mem; bucket; bucket = bucket->next)
+    if (!bucket->used && (size <= bucket->size))
+      break;
+  if (!bucket) {
+    SDL_SetError("Video memory too fragmented");
+    return NULL;
+  }
+
+  left_over = bucket->size - size;
+  if (left_over) {
+    video_bucket *new_bucket;
+    new_bucket = (video_bucket *)malloc(sizeof(*new_bucket));
+    if (!new_bucket) {
+      SDL_OutOfMemory();
+      return NULL;
+    }
+#ifdef GP2X_DEBUG
+    fprintf(stderr, "SDL_GP2X: SurfaceManager adding new free bucket of %d bytes @ %p\n", left_over, new_bucket);
+#endif
+    new_bucket->prev = bucket;
+    new_bucket->used = 0;
+    new_bucket->dirty = 0;
+    new_bucket->size = left_over;
+    new_bucket->base = bucket->base + size;
+    new_bucket->next = bucket->next;
+    if (bucket->next)
+      bucket->next->prev = new_bucket;
+    bucket->next = new_bucket;
+  }
+  bucket->used = 1;
+  bucket->size = size;
+  bucket->dirty = 0;
+  data->memory_left -= size;
+
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: SurfaceManager allocated %d bytes at %p\n", size, bucket->base);
+#endif
+  return bucket;
+}
+
+////
+// Return memory to free pool
+static void GP2X_SurfaceFree(_THIS, video_bucket *bucket)
+{
+  video_bucket *wanted;
+  SDL_PrivateVideoData *data = this->hidden;
+#ifdef GP2X_DEBUG
+    fprintf(stderr, "SDL_GP2X: SurfaceManager freeing %d bytes @ %p from bucket %p\n", bucket->size, bucket->base, bucket);
+#endif
+
+  if (bucket->used) {
+    data->memory_left += bucket->size;
+    bucket->used = 0;
+
+    if (bucket->next && !bucket->next->used) {
+#ifdef GP2X_DEBUG
+      fprintf(stderr, "SDL_GP2X: merging with next bucket (%p) making %d bytes\n",
+	      bucket->next, bucket->size + bucket->next->size);
+#endif
+      wanted = bucket->next;
+      bucket->size += bucket->next->size;
+      bucket->next = bucket->next->next;
+      if (bucket->next)
+	bucket->next->prev = bucket;
+      free(wanted);
+    }
+
+    if (bucket->prev && !bucket->prev->used) {
+#ifdef GP2X_DEBUG
+      fprintf(stderr, "SDL_GP2X: merging with previous bucket (%p) making %d bytes\n",
+	      bucket->prev, bucket->size + bucket->prev->size);
+#endif
+      wanted = bucket->prev;
+      wanted->size += bucket->size;
+      wanted->next = bucket->next;
+      if (bucket->next)
+	bucket->next->prev = wanted;
+      free(bucket);
+    }
+  }
+}
+
+////
+// Allocate a surface from video memory
+static int GP2X_AllocHWSurface(_THIS, SDL_Surface *surface)
+{
+  int w, h, pitch, size;
+  video_bucket *gfx_memory;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: AllocHWSurface %p\n", surface);
+#endif
+  h = surface->h;
+  w = surface->w;
+  pitch = ((w * surface->format->BytesPerPixel) + 3) & ~3; // 32-bit align
+  size = h * pitch;
+  gfx_memory = GP2X_SurfaceAllocate(this, size);
+  if (gfx_memory == NULL)
+    return -1;
+
+  surface->hwdata = (struct private_hwdata *)gfx_memory;
+  surface->pixels = gfx_memory->base;
+  surface->flags |= SDL_HWSURFACE;
+  fputs("SDL_GP2X: Allocated\n", stderr);
+  return 0;
+}
+
+////
+// Free a surface back to video memry
+static void GP2X_FreeHWSurface(_THIS, SDL_Surface *surface)
+{
+  video_bucket *bucket;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: FreeHWSurface %p\n", surface);
+#endif
+  /*  
+  for (bucket = &data->video_mem; bucket; bucket = bucket->next)
+    if (bucket == (video_bucket *)surface->hwdata)
+      break;
+  */
+  bucket = (video_bucket *)surface->hwdata;
+  GP2X_SurfaceFree(this, bucket);
+  surface->pixels = NULL;
+  surface->hwdata = NULL;
+}
+
+////
+// Mark surface as unavailable for HW acceleration
+static int GP2X_LockHWSurface(_THIS, SDL_Surface *surface)
+{
+  if (surface == this->screen)
+    SDL_mutexP(this->hidden->hw_lock);
+
+  if (GP2X_IsSurfaceBusy(surface)) {
+    GP2X_DummyBlit(this);
+    GP2X_WaitBusySurfaces(this);
+  }
+  return 0;
+}
+
+////
+// Hardware can use the surface now
+static void GP2X_UnlockHWSurface(_THIS, SDL_Surface *surface)
+{
+  if (surface == this->screen)
+    SDL_mutexV(this->hidden->hw_lock);
+}
+
+////
+// Dummy blit to flush blitter cache
+static void GP2X_DummyBlit(_THIS)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+#ifdef GP2X_DEBUG
+  //  fputs("SDL_GP2X: DummyBlit\n", stderr);
+#endif
+  do {} while (data->fio[MESGSTATUS] & MESG_BUSY);
+  data->fio[MESGDSTCTRL] = MESG_DSTENB | MESG_DSTBPP_16;
+  data->fio[MESGDSTADDR] = 0x3101000;
+  data->fio[MESGDSTSTRIDE] = 4;
+  data->fio[MESGSRCCTRL] = MESG_SRCBPP_16 | MESG_INVIDEO;
+  data->fio[MESGPATCTRL] = MESG_PATENB | MESG_PATBPP_1;
+  data->fio[MESGFORCOLOR] = ~0;
+  data->fio[MESGBACKCOLOR] = ~0;
+  data->fio[MESGSIZE] = (1 << MESG_HEIGHT) | 32;
+  data->fio[MESGCTRL] = MESG_FFCLR | MESG_XDIR_POS | MESG_YDIR_POS | 0xAA;
+  asm volatile ("":::"memory");
+  data->fio[MESGSTATUS] = MESG_BUSY;
+  do {} while (data->fio[MESGSTATUS] & MESG_BUSY);
+}
+
+////
+// Flip between double-buffer pages
+//  - added: moved setting scaler in here too
+static int GP2X_FlipHWSurface(_THIS, SDL_Surface *surface)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+  char *pixeldata;
+#ifdef GP2X_DEBUG
+  //  fprintf(stderr, "SDL_GP2X: Flip %p\n", surface);
+#endif
+  // make sure the blitter has finished
+  if (GP2X_IsSurfaceBusy(this->screen)) {
+    GP2X_WaitBusySurfaces(this);
+    GP2X_DummyBlit(this);
+  }
+
+  // wait for vblank to start
+  do {} while ((data->io[GPIOB_PINLVL] & GPIOB_VSYNC));
+
+  // Wait to be on even field (non-interlaced always returns 0)
+  //  do {} while (data->io[SC_STATUS] & SC_DISP_FIELD);
+
+  // set write address to be the page currently showing
+  surface->pixels = data->buffer_addr[data->buffer_showing];
+  // Flip buffers if need be
+  if (surface->flags & SDL_DOUBLEBUF)
+    data->buffer_showing = 1 - data->buffer_showing;
+
+  pixeldata = data->buffer_addr[data->buffer_showing] + data->ptr_offset;
+  if (data->phys_ilace) {
+    data->io[MLC_STL_OADRL] = GP2X_PhysL(this, pixeldata);
+    data->io[MLC_STL_OADRH] = GP2X_PhysH(this, pixeldata);
+    if (data->w == 720) pixeldata += data->pitch;
+  }
+  data->io[MLC_STL_EADRL] = GP2X_PhysL(this, pixeldata);
+  data->io[MLC_STL_EADRH] = GP2X_PhysH(this, pixeldata);
+
+  data->io[MLC_STL_HSC] = data->scale_x;
+  data->io[MLC_STL_VSCL] = data->scale_y & 0xffff;
+  data->io[MLC_STL_VSCH] = data->scale_y >> 16;
+
+  // Wait for vblank to end (to prevent 2 close page flips in one frame)
+  //  while (!(data->io[GPIOB_PINLVL] & GPIOB_VSYNC));
+  return 0;
+}
+
+////
+//
+static void GP2X_UpdateRects(_THIS, int numrects, SDL_Rect *rects)
+{
+  // We're writing directly to video memory
+}
+
+////
+// Set HW palette (8-bit only)
+static int GP2X_SetColors(_THIS, int firstcolour, int ncolours,
+			  SDL_Color *colours)
+{
+  unsigned short volatile *memregs = this->hidden->io;
+  int i;
+#ifdef GP2X_DEBUG
+  //  fprintf(stderr, "SDL_GP2X: Setting %d colours, starting with %d\n",
+  //  	  ncolours, firstcolour);
+#endif
+  memregs[MLC_STL_PALLT_A] = firstcolour;
+  asm volatile ("":::"memory");
+  for (i = 0; i < ncolours; i++) {
+    memregs[MLC_STL_PALLT_D] = ((int)colours[i].g << 8) + colours[i].b;
+    asm volatile ("":::"memory");
+    memregs[MLC_STL_PALLT_D] = colours[i].r;
+    asm volatile ("":::"memory");
+  }
+  return 0;
+}
+
+////
+// Note:  If we are terminated, this could be called in the middle of
+//        another SDL video routine -- notably UpdateRects.
+static void GP2X_VideoQuit(_THIS)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+  int i;
+#ifdef GP2X_DEBUG
+  fputs("SDL_GP2X: VideoQuit\n", stderr);
+#endif
+
+  if (data->hw_lock) {
+    SDL_DestroyMutex(data->hw_lock);
+    data->hw_lock = NULL;
+  }
+
+  for (i = 0; i < SDL_NUMMODES; i++)
+    if (data->SDL_modelist[i]) {
+      free(data->SDL_modelist[i]);
+      data->SDL_modelist[i] = NULL;
+    }
+
+  GP2X_FreeHWSurfaces(this);
+}
+
+
+////
+// Check if blit between surfaces can be accelerated
+static int GP2X_CheckHWBlit(_THIS, SDL_Surface *src, SDL_Surface *dst)
+{
+#ifdef GP2X_DEBUG
+  //  fprintf(stderr, "SDL_GP2X: Checking HW accel of %p to %p... ", src, dst);
+#endif
+  // dst has to be HW to accelerate blits
+  // can't accelerate alpha blits
+  if ((dst->flags & SDL_HWSURFACE) && !(src->flags & SDL_SRCALPHA)) {
+    src->flags |= SDL_HWACCEL;
+    src->map->hw_blit = GP2X_HWAccelBlit;
+#ifdef GP2X_DEBUG
+    // fputs("Okay\n", stderr);
+#endif
+    return -1;
+  } else {
+    src->flags &= ~SDL_HWACCEL;
+#ifdef GP2X_DEBUG
+    // fputs("Nope\n", stderr);
+#endif
+    return 0;
+  }
+}
+
+////
+// Hardware accelerated fill
+static int GP2X_FillHWRect(_THIS, SDL_Surface *surface,
+			   SDL_Rect *area, Uint32 colour)
+{
+  Uint32 dstctrl, dest;
+  SDL_PrivateVideoData *data = this->hidden;
+#ifdef GP2X_DEBUG
+  /*
+  fprintf(stderr, "SDL_GP2X: FillHWRect %p (%d,%d)x(%d,%d) in %d\n",
+      	  surface, area->x, area->y, area->w, area->h, colour);
+  */
+#endif
+
+  if (surface == this->screen)
+    SDL_mutexP(data->hw_lock);
+
+  switch (surface->format->BitsPerPixel) {
+  case 8:
+    dstctrl = MESG_DSTBPP_8 | ((area->x & 0x03) << 3);
+    dest = GP2X_Phys(this, surface->pixels) +
+      (area->y * surface->pitch) + (area->x);
+    break;
+  case 16:
+    dstctrl = MESG_DSTBPP_16 | ((area->x & 0x01) << 4);
+    dest = GP2X_Phys(this, surface->pixels) +
+      (area->y * surface->pitch) + (area->x << 1);
+    break;
+  default:
+    SDL_SetError("SDL: GP2X can't hardware FillRect to surface");
+    return -1;
+    break;
+  }
+  do {} while (data->fio[MESGSTATUS] & MESG_BUSY);
+  data->fio[MESGDSTCTRL] = dstctrl;
+  data->fio[MESGDSTADDR] = dest & ~3;
+  data->fio[MESGDSTSTRIDE] = surface->pitch;
+  data->fio[MESGSRCCTRL] = 0;
+  data->fio[MESGPATCTRL] = MESG_PATENB | MESG_PATBPP_1;
+  data->fio[MESGFORCOLOR] = colour;
+  data->fio[MESGBACKCOLOR] = colour;
+  data->fio[MESGSIZE] = (area->h << MESG_HEIGHT) | area->w;
+  data->fio[MESGCTRL] = MESG_FFCLR | MESG_XDIR_POS | MESG_YDIR_POS | MESG_ROP_PAT;
+  asm volatile ("":::"memory");
+  data->fio[MESGSTATUS] = MESG_BUSY;
+
+  GP2X_AddBusySurface(surface);
+
+  if (surface == this->screen)
+    SDL_mutexV(data->hw_lock);
+  return 0;
+}
+
+////
+// Accelerated blit, 1->8, 1->16, 8->8, 16->16
+static int GP2X_HWAccelBlit(SDL_Surface *src, SDL_Rect *src_rect,
+			    SDL_Surface *dst, SDL_Rect *dst_rect)
+{
+  SDL_VideoDevice *this = current_video;
+  SDL_PrivateVideoData *data = this->hidden;
+  int w, h, src_x, src_y, src_stride, dst_stride, dst_x, dst_y;
+  Uint32 ctrl, src_start, dst_start, src_ctrl, dst_ctrl;
+  Uint32 *read_addr;
+#ifdef GP2X_DEBUG
+  /*
+  fprintf(stderr, "SDL_GP2X: HWBlit src:%p (%d,%d)x(%d,%d) -> %p (%d,%d)\n",
+    	  src, src_rect->x, src_rect->y, src_rect->w, src_rect->h,
+    	  dst, dst_rect->x, dst_rect->y);
+  */
+#endif
+
+  if (dst == this->screen)
+    SDL_mutexP(data->hw_lock);
+
+  src_x = src_rect->x;
+  src_y = src_rect->y;
+  dst_x = dst_rect->x;
+  dst_y = dst_rect->y;
+  w = src_rect->w;
+  h = src_rect->h;
+  src_stride = src->pitch;
+  dst_stride = dst->pitch;
+
+  // set blitter control with ROP and colourkey
+  ctrl = MESG_ROP_COPY | MESG_FFCLR;
+  if (src->flags & SDL_SRCCOLORKEY)
+    ctrl |= MESG_TRANSPEN | (src->format->colorkey << MESG_TRANSPCOLOR);
+
+  // In the case where src == dst, reverse blit direction if need be
+  //  to cope with potential overlap.
+  if (src != dst)
+    ctrl |= MESG_XDIR_POS | MESG_YDIR_POS;
+  else {
+    // if src rightof dst, blit left->right else right->left
+    if (src_x >= dst_x)
+      ctrl |= MESG_XDIR_POS;
+    else {
+      src_x += w - 1;
+      dst_x += w - 1;
+    }
+    // likewise, if src below dst blit top->bottom else bottom->top
+    if (src_y >= dst_y)
+      ctrl |= MESG_YDIR_POS;
+    else {
+      src_y += h - 1;
+      dst_y += h - 1;
+      src_stride = -src_stride;
+      dst_stride = -dst_stride;
+    }
+  }
+
+  if (dst->format->BitsPerPixel == 8) {
+    dst_start = GP2X_Phys(this, dst->pixels) + (dst_y * dst->pitch) + dst_x;
+    dst_ctrl = MESG_DSTBPP_8 | (dst_start & 0x03) << 3;
+  } else {
+    dst_start = GP2X_Phys(this, dst->pixels) +(dst_y*dst->pitch) +(dst_x<<1);
+    dst_ctrl = MESG_DSTBPP_16 | (dst_start & 0x02) << 3;
+  }
+  do {} while (data->fio[MESGSTATUS] & MESG_BUSY);
+  data->fio[MESGDSTCTRL] = dst_ctrl;
+  data->fio[MESGDSTADDR] = dst_start & ~3;
+  data->fio[MESGDSTSTRIDE] = dst_stride;
+  data->fio[MESGFORCOLOR] = data->src_foreground;
+  data->fio[MESGBACKCOLOR] = data->src_background;
+  data->fio[MESGPATCTRL] = 0;
+  data->fio[MESGSIZE] = (h << MESG_HEIGHT) | w;
+  data->fio[MESGCTRL] = ctrl;
+
+  ////// STILL TO CHECK SW->HW BLIT & 1bpp BLIT
+  if (src->flags & SDL_HWSURFACE) {
+    // src HW surface needs mapping from virtual -> physical
+    switch (src->format->BitsPerPixel) {
+    case 1:
+      src_start = GP2X_Phys(this, src->pixels) +(src_y*src->pitch) +(src_x>>3);
+      src_ctrl = MESG_SRCBPP_1 | (src_x & 0x1f);
+      break;
+    case 8:
+      src_start = GP2X_Phys(this, src->pixels) + (src_y * src->pitch) + src_x;
+      src_ctrl = MESG_SRCBPP_8 | (src_start & 0x03) << 3;
+      break;
+    case 16:
+      src_start = GP2X_Phys(this, src->pixels) +(src_y*src->pitch) +(src_x<<1);
+      src_ctrl = MESG_SRCBPP_16 | (src_start & 0x02) << 3;
+      break;
+    default:
+      SDL_SetError("Invalid bit depth for GP2X_HWBlit");
+      return -1;
+    }
+    data->fio[MESGSRCCTRL] = src_ctrl | MESG_SRCENB | MESG_INVIDEO;
+    data->fio[MESGSRCADDR] = src_start & ~3;
+    data->fio[MESGSRCSTRIDE] = src_stride;
+    asm volatile ("":::"memory");
+    data->fio[MESGSTATUS] = MESG_BUSY;
+  } else {
+    // src SW surface needs CPU to pump blitter
+    int src_int_width, frac;
+    switch (src->format->BitsPerPixel) {
+    case 1:
+      src_start = (Uint32)src->pixels + (src_y * src->pitch) + (src_x >> 3);
+      frac = src_x & 0x1f;
+      src_ctrl = MESG_SRCENB | MESG_SRCBPP_1 | frac;
+      src_int_width = (frac + w + 31) / 32;
+      break;
+    case 8:
+      src_start = (Uint32)src->pixels + (src_y * src->pitch) + src_x;
+      frac = (src_start & 0x03) << 3;
+      src_ctrl = MESG_SRCENB | MESG_SRCBPP_8 | frac;
+      src_int_width = (frac + w*8 + 31) / 32;
+      break;
+    case 16:
+      src_start = (Uint32)src->pixels + (src_y * src->pitch) + (src_x << 1);
+      frac = (src_start & 0x02) << 3;
+      src_ctrl = MESG_SRCENB | MESG_SRCBPP_16 | frac;
+      src_int_width = (frac + w*16 + 31) / 32;
+      break;
+    default:
+      SDL_SetError("Invalid bit depth for GP2X_HWBlit");
+      return -1;
+    }
+    data->fio[MESGSRCCTRL] = src_ctrl;
+    asm volatile ("":::"memory");
+    data->fio[MESGSTATUS] = MESG_BUSY;
+
+    while (--h) {
+      int i = src_int_width;
+      read_addr = (Uint32 *)(src_start & ~3);
+      src_start += src_stride;
+      if (ctrl & MESG_XDIR_POS)
+	while (--i)
+	  data->fio[MESGFIFO] = 0xff; //*read_addr++;
+      else
+	while (--i)
+	  data->fio[MESGFIFO] = 0x80; //*read_addr--;
+    }
+  }
+
+  GP2X_AddBusySurface(src);
+  GP2X_AddBusySurface(dst);
+
+  if (dst == this->screen)
+    SDL_mutexV(data->hw_lock);
+
+  return 0;
+}
+
+////
+// HW cursor support
+
+// Create cursor in HW format
+static WMcursor *GP2X_CreateWMCursor(SDL_VideoDevice *video,
+				     Uint8 *data, Uint8 *mask,
+				     int w, int h,
+				     int hot_x, int hot_y)
+{
+  SDL_PrivateVideoData *pvd = video->hidden;
+  int cursor_size, cursor_dimension, x, y, i;
+  Uint16 *cursor_addr, *cursor_end;
+  Uint16 pixel;
+  Uint8 datab, maskb;
+  SDL_WMcursor *cursor;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: Creating cursor %dx%d\n", w, h);
+#endif
+
+  // HW only supports 32x32 or 64x64. Pick smallest possible or crop
+  cursor_dimension = ((w < h) ? h : w) <= 32 ? 32 : 64;
+  cursor_size = cursor_dimension * cursor_dimension / 4;
+  if (!(cursor = (SDL_WMcursor*)malloc(sizeof *cursor))) {
+    SDL_OutOfMemory();
+    return NULL;
+  }
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: Allocated WMcursor @ %p (%d)\n",
+	  cursor, cursor_dimension);
+#endif
+
+  if (!(cursor->bucket = GP2X_SurfaceAllocate(video, cursor_size))) {
+    free(cursor);
+    return NULL;
+  }
+
+  cursor->dimension = cursor_dimension;
+  cursor->fgr = 0xffff;
+  cursor->fb = 0xff;
+  cursor->bgr = 0x0000;
+  cursor->bb = 0x00;
+  cursor->falpha = 0xf;
+  cursor->balpha = 0xf;
+
+  if (pvd->phys_ilace) {
+  } else {
+    cursor_addr = (Uint16*)cursor->bucket->base;
+    cursor_end = cursor_addr + cursor_size;
+    for (y = 0; y < h; y++) {
+      for (x = 0; x < w; x += 8) {
+	datab = *data++;
+	maskb = *mask++;
+	pixel = 0;
+	for (i = 8; i; i--) {
+	  pixel <<= 2;
+	  if (!(maskb & 0x01))
+	    pixel |= 0x02;
+	  else if (!(datab & 0x01))
+	    pixel |= 0x01;
+	  maskb >>= 1;
+	  datab >>= 1;
+	}
+	*cursor_addr++ = pixel;
+      }
+      while (x < cursor_dimension) {
+	*cursor_addr++ = 0xAAAA;
+	x += 8;
+      }
+    }
+    while(cursor_addr < cursor_end)
+      *cursor_addr++ = 0xAAAA;
+  }
+  return (WMcursor*)cursor;
+}
+
+////
+// Free the cursor memory
+static void GP2X_FreeWMCursor(_THIS, WMcursor *wmcursor)
+{
+  SDL_WMcursor *cursor = (SDL_WMcursor*)wmcursor;
+#ifdef GP2X_DEBUG
+  fprintf(stderr, "SDL_GP2X: Freeing cursor %p\n", cursor);
+#endif
+  if (cursor->bucket)
+    GP2X_SurfaceFree(this, cursor->bucket);
+  free(cursor);
+}
+
+////
+// Change HW cursor to passed, NULL to turn cursor off
+static int GP2X_ShowWMCursor(_THIS, WMcursor *wmcursor)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+  unsigned short volatile *io = data->io;
+  SDL_WMcursor *cursor = (SDL_WMcursor*)wmcursor;
+
+  data->visible_cursor = cursor;
+  if (cursor) {
+    io[MLC_HWC_OADRL] = io[MLC_HWC_EADRL] =
+      GP2X_PhysL(this, cursor->bucket->base);
+    io[MLC_HWC_OADRH] = io[MLC_HWC_EADRH] =
+      GP2X_PhysH(this, cursor->bucket->base);
+    io[MLC_HWC_FGR] = cursor->fgr;
+    io[MLC_HWC_FB] = cursor->fb;
+    io[MLC_HWC_BGR] = cursor->bgr;
+    io[MLC_HWC_BB] = cursor->bb;
+    io[MLC_HWC_CNTL] = (cursor->falpha << 12) |
+      (cursor->balpha << 8) |
+      cursor->dimension;
+    io[MLC_OVLAY_CNTR] |= DISP_CURSOR;
+    return -1;
+  } else
+    io[MLC_OVLAY_CNTR] &= ~DISP_CURSOR;
+  return 0;
+}
+
+////
+// Set colour & alpha of a cursor (alpha is 0-15)
+void SDL_GP2X_SetCursorColour(SDL_Cursor *scursor,
+			      int bred, int bgreen, int bblue, int balpha,
+			      int fred, int fgreen, int fblue, int falpha)
+{
+  SDL_PrivateVideoData *data = current_video->hidden;
+  SDL_WMcursor *cursor = (SDL_WMcursor*)scursor->wm_cursor;
+
+  cursor->fgr = ((fgreen & 0xFF) << 8) | (fred & 0xFF);
+  cursor->fb = fblue & 0xFF;
+  cursor->bgr = ((bgreen &0xFF) << 8) | (bred & 0xFF);
+  cursor->bb = bblue & 0xFF;
+  cursor->falpha = falpha & 0x0F;
+  cursor->balpha = balpha & 0x0F;
+
+  if (cursor == data->visible_cursor) {
+    data->io[MLC_HWC_FGR] = cursor->fgr;
+    data->io[MLC_HWC_FB] =  cursor->fb;
+    data->io[MLC_HWC_BGR] = cursor->bgr;
+    data->io[MLC_HWC_BB] =  cursor->bb;
+    data->io[MLC_HWC_CNTL] = (cursor->falpha << 12) |
+      (cursor->balpha << 8) |
+      cursor->dimension;
+  }
+}
+
+
+////
+// Move the cursor to specified (physical) coordinate
+static void GP2X_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+
+  data->cursor_px = x;
+  data->cursor_py = y;
+  data->io[MLC_HWC_STX] = x;
+  data->io[MLC_HWC_STY] = y;
+}
+
+////
+// Move the cursor to (virtual) coordinate
+static void GP2X_MoveWMCursor(_THIS, int x, int y)
+{
+  SDL_PrivateVideoData *data = this->hidden;
+
+  data->cursor_vx = x;
+  data->cursor_vy = y;
+  // convert virtual coordinate into physical
+  x -= data->x_offset;
+  x *= data->xscale;
+  y -= data->y_offset;
+  y *= data->yscale;
+  GP2X_WarpWMCursor(this, x, y);
+}
+
+
+////////
+// GP2X specific functions -
+
+////
+// Set foreground & background colours for 1bpp blits
+void SDL_GP2X_SetMonoColours(int background, int foreground)
+{
+  if (current_video) {
+    current_video->hidden->src_foreground = foreground;
+    current_video->hidden->src_background = background;
+  }
+}
+
+////
+// Enquire physical screen size - for detecting LCD / TV
+//  Returns 0: Progressive
+//          1: Interlaced
+int SDL_GP2X_GetPhysicalScreenSize(SDL_Rect *size)
+{
+  if (current_video) {
+    SDL_PrivateVideoData *data = current_video->hidden;
+    size->w = data->phys_width;
+    size->h = data->phys_height;
+    return data->phys_ilace;
+  }
+  return -1;
+}
+
+////
+// Dynamic screen scaling
+void SDL_GP2X_Display(SDL_Rect *area)
+{
+  SDL_PrivateVideoData *data = current_video->hidden;
+  int sc_x, sc_y;
+
+  // If top-left is out of bounds then correct it
+  if (area->x < 0)
+    area->x = 0;
+  if (area->x > (data->w - 8))
+    area->x = data->w - 8;
+  if (area->y < 0)
+    area->y = 0;
+  if (area->y > (data->h - 8))
+    area->y = data->h - 8;
+  // if requested area is wider than screen, reduce width
+  if (data->w < (area->x + area->w))
+    area->w = data->w - area->x;
+  // if requested area is taller than screen, reduce height
+  if (data->h < (area->y + area->h))
+    area->h = data->h - area->y;
+
+  data->xscale = (float)data->phys_width / (float)area->w;
+  data->yscale = (float)data->phys_height / (float)area->h;
+  sc_x = (1024 * area->w) / data->phys_width;
+  sc_y = (area->h * data->pitch) / data->phys_height;
+  // Evil hacky thing. Scaler only works if horiz needs scaling.
+  // If requested scale only needs to scale in vertical, fudge horiz
+  if ((sc_x == 1024) && (area->h != data->phys_height))
+    sc_x++;
+
+  data->scale_x = sc_x;
+  data->scale_y = sc_y;
+  data->x_offset = area->x;
+  data->y_offset = area->y;
+  data->ptr_offset = ((area->y * data->pitch) +
+		      (area->x *current_video->info.vfmt->BytesPerPixel)) & ~3;
+
+  // Apply immediately if we're not double-buffered
+  if (!(current_video->screen->flags & SDL_DOUBLEBUF)) {
+    char *pixeldata = data->buffer_addr[data->buffer_showing]+data->ptr_offset;
+    if (data->phys_ilace) {
+      data->io[MLC_STL_OADRL] = GP2X_PhysL(current_video, pixeldata);
+      data->io[MLC_STL_OADRH] = GP2X_PhysH(current_video, pixeldata);
+      if (data->w == 720) pixeldata += data->pitch;
+    }
+    data->io[MLC_STL_EADRL] = GP2X_PhysL(current_video, pixeldata);
+    data->io[MLC_STL_EADRH] = GP2X_PhysH(current_video, pixeldata);
+    data->io[MLC_STL_HSC] = data->scale_x;
+    data->io[MLC_STL_VSCL] = data->scale_y & 0xffff;
+    data->io[MLC_STL_VSCH] = data->scale_y >> 16;
+  }
+}
+
+////
+// window region routines - 
+//
+// Set region area.
+//   region = which hw region 1-4
+//   area   = coords of area
+void SDL_GP2X_DefineRegion(int region, SDL_Rect *area)
+{
+  if ((region >= 1) && (region <= 4) && (area)) {
+    SDL_PrivateVideoData *data = current_video->hidden;
+    unsigned short volatile *region_reg;
+    
+    region_reg = &data->io[MLC_STL1_STX + (region - 1) * 4];
+    *region_reg++ = area->x;
+    *region_reg++ = area->x + area->w - 1;
+    *region_reg++ = area->y;
+    *region_reg++ = area->y + area->h - 1;
+  }
+}
+
+// (De)activate region
+void SDL_GP2X_ActivateRegion(int region, int activate)
+{
+  if ((region >= 1) && (region <= 5)) {
+    SDL_PrivateVideoData *data = current_video->hidden;
+    int stl_region_bit = 1 >> ((region - 1) * 2);
+    int ovlay_region_bit = 1 >> (region + 1);
+
+    if (activate) {
+      data->io[MLC_STL_CNTL] |= stl_region_bit;
+      data->io[MLC_OVLAY_CNTR] |= ovlay_region_bit;
+    } else {
+      data->io[MLC_STL_CNTL] &= ~stl_region_bit;
+      data->io[MLC_OVLAY_CNTR] &= ~ovlay_region_bit;
+    }
+  }
+}
+
+// Allow a smaller screen than the display, without scaling
+void SDL_GP2X_MiniDisplay(int x, int y)
+{
+  SDL_PrivateVideoData *data = current_video->hidden;
+  SDL_Rect mini_region;
+
+  // Set scaler back to 1:1
+  data->scale_x = 1024;
+  data->scale_y = data->phys_pitch;
+  data->xscale = data->yscale = 1.0;
+  // offsets needed to start screen at (x,y)
+  data->x_offset = -x;
+  data->y_offset = -y;
+  data->ptr_offset = -((y * data->pitch) +
+		       (x *current_video->info.vfmt->BytesPerPixel)) & ~3;
+  // Apply immediately if we're not double-buffered
+  if (!(current_video->screen->flags & SDL_DOUBLEBUF)) {
+    char *pixeldata = data->buffer_addr[data->buffer_showing]+data->ptr_offset;
+    if (data->phys_ilace) {
+      data->io[MLC_STL_OADRL] = GP2X_PhysL(current_video, pixeldata);
+      data->io[MLC_STL_OADRH] = GP2X_PhysH(current_video, pixeldata);
+      if (data->w == 720) pixeldata += data->pitch;
+    }
+    data->io[MLC_STL_EADRL] = GP2X_PhysL(current_video, pixeldata);
+    data->io[MLC_STL_EADRH] = GP2X_PhysH(current_video, pixeldata);
+    data->io[MLC_STL_HSC] = 1024;
+    data->io[MLC_STL_VSCL] = data->scale_y & 0xffff;
+    data->io[MLC_STL_VSCH] = data->scale_y >> 16;
+  }
+
+  mini_region.x = x;
+  mini_region.y = y;
+  mini_region.w = data->w;
+  mini_region.h = data->h;
+  SDL_GP2X_DefineRegion(1, &mini_region);
+}
diff -urN SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.h
--- SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.h	1970-01-01 01:00:00.000000000 +0100
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/gp2x/SDL_gp2xvideo.h	2006-05-19 09:11:11.000000000 +0200
@@ -0,0 +1,153 @@
+/*
+    SDL - Simple DirectMedia Layer
+    Copyright (C) 1997-2004 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
+*/
+
+#ifdef SAVE_RCSID
+static char rcsid =
+ "@(#) $Id: gp2x-SDL.patch,v 1.1 2007/08/07 13:54:49 jwrdegoede Exp $";
+#endif
+
+#ifndef _SDL_gp2xvideo_h
+#define _SDL_gp2xvideo_h
+
+#include "SDL_mouse.h"
+#include "SDL_sysvideo.h"
+#include "SDL_mutex.h"
+
+#include "mmsp2_regs.h"
+
+// Hidden "this" pointer for the video functions
+#define _THIS	SDL_VideoDevice *this
+
+// Allocate 5MB for the frame buffer (seems to be how gph have it)
+#define GP2X_VIDEO_MEM_SIZE ((5*1024*1024) - 4096)
+
+// Number of native modes supported
+#define SDL_NUMMODES 8
+
+
+////
+// Internal structure for allocating video memory
+typedef struct video_bucket {
+  struct video_bucket *prev, *next;
+  char *base;
+  unsigned int size;
+  short used;
+  short dirty;
+} video_bucket;
+
+////
+// Internal structure for hardware cursor
+typedef struct SDL_WMcursor {
+  video_bucket *bucket;
+  int dimension;
+  unsigned short fgr, fb, bgr, bb, falpha, balpha;
+} SDL_WMcursor;
+
+////
+// Private display data
+
+typedef struct SDL_PrivateVideoData {
+  int memory_fd, fbcon_fd, mouse_fd, keyboard_fd;
+  int saved_keybd_mode;
+  //  struct termios saved_kbd_termios;
+
+  int x_offset, y_offset, ptr_offset;
+  int w, h, pitch;
+  int phys_width, phys_height, phys_pitch, phys_ilace;
+  int scale_x, scale_y;
+  float xscale, yscale;
+  SDL_mutex *hw_lock;
+  unsigned short fastioclk, grpclk;
+  unsigned short src_foreground, src_background;
+  char *vmem;
+  int buffer_showing;
+  char *buffer_addr[2];
+  unsigned short volatile *io;
+  unsigned int volatile *fio;
+  video_bucket video_mem;
+  char *surface_mem;
+  int memory_left;
+  int memory_max;
+  SDL_WMcursor *visible_cursor;
+  int cursor_px, cursor_py, cursor_vx, cursor_vy;
+  SDL_Rect *SDL_modelist[SDL_NUMMODES+1];
+  unsigned short stl_cntl, stl_mixmux, stl_alphal, stl_alphah;
+  unsigned short stl_hsc, stl_vscl, stl_vsch, stl_hw;
+  unsigned short stl_oadrl, stl_oadrh, stl_eadrl, stl_eadrh;
+  unsigned short stl_regions[16]; // 1<=x<=4 of STLx_STX, _ENDX, _STY, _ENDY
+  unsigned short mlc_ovlay_cntr;
+} SDL_PrivateVideoData;
+
+extern VideoBootStrap GP2X_bootstrap;
+
+////
+// utility functions
+////
+
+////
+// convert virtual address to physical
+static inline unsigned int GP2X_Phys(_THIS, char *virt)
+{
+  return (unsigned int)((long)virt - (long)(this->hidden->vmem) + 0x3101000);
+}
+
+////
+// convert virtual address to physical (lower word)
+static inline unsigned short GP2X_PhysL(_THIS, char *virt)
+{
+  return (unsigned short)(((long)virt - (long)(this->hidden->vmem) + 0x3101000) & 0xffff);
+}
+
+////
+// convert virtual address to phyical (upper word)
+static inline unsigned short GP2X_PhysH(_THIS, char *virt)
+{
+  return (unsigned short)(((long)virt - (long)(this->hidden->vmem) + 0x3101000) >> 16);
+}
+
+////
+// mark surface has been used in HW accel
+static inline void GP2X_AddBusySurface(SDL_Surface *surface)
+{
+  ((video_bucket *)surface->hwdata)->dirty = 1;
+}
+
+////
+// test if surface has been used in HW accel
+static inline int GP2X_IsSurfaceBusy(SDL_Surface *surface)
+{
+  return ((video_bucket *)surface->hwdata)->dirty;
+}
+
+////
+// wait for blitter to finish with all busy surfaces
+static inline void GP2X_WaitBusySurfaces(_THIS)
+{
+  video_bucket *bucket;
+
+  for (bucket = &this->hidden->video_mem; bucket; bucket = bucket->next)
+    bucket->dirty = 0;
+  do {} while (this->hidden->fio[MESGSTATUS] & MESG_BUSY);
+}
+
+#define GP2X_DEBUG 1
+#endif // _SDL_gp2xvideo_h
diff -urN SDL-1.2.9/src/video/maccommon/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/maccommon/Makefile.in
--- SDL-1.2.9/src/video/maccommon/Makefile.in	2005-08-28 08:32:03.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/maccommon/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_maccommon_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/macdsp/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/macdsp/Makefile.in
--- SDL-1.2.9/src/video/macdsp/Makefile.in	2005-08-28 08:32:03.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/macdsp/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_dsp_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/macrom/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/macrom/Makefile.in
--- SDL-1.2.9/src/video/macrom/Makefile.in	2005-08-28 08:32:03.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/macrom/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_macrom_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/Makefile.in
--- SDL-1.2.9/src/video/Makefile.in	2005-08-28 08:31:56.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/nanox/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/nanox/Makefile.in
--- SDL-1.2.9/src/video/nanox/Makefile.in	2005-08-28 08:32:04.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/nanox/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_nanox_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/photon/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/photon/Makefile.in
--- SDL-1.2.9/src/video/photon/Makefile.in	2005-08-28 08:32:04.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/photon/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_photon_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/picogui/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/picogui/Makefile.in
--- SDL-1.2.9/src/video/picogui/Makefile.in	2005-08-28 08:32:04.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/picogui/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_picogui_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/ps2gs/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/ps2gs/Makefile.in
--- SDL-1.2.9/src/video/ps2gs/Makefile.in	2005-08-28 08:32:05.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/ps2gs/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_ps2gs_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/qtopia/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/qtopia/Makefile.in
--- SDL-1.2.9/src/video/qtopia/Makefile.in	2005-08-28 08:32:05.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/qtopia/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_qtopia_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/quartz/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/quartz/Makefile.in
--- SDL-1.2.9/src/video/quartz/Makefile.in	2005-08-28 08:32:06.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/quartz/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_quartz_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/riscos/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/riscos/Makefile.in
--- SDL-1.2.9/src/video/riscos/Makefile.in	2005-08-28 08:32:06.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/riscos/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_riscos_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/SDL_sysvideo.h /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/SDL_sysvideo.h
--- SDL-1.2.9/src/video/SDL_sysvideo.h	2005-04-17 12:40:41.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/SDL_sysvideo.h	2006-05-19 09:11:11.000000000 +0200
@@ -417,6 +417,9 @@
 #ifdef ENABLE_RISCOS
 extern VideoBootStrap RISCOS_bootstrap;
 #endif
+#ifdef ENABLE_GP2XVIDEO
+extern VideoBootStrap GP2X_bootstrap;
+#endif
 /* This is the current video device */
 extern SDL_VideoDevice *current_video;
 
diff -urN SDL-1.2.9/src/video/SDL_video.c /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/SDL_video.c
--- SDL-1.2.9/src/video/SDL_video.c	2005-06-12 18:12:55.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/SDL_video.c	2006-05-19 09:11:11.000000000 +0200
@@ -120,6 +120,9 @@
 #ifdef ENABLE_RISCOS
     &RISCOS_bootstrap,
 #endif
+#ifdef ENABLE_GP2XVIDEO
+	&GP2X_bootstrap,
+#endif
 #ifdef ENABLE_DUMMYVIDEO
 	&DUMMY_bootstrap,
 #endif
diff -urN SDL-1.2.9/src/video/svga/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/svga/Makefile.in
--- SDL-1.2.9/src/video/svga/Makefile.in	2005-08-28 08:32:06.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/svga/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_svga_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/vgl/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/vgl/Makefile.in
--- SDL-1.2.9/src/video/vgl/Makefile.in	2005-08-28 08:32:07.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/vgl/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_vgl_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/wincommon/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/wincommon/Makefile.in
--- SDL-1.2.9/src/video/wincommon/Makefile.in	2005-08-28 08:32:07.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/wincommon/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_wincommon_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/windib/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/windib/Makefile.in
--- SDL-1.2.9/src/video/windib/Makefile.in	2005-08-28 08:32:07.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/windib/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_windib_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/windx5/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/windx5/Makefile.in
--- SDL-1.2.9/src/video/windx5/Makefile.in	2005-08-28 08:32:08.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/windx5/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_windx5_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/x11/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/x11/Makefile.in
--- SDL-1.2.9/src/video/x11/Makefile.in	2005-08-28 08:32:08.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/x11/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_x11_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/xbios/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/xbios/Makefile.in
--- SDL-1.2.9/src/video/xbios/Makefile.in	2005-08-28 08:32:08.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/xbios/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libvideo_xbios_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/XFree86/extensions/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/extensions/Makefile.in
--- SDL-1.2.9/src/video/XFree86/extensions/Makefile.in	2005-08-28 08:31:58.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/extensions/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/src/video/XFree86/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Makefile.in
--- SDL-1.2.9/src/video/XFree86/Makefile.in	2005-08-28 08:31:57.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
diff -urN SDL-1.2.9/src/video/XFree86/Xinerama/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xinerama/Makefile.in
--- SDL-1.2.9/src/video/XFree86/Xinerama/Makefile.in	2005-08-28 08:31:57.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xinerama/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libXFree86_Xinerama_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/XFree86/Xv/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xv/Makefile.in
--- SDL-1.2.9/src/video/XFree86/Xv/Makefile.in	2005-08-28 08:31:57.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xv/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libXFree86_Xv_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/XFree86/Xxf86dga/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xxf86dga/Makefile.in
--- SDL-1.2.9/src/video/XFree86/Xxf86dga/Makefile.in	2005-08-28 08:31:58.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xxf86dga/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libXFree86_Xxf86dga_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@
diff -urN SDL-1.2.9/src/video/XFree86/Xxf86vm/Makefile.in /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xxf86vm/Makefile.in
--- SDL-1.2.9/src/video/XFree86/Xxf86vm/Makefile.in	2005-08-28 08:31:58.000000000 +0200
+++ /root/Desktop/gp2xdev/libs/SDL-1.2.9/src/video/XFree86/Xxf86vm/Makefile.in	2006-05-19 09:11:11.000000000 +0200
@@ -1,4 +1,4 @@
-# Makefile.in generated by automake 1.9.6 from Makefile.am.
+# Makefile.in generated by automake 1.9.5 from Makefile.am.
 # @configure_input@
 
 # Copyright (C) 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002,
@@ -14,6 +14,8 @@
 
 @SET_MAKE@
 
+SOURCES = $(libXFree86_Xxf86vm_la_SOURCES)
+
 srcdir = @srcdir@
 top_srcdir = @top_srcdir@
 VPATH = @srcdir@