Added initial support for Nano-X (thanks Hsieh-Fu!)

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%4031
This commit is contained in:
Sam Lantinga 2001-05-11 01:13:35 +00:00
parent 6216069aa3
commit 367f76c103
20 changed files with 1709 additions and 2 deletions

View file

@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libvideo.la
# Define which subdirectories need to be built
SUBDIRS = @VIDEO_SUBDIRS@
DIST_SUBDIRS = dummy x11 dga fbcon svga ggi aalib \
DIST_SUBDIRS = dummy x11 dga nanox fbcon svga ggi aalib \
wincommon windib windx5 \
maccommon macdsp macrom bwindow photon cybergfx

View file

@ -331,6 +331,9 @@ extern VideoBootStrap X11_bootstrap;
#ifdef ENABLE_DGA
extern VideoBootStrap DGA_bootstrap;
#endif
#ifdef ENABLE_NANOX
extern VideoBootStrap NX_bootstrap;
#endif
#ifdef ENABLE_FBCON
extern VideoBootStrap FBCON_bootstrap;
#endif

View file

@ -51,6 +51,9 @@ static VideoBootStrap *bootstrap[] = {
#ifdef ENABLE_DGA
&DGA_bootstrap,
#endif
#ifdef ENABLE_NANOX
&NX_bootstrap,
#endif
#ifdef ENABLE_FBCON
&FBCON_bootstrap,
#endif

View file

@ -0,0 +1,20 @@
## Makefile.am for SDL using the nanox video driver
noinst_LTLIBRARIES = libvideo_nanox.la
libvideo_nanox_la_SOURCES = $(NANOX_SRCS)
# The SDL nanox video driver sources
NANOX_SRCS = \
SDL_nxmodes.c \
SDL_nxmodes_c.h \
SDL_nxmouse.c \
SDL_nxmouse_c.h \
SDL_nxvideo.c \
SDL_nxvideo.h \
SDL_nxwm.c \
SDL_nxwm_c.h \
SDL_nxevents.c \
SDL_nxevents_c.h \
SDL_nximage.c \
SDL_nximage_c.h

View file

@ -0,0 +1,364 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include "SDL_keysym.h"
#include "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_TABLESIZE (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 ;
}
default :
Dprintf ("unknown GR_EVENT_TYPE_UPDATE\n") ;
break ;
}
break ;
}
default :
{
Dprintf ("pump event default\n") ;
}
}
GrCheckNextEvent (& event) ;
}
}

View file

@ -0,0 +1,31 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include "SDL_nxvideo.h"
// Functions to be exported
extern void NX_InitOSKeymap (_THIS) ;
extern void NX_PumpEvents (_THIS) ;

View file

@ -0,0 +1,166 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include <stdlib.h>
#include "SDL_error.h"
#include "SDL_nximage_c.h"
void NX_NormalUpdate (_THIS, int numrects, SDL_Rect * rects)
{
int i, j, xinc, yinc, destinc ;
int x, y, w, h ;
unsigned char * src = NULL, * dest = NULL ;
Dprintf ("enter NX_NormalUpdate\n") ;
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 ;
dest = Image_buff ;
destinc = w * xinc ;
// apply GammaRamp table
#if (defined (NANOX_PIXEL_RGB) || defined (NANOX_PIXEL_0888) || \
defined (NANOX_PIXEL_888))
if (GammaRamp_R && GammaRamp_G && GammaRamp_B) {
Uint8 * ptr ;
int k ;
for (j = h; j > 0; -- j, src += yinc) {
ptr = src - 1 ;
for (k = w; k > 0; -- k) {
#ifdef NANOX_PIXEL_RGB
ptr += 2 ;
#endif
#ifdef NANOX_PIXEL_0888
ptr += 2 ;
#endif
#ifdef NANOX_PIXEL_888
++ ptr ;
#endif
(* ptr) = GammaRamp_B [(* ptr)] ;
++ ptr ;
(* ptr) = GammaRamp_G [(* ptr)] ;
++ ptr ;
(* ptr) = GammaRamp_R [(* ptr)] ;
}
}
src = SDL_Image + y * yinc + x * xinc ;
}
#endif // apply Gamma table
for (j = h; j > 0; -- j, src += yinc, dest += destinc) {
memcpy (dest, src, destinc) ;
}
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) ;
}
}
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 *) malloc (size) ;
Image_buff = (unsigned char *) malloc (size) ;
if (screen -> pixels == NULL || Image_buff == NULL) {
free (screen -> pixels) ;
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) free (SDL_Image) ;
if (Image_buff) 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 ;
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;
}
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) ;
}
Dprintf ("leave NX_RefreshDisplay\n") ;
}

View file

@ -0,0 +1,34 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#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) ;

View file

@ -0,0 +1,84 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include <stdlib.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) {
free (SDL_modelist [i]) ;
}
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 ;
}

View file

@ -0,0 +1,33 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include "SDL_nxvideo.h"
#include <SDL/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) ;

View file

@ -0,0 +1,81 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include <stdlib.h>
#include "SDL_error.h"
#include "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 *) 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") ;
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 ;
}

View file

@ -0,0 +1,6 @@
#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) ;

View file

@ -0,0 +1,557 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include <stdlib.h>
#include "SDL_video.h"
#include "SDL_pixels_c.h"
#include "SDL_events_c.h"
#include "SDL_thread.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) free (device -> hidden) ;
if (device -> gl_data) free (device -> gl_data) ;
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 *) malloc (sizeof (SDL_VideoDevice)) ;
if (device) {
memset (device, 0, (sizeof * device)) ;
device -> hidden = (struct SDL_PrivateVideoData *)
malloc ((sizeof * device -> hidden)) ;
device -> gl_data = NULL ;
}
if ((device == NULL) || (device -> hidden == NULL)) {
SDL_OutOfMemory () ;
NX_DeleteDevice (device) ;
return 0 ;
}
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 ;
#ifdef HAVE_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 ;
// GetVideoMode
SDL_modelist = (SDL_Rect **) malloc (sizeof (SDL_Rect *) * 2) ;
if (SDL_modelist) {
SDL_modelist [0] = (SDL_Rect *) 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 ;
}
#ifdef NANOX_PIXEL_RGB
pixel_type = MWPF_RGB ;
SDL_Visual.red_mask = 0x000000FF ;
SDL_Visual.green_mask = 0x0000FF00 ;
SDL_Visual.blue_mask = 0x00FF0000 ;
#endif
#ifdef NANOX_PIXEL_0888
pixel_type = MWPF_TRUECOLOR0888 ;
SDL_Visual.red_mask = 0x00FF0000 ;
SDL_Visual.green_mask = 0x0000FF00 ;
SDL_Visual.blue_mask = 0x000000FF ;
#endif
#ifdef NANOX_PIXEL_888
pixel_type = MWPF_TRUECOLOR888 ;
SDL_Visual.red_mask = 0xFF0000 ;
SDL_Visual.green_mask = 0x00FF00 ;
SDL_Visual.blue_mask = 0x0000FF ;
#endif
#ifdef NANOX_PIXEL_565
pixel_type = MWPF_TRUECOLOR565 ;
SDL_Visual.red_mask = 0xF800 ;
SDL_Visual.green_mask = 0x07E0 ;
SDL_Visual.blue_mask = 0x001F ;
#endif
#ifdef NANOX_PIXEL_555
pixel_type = MWPF_TRUECOLOR555 ;
SDL_Visual.red_mask = 0x7C00 ;
SDL_Visual.green_mask = 0x03E0 ;
SDL_Visual.blue_mask = 0x001F ;
#endif
#ifdef NANOX_PIXEL_332
pixel_type = MWPF_TRUECOLOR332 ;
#endif
#ifdef NANOX_PIXEL_PAL
pixel_type = MWPF_PALETTE ;
#endif
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) ;
free (GammaRamp_R) ;
free (GammaRamp_G) ;
free (GammaRamp_B) ;
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 = 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 ;
}
}
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) ;
}
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 *) malloc (sizeof (Uint16) * CI_SIZE) ;
if (! GammaRamp_G) GammaRamp_G = (Uint16 *) malloc (sizeof (Uint16) * CI_SIZE) ;
if (! GammaRamp_B) GammaRamp_B = (Uint16 *) 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] ;
}
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 ;
}

View file

@ -0,0 +1,89 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#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 ;
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 ;
} ;
#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 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 CI_SIZE 256 // color index size
#endif // _SDL_nxvideo_h

View file

@ -0,0 +1,63 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#include <stdlib.h>
#include "SDL_syswm.h"
#include "SDL_error.h"
#include "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") ;
}

View file

@ -0,0 +1,31 @@
/*
SDL - Simple DirectMedia Layer
Copyright (C) 1997, 1998, 1999, 2000, 2001 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@devolution.com
Hsieh-Fu Tsai
clare@setabox.com
*/
#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) ;