aboutsummaryrefslogtreecommitdiffstats
path: root/distrib/sdl-1.2.15/src/video/nanox
diff options
context:
space:
mode:
Diffstat (limited to 'distrib/sdl-1.2.15/src/video/nanox')
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents.c382
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents_c.h32
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nximage.c230
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nximage_c.h35
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes.c84
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes_c.h34
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse.c79
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse_c.h29
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.c544
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.h96
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm.c61
-rw-r--r--distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm_c.h32
12 files changed, 1638 insertions, 0 deletions
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents.c b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents.c
new file mode 100644
index 0000000..788c794
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents.c
@@ -0,0 +1,382 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+ Copyright (C) 2002 Greg Haerr <greg@censoft.com>
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_keysym.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_nxevents_c.h"
+#include "SDL_nximage_c.h"
+
+// The translation tables from a nanox keysym to a SDL keysym
+static SDLKey NX_NONASCII_keymap [MWKEY_LAST + 1] ;
+
+void NX_InitOSKeymap (_THIS)
+{
+ int i ;
+
+ Dprintf ("enter NX_InitOSKeymap\n") ;
+
+ // Map the nanox scancodes to SDL keysyms
+ for (i = 0; i < SDL_arraysize (NX_NONASCII_keymap); ++ i)
+ NX_NONASCII_keymap [i] = SDLK_UNKNOWN ;
+
+ NX_NONASCII_keymap [MWKEY_LEFT & 0xFF] = SDLK_LEFT ;
+ NX_NONASCII_keymap [MWKEY_RIGHT & 0xFF] = SDLK_RIGHT ;
+ NX_NONASCII_keymap [MWKEY_UP & 0xFF] = SDLK_UP ;
+ NX_NONASCII_keymap [MWKEY_DOWN & 0xFF] = SDLK_DOWN ;
+ NX_NONASCII_keymap [MWKEY_INSERT & 0xFF] = SDLK_INSERT ;
+ NX_NONASCII_keymap [MWKEY_DELETE & 0xFF] = SDLK_DELETE ;
+ NX_NONASCII_keymap [MWKEY_HOME & 0xFF] = SDLK_HOME ;
+ NX_NONASCII_keymap [MWKEY_END & 0xFF] = SDLK_END ;
+ NX_NONASCII_keymap [MWKEY_PAGEUP & 0xFF] = SDLK_PAGEUP ;
+ NX_NONASCII_keymap [MWKEY_PAGEDOWN & 0xFF] = SDLK_PAGEDOWN ;
+
+ NX_NONASCII_keymap [MWKEY_KP0 & 0xFF] = SDLK_KP0 ;
+ NX_NONASCII_keymap [MWKEY_KP1 & 0xFF] = SDLK_KP1 ;
+ NX_NONASCII_keymap [MWKEY_KP2 & 0xFF] = SDLK_KP2 ;
+ NX_NONASCII_keymap [MWKEY_KP3 & 0xFF] = SDLK_KP3 ;
+ NX_NONASCII_keymap [MWKEY_KP4 & 0xFF] = SDLK_KP4 ;
+ NX_NONASCII_keymap [MWKEY_KP5 & 0xFF] = SDLK_KP5 ;
+ NX_NONASCII_keymap [MWKEY_KP6 & 0xFF] = SDLK_KP6 ;
+ NX_NONASCII_keymap [MWKEY_KP7 & 0xFF] = SDLK_KP7 ;
+ NX_NONASCII_keymap [MWKEY_KP8 & 0xFF] = SDLK_KP8 ;
+ NX_NONASCII_keymap [MWKEY_KP9 & 0xFF] = SDLK_KP9 ;
+ NX_NONASCII_keymap [MWKEY_KP_PERIOD & 0xFF] = SDLK_KP_PERIOD ;
+ NX_NONASCII_keymap [MWKEY_KP_DIVIDE & 0xFF] = SDLK_KP_DIVIDE ;
+ NX_NONASCII_keymap [MWKEY_KP_MULTIPLY & 0xFF] = SDLK_KP_MULTIPLY ;
+ NX_NONASCII_keymap [MWKEY_KP_MINUS & 0xFF] = SDLK_KP_MINUS ;
+ NX_NONASCII_keymap [MWKEY_KP_PLUS & 0xFF] = SDLK_KP_PLUS ;
+ NX_NONASCII_keymap [MWKEY_KP_ENTER & 0xFF] = SDLK_KP_ENTER ;
+ NX_NONASCII_keymap [MWKEY_KP_EQUALS & 0xFF] = SDLK_KP_EQUALS ;
+
+ NX_NONASCII_keymap [MWKEY_F1 & 0xFF] = SDLK_F1 ;
+ NX_NONASCII_keymap [MWKEY_F2 & 0xFF] = SDLK_F2 ;
+ NX_NONASCII_keymap [MWKEY_F3 & 0xFF] = SDLK_F3 ;
+ NX_NONASCII_keymap [MWKEY_F4 & 0xFF] = SDLK_F4 ;
+ NX_NONASCII_keymap [MWKEY_F5 & 0xFF] = SDLK_F5 ;
+ NX_NONASCII_keymap [MWKEY_F6 & 0xFF] = SDLK_F6 ;
+ NX_NONASCII_keymap [MWKEY_F7 & 0xFF] = SDLK_F7 ;
+ NX_NONASCII_keymap [MWKEY_F8 & 0xFF] = SDLK_F8 ;
+ NX_NONASCII_keymap [MWKEY_F9 & 0xFF] = SDLK_F9 ;
+ NX_NONASCII_keymap [MWKEY_F10 & 0xFF] = SDLK_F10 ;
+ NX_NONASCII_keymap [MWKEY_F11 & 0xFF] = SDLK_F11 ;
+ NX_NONASCII_keymap [MWKEY_F12 & 0xFF] = SDLK_F12 ;
+
+ NX_NONASCII_keymap [MWKEY_NUMLOCK & 0xFF] = SDLK_NUMLOCK ;
+ NX_NONASCII_keymap [MWKEY_CAPSLOCK & 0xFF] = SDLK_CAPSLOCK ;
+ NX_NONASCII_keymap [MWKEY_SCROLLOCK & 0xFF] = SDLK_SCROLLOCK ;
+ NX_NONASCII_keymap [MWKEY_LSHIFT & 0xFF] = SDLK_LSHIFT ;
+ NX_NONASCII_keymap [MWKEY_RSHIFT & 0xFF] = SDLK_RSHIFT ;
+ NX_NONASCII_keymap [MWKEY_LCTRL & 0xFF] = SDLK_LCTRL ;
+ NX_NONASCII_keymap [MWKEY_RCTRL & 0xFF] = SDLK_RCTRL ;
+ NX_NONASCII_keymap [MWKEY_LALT & 0xFF] = SDLK_LALT ;
+ NX_NONASCII_keymap [MWKEY_RALT & 0xFF] = SDLK_RALT ;
+ NX_NONASCII_keymap [MWKEY_LMETA & 0xFF] = SDLK_LMETA ;
+ NX_NONASCII_keymap [MWKEY_RMETA & 0xFF] = SDLK_RMETA ;
+ NX_NONASCII_keymap [MWKEY_ALTGR & 0xFF] = SDLK_MODE ;
+
+ NX_NONASCII_keymap [MWKEY_PRINT & 0xFF] = SDLK_PRINT ;
+ NX_NONASCII_keymap [MWKEY_SYSREQ & 0xFF] = SDLK_SYSREQ ;
+ NX_NONASCII_keymap [MWKEY_PAUSE & 0xFF] = SDLK_PAUSE ;
+ NX_NONASCII_keymap [MWKEY_BREAK & 0xFF] = SDLK_BREAK ;
+ NX_NONASCII_keymap [MWKEY_MENU & 0xFF] = SDLK_MENU ;
+
+ Dprintf ("leave NX_InitOSKeymap\n") ;
+}
+
+SDL_keysym * NX_TranslateKey (GR_EVENT_KEYSTROKE * keystroke, SDL_keysym * keysym)
+{
+ GR_KEY ch = keystroke -> ch ;
+
+ Dprintf ("enter NX_TranslateKey\n") ;
+
+ keysym -> scancode = keystroke -> scancode ;
+ keysym -> sym = SDLK_UNKNOWN ;
+
+ if (ch & MWKEY_NONASCII_MASK) {
+ keysym -> sym = NX_NONASCII_keymap [ch & 0xFF] ;
+ } else {
+ keysym -> sym = ch & 0x7F ;
+ }
+
+ keysym -> mod = KMOD_NONE ;
+
+#if 1 // Retrieve more mode information
+ {
+ GR_KEYMOD mod = keystroke -> modifiers ;
+
+ if (mod & MWKMOD_LSHIFT)
+ keysym -> mod |= KMOD_LSHIFT ;
+ if (mod & MWKMOD_RSHIFT)
+ keysym -> mod |= KMOD_RSHIFT ;
+ if (mod & MWKMOD_LCTRL)
+ keysym -> mod |= KMOD_LCTRL ;
+ if (mod & MWKMOD_RCTRL)
+ keysym -> mod |= KMOD_RCTRL ;
+ if (mod & MWKMOD_LALT)
+ keysym -> mod |= KMOD_LALT ;
+ if (mod & MWKMOD_RALT)
+ keysym -> mod |= KMOD_RALT ;
+ if (mod & MWKMOD_LMETA)
+ keysym -> mod |= KMOD_LMETA ;
+ if (mod & MWKMOD_RMETA)
+ keysym -> mod |= KMOD_RMETA ;
+ if (mod & MWKMOD_NUM)
+ keysym -> mod |= KMOD_NUM ;
+ if (mod & MWKMOD_CAPS)
+ keysym -> mod |= KMOD_CAPS ;
+ if (mod & MWKMOD_ALTGR)
+ keysym -> mod |= KMOD_MODE ;
+ }
+#endif
+
+ keysym -> unicode = ch ;
+
+ Dprintf ("leave NX_TranslateKey\n") ;
+ return keysym ;
+}
+
+static int check_boundary (_THIS, int x, int y)
+{
+ if (x < OffsetX || y < OffsetY || x > OffsetX + this -> screen -> w ||
+ y > OffsetY + this -> screen -> h)
+ return 0 ;
+
+ return 1 ;
+}
+
+void NX_PumpEvents (_THIS)
+{
+ GR_EVENT event ;
+ static GR_BUTTON last_button_down = 0 ;
+
+ GrCheckNextEvent (& event) ;
+ while (event.type != GR_EVENT_TYPE_NONE) {
+
+ // dispatch event
+ switch (event.type) {
+ case GR_EVENT_TYPE_MOUSE_ENTER :
+ {
+ Dprintf ("mouse enter\n") ;
+ SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_MOUSE_EXIT :
+ {
+ Dprintf ("mouse exit\n") ;
+ SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_FOCUS_IN :
+ {
+ Dprintf ("focus in\n") ;
+ SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS) ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_FOCUS_OUT :
+ {
+ Dprintf ("focus out\n") ;
+ SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS) ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_MOUSE_MOTION :
+ {
+ Dprintf ("mouse motion\n") ;
+
+ if (SDL_VideoSurface) {
+ if (currently_fullscreen) {
+ if (check_boundary (this, event.button.x, event.button.y)) {
+ SDL_PrivateMouseMotion (0, 0, event.button.x - OffsetX,
+ event.button.y - OffsetY) ;
+ }
+ } else {
+ SDL_PrivateMouseMotion (0, 0, event.button.x, event.button.y) ;
+ }
+ }
+ break ;
+ }
+
+ case GR_EVENT_TYPE_BUTTON_DOWN :
+ {
+ int button = event.button.buttons ;
+
+ Dprintf ("button down\n") ;
+
+ switch (button) {
+ case MWBUTTON_L :
+ button = 1 ;
+ break ;
+ case MWBUTTON_M :
+ button = 2 ;
+ break ;
+ case MWBUTTON_R :
+ button = 3 ;
+ break ;
+ default :
+ button = 0 ;
+ }
+ last_button_down = button ;
+
+ if (currently_fullscreen) {
+ if (check_boundary (this, event.button.x, event.button.y)) {
+ SDL_PrivateMouseButton (SDL_PRESSED, button,
+ event.button.x - OffsetX, event.button.y - OffsetY) ;
+ }
+ } else {
+ SDL_PrivateMouseButton (SDL_PRESSED, button,
+ event.button.x, event.button.y) ;
+ }
+ break ;
+ }
+
+ // do not konw which button is released
+ case GR_EVENT_TYPE_BUTTON_UP :
+ {
+ Dprintf ("button up\n") ;
+
+ if (currently_fullscreen) {
+ if (check_boundary (this, event.button.x, event.button.y)) {
+ SDL_PrivateMouseButton (SDL_RELEASED, last_button_down,
+ event.button.x - OffsetX, event.button.y - OffsetY) ;
+ }
+ } else {
+ SDL_PrivateMouseButton (SDL_RELEASED, last_button_down,
+ event.button.x, event.button.y) ;
+ }
+ last_button_down = 0 ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_KEY_DOWN :
+ {
+ SDL_keysym keysym ;
+
+ Dprintf ("key down\n") ;
+ SDL_PrivateKeyboard (SDL_PRESSED,
+ NX_TranslateKey (& event.keystroke, & keysym)) ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_KEY_UP :
+ {
+ SDL_keysym keysym ;
+
+ Dprintf ("key up\n") ;
+ SDL_PrivateKeyboard (SDL_RELEASED,
+ NX_TranslateKey (& event.keystroke, & keysym)) ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_CLOSE_REQ :
+ {
+ Dprintf ("close require\n") ;
+ SDL_PrivateQuit () ;
+ break ;
+ }
+
+ case GR_EVENT_TYPE_EXPOSURE :
+ {
+ Dprintf ("event_type_exposure\n") ;
+ if (SDL_VideoSurface) {
+ NX_RefreshDisplay (this) ;//, & event.exposure) ;
+ }
+ break ;
+ }
+
+ case GR_EVENT_TYPE_UPDATE :
+ {
+ switch (event.update.utype) {
+ case GR_UPDATE_MAP :
+ {
+ Dprintf ("GR_UPDATE_MAP\n") ;
+ // If we're not active, make ourselves active
+ if (!(SDL_GetAppState () & SDL_APPACTIVE)) {
+ // Send an internal activate event
+ SDL_PrivateAppActive (1, SDL_APPACTIVE) ;
+ }
+ if (SDL_VideoSurface) {
+ NX_RefreshDisplay (this) ;
+ }
+ break ;
+ }
+
+ case GR_UPDATE_UNMAP :
+ case GR_UPDATE_UNMAPTEMP :
+ {
+ Dprintf ("GR_UPDATE_UNMAP or GR_UPDATE_UNMAPTEMP\n") ;
+ // If we're active, make ourselves inactive
+ if (SDL_GetAppState () & SDL_APPACTIVE) {
+ // Send an internal deactivate event
+ SDL_PrivateAppActive (0, SDL_APPACTIVE | SDL_APPINPUTFOCUS) ;
+ }
+ break ;
+ }
+
+ case GR_UPDATE_SIZE :
+ {
+ Dprintf ("GR_UPDATE_SIZE\n") ;
+ SDL_PrivateResize (event.update.width, event.update.height) ;
+ break ;
+ }
+
+ case GR_UPDATE_MOVE :
+ case GR_UPDATE_REPARENT :
+ {
+ Dprintf ("GR_UPDATE_MOVE or GR_UPDATE_REPARENT\n") ;
+#ifdef ENABLE_NANOX_DIRECT_FB
+ if (Clientfb) {
+ /* Get current window position and fb pointer*/
+ if (currently_fullscreen)
+ GrGetWindowFBInfo(FSwindow, &fbinfo);
+ else
+ GrGetWindowFBInfo(SDL_Window, &fbinfo);
+ }
+#endif
+ break ;
+ }
+
+ default :
+ Dprintf ("unknown GR_EVENT_TYPE_UPDATE\n") ;
+ break ;
+ }
+ break ;
+ }
+
+ default :
+ {
+ Dprintf ("pump event default\n") ;
+ }
+ }
+
+ GrCheckNextEvent (& event) ;
+ }
+}
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents_c.h b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents_c.h
new file mode 100644
index 0000000..b3b4f97
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxevents_c.h
@@ -0,0 +1,32 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_nxvideo.h"
+
+// Functions to be exported
+extern void NX_InitOSKeymap (_THIS) ;
+extern void NX_PumpEvents (_THIS) ;
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nximage.c b/distrib/sdl-1.2.15/src/video/nanox/SDL_nximage.c
new file mode 100644
index 0000000..23d3157
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nximage.c
@@ -0,0 +1,230 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+ Copyright (C) 2002 Greg Haerr <greg@censoft.com>
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_nximage_c.h"
+
+void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
+{
+ int i, j, xinc, yinc, destinc, rowinc ;
+ int x, y, w, h ;
+ unsigned char * src = NULL, * dest = NULL ;
+
+ Dprintf ("enter NX_NormalUpdate\n") ;
+
+ /* These are the values for the incoming image */
+ xinc = this -> screen -> format -> BytesPerPixel ;
+ yinc = this -> screen -> pitch ;
+
+ for (i = 0; i < numrects; ++ i) {
+ x = rects [i].x, y = rects [i].y ;
+ w = rects [i].w, h = rects [i].h ;
+ src = SDL_Image + y * yinc + x * xinc ;
+#ifdef ENABLE_NANOX_DIRECT_FB
+ if (Clientfb) {
+ if (currently_fullscreen)
+ dest = fbinfo.winpixels + (((y+OffsetY) * fbinfo.pitch) +
+ ((x+OffsetX) * fbinfo.bytespp));
+ else
+ dest = fbinfo.winpixels + ((y * fbinfo.pitch) + (x * fbinfo.bytespp));
+ destinc = fbinfo.pitch;
+ }
+ else
+#endif
+ {
+ dest = Image_buff ;
+ destinc = w * xinc ;
+ }
+ rowinc = w * xinc;
+
+ // apply GammaRamp table
+ if ((pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888)
+ && GammaRamp_R && GammaRamp_G && GammaRamp_B) {
+ Uint8 * ptrsrc ;
+ Uint8 * ptrdst ;
+ int k ;
+
+ for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
+ ptrsrc = src ;
+ ptrdst = dest ;
+ for (k = w; k > 0; -- k) {
+ *ptrdst++ = GammaRamp_B [*ptrsrc++] >> 8;
+ *ptrdst++ = GammaRamp_G [*ptrsrc++] >> 8;
+ *ptrdst++ = GammaRamp_R [*ptrsrc++] >> 8;
+ *ptrdst++ = 0;
+ ++ptrsrc;
+ }
+ }
+ }
+#if 1 /* This is needed for microwindows 0.90 or older */
+ else if (pixel_type == MWPF_TRUECOLOR0888 || pixel_type == MWPF_TRUECOLOR888) {
+ Uint8 * ptrsrc ;
+ Uint8 * ptrdst ;
+ int k ;
+
+ for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
+ ptrsrc = src ;
+ ptrdst = dest ;
+ for (k = w; k > 0; -- k) {
+ *ptrdst++ = *ptrsrc++;
+ *ptrdst++ = *ptrsrc++;
+ *ptrdst++ = *ptrsrc++;
+ *ptrdst++ = 0;
+ ++ptrsrc;
+ }
+ }
+ }
+#endif
+ else
+ {
+ for (j = h; j > 0; -- j, src += yinc, dest += destinc)
+ SDL_memcpy (dest, src, rowinc) ;
+ }
+ if (!Clientfb) {
+ if (currently_fullscreen) {
+ GrArea (FSwindow, SDL_GC, x + OffsetX, y + OffsetY, w, h, Image_buff,
+ pixel_type) ;
+ } else {
+ GrArea (SDL_Window, SDL_GC, x, y, w, h, Image_buff, pixel_type) ;
+ }
+ }
+ }
+ GrFlush();
+
+ Dprintf ("leave NX_NormalUpdate\n") ;
+}
+
+int NX_SetupImage (_THIS, SDL_Surface * screen)
+{
+ int size = screen -> h * screen -> pitch ;
+
+ Dprintf ("enter NX_SetupImage\n") ;
+
+ screen -> pixels = (void *) SDL_malloc (size) ;
+
+ if (!Clientfb) {
+ Image_buff = (unsigned char *) SDL_malloc (size) ;
+ if (screen -> pixels == NULL || Image_buff == NULL) {
+ SDL_free (screen -> pixels) ;
+ SDL_free (Image_buff) ;
+ SDL_OutOfMemory () ;
+ return -1 ;
+ }
+ }
+
+ SDL_Image = (unsigned char *) screen -> pixels ;
+
+ this -> UpdateRects = NX_NormalUpdate ;
+
+ Dprintf ("leave NX_SetupImage\n") ;
+ return 0 ;
+}
+
+void NX_DestroyImage (_THIS, SDL_Surface * screen)
+{
+ Dprintf ("enter NX_DestroyImage\n") ;
+
+ if (SDL_Image) SDL_free (SDL_Image) ;
+ if (Image_buff) SDL_free (Image_buff) ;
+ if (screen) screen -> pixels = NULL ;
+
+ Dprintf ("leave NX_DestroyImage\n") ;
+}
+
+int NX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags)
+{
+ int retval ;
+ GR_SCREEN_INFO si ;
+
+ Dprintf ("enter NX_ResizeImage\n") ;
+
+ NX_DestroyImage (this, screen) ;
+ retval = NX_SetupImage (this, screen) ;
+
+ GrGetScreenInfo (& si) ;
+ OffsetX = (si.cols - screen -> w) / 2 ;
+ OffsetY = (si.rows - screen -> h) / 2 ;
+
+#ifdef ENABLE_NANOX_DIRECT_FB
+ if (Clientfb) {
+ /* Get current window position and fb pointer*/
+ if (currently_fullscreen)
+ GrGetWindowFBInfo(FSwindow, &fbinfo);
+ else
+ GrGetWindowFBInfo(SDL_Window, &fbinfo);
+ }
+#endif
+ Dprintf ("leave NX_ResizeImage\n") ;
+ return retval ;
+}
+
+void NX_RefreshDisplay (_THIS)
+{
+ Dprintf ("enter NX_RefreshDisplay\n") ;
+
+ // Don't refresh a display that doesn't have an image (like GL)
+ if (! SDL_Image) {
+ return;
+ }
+
+#ifdef ENABLE_NANOX_DIRECT_FB
+ if (Clientfb) {
+ int j;
+ char *src, *dest = NULL;
+ int xinc, yinc, rowinc;
+
+ GrGetWindowFBInfo(SDL_Window, &fbinfo);
+
+ xinc = this -> screen -> format -> BytesPerPixel ;
+ yinc = this -> screen -> pitch ;
+
+ src = SDL_Image;
+ if (currently_fullscreen)
+ dest = fbinfo.winpixels + ((OffsetY * fbinfo.pitch) +
+ (OffsetX * fbinfo.bytespp));
+ else
+ dest = fbinfo.winpixels;
+ rowinc = xinc * this -> screen -> w;
+
+ for (j = this -> screen -> h; j > 0; -- j, src += yinc, dest += fbinfo.pitch)
+ SDL_memcpy (dest, src, rowinc) ;
+ }
+ else
+#endif
+ {
+ if (currently_fullscreen) {
+ GrArea (FSwindow, SDL_GC, OffsetX, OffsetY, this -> screen -> w,
+ this -> screen -> h, SDL_Image, pixel_type) ;
+ } else {
+ GrArea (SDL_Window, SDL_GC, 0, 0, this -> screen -> w,
+ this -> screen -> h, SDL_Image, pixel_type) ;
+ }
+ }
+ GrFlush();
+
+ Dprintf ("leave NX_RefreshDisplay\n") ;
+}
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nximage_c.h b/distrib/sdl-1.2.15/src/video/nanox/SDL_nximage_c.h
new file mode 100644
index 0000000..0bf29e5
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nximage_c.h
@@ -0,0 +1,35 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_nxvideo.h"
+
+extern int NX_SetupImage (_THIS, SDL_Surface * screen) ;
+extern void NX_DestroyImage (_THIS, SDL_Surface * screen) ;
+extern int NX_ResizeImage (_THIS, SDL_Surface * screen, Uint32 flags) ;
+
+extern void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects) ;
+extern void NX_RefreshDisplay (_THIS) ;
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes.c b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes.c
new file mode 100644
index 0000000..bcf74e5
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes.c
@@ -0,0 +1,84 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_stdinc.h"
+#include "SDL_nxmodes_c.h"
+
+SDL_Rect ** NX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags)
+{
+ if (flags & SDL_FULLSCREEN)
+ return SDL_modelist ;
+
+ if (SDL_Visual.bpp == format -> BitsPerPixel) {
+ return ((SDL_Rect **) -1) ;
+ } else {
+ return ((SDL_Rect **) 0) ;
+ }
+}
+
+void NX_FreeVideoModes (_THIS)
+{
+ int i ;
+
+ if (SDL_modelist) {
+ for (i = 0; SDL_modelist [i]; ++ i) {
+ SDL_free (SDL_modelist [i]) ;
+ }
+ SDL_free (SDL_modelist) ;
+ SDL_modelist = NULL;
+ }
+}
+
+int NX_EnterFullScreen (_THIS)
+{
+ if (! currently_fullscreen) {
+ GR_SCREEN_INFO si ;
+
+ GrGetScreenInfo (& si) ;
+ GrResizeWindow (FSwindow, si.cols, si.rows) ;
+ GrUnmapWindow (SDL_Window) ;
+ GrMapWindow (FSwindow) ;
+ GrRaiseWindow (FSwindow) ;
+ GrSetFocus (FSwindow) ;
+ currently_fullscreen = 1 ;
+ }
+
+ return 1 ;
+}
+
+int NX_LeaveFullScreen (_THIS)
+{
+ if (currently_fullscreen) {
+ GrUnmapWindow (FSwindow) ;
+ GrMapWindow (SDL_Window) ;
+ GrRaiseWindow (SDL_Window) ;
+ GrSetFocus (SDL_Window) ;
+ currently_fullscreen = 0 ;
+ }
+
+ return 0 ;
+}
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes_c.h b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes_c.h
new file mode 100644
index 0000000..fe2e655
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmodes_c.h
@@ -0,0 +1,34 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_nxvideo.h"
+#include <SDL.h>
+
+extern SDL_Rect ** NX_ListModes (_THIS, SDL_PixelFormat * format, Uint32 flags) ;
+extern void NX_FreeVideoModes (_THIS) ;
+extern int NX_EnterFullScreen (_THIS) ;
+extern int NX_LeaveFullScreen (_THIS) ;
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse.c b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse.c
new file mode 100644
index 0000000..9c8f382
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse.c
@@ -0,0 +1,79 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_nxmouse_c.h"
+
+// The implementation dependent data for the window manager cursor
+struct WMcursor {
+ int unused ;
+} ;
+
+WMcursor * NX_CreateWMCursor (_THIS,
+ Uint8 * data, Uint8 * mask, int w, int h, int hot_x, int hot_y)
+{
+ WMcursor * cursor ;
+
+ Dprintf ("enter NX_CreateWMCursor\n") ;
+
+ cursor = (WMcursor *) SDL_malloc (sizeof (WMcursor)) ;
+ if (cursor == NULL) {
+ SDL_OutOfMemory () ;
+ return NULL ;
+ }
+
+ Dprintf ("leave NX_CreateWMCursor\n") ;
+ return cursor ;
+}
+
+void NX_FreeWMCursor (_THIS, WMcursor * cursor)
+{
+ Dprintf ("NX_FreeWMCursor\n") ;
+ SDL_free (cursor) ;
+ return ;
+}
+
+void NX_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
+{
+ GR_WINDOW_INFO info ;
+
+ Dprintf ("enter NX_WarpWMCursor\n") ;
+ SDL_Lock_EventThread () ;
+
+ GrGetWindowInfo (SDL_Window, & info) ;
+ GrMoveCursor (info.x + x, info.y + y) ;
+
+ SDL_Unlock_EventThread () ;
+ Dprintf ("leave NX_WarpWMCursor\n") ;
+}
+
+int NX_ShowWMCursor (_THIS, WMcursor * cursor)
+{
+ Dprintf ("NX_ShowWMCursor\n") ;
+ return 1 ;
+}
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse_c.h b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse_c.h
new file mode 100644
index 0000000..d7fedb5
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxmouse_c.h
@@ -0,0 +1,29 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+
+ This library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ This library is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this library; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+
+ Sam Lantinga
+ slouken@libsdl.org
+*/
+#include "SDL_config.h"
+
+#include "SDL_nxvideo.h"
+
+extern WMcursor * NX_CreateWMCursor (_THIS, Uint8 * data, Uint8 * mask, int w, int h, int hot_x, int hot_y) ;
+void NX_FreeWMCursor (_THIS, WMcursor * cursor) ;
+extern void NX_WarpWMCursor (_THIS, Uint16 x, Uint16 y) ;
+extern int NX_ShowWMCursor (_THIS, WMcursor * cursor) ;
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.c b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.c
new file mode 100644
index 0000000..b188e09
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.c
@@ -0,0 +1,544 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+ Copyright (C) 2002 Greg Haerr <greg@censoft.com>
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_thread.h"
+#include "SDL_video.h"
+#include "../SDL_pixels_c.h"
+#include "../../events/SDL_events_c.h"
+
+#define MWINCLUDECOLORS
+#include "SDL_nxvideo.h"
+#include "SDL_nxmodes_c.h"
+#include "SDL_nxwm_c.h"
+#include "SDL_nxmouse_c.h"
+#include "SDL_nximage_c.h"
+#include "SDL_nxevents_c.h"
+
+// Initialization/Query functions
+static int NX_VideoInit (_THIS, SDL_PixelFormat * vformat) ;
+static SDL_Surface * NX_SetVideoMode (_THIS, SDL_Surface * current, int width, int height, int bpp, Uint32 flags) ;
+static int NX_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors) ;
+static void NX_VideoQuit (_THIS) ;
+static void NX_DestroyWindow (_THIS, SDL_Surface * screen) ;
+static int NX_ToggleFullScreen (_THIS, int on) ;
+static void NX_UpdateMouse (_THIS) ;
+static int NX_SetGammaRamp (_THIS, Uint16 * ramp) ;
+static int NX_GetGammaRamp (_THIS, Uint16 * ramp) ;
+
+// Microwin driver bootstrap functions
+static int NX_Available ()
+{
+ Dprintf ("enter NX_Available\n") ;
+
+ if (GrOpen () < 0) return 0 ;
+ GrClose () ;
+
+ Dprintf ("leave NX_Available\n") ;
+ return 1 ;
+}
+
+static void NX_DeleteDevice (SDL_VideoDevice * device)
+{
+ Dprintf ("enter NX_DeleteDevice\n") ;
+
+ if (device) {
+ if (device -> hidden) SDL_free (device -> hidden) ;
+ if (device -> gl_data) SDL_free (device -> gl_data) ;
+ SDL_free (device) ;
+ }
+
+ Dprintf ("leave NX_DeleteDevice\n") ;
+}
+
+static SDL_VideoDevice * NX_CreateDevice (int devindex)
+{
+ SDL_VideoDevice * device ;
+
+ Dprintf ("enter NX_CreateDevice\n") ;
+
+ // Initialize all variables that we clean on shutdown
+ device = (SDL_VideoDevice *) SDL_malloc (sizeof (SDL_VideoDevice)) ;
+ if (device) {
+ SDL_memset (device, 0, (sizeof * device)) ;
+ device -> hidden = (struct SDL_PrivateVideoData *)
+ SDL_malloc ((sizeof * device -> hidden)) ;
+ device -> gl_data = NULL ;
+ }
+ if ((device == NULL) || (device -> hidden == NULL)) {
+ SDL_OutOfMemory () ;
+ NX_DeleteDevice (device) ;
+ return 0 ;
+ }
+ SDL_memset (device -> hidden, 0, (sizeof * device -> hidden)) ;
+
+ // Set the function pointers
+ device -> VideoInit = NX_VideoInit ;
+ device -> ListModes = NX_ListModes ;
+ device -> SetVideoMode = NX_SetVideoMode ;
+ device -> ToggleFullScreen = NX_ToggleFullScreen ;
+ device -> UpdateMouse = NX_UpdateMouse ;
+ device -> CreateYUVOverlay = NULL ;
+ device -> SetColors = NX_SetColors ;
+ device -> UpdateRects = NULL ;
+ device -> VideoQuit = NX_VideoQuit;
+ device -> AllocHWSurface = NULL ;
+ device -> CheckHWBlit = NULL ;
+ device -> FillHWRect = NULL ;
+ device -> SetHWColorKey = NULL ;
+ device -> SetHWAlpha = NULL ;
+ device -> LockHWSurface = NULL ;
+ device -> UnlockHWSurface = NULL ;
+ device -> FlipHWSurface = NULL ;
+ device -> FreeHWSurface = NULL ;
+ device -> SetGamma = NULL ;
+ device -> GetGamma = NULL ;
+ device -> SetGammaRamp = NX_SetGammaRamp ;
+ device -> GetGammaRamp = NX_GetGammaRamp ;
+
+#if SDL_VIDEO_OPENGL
+ device -> GL_LoadLibrary = NULL ;
+ device -> GL_GetProcAddress = NULL ;
+ device -> GL_GetAttribute = NULL ;
+ device -> GL_MakeCurrent = NULL ;
+ device -> GL_SwapBuffers = NULL ;
+#endif
+
+ device -> SetIcon = NULL ;
+ device -> SetCaption = NX_SetCaption;
+ device -> IconifyWindow = NULL ;
+ device -> GrabInput = NULL ;
+ device -> GetWMInfo = NX_GetWMInfo ;
+ device -> FreeWMCursor = NX_FreeWMCursor ;
+ device -> CreateWMCursor = NX_CreateWMCursor ;
+ device -> ShowWMCursor = NX_ShowWMCursor ;
+ device -> WarpWMCursor = NX_WarpWMCursor ;
+ device -> CheckMouseMode = NULL ;
+ device -> InitOSKeymap = NX_InitOSKeymap ;
+ device -> PumpEvents = NX_PumpEvents ;
+
+ device -> free = NX_DeleteDevice ;
+
+ Dprintf ("leave NX_CreateDevice\n") ;
+ return device ;
+}
+
+VideoBootStrap NX_bootstrap = {
+ "nanox", "nanox", NX_Available, NX_CreateDevice
+} ;
+
+static void create_aux_windows (_THIS)
+{
+ GR_WM_PROPERTIES props ;
+
+ Dprintf ("enter create_aux_windows\n") ;
+
+ // Don't create any extra windows if we are being managed
+ if (SDL_windowid) {
+ FSwindow = 0 ;
+ return ;
+ }
+
+ if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) {
+ GrDestroyWindow (FSwindow) ;
+ }
+
+ FSwindow = GrNewWindow (GR_ROOT_WINDOW_ID, 0, 0, 1, 1, 0, BLACK, BLACK) ;
+ props.flags = GR_WM_FLAGS_PROPS ;
+ props.props = GR_WM_PROPS_NODECORATE ;
+ GrSetWMProperties (FSwindow, & props) ;
+
+ GrSelectEvents (FSwindow, (GR_EVENT_MASK_EXPOSURE |
+ GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_BUTTON_UP |
+ GR_EVENT_MASK_FOCUS_IN | GR_EVENT_MASK_FOCUS_OUT |
+ GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP |
+ GR_EVENT_MASK_MOUSE_ENTER | GR_EVENT_MASK_MOUSE_EXIT |
+ GR_EVENT_MASK_MOUSE_MOTION | GR_EVENT_MASK_UPDATE |
+ GR_EVENT_MASK_CLOSE_REQ)) ;
+
+ Dprintf ("leave create_aux_windows\n") ;
+}
+
+int NX_VideoInit (_THIS, SDL_PixelFormat * vformat)
+{
+ GR_SCREEN_INFO si ;
+
+ Dprintf ("enter NX_VideoInit\n") ;
+
+ if (GrOpen () < 0) {
+ SDL_SetError ("GrOpen() fail") ;
+ return -1 ;
+ }
+
+ // use share memory to speed up
+#ifdef NANOX_SHARE_MEMORY
+ GrReqShmCmds (0xFFFF);
+#endif
+
+ SDL_Window = 0 ;
+ FSwindow = 0 ;
+
+ GammaRamp_R = NULL ;
+ GammaRamp_G = NULL ;
+ GammaRamp_B = NULL ;
+
+ GrGetScreenInfo (& si) ;
+ SDL_Visual.bpp = si.bpp ;
+
+ /* Determine the current screen size */
+ this->info.current_w = si.cols ;
+ this->info.current_h = si.rows ;
+
+ // GetVideoMode
+ SDL_modelist = (SDL_Rect **) SDL_malloc (sizeof (SDL_Rect *) * 2) ;
+ if (SDL_modelist) {
+ SDL_modelist [0] = (SDL_Rect *) SDL_malloc (sizeof(SDL_Rect)) ;
+ if (SDL_modelist [0]) {
+ SDL_modelist [0] -> x = 0 ;
+ SDL_modelist [0] -> y = 0 ;
+ SDL_modelist [0] -> w = si.cols ;
+ SDL_modelist [0] -> h = si.rows ;
+ }
+ SDL_modelist [1] = NULL ;
+ }
+
+ pixel_type = si.pixtype;
+ SDL_Visual.red_mask = si.rmask;
+ SDL_Visual.green_mask = si.gmask;
+ SDL_Visual.blue_mask = si.bmask;
+
+ vformat -> BitsPerPixel = SDL_Visual.bpp ;
+ if (vformat -> BitsPerPixel > 8) {
+ vformat -> Rmask = SDL_Visual.red_mask ;
+ vformat -> Gmask = SDL_Visual.green_mask ;
+ vformat -> Bmask = SDL_Visual.blue_mask ;
+ }
+
+ // See if we have been passed a window to use
+ SDL_windowid = getenv ("SDL_WINDOWID") ;
+
+ // Create the fullscreen (and managed windows : no implement)
+ create_aux_windows (this) ;
+
+ Dprintf ("leave NX_VideoInit\n") ;
+ return 0 ;
+}
+
+void NX_VideoQuit (_THIS)
+{
+ Dprintf ("enter NX_VideoQuit\n") ;
+
+ // Start shutting down the windows
+ NX_DestroyImage (this, this -> screen) ;
+ NX_DestroyWindow (this, this -> screen) ;
+ if (FSwindow && FSwindow != GR_ROOT_WINDOW_ID) {
+ GrDestroyWindow (FSwindow) ;
+ }
+ NX_FreeVideoModes (this) ;
+ SDL_free (GammaRamp_R) ;
+ SDL_free (GammaRamp_G) ;
+ SDL_free (GammaRamp_B) ;
+
+#ifdef ENABLE_NANOX_DIRECT_FB
+ if (Clientfb)
+ GrCloseClientFramebuffer();
+#endif
+ GrClose () ;
+
+ Dprintf ("leave NX_VideoQuit\n") ;
+}
+
+static void NX_DestroyWindow (_THIS, SDL_Surface * screen)
+{
+ Dprintf ("enter NX_DestroyWindow\n") ;
+
+ if (! SDL_windowid) {
+ if (screen && (screen -> flags & SDL_FULLSCREEN)) {
+ screen -> flags &= ~ SDL_FULLSCREEN ;
+ NX_LeaveFullScreen (this) ;
+ }
+
+ // Destroy the output window
+ if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) {
+ GrDestroyWindow (SDL_Window) ;
+ }
+ }
+
+ // Free the graphics context
+ if (! SDL_GC) {
+ GrDestroyGC (SDL_GC) ;
+ SDL_GC = 0;
+ }
+
+ Dprintf ("leave NX_DestroyWindow\n") ;
+}
+
+static int NX_CreateWindow (_THIS, SDL_Surface * screen,
+ int w, int h, int bpp, Uint32 flags)
+{
+ Dprintf ("enter NX_CreateWindow\n") ;
+
+ // If a window is already present, destroy it and start fresh
+ if (SDL_Window && SDL_Window != GR_ROOT_WINDOW_ID) {
+ NX_DestroyWindow (this, screen) ;
+ }
+
+ // See if we have been given a window id
+ if (SDL_windowid) {
+ SDL_Window = SDL_strtol (SDL_windowid, NULL, 0) ;
+ } else {
+ SDL_Window = 0 ;
+ }
+
+ if ( ! SDL_ReallocFormat (screen, bpp, SDL_Visual.red_mask,
+ SDL_Visual.green_mask, SDL_Visual.blue_mask, 0))
+ return -1;
+
+ // Create (or use) the nanox display window
+ if (! SDL_windowid) {
+
+ SDL_Window = GrNewWindow (GR_ROOT_WINDOW_ID, 0, 0, w, h, 0, BLACK, WHITE) ;
+
+ GrSelectEvents (SDL_Window, (GR_EVENT_MASK_EXPOSURE |
+ GR_EVENT_MASK_BUTTON_DOWN | GR_EVENT_MASK_BUTTON_UP |
+ GR_EVENT_MASK_FOCUS_IN | GR_EVENT_MASK_FOCUS_OUT |
+ GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP |
+ GR_EVENT_MASK_MOUSE_ENTER | GR_EVENT_MASK_MOUSE_EXIT |
+ GR_EVENT_MASK_MOUSE_MOTION | GR_EVENT_MASK_UPDATE |
+ GR_EVENT_MASK_CLOSE_REQ)) ;
+ }
+
+ /* Create the graphics context here, once we have a window */
+ SDL_GC = GrNewGC () ;
+ if (SDL_GC == 0) {
+ SDL_SetError("Couldn't create graphics context");
+ return(-1);
+ }
+
+ // Map them both and go fullscreen, if requested
+ if (! SDL_windowid) {
+ GrMapWindow (SDL_Window) ;
+ if (flags & SDL_FULLSCREEN) {
+ screen -> flags |= SDL_FULLSCREEN ;
+ NX_EnterFullScreen (this) ;
+ } else {
+ screen -> flags &= ~ SDL_FULLSCREEN ;
+ }
+ }
+
+#ifdef ENABLE_NANOX_DIRECT_FB
+ /* attempt allocating the client side framebuffer */
+ Clientfb = GrOpenClientFramebuffer();
+ /* NULL return will default to using GrArea()*/
+#endif
+
+ Dprintf ("leave NX_CreateWindow\n") ;
+ return 0 ;
+}
+
+SDL_Surface * NX_SetVideoMode (_THIS, SDL_Surface * current,
+ int width, int height, int bpp, Uint32 flags)
+{
+ Dprintf ("enter NX_SetVideoMode\n") ;
+
+ // Lock the event thread, in multi-threading environments
+ SDL_Lock_EventThread () ;
+
+ bpp = SDL_Visual.bpp ;
+ if (NX_CreateWindow (this, current, width, height, bpp, flags) < 0) {
+ current = NULL;
+ goto done;
+ }
+
+ if (current -> w != width || current -> h != height) {
+ current -> w = width ;
+ current -> h = height ;
+ current -> pitch = SDL_CalculatePitch (current) ;
+ NX_ResizeImage (this, current, flags) ;
+ }
+
+ /* Clear these flags and set them only if they are in the new set. */
+ current -> flags &= ~(SDL_RESIZABLE|SDL_NOFRAME);
+ current -> flags |= (flags & (SDL_RESIZABLE | SDL_NOFRAME)) ;
+
+ done:
+ SDL_Unlock_EventThread () ;
+
+ Dprintf ("leave NX_SetVideoMode\n") ;
+
+ // We're done!
+ return current ;
+}
+
+// ncolors <= 256
+int NX_SetColors (_THIS, int firstcolor, int ncolors, SDL_Color * colors)
+{
+ int i ;
+ GR_PALETTE pal ;
+
+ Dprintf ("enter NX_SetColors\n") ;
+
+ if (ncolors > 256) return 0 ;
+
+ pal.count = ncolors ;
+ for (i = 0; i < ncolors; ++ i) {
+ pal.palette [i].r = colors [i].r ;
+ pal.palette [i].g = colors [i].g ;
+ pal.palette [i].b = colors [i].b ;
+ }
+ GrSetSystemPalette (firstcolor, & pal) ;
+
+ Dprintf ("leave NX_SetColors\n") ;
+ return 1 ;
+}
+
+static int NX_ToggleFullScreen (_THIS, int on)
+{
+ SDL_Rect rect ;
+ Uint32 event_thread ;
+
+ Dprintf ("enter NX_ToggleFullScreen\n") ;
+
+ // Don't switch if we don't own the window
+ if (SDL_windowid) return 0 ;
+
+ // Don't lock if we are the event thread
+ event_thread = SDL_EventThreadID () ;
+ if (event_thread && (SDL_ThreadID () == event_thread)) {
+ event_thread = 0 ;
+ }
+ if (event_thread) {
+ SDL_Lock_EventThread() ;
+ }
+
+ if (on) {
+ NX_EnterFullScreen (this) ;
+ } else {
+ this -> screen -> flags &= ~ SDL_FULLSCREEN ;
+ NX_LeaveFullScreen (this) ;
+ }
+
+ rect.x = rect.y = 0 ;
+ rect.w = this -> screen -> w, rect.h = this -> screen -> h ;
+ NX_NormalUpdate (this, 1, & rect) ;
+
+ if (event_thread) {
+ SDL_Unlock_EventThread () ;
+ }
+
+ Dprintf ("leave NX_ToggleFullScreen\n") ;
+ return 1 ;
+}
+
+// Update the current mouse state and position
+static void NX_UpdateMouse (_THIS)
+{
+ int x, y ;
+ GR_WINDOW_INFO info ;
+ GR_SCREEN_INFO si ;
+
+
+ Dprintf ("enter NX_UpdateMouse\n") ;
+
+ // Lock the event thread, in multi-threading environments
+ SDL_Lock_EventThread () ;
+
+ GrGetScreenInfo (& si) ;
+ GrGetWindowInfo (SDL_Window, & info) ;
+ x = si.xpos - info.x ;
+ y = si.ypos - info.y ;
+ if (x >= 0 && x <= info.width && y >= 0 && y <= info.height) {
+ SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ;
+ SDL_PrivateMouseMotion (0, 0, x, y);
+ } else {
+ SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ;
+ }
+
+ SDL_Unlock_EventThread () ;
+ Dprintf ("leave NX_UpdateMouse\n") ;
+}
+
+static int NX_SetGammaRamp (_THIS, Uint16 * ramp)
+{
+ int i ;
+ Uint16 * red, * green, * blue ;
+
+ Dprintf ("enter NX_SetGammaRamp\n") ;
+
+ if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1 ;
+
+ if (! GammaRamp_R) GammaRamp_R = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ;
+ if (! GammaRamp_G) GammaRamp_G = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ;
+ if (! GammaRamp_B) GammaRamp_B = (Uint16 *) SDL_malloc (sizeof (Uint16) * CI_SIZE) ;
+ if ((! GammaRamp_R) || (! GammaRamp_G) || (! GammaRamp_B)) {
+ SDL_OutOfMemory () ;
+ return -1 ;
+ }
+
+ for (i = 0; i < CI_SIZE; ++ i)
+ GammaRamp_R [i] = GammaRamp_G [i] = GammaRamp_B [i] = i ;
+
+ red = ramp ;
+ green = ramp + CI_SIZE ;
+ blue = green + CI_SIZE ;
+
+ for (i = 0; i < CI_SIZE; ++ i) {
+ GammaRamp_R [i] = red [i] ;
+ GammaRamp_G [i] = green [i] ;
+ GammaRamp_B [i] = blue [i] ;
+ }
+ SDL_UpdateRect(this->screen, 0, 0, 0, 0);
+
+ Dprintf ("leave NX_SetGammaRamp\n") ;
+ return 0 ;
+}
+
+static int NX_GetGammaRamp (_THIS, Uint16 * ramp)
+{
+ int i ;
+ Uint16 * red, * green, * blue ;
+
+ Dprintf ("enter NX_GetGammaRamp\n") ;
+
+ if (SDL_Visual.bpp != 32 && SDL_Visual.bpp != 24) return -1 ;
+ red = ramp ;
+ green = ramp + CI_SIZE ;
+ blue = green + CI_SIZE ;
+ if (GammaRamp_R && GammaRamp_G && GammaRamp_B) {
+ for (i = 0; i < CI_SIZE; ++ i) {
+ red [i] = GammaRamp_R [i] ;
+ green [i] = GammaRamp_G [i] ;
+ blue [i] = GammaRamp_B [i] ;
+ }
+ } else {
+ for (i = 0; i < CI_SIZE; ++ i)
+ red [i] = green [i] = blue [i] = i ;
+ }
+
+ Dprintf ("leave NX_GetGammaRamp\n") ;
+ return 0 ;
+}
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.h b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.h
new file mode 100644
index 0000000..1d858d9
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxvideo.h
@@ -0,0 +1,96 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#ifndef _SDL_nxvideo_h
+#define _SDL_nxvideo_h
+
+#include <microwin/nano-X.h>
+
+#include "../SDL_sysvideo.h"
+
+#ifdef ENABLE_NANOX_DEBUG
+#define Dprintf printf
+#else
+#define Dprintf(ignore...)
+#endif
+
+// Hidden "this" pointer for the video functions
+#define _THIS SDL_VideoDevice * this
+
+// Private display data
+typedef struct NX_SDL_VISUAL {
+ int bpp ;
+ Uint32 red_mask ;
+ Uint32 green_mask ;
+ Uint32 blue_mask ;
+} nx_sdl_visual_t ;
+
+struct SDL_PrivateVideoData {
+ GR_WINDOW_ID SDL_Window ;
+ GR_WINDOW_ID FSwindow ;
+ // Flag: true if we have been passed a window
+ char * SDL_windowid ;
+ GR_GC_ID GC ;
+ unsigned char * Image ;
+ unsigned char * Image_buff ; /* for GrArea*/
+ unsigned char * Clientfb; /* for DirectFB*/
+ nx_sdl_visual_t SDL_Visual ;
+ // The current list of available video modes
+ SDL_Rect ** modelist ;
+ int currently_fullscreen ;
+ // for fullscreen
+ int OffsetX, OffsetY ;
+ // for GammaRamp
+ Uint16 * GammaRamp_R, * GammaRamp_G, * GammaRamp_B ;
+ // for GrArea, r_mask, g_mask, b_mask
+ int pixel_type ;
+#ifdef ENABLE_NANOX_DIRECT_FB
+ GR_WINDOW_FB_INFO fbinfo;
+#endif
+} ;
+
+#define SDL_Window (this -> hidden -> SDL_Window)
+#define FSwindow (this -> hidden -> FSwindow)
+#define SDL_windowid (this -> hidden -> SDL_windowid)
+#define SDL_GC (this -> hidden -> GC)
+#define SDL_Image (this -> hidden -> Image)
+#define Image_buff (this -> hidden -> Image_buff)
+#define Clientfb (this -> hidden -> Clientfb)
+#define SDL_Visual (this -> hidden -> SDL_Visual)
+#define SDL_modelist (this -> hidden -> modelist)
+#define currently_fullscreen (this -> hidden -> currently_fullscreen)
+#define OffsetX (this -> hidden -> OffsetX)
+#define OffsetY (this -> hidden -> OffsetY)
+#define GammaRamp_R (this -> hidden -> GammaRamp_R)
+#define GammaRamp_G (this -> hidden -> GammaRamp_G)
+#define GammaRamp_B (this -> hidden -> GammaRamp_B)
+#define pixel_type (this -> hidden -> pixel_type)
+#define fbinfo (this -> hidden -> fbinfo)
+
+#define CI_SIZE 256 // color index size
+
+#endif // _SDL_nxvideo_h
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm.c b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm.c
new file mode 100644
index 0000000..c60ebb0
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm.c
@@ -0,0 +1,61 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_syswm.h"
+#include "../../events/SDL_events_c.h"
+
+#include "SDL_nxwm_c.h"
+
+void NX_SetCaption (_THIS, const char * title, const char * icon)
+{
+ Dprintf ("enter NX_SetCaption\n") ;
+
+ // Lock the event thread, in multi-threading environments
+ SDL_Lock_EventThread () ;
+
+ if (SDL_Window)
+ GrSetWindowTitle (SDL_Window, title) ;
+
+ SDL_Unlock_EventThread () ;
+ Dprintf ("leave NX_SetCaption\n") ;
+}
+
+int NX_GetWMInfo (_THIS, SDL_SysWMinfo * info)
+{
+ Dprintf ("enter NX_GetWMInfo\n") ;
+
+ if (info -> version.major <= SDL_MAJOR_VERSION) {
+ info -> window = SDL_Window ;
+ return 1 ;
+ } else {
+ SDL_SetError("Application not compiled with SDL %d.%d\n",
+ SDL_MAJOR_VERSION, SDL_MINOR_VERSION) ;
+ return -1 ;
+ }
+
+ Dprintf ("leave NX_GetWMInfo\n") ;
+}
diff --git a/distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm_c.h b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm_c.h
new file mode 100644
index 0000000..77be794
--- /dev/null
+++ b/distrib/sdl-1.2.15/src/video/nanox/SDL_nxwm_c.h
@@ -0,0 +1,32 @@
+/*
+ SDL - Simple DirectMedia Layer
+ Copyright (C) 1997-2012 Sam Lantinga
+ Copyright (C) 2001 Hsieh-Fu Tsai
+
+ 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
+
+ Hsieh-Fu Tsai
+ clare@setabox.com
+*/
+#include "SDL_config.h"
+
+#include "SDL_nxvideo.h"
+
+// Functions to be exported
+extern void NX_SetCaption (_THIS, const char * title, const char * icon) ;
+extern int NX_GetWMInfo (_THIS, SDL_SysWMinfo * info) ;