Date: Sat, 24 Aug 2002 22:20:01 -0600
authorSam Lantinga <slouken@libsdl.org>
Sun, 25 Aug 2002 06:21:49 +0000
changeset 47126dafefeebb2
parent 470 877b992f2d0c
child 472 34fb7043b18b
Date: Sat, 24 Aug 2002 22:20:01 -0600
From: "Greg Haerr"
Subject: Announce: sdl-nanox-patch

Sam,
I've created an update patch for enhanced Nano-X support
with SDL. I've created the patch against SDL-1.2.4. I'd appreciate
it if you would apply it to the next SDL version.

Enhancements include:

1. Small bugfixes to compile without errors
2. Support for direct client-side framebuffer access with configure option
3. Add dynamic pixel type support for hardware framebuffer; eliminating the
need for compile-time configuration option.

I've updated the README.NanoX file with the details.

This version has been tested with Microwindows v0.89pre9 CVS
and SMPEG 0.4.4. I've added multi-threading support to
Microwindows to support the multi-threaded SMPEG, and
all works fine. To turn on thread safety in Microwindows,
use THREADSAFE=Y in the Microwindows config file.

Thanks!

Regards,

Greg
Founder, The Microwindows Project
http://microwindows.org
README.NanoX
configure.in
include/SDL_syswm.h
src/video/nanox/SDL_nxevents.c
src/video/nanox/SDL_nximage.c
src/video/nanox/SDL_nxmodes_c.h
src/video/nanox/SDL_nxvideo.c
src/video/nanox/SDL_nxvideo.h
     1.1 --- a/README.NanoX	Sun Aug 25 02:05:24 2002 +0000
     1.2 +++ b/README.NanoX	Sun Aug 25 06:21:49 2002 +0000
     1.3 @@ -1,14 +1,23 @@
     1.4    =================================================================
     1.5 -  Patch version 0.8 of SDL(Simple DirectMedia Layer) for Nano-X API
     1.6 +  Patch version 0.9 of SDL(Simple DirectMedia Layer) for Nano-X API
     1.7    =================================================================
     1.8    
     1.9 -  Author: Hsieh-Fu Tsai, clare@setabox.com
    1.10 +  Authors: Hsieh-Fu Tsai, clare@setabox.com
    1.11 +           Greg Haerr, greg@censoft.com
    1.12  
    1.13 -  There are two patch files in this package. 
    1.14 +  This patch is against SDL version 1.2.4.
    1.15 +  It enhances previous patch 0.8 by providing direct framebuffer
    1.16 +  access as well as dynamic hardware pixel type support, not
    1.17 +  requiring a compile-time option setting for different framebuffer
    1.18 +  modes.
    1.19 +  Tested against Microwindows version 0.89pre9.
    1.20  
    1.21 -  1. The first patch file, nanox.patch, is to fix a bug in Nano-X. 
    1.22 -     This patch is proposed by Gary James (gjames@twcny.rr.com).
    1.23 +  Older Microwindows versions
    1.24 +  ===========================
    1.25 +  If running on a version older than Microwindows 0.89pre9,
    1.26 +  the following items might need to be patched in Microwindows.
    1.27  
    1.28 +  1. Patch src/nanox/client.c::GrClose()
    1.29    It fixes the client side GrClose(). In the original version, 
    1.30    GrOpen() can only be called once. When the GrOpen() is called at 
    1.31    the second time, the program will terminate. In order to prevent
    1.32 @@ -16,6 +25,11 @@
    1.33    "close(nxSocket)" in GrClose(). If you do not have this problem,
    1.34    you may skip this step. 
    1.35  
    1.36 +  2. Patch src/nanox/clientfb.c to return absolute x,y coordinates
    1.37 +  when using GrGetWindowFBInfo().  Copy the version 0.89pre9
    1.38 +  of src/nanox/clientfb.c to your system, or configure
    1.39 +  using --disable-nanox-direct-fb.
    1.40 +
    1.41    =============
    1.42    Quick Install 
    1.43    =============
    1.44 @@ -31,18 +45,14 @@
    1.45    Nitty-gritty 
    1.46    ============
    1.47  
    1.48 -  --with-nanox-pixel-type=[rgb/0888/888/565/555/332/pal] 
    1.49 -
    1.50 -  If the wrong pixel type is used, the program will crash when the 
    1.51 -  sub-routine updates the screen. This option depends on SCREEN_PIXTYPE 
    1.52 -  which is defined in Microwin0.89pre7/src/config. SCREEN_PIXTYPE 
    1.53 -  is used to define the pixel type in Microwindows/Nano-X. 
    1.54 -  I only test the program when the pixel type is in "rgb" 
    1.55 -  (Microwin under X11) or "888" (framebuffer in 24-bit).
    1.56 -
    1.57 +  --enable-nanox-direct-fb       Use direct framebuffer access
    1.58    --enable-nanox-debug           Show debug messages 
    1.59    --enable-nanox-share-memory    Use shared-memory to speed up 
    1.60  
    1.61 +  When running multi-threaded applications using SDL, such
    1.62 +  as SMPEG, set THREADSAFE=Y in Microwindows' config file,
    1.63 +  to enable GrXXX() system call critical section support.
    1.64 +
    1.65    =============================================
    1.66    Some programs can be used to test this patch. 
    1.67    =============================================
    1.68 @@ -52,7 +62,8 @@
    1.69    3. http://www.libsdl.org/projects/xflame/
    1.70    4. http://www.libsdl.org/projects/optimum/ 
    1.71    5. http://www.gnugeneration.com/software/loop/ 
    1.72 -    
    1.73 +  6: http://www.lokigames.com/development/smpeg.php3 (SMPEG version 0.4.4)
    1.74 +
    1.75    =========
    1.76    Todo List 
    1.77    =========
    1.78 @@ -62,6 +73,8 @@
    1.79    3. Use OpenGL
    1.80    4. Gamma correction
    1.81    5. Hide/Change mouse pointer
    1.82 +  6. Better window movement control with direct fb access
    1.83 +  7. Palette handling in 8bpp could be improved
    1.84  
    1.85    =====================
    1.86    Supporting Institutes
    1.87 @@ -72,10 +85,13 @@
    1.88    Department of Computer Science and Information Engineering of 
    1.89    National Taiwan University for supporting this porting project.
    1.90    
    1.91 +  Century Embedded Technologies (http://embedded.censoft.com)
    1.92 +  for this patch.
    1.93 +
    1.94    ===================
    1.95    Contact Information
    1.96    ===================
    1.97  
    1.98    Welcome to give me any suggestion and to report bugs.
    1.99    My e-mail address : clare@setabox.com or niky@cmlab.csie.ntu.edu.tw
   1.100 -  
   1.101 +                      or greg@censoft.com
     2.1 --- a/configure.in	Sun Aug 25 02:05:24 2002 +0000
     2.2 +++ b/configure.in	Sun Aug 25 06:21:49 2002 +0000
     2.3 @@ -511,9 +511,9 @@
     2.4      AC_ARG_ENABLE(nanox-share-memory,  
     2.5          [  --enable-nanox-share-memory use share memory [default=no]],
     2.6          , enable_nanox_share_memory=no)
     2.7 -
     2.8 -    AC_ARG_WITH(nanox_pixel_type, 
     2.9 -        [  --with-nanox-pixel-type=[rgb/0888/888/565/555/332/pal]])
    2.10 +    AC_ARG_ENABLE(nanox_direct_fb, 
    2.11 +        [  --enable-nanox-direct-fb use direct framebuffer access [default=no]],
    2.12 +        , enable_nanox_direct_fb=no)
    2.13  
    2.14      if test x$enable_video = xyes -a x$enable_video_nanox = xyes; then
    2.15          if test x$enable_nanox_debug = xyes; then
    2.16 @@ -524,16 +524,9 @@
    2.17              CFLAGS="$CFLAGS -DNANOX_SHARE_MEMORY"
    2.18          fi
    2.19  
    2.20 -        case "$with_nanox_pixel_type" in
    2.21 -             rgb) CFLAGS="$CFLAGS -DNANOX_PIXEL_RGB" ;;
    2.22 -            0888) CFLAGS="$CFLAGS -DNANOX_PIXEL_0888" ;;
    2.23 -             888) CFLAGS="$CFLAGS -DNANOX_PIXEL_888"  ;;
    2.24 -             565) CFLAGS="$CFLAGS -DNANOX_PIXEL_565"  ;;
    2.25 -             555) CFLAGS="$CFLAGS -DNANOX_PIXEL_555"  ;;
    2.26 -             332) CFLAGS="$CFLAGS -DNANOX_PIXEL_332"  ;;
    2.27 -             pal) CFLAGS="$CFLAGS -DNANOX_PIXEL_PAL"  ;;
    2.28 -               *) AC_MSG_ERROR([Invalid nanox_pixel_type]);;
    2.29 -        esac
    2.30 +        if test x$enable_nanox_direct_fb = xyes; then
    2.31 +            CFLAGS="$CFLAGS -DENABLE_NANOX_DIRECT_FB"
    2.32 +        fi
    2.33  
    2.34          CFLAGS="$CFLAGS $X_CFLAGS -DENABLE_NANOX"
    2.35          SYSTEM_LIBS="$SYSTEM_LIBS -lnano-X"
     3.1 --- a/include/SDL_syswm.h	Sun Aug 25 02:05:24 2002 +0000
     3.2 +++ b/include/SDL_syswm.h	Sun Aug 25 06:21:49 2002 +0000
     3.3 @@ -50,7 +50,7 @@
     3.4  
     3.5  /* This is the structure for custom window manager events */
     3.6  #if (defined(unix) || defined(__unix__) || defined(_AIX) || defined(__OpenBSD__)) && \
     3.7 -    (!defined(DISABLE_X11) && !defined(__CYGWIN32__))
     3.8 +    (!defined(DISABLE_X11) && !defined(__CYGWIN32__) && !defined(ENABLE_NANOX))
     3.9   /* AIX is unix, of course, but the native compiler CSet doesn't define unix */
    3.10  #include <X11/Xlib.h>
    3.11  #include <X11/Xatom.h>
     4.1 --- a/src/video/nanox/SDL_nxevents.c	Sun Aug 25 02:05:24 2002 +0000
     4.2 +++ b/src/video/nanox/SDL_nxevents.c	Sun Aug 25 06:21:49 2002 +0000
     4.3 @@ -2,6 +2,7 @@
     4.4      SDL - Simple DirectMedia Layer
     4.5      Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     4.6      Copyright (C) 2001  Hsieh-Fu Tsai
     4.7 +    Copyright (C) 2002  Greg Haerr <greg@censoft.com>
     4.8  
     4.9      This library is free software; you can redistribute it and/or
    4.10      modify it under the terms of the GNU Library General Public
    4.11 @@ -345,6 +346,22 @@
    4.12                          SDL_PrivateResize (event.update.width, event.update.height) ;
    4.13                          break ; 
    4.14                      }
    4.15 +
    4.16 +                    case GR_UPDATE_MOVE :
    4.17 +		    case GR_UPDATE_REPARENT :
    4.18 +                    {
    4.19 +                        Dprintf ("GR_UPDATE_MOVE or GR_UPDATE_REPARENT\n") ;
    4.20 +#ifdef ENABLE_NANOX_DIRECT_FB
    4.21 +			if (Clientfb) {
    4.22 +			    /* Get current window position and fb pointer*/
    4.23 +			    if (currently_fullscreen) 
    4.24 +				GrGetWindowFBInfo(FSwindow, &fbinfo);
    4.25 +			    else
    4.26 +				GrGetWindowFBInfo(SDL_Window, &fbinfo);
    4.27 +			}
    4.28 +#endif
    4.29 +                        break ; 
    4.30 +                    }
    4.31                      
    4.32                      default :
    4.33                          Dprintf ("unknown GR_EVENT_TYPE_UPDATE\n") ;
     5.1 --- a/src/video/nanox/SDL_nximage.c	Sun Aug 25 02:05:24 2002 +0000
     5.2 +++ b/src/video/nanox/SDL_nximage.c	Sun Aug 25 06:21:49 2002 +0000
     5.3 @@ -2,6 +2,7 @@
     5.4      SDL - Simple DirectMedia Layer
     5.5      Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     5.6      Copyright (C) 2001  Hsieh-Fu Tsai
     5.7 +    Copyright (C) 2002  Greg Haerr <greg@censoft.com>
     5.8  
     5.9      This library is free software; you can redistribute it and/or
    5.10      modify it under the terms of the GNU Library General Public
    5.11 @@ -32,12 +33,13 @@
    5.12  
    5.13  void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
    5.14  {
    5.15 -    int           i, j, xinc, yinc, destinc ;
    5.16 +    int           i, j, xinc, yinc, destinc, rowinc ;
    5.17      int           x, y, w, h ;
    5.18      unsigned char * src = NULL, * dest = NULL ;
    5.19 -            
    5.20 +
    5.21      Dprintf ("enter NX_NormalUpdate\n") ;
    5.22 -
    5.23 +    
    5.24 +    /* These are the values for the incoming image */
    5.25      xinc = this -> screen -> format -> BytesPerPixel ;
    5.26      yinc = this -> screen -> pitch ;
    5.27          
    5.28 @@ -45,28 +47,36 @@
    5.29          x = rects [i].x, y = rects [i].y ;
    5.30          w = rects [i].w, h = rects [i].h ;
    5.31          src = SDL_Image + y * yinc + x * xinc ;
    5.32 -        dest = Image_buff ;
    5.33 -        destinc = w * xinc ;
    5.34 +#ifdef ENABLE_NANOX_DIRECT_FB
    5.35 +	if (Clientfb) {
    5.36 +	    if (currently_fullscreen)
    5.37 +	        dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) +
    5.38 +		    ((x+OffsetX) * fbinfo.bytespp));
    5.39 +	    else
    5.40 +	        dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp));
    5.41 +	    destinc = fbinfo.pitch;
    5.42 +	} else {
    5.43 +#endif
    5.44 +            dest = Image_buff ;
    5.45 +            destinc = w * xinc ;
    5.46 +#ifdef ENABLE_NANOX_DIRECT_FB
    5.47 +	}
    5.48 +#endif
    5.49 +	rowinc = w * xinc;
    5.50  
    5.51          // apply GammaRamp table
    5.52 -#if (defined (NANOX_PIXEL_RGB) || defined (NANOX_PIXEL_0888) || \
    5.53 -     defined (NANOX_PIXEL_888))
    5.54 -        if (GammaRamp_R && GammaRamp_G && GammaRamp_B) {
    5.55 +        if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888)
    5.56 +	  && GammaRamp_R && GammaRamp_G && GammaRamp_B) {
    5.57              Uint8 * ptr ;
    5.58              int   k ;
    5.59  
    5.60              for (j = h; j > 0; -- j, src += yinc) {
    5.61                  ptr = src - 1 ;
    5.62                  for (k = w; k > 0; -- k) {
    5.63 -#ifdef NANOX_PIXEL_RGB
    5.64 -                    ptr += 2 ;
    5.65 -#endif
    5.66 -#ifdef NANOX_PIXEL_0888
    5.67 -                    ptr += 2 ;
    5.68 -#endif
    5.69 -#ifdef NANOX_PIXEL_888
    5.70 -                    ++ ptr ;
    5.71 -#endif
    5.72 +		    if (pixel_type == MWPF_TRUECOLOR0888)
    5.73 +                        ptr += 2 ;
    5.74 +                    else
    5.75 +                        ++ ptr ;
    5.76                      (* ptr) = GammaRamp_B [(* ptr)] ;
    5.77                      ++ ptr ;
    5.78                      (* ptr) = GammaRamp_G [(* ptr)] ;
    5.79 @@ -76,19 +86,19 @@
    5.80              }
    5.81              src = SDL_Image + y * yinc + x * xinc ;
    5.82          }
    5.83 -#endif // apply Gamma table
    5.84  
    5.85 -        for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
    5.86 -            memcpy (dest, src, destinc) ;
    5.87 -        }
    5.88 -
    5.89 -        if (currently_fullscreen) {
    5.90 -            GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, 
    5.91 -                pixel_type) ;
    5.92 -        } else {
    5.93 -            GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ;
    5.94 -        }
    5.95 +        for (j = h; j > 0; -- j, src += yinc, dest += destinc)
    5.96 +            memcpy (dest, src, rowinc) ;
    5.97 +	if (!Clientfb) {
    5.98 +            if (currently_fullscreen) {
    5.99 +                GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff, 
   5.100 +                    pixel_type) ;
   5.101 +            } else {
   5.102 +                GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ;
   5.103 +            }
   5.104 +	}
   5.105      }
   5.106 +    GrFlush();
   5.107  
   5.108      Dprintf ("leave NX_NormalUpdate\n") ;
   5.109  }
   5.110 @@ -100,12 +110,15 @@
   5.111      Dprintf ("enter NX_SetupImage\n") ;
   5.112  
   5.113      screen -> pixels = (void *) malloc (size) ;
   5.114 -    Image_buff = (unsigned char *) malloc (size) ;
   5.115 -    if (screen -> pixels == NULL || Image_buff == NULL) {
   5.116 -        free (screen -> pixels) ;
   5.117 -        free (Image_buff) ;
   5.118 -        SDL_OutOfMemory () ;
   5.119 -        return -1 ;
   5.120 +
   5.121 +    if (!Clientfb) {
   5.122 +        Image_buff = (unsigned char *) malloc (size) ;
   5.123 +        if (screen -> pixels == NULL || Image_buff == NULL) {
   5.124 +            free (screen -> pixels) ;
   5.125 +            free (Image_buff) ;
   5.126 +            SDL_OutOfMemory () ;
   5.127 +            return -1 ;
   5.128 +        }
   5.129      }
   5.130  
   5.131      SDL_Image = (unsigned char *) screen -> pixels ;
   5.132 @@ -140,7 +153,16 @@
   5.133      GrGetScreenInfo (& si) ;
   5.134      OffsetX = (si.cols - screen -> w) / 2 ;
   5.135      OffsetY = (si.rows - screen -> h) / 2 ;
   5.136 -    
   5.137 +
   5.138 +#ifdef ENABLE_NANOX_DIRECT_FB
   5.139 +    if (Clientfb) {
   5.140 +        /* Get current window position and fb pointer*/
   5.141 +        if (currently_fullscreen) 
   5.142 +            GrGetWindowFBInfo(FSwindow, &fbinfo);
   5.143 +        else
   5.144 +            GrGetWindowFBInfo(SDL_Window, &fbinfo);
   5.145 +    }
   5.146 +#endif
   5.147      Dprintf ("leave NX_ResizeImage\n") ;
   5.148      return retval ;
   5.149  }
   5.150 @@ -154,13 +176,40 @@
   5.151          return;
   5.152      }
   5.153  
   5.154 -    if (currently_fullscreen) {
   5.155 -        GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, 
   5.156 -            this -> screen -> h, SDL_Image, pixel_type) ;
   5.157 +#ifdef ENABLE_NANOX_DIRECT_FB
   5.158 +    if (Clientfb) {
   5.159 +        int j;
   5.160 +        char *src, *dest = NULL;
   5.161 +        int xinc, yinc, rowinc;
   5.162 +
   5.163 +	GrGetWindowFBInfo(SDL_Window, &fbinfo);
   5.164 +
   5.165 +	xinc = this -> screen -> format -> BytesPerPixel ; 
   5.166 +	yinc = this -> screen -> pitch ;           
   5.167 +
   5.168 +	src = SDL_Image;
   5.169 +	if (currently_fullscreen)
   5.170 +	    dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
   5.171 +	        (OffsetX * fbinfo.bytespp));
   5.172 +	else
   5.173 +	    dest = fbinfo.winpixels;
   5.174 +	rowinc = xinc * this -> screen -> w;
   5.175 +
   5.176 +	for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
   5.177 +	    memcpy (dest, src, rowinc) ;
   5.178      } else {
   5.179 -        GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, 
   5.180 -            this -> screen -> h, SDL_Image, pixel_type) ;
   5.181 +#endif
   5.182 +        if (currently_fullscreen) {
   5.183 +            GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w, 
   5.184 +                this -> screen -> h, SDL_Image, pixel_type) ;
   5.185 +	} else {
   5.186 +            GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w, 
   5.187 +                this -> screen -> h, SDL_Image, pixel_type) ;
   5.188 +	}
   5.189 +#ifdef ENABLE_NANOX_DIRECT_FB
   5.190      }
   5.191 +#endif
   5.192 +    GrFlush();
   5.193  
   5.194      Dprintf ("leave NX_RefreshDisplay\n") ;
   5.195  }
     6.1 --- a/src/video/nanox/SDL_nxmodes_c.h	Sun Aug 25 02:05:24 2002 +0000
     6.2 +++ b/src/video/nanox/SDL_nxmodes_c.h	Sun Aug 25 06:21:49 2002 +0000
     6.3 @@ -25,7 +25,7 @@
     6.4  */
     6.5  
     6.6  #include "SDL_nxvideo.h"
     6.7 -#include <SDL/SDL.h>
     6.8 +#include <SDL.h>
     6.9  
    6.10  extern SDL_Rect ** NX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) ;
    6.11  extern void NX_FreeVideoModes (_THIS) ;
     7.1 --- a/src/video/nanox/SDL_nxvideo.c	Sun Aug 25 02:05:24 2002 +0000
     7.2 +++ b/src/video/nanox/SDL_nxvideo.c	Sun Aug 25 06:21:49 2002 +0000
     7.3 @@ -2,6 +2,7 @@
     7.4      SDL - Simple DirectMedia Layer
     7.5      Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002  Sam Lantinga
     7.6      Copyright (C) 2001  Hsieh-Fu Tsai
     7.7 +    Copyright (C) 2002  Greg Haerr <greg@censoft.com>
     7.8  
     7.9      This library is free software; you can redistribute it and/or
    7.10      modify it under the terms of the GNU Library General Public
    7.11 @@ -222,42 +223,10 @@
    7.12          SDL_modelist [1] = NULL ;
    7.13      }
    7.14  
    7.15 -#ifdef NANOX_PIXEL_RGB
    7.16 -    pixel_type = MWPF_RGB ;
    7.17 -    SDL_Visual.red_mask   = 0x000000FF ;
    7.18 -    SDL_Visual.green_mask = 0x0000FF00 ;
    7.19 -    SDL_Visual.blue_mask  = 0x00FF0000 ;
    7.20 -#endif
    7.21 -#ifdef NANOX_PIXEL_0888
    7.22 -    pixel_type = MWPF_TRUECOLOR0888 ;
    7.23 -    SDL_Visual.red_mask   = 0x00FF0000 ;
    7.24 -    SDL_Visual.green_mask = 0x0000FF00 ;
    7.25 -    SDL_Visual.blue_mask  = 0x000000FF ;
    7.26 -#endif
    7.27 -#ifdef NANOX_PIXEL_888
    7.28 -    pixel_type = MWPF_TRUECOLOR888 ;
    7.29 -    SDL_Visual.red_mask   = 0xFF0000 ;
    7.30 -    SDL_Visual.green_mask = 0x00FF00 ;
    7.31 -    SDL_Visual.blue_mask  = 0x0000FF ;
    7.32 -#endif
    7.33 -#ifdef NANOX_PIXEL_565
    7.34 -    pixel_type = MWPF_TRUECOLOR565 ;
    7.35 -    SDL_Visual.red_mask   = 0xF800 ;
    7.36 -    SDL_Visual.green_mask = 0x07E0 ;
    7.37 -    SDL_Visual.blue_mask  = 0x001F ;
    7.38 -#endif
    7.39 -#ifdef NANOX_PIXEL_555
    7.40 -    pixel_type = MWPF_TRUECOLOR555 ;
    7.41 -    SDL_Visual.red_mask   = 0x7C00 ;
    7.42 -    SDL_Visual.green_mask = 0x03E0 ;
    7.43 -    SDL_Visual.blue_mask  = 0x001F ;
    7.44 -#endif
    7.45 -#ifdef NANOX_PIXEL_332
    7.46 -    pixel_type = MWPF_TRUECOLOR332 ;
    7.47 -#endif
    7.48 -#ifdef NANOX_PIXEL_PAL
    7.49 -    pixel_type = MWPF_PALETTE ;
    7.50 -#endif
    7.51 +    pixel_type = si.pixtype;
    7.52 +    SDL_Visual.red_mask = si.rmask;
    7.53 +    SDL_Visual.green_mask = si.gmask;
    7.54 +    SDL_Visual.blue_mask = si.bmask;
    7.55  
    7.56      vformat -> BitsPerPixel = SDL_Visual.bpp ;
    7.57      if (vformat -> BitsPerPixel > 8) {
    7.58 @@ -290,6 +259,11 @@
    7.59      free (GammaRamp_R) ;
    7.60      free (GammaRamp_G) ;
    7.61      free (GammaRamp_B) ;
    7.62 +
    7.63 +#ifdef ENABLE_NANOX_DIRECT_FB
    7.64 +    if (Clientfb)
    7.65 +        GrCloseClientFramebuffer();
    7.66 +#endif
    7.67      GrClose () ;
    7.68  
    7.69      Dprintf ("leave NX_VideoQuit\n") ;
    7.70 @@ -373,6 +347,12 @@
    7.71          }
    7.72      }
    7.73  
    7.74 +#ifdef ENABLE_NANOX_DIRECT_FB
    7.75 +    /* attempt allocating the client side framebuffer */
    7.76 +    Clientfb = GrOpenClientFramebuffer();
    7.77 +    /* NULL return will default to using GrArea()*/
    7.78 +#endif
    7.79 +
    7.80      Dprintf ("leave NX_CreateWindow\n") ;
    7.81      return 0 ;
    7.82  }
     8.1 --- a/src/video/nanox/SDL_nxvideo.h	Sun Aug 25 02:05:24 2002 +0000
     8.2 +++ b/src/video/nanox/SDL_nxvideo.h	Sun Aug 25 06:21:49 2002 +0000
     8.3 @@ -55,7 +55,8 @@
     8.4      char            * SDL_windowid ;
     8.5      GR_GC_ID        GC ;
     8.6      unsigned char   * Image ;
     8.7 -    unsigned char   * Image_buff ;
     8.8 +    unsigned char   * Image_buff ;	/* for GrArea*/
     8.9 +    unsigned char   * Clientfb;		/* for DirectFB*/
    8.10      nx_sdl_visual_t SDL_Visual ;
    8.11      // The current list of available video modes
    8.12      SDL_Rect        ** modelist ;
    8.13 @@ -66,6 +67,9 @@
    8.14      Uint16          * GammaRamp_R, * GammaRamp_G, * GammaRamp_B ;
    8.15      // for GrArea, r_mask, g_mask, b_mask
    8.16      int             pixel_type ;
    8.17 +#ifdef ENABLE_NANOX_DIRECT_FB
    8.18 +    GR_WINDOW_FB_INFO fbinfo;
    8.19 +#endif
    8.20  } ;
    8.21  
    8.22  #define SDL_Window           (this -> hidden -> SDL_Window)
    8.23 @@ -74,6 +78,7 @@
    8.24  #define SDL_GC               (this -> hidden -> GC)
    8.25  #define SDL_Image            (this -> hidden -> Image)
    8.26  #define Image_buff           (this -> hidden -> Image_buff)
    8.27 +#define Clientfb             (this -> hidden -> Clientfb)
    8.28  #define SDL_Visual           (this -> hidden -> SDL_Visual)
    8.29  #define SDL_modelist         (this -> hidden -> modelist)
    8.30  #define currently_fullscreen (this -> hidden -> currently_fullscreen)
    8.31 @@ -83,6 +88,7 @@
    8.32  #define GammaRamp_G          (this -> hidden -> GammaRamp_G)
    8.33  #define GammaRamp_B          (this -> hidden -> GammaRamp_B)
    8.34  #define pixel_type           (this -> hidden -> pixel_type)
    8.35 +#define fbinfo               (this -> hidden -> fbinfo)
    8.36  
    8.37  #define CI_SIZE 256   // color index size
    8.38