Update GEM driver to new API, will have to fill the void later :)
authorPatrice Mandin <patmandin@gmail.com>
Fri, 13 Jul 2007 22:55:15 +0000
changeset 2189f54670a477bb
parent 2188 0e751c1f83f5
child 2190 eff1ccd88273
Update GEM driver to new API, will have to fill the void later :)
src/video/gem/SDL_gemevents.c
src/video/gem/SDL_gemevents.h
src/video/gem/SDL_gemkeyboard.c
src/video/gem/SDL_gemkeyboard.h
src/video/gem/SDL_gemmodes.c
src/video/gem/SDL_gemmodes.h
src/video/gem/SDL_gemmouse.c
src/video/gem/SDL_gemmouse.h
src/video/gem/SDL_gemvideo.c
src/video/gem/SDL_gemvideo.h
src/video/gem/SDL_gemwindow.c
src/video/gem/SDL_gemwindow.h
     1.1 --- a/src/video/gem/SDL_gemevents.c	Fri Jul 13 22:52:53 2007 +0000
     1.2 +++ b/src/video/gem/SDL_gemevents.c	Fri Jul 13 22:55:15 2007 +0000
     1.3 @@ -32,10 +32,9 @@
     1.4  
     1.5  #include <gem.h>
     1.6  
     1.7 -#include "../../events/SDL_sysevents.h"
     1.8 +#include "SDL_gemvideo.h"
     1.9 +#include "SDL_gemevents.h"
    1.10  #include "../../events/SDL_events_c.h"
    1.11 -#include "SDL_gemvideo.h"
    1.12 -#include "SDL_gemevents_c.h"
    1.13  #include "../ataricommon/SDL_atarikeys.h"       /* for keyboard scancodes */
    1.14  #include "../ataricommon/SDL_atarievents_c.h"
    1.15  #include "../ataricommon/SDL_xbiosevents_c.h"
    1.16 @@ -55,20 +54,9 @@
    1.17  /* Functions */
    1.18  
    1.19  void
    1.20 -GEM_InitOSKeymap(_THIS)
    1.21 -{
    1.22 -    SDL_memset(gem_currentkeyboard, 0, sizeof(gem_currentkeyboard));
    1.23 -    SDL_memset(gem_previouskeyboard, 0, sizeof(gem_previouskeyboard));
    1.24 -
    1.25 -    /* Mouse init */
    1.26 -    GEM_mouse_relative = SDL_FALSE;
    1.27 -
    1.28 -    SDL_Atari_InitInternalKeymap(this);
    1.29 -}
    1.30 -
    1.31 -void
    1.32  GEM_PumpEvents(_THIS)
    1.33  {
    1.34 +#if 0
    1.35      short mousex, mousey, mouseb, dummy;
    1.36      short kstate, prevkc, prevks;
    1.37      int i;
    1.38 @@ -88,11 +76,8 @@
    1.39          if (!GEM_fullscreen && (GEM_handle >= 0)) {
    1.40              wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
    1.41              event_mask |= MU_M1;
    1.42 -            if ((SDL_GetAppState() & SDL_APPMOUSEFOCUS)) {
    1.43 -                mouse_event = MO_LEAVE;
    1.44 -            } else {
    1.45 -                mouse_event = MO_ENTER;
    1.46 -            }
    1.47 +            mouse_event = ((SDL_GetAppState() & SDL_APPMOUSEFOCUS) ==
    1.48 +                SDL_APPMOUSEFOCUS) ? MO_LEAVE : MO_ENTER;
    1.49          }
    1.50  
    1.51          resultat = evnt_multi(event_mask,
    1.52 @@ -120,12 +105,11 @@
    1.53          /* Mouse entering/leaving window */
    1.54          if (resultat & MU_M1) {
    1.55              if (this->input_grab == SDL_GRAB_OFF) {
    1.56 -                if (SDL_GetAppState() & SDL_APPMOUSEFOCUS) {
    1.57 -                    SDL_PrivateAppActive(0, SDL_APPMOUSEFOCUS);
    1.58 -                } else {
    1.59 -                    SDL_PrivateAppActive(1, SDL_APPMOUSEFOCUS);
    1.60 -                }
    1.61 +                /* Switch mouse focus state */
    1.62 +                SDL_PrivateAppActive((mouse_event == MO_ENTER),
    1.63 +                    SDL_APPMOUSEFOCUS);
    1.64              }
    1.65 +            GEM_CheckMouseMode(this);
    1.66          }
    1.67  
    1.68          /* Timer event ? */
    1.69 @@ -165,15 +149,17 @@
    1.70          }
    1.71          GEM_refresh_name = SDL_FALSE;
    1.72      }
    1.73 +#endif
    1.74  }
    1.75  
    1.76  static int
    1.77  do_messages(_THIS, short *message)
    1.78  {
    1.79 -    int quit, posted;
    1.80 +#if 0
    1.81 +    int quit, posted, check_mouse_mode;
    1.82      short x2, y2, w2, h2;
    1.83  
    1.84 -    quit = 0;
    1.85 +    quit = check_mouse_mode = 0;
    1.86      switch (message[0]) {
    1.87      case WM_CLOSED:
    1.88      case AP_TERM:
    1.89 @@ -192,6 +178,7 @@
    1.90          if (VDI_setpalette) {
    1.91              VDI_setpalette(this, VDI_curpalette);
    1.92          }
    1.93 +        check_mouse_mode = 1;
    1.94          break;
    1.95      case WM_REDRAW:
    1.96          if (!GEM_lock_redraw) {
    1.97 @@ -215,6 +202,7 @@
    1.98                       0, 0);
    1.99              GEM_refresh_name = SDL_FALSE;
   1.100          }
   1.101 +        check_mouse_mode = 1;
   1.102          break;
   1.103      case WM_UNICONIFY:
   1.104          wind_set(message[3], WF_UNICONIFY, message[4], message[5],
   1.105 @@ -231,6 +219,7 @@
   1.106                       0, 0);
   1.107              GEM_refresh_name = SDL_FALSE;
   1.108          }
   1.109 +        check_mouse_mode = 1;
   1.110          break;
   1.111      case WM_SIZED:
   1.112          wind_set(message[3], WF_CURRXYWH, message[4], message[5],
   1.113 @@ -268,15 +257,24 @@
   1.114          if (VDI_setpalette) {
   1.115              VDI_setpalette(this, VDI_oldpalette);
   1.116          }
   1.117 +        check_mouse_mode = 1;
   1.118          break;
   1.119      }
   1.120  
   1.121 +    if (check_mouse_mode) {
   1.122 +        GEM_CheckMouseMode(this);
   1.123 +    }
   1.124 +
   1.125      return quit;
   1.126 +#else
   1.127 +    return 0;
   1.128 +#endif
   1.129  }
   1.130  
   1.131  static void
   1.132  do_keyboard(short kc, short ks)
   1.133  {
   1.134 +#if 0
   1.135      int scancode, asciicode;
   1.136  
   1.137      if (kc) {
   1.138 @@ -293,11 +291,13 @@
   1.139          gem_currentkeyboard[SCANCODE_LEFTCONTROL] = 0xFF;
   1.140      if (ks & K_ALT)
   1.141          gem_currentkeyboard[SCANCODE_LEFTALT] = 0xFF;
   1.142 +#endif
   1.143  }
   1.144  
   1.145  static void
   1.146  do_mouse(_THIS, short mx, short my, short mb, short ks)
   1.147  {
   1.148 +#if 0
   1.149      static short prevmousex = 0, prevmousey = 0, prevmouseb = 0;
   1.150      short x2, y2, w2, h2;
   1.151  
   1.152 @@ -377,6 +377,7 @@
   1.153          gem_currentkeyboard[SCANCODE_LEFTCONTROL] = 0xFF;
   1.154      if (ks & K_ALT)
   1.155          gem_currentkeyboard[SCANCODE_LEFTALT] = 0xFF;
   1.156 +#endif
   1.157  }
   1.158  
   1.159  /* vi: set ts=4 sw=4 expandtab: */
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/video/gem/SDL_gemevents.h	Fri Jul 13 22:55:15 2007 +0000
     2.3 @@ -0,0 +1,31 @@
     2.4 +/*
     2.5 +    SDL - Simple DirectMedia Layer
     2.6 +    Copyright (C) 1997-2006 Sam Lantinga
     2.7 +
     2.8 +    This library is free software; you can redistribute it and/or
     2.9 +    modify it under the terms of the GNU Lesser General Public
    2.10 +    License as published by the Free Software Foundation; either
    2.11 +    version 2.1 of the License, or (at your option) any later version.
    2.12 +
    2.13 +    This library is distributed in the hope that it will be useful,
    2.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    2.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    2.16 +    Lesser General Public License for more details.
    2.17 +
    2.18 +    You should have received a copy of the GNU Lesser General Public
    2.19 +    License along with this library; if not, write to the Free Software
    2.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    2.21 +
    2.22 +    Sam Lantinga
    2.23 +    slouken@libsdl.org
    2.24 +*/
    2.25 +#include "SDL_config.h"
    2.26 +
    2.27 +#ifndef _SDL_gemevents_h
    2.28 +#define _SDL_gemevents_h
    2.29 +
    2.30 +extern void GEM_PumpEvents(_THIS);
    2.31 +
    2.32 +#endif /* _SDL_gemevents_h */
    2.33 +
    2.34 +/* vi: set ts=4 sw=4 expandtab: */
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/gem/SDL_gemkeyboard.c	Fri Jul 13 22:55:15 2007 +0000
     3.3 @@ -0,0 +1,46 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2006 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +#include "SDL_config.h"
    3.26 +
    3.27 +#include "SDL_gemvideo.h"
    3.28 +
    3.29 +#include "../../events/SDL_keyboard_c.h"
    3.30 +
    3.31 +void
    3.32 +GEM_InitKeyboard(_THIS)
    3.33 +{
    3.34 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    3.35 +    SDL_Keyboard keyboard;
    3.36 +
    3.37 +    SDL_zero(keyboard);
    3.38 +    data->keyboard = SDL_AddKeyboard(&keyboard, -1);
    3.39 +}
    3.40 +
    3.41 +void
    3.42 +GEM_QuitKeyboard(_THIS)
    3.43 +{
    3.44 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    3.45 +
    3.46 +    SDL_DelKeyboard(data->keyboard);
    3.47 +}
    3.48 +
    3.49 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/gem/SDL_gemkeyboard.h	Fri Jul 13 22:55:15 2007 +0000
     4.3 @@ -0,0 +1,32 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2006 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Lesser General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2.1 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Lesser General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Lesser General Public
    4.19 +    License along with this library; if not, write to the Free Software
    4.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +#include "SDL_config.h"
    4.26 +
    4.27 +#ifndef _SDL_gemkeyboard_h
    4.28 +#define _SDL_gemkeyboard_h
    4.29 +
    4.30 +extern void GEM_InitKeyboard(_THIS);
    4.31 +extern void GEM_QuitKeyboard(_THIS);
    4.32 +
    4.33 +#endif /* _SDL_gemkeyboard_h */
    4.34 +
    4.35 +/* vi: set ts=4 sw=4 expandtab: */
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/gem/SDL_gemmodes.c	Fri Jul 13 22:55:15 2007 +0000
     5.3 @@ -0,0 +1,79 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997-2006 Sam Lantinga
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Lesser General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2.1 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Lesser General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Lesser General Public
    5.19 +    License along with this library; if not, write to the Free Software
    5.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    5.21 +
    5.22 +    Sam Lantinga
    5.23 +    slouken@libsdl.org
    5.24 +*/
    5.25 +#include "SDL_config.h"
    5.26 +
    5.27 +#include "SDL_gemvideo.h"
    5.28 +
    5.29 +
    5.30 +void
    5.31 +GEM_InitModes(_THIS)
    5.32 +{
    5.33 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    5.34 +    Uint32 Rmask, Gmask, Bmask, Amask;
    5.35 +    SDL_VideoDisplay display;
    5.36 +    SDL_DisplayData *displaydata;
    5.37 +    SDL_DisplayMode mode;
    5.38 +    int bpp;
    5.39 +
    5.40 +    /* read vdi bpp, rmask, gmask, bmask, amask */
    5.41 +
    5.42 +    mode.format =
    5.43 +        SDL_MasksToPixelFormatEnum(bpp, Rmask, Gmask, Bmask, Amask);
    5.44 +    mode.w = 0 /* vdi width */;
    5.45 +    mode.h = 0 /* vdi height */;
    5.46 +    mode.refresh_rate = 0;
    5.47 +    mode.driverdata = NULL;
    5.48 +
    5.49 +    displaydata = (SDL_DisplayData *) SDL_malloc(sizeof(*displaydata));
    5.50 +    if (!displaydata) {
    5.51 +        return;
    5.52 +    }
    5.53 +    /* fill display data */
    5.54 +
    5.55 +    SDL_zero(display);
    5.56 +    display.desktop_mode = mode;
    5.57 +    display.current_mode = mode;
    5.58 +    display.driverdata = displaydata;
    5.59 +    SDL_AddVideoDisplay(&display);
    5.60 +}
    5.61 +
    5.62 +void
    5.63 +GEM_GetDisplayModes(_THIS)
    5.64 +{
    5.65 +    SDL_DisplayData *data = (SDL_DisplayData *) SDL_CurrentDisplay.driverdata;
    5.66 +    SDL_DisplayMode mode;
    5.67 +    //SDL_AddDisplayMode(_this->current_display, &mode);
    5.68 +}
    5.69 +
    5.70 +int
    5.71 +GEM_SetDisplayMode(_THIS, SDL_DisplayMode * mode)
    5.72 +{
    5.73 +    //SDL_DisplayModeData *data = (SDL_DisplayModeData *) mode->driverdata;
    5.74 +    return -1;
    5.75 +}
    5.76 +
    5.77 +void
    5.78 +GEM_QuitModes(_THIS)
    5.79 +{
    5.80 +}
    5.81 +
    5.82 +/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/video/gem/SDL_gemmodes.h	Fri Jul 13 22:55:15 2007 +0000
     6.3 @@ -0,0 +1,41 @@
     6.4 +/*
     6.5 +    SDL - Simple DirectMedia Layer
     6.6 +    Copyright (C) 1997-2006 Sam Lantinga
     6.7 +
     6.8 +    This library is free software; you can redistribute it and/or
     6.9 +    modify it under the terms of the GNU Lesser General Public
    6.10 +    License as published by the Free Software Foundation; either
    6.11 +    version 2.1 of the License, or (at your option) any later version.
    6.12 +
    6.13 +    This library is distributed in the hope that it will be useful,
    6.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 +    Lesser General Public License for more details.
    6.17 +
    6.18 +    You should have received a copy of the GNU Lesser General Public
    6.19 +    License along with this library; if not, write to the Free Software
    6.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 +
    6.22 +    Sam Lantinga
    6.23 +    slouken@libsdl.org
    6.24 +*/
    6.25 +#include "SDL_config.h"
    6.26 +
    6.27 +#ifndef _SDL_gemmodes_h
    6.28 +#define _SDL_gemmodes_h
    6.29 +
    6.30 +typedef struct
    6.31 +{
    6.32 +    int width;
    6.33 +    int height;
    6.34 +    int depth;
    6.35 +} SDL_DisplayData;
    6.36 +
    6.37 +extern void GEM_InitModes(_THIS);
    6.38 +extern void GEM_GetDisplayModes(_THIS);
    6.39 +extern int GEM_SetDisplayMode(_THIS, SDL_DisplayMode * mode);
    6.40 +extern void GEM_QuitModes(_THIS);
    6.41 +
    6.42 +#endif /* _SDL_gemmodes_h */
    6.43 +
    6.44 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/gem/SDL_gemmouse.c	Fri Jul 13 22:52:53 2007 +0000
     7.2 +++ b/src/video/gem/SDL_gemmouse.c	Fri Jul 13 22:55:15 2007 +0000
     7.3 @@ -21,161 +21,26 @@
     7.4  */
     7.5  #include "SDL_config.h"
     7.6  
     7.7 -/*
     7.8 - *	GEM Mouse manager
     7.9 - *
    7.10 - *	Patrice Mandin
    7.11 - */
    7.12 +#include "SDL_gemvideo.h"
    7.13  
    7.14 -#include <gem.h>
    7.15 -
    7.16 -#include "SDL_mouse.h"
    7.17 -#include "../../events/SDL_events_c.h"
    7.18 -#include "../SDL_cursor_c.h"
    7.19 -#include "SDL_gemmouse_c.h"
    7.20 -
    7.21 -/* Defines */
    7.22 -
    7.23 -/*#define DEBUG_VIDEO_GEM 1*/
    7.24 -
    7.25 -#define MAXCURWIDTH 16
    7.26 -#define MAXCURHEIGHT 16
    7.27 -
    7.28 -/* The implementation dependent data for the window manager cursor */
    7.29 -struct WMcursor
    7.30 -{
    7.31 -    MFORM *mform_p;
    7.32 -};
    7.33 -
    7.34 +#include "../../events/SDL_mouse_c.h"
    7.35  
    7.36  void
    7.37 -GEM_FreeWMCursor(_THIS, WMcursor * cursor)
    7.38 +GEM_InitMouse(_THIS)
    7.39  {
    7.40 -    if (cursor == NULL)
    7.41 -        return;
    7.42 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    7.43 +    SDL_Mouse mouse;
    7.44  
    7.45 -    graf_mouse(ARROW, NULL);
    7.46 -
    7.47 -    if (cursor->mform_p != NULL)
    7.48 -        SDL_free(cursor->mform_p);
    7.49 -
    7.50 -    SDL_free(cursor);
    7.51 +    SDL_zero(mouse);
    7.52 +    data->mouse = SDL_AddMouse(&mouse, -1);
    7.53  }
    7.54  
    7.55 -WMcursor *
    7.56 -GEM_CreateWMCursor(_THIS,
    7.57 -                   Uint8 * data, Uint8 * mask, int w, int h, int hot_x,
    7.58 -                   int hot_y)
    7.59 +void
    7.60 +GEM_QuitMouse(_THIS)
    7.61  {
    7.62 -    WMcursor *cursor;
    7.63 -    MFORM *new_mform;
    7.64 -    int i;
    7.65 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
    7.66  
    7.67 -    /* Check the size */
    7.68 -    if ((w > MAXCURWIDTH) || (h > MAXCURHEIGHT)) {
    7.69 -        SDL_SetError("Only cursors of dimension (%dx%d) are allowed",
    7.70 -                     MAXCURWIDTH, MAXCURHEIGHT);
    7.71 -        return (NULL);
    7.72 -    }
    7.73 -
    7.74 -    /* Allocate the cursor memory */
    7.75 -    cursor = (WMcursor *) SDL_malloc(sizeof(WMcursor));
    7.76 -    if (cursor == NULL) {
    7.77 -        SDL_OutOfMemory();
    7.78 -        return (NULL);
    7.79 -    }
    7.80 -
    7.81 -    /* Allocate mform */
    7.82 -    new_mform = (MFORM *) SDL_malloc(sizeof(MFORM));
    7.83 -    if (new_mform == NULL) {
    7.84 -        SDL_free(cursor);
    7.85 -        SDL_OutOfMemory();
    7.86 -        return (NULL);
    7.87 -    }
    7.88 -
    7.89 -    cursor->mform_p = new_mform;
    7.90 -
    7.91 -    new_mform->mf_xhot = hot_x;
    7.92 -    new_mform->mf_yhot = hot_y;
    7.93 -    new_mform->mf_nplanes = 1;
    7.94 -    new_mform->mf_fg = 0;
    7.95 -    new_mform->mf_bg = 1;
    7.96 -
    7.97 -    for (i = 0; i < MAXCURHEIGHT; i++) {
    7.98 -        new_mform->mf_mask[i] = 0;
    7.99 -        new_mform->mf_data[i] = 0;
   7.100 -    }
   7.101 -
   7.102 -    if (w <= 8) {
   7.103 -        for (i = 0; i < h; i++) {
   7.104 -            new_mform->mf_mask[i] = mask[i] << 8;
   7.105 -            new_mform->mf_data[i] = data[i] << 8;
   7.106 -        }
   7.107 -    } else {
   7.108 -        for (i = 0; i < h; i++) {
   7.109 -            new_mform->mf_mask[i] = mask[i << 1] << 8 | mask[(i << 1) + 1];
   7.110 -            new_mform->mf_data[i] = data[i << 1] << 8 | data[(i << 1) + 1];
   7.111 -        }
   7.112 -    }
   7.113 -
   7.114 -#ifdef DEBUG_VIDEO_GEM
   7.115 -    for (i = 0; i < h; i++) {
   7.116 -        printf("sdl:video:gem: cursor, line %d = 0x%04x\n", i,
   7.117 -               new_mform->mf_mask[i]);
   7.118 -    }
   7.119 -
   7.120 -    printf("sdl:video:gem: CreateWMCursor(): done\n");
   7.121 -#endif
   7.122 -
   7.123 -    return cursor;
   7.124 -}
   7.125 -
   7.126 -int
   7.127 -GEM_ShowWMCursor(_THIS, WMcursor * cursor)
   7.128 -{
   7.129 -/*
   7.130 -	if (cursor == NULL) {
   7.131 -		graf_mouse(M_OFF, NULL);
   7.132 -	} else if (cursor->mform_p) {
   7.133 -		graf_mouse(USER_DEF, cursor->mform_p);
   7.134 -	}
   7.135 -*/
   7.136 -#ifdef DEBUG_VIDEO_GEM
   7.137 -    printf("sdl:video:gem: ShowWMCursor(0x%08x)\n", (long) cursor);
   7.138 -#endif
   7.139 -
   7.140 -    return 1;
   7.141 -}
   7.142 -
   7.143 -#if 0
   7.144 -void
   7.145 -GEM_WarpWMCursor(_THIS, Uint16 x, Uint16 y)
   7.146 -{
   7.147 -    /* This seems to work only on AES 3.4 (Falcon) */
   7.148 -
   7.149 -    EVNTREC warpevent;
   7.150 -
   7.151 -    warpevent.ap_event = APPEVNT_MOUSE;
   7.152 -    warpevent.ap_value = (x << 16) | y;
   7.153 -
   7.154 -    appl_tplay(&warpevent, 1, 1000);
   7.155 -}
   7.156 -#endif
   7.157 -
   7.158 -void
   7.159 -GEM_CheckMouseMode(_THIS)
   7.160 -{
   7.161 -    /* If the mouse is hidden and input is grabbed, we use relative mode */
   7.162 -    if ((!(SDL_cursorstate & CURSOR_VISIBLE)) &&
   7.163 -        (this->input_grab != SDL_GRAB_OFF) &&
   7.164 -        (SDL_GetAppState() & SDL_APPACTIVE)) {
   7.165 -        SDL_AtariXbios_LockMousePosition(SDL_TRUE);
   7.166 -        GEM_mouse_relative = SDL_TRUE;
   7.167 -    } else {
   7.168 -        SDL_AtariXbios_LockMousePosition(SDL_FALSE);
   7.169 -        GEM_mouse_relative = SDL_FALSE;
   7.170 -        graf_mouse(M_ON, NULL);
   7.171 -    }
   7.172 +    SDL_DelMouse(data->mouse);
   7.173  }
   7.174  
   7.175  /* vi: set ts=4 sw=4 expandtab: */
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/src/video/gem/SDL_gemmouse.h	Fri Jul 13 22:55:15 2007 +0000
     8.3 @@ -0,0 +1,32 @@
     8.4 +/*
     8.5 +    SDL - Simple DirectMedia Layer
     8.6 +    Copyright (C) 1997-2006 Sam Lantinga
     8.7 +
     8.8 +    This library is free software; you can redistribute it and/or
     8.9 +    modify it under the terms of the GNU Lesser General Public
    8.10 +    License as published by the Free Software Foundation; either
    8.11 +    version 2.1 of the License, or (at your option) any later version.
    8.12 +
    8.13 +    This library is distributed in the hope that it will be useful,
    8.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    8.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    8.16 +    Lesser General Public License for more details.
    8.17 +
    8.18 +    You should have received a copy of the GNU Lesser General Public
    8.19 +    License along with this library; if not, write to the Free Software
    8.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    8.21 +
    8.22 +    Sam Lantinga
    8.23 +    slouken@libsdl.org
    8.24 +*/
    8.25 +#include "SDL_config.h"
    8.26 +
    8.27 +#ifndef _SDL_gemmouse_h
    8.28 +#define _SDL_gemmouse_h
    8.29 +
    8.30 +extern void GEM_InitMouse(_THIS);
    8.31 +extern void GEM_QuitMouse(_THIS);
    8.32 +
    8.33 +#endif /* _SDL_gemmouse_h */
    8.34 +
    8.35 +/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/video/gem/SDL_gemvideo.c	Fri Jul 13 22:52:53 2007 +0000
     9.2 +++ b/src/video/gem/SDL_gemvideo.c	Fri Jul 13 22:55:15 2007 +0000
     9.3 @@ -35,82 +35,19 @@
     9.4  #include <mint/osbind.h>
     9.5  #include <mint/cookie.h>
     9.6  
     9.7 -#include "SDL_endian.h"
     9.8  #include "SDL_video.h"
     9.9  #include "SDL_mouse.h"
    9.10  #include "../SDL_sysvideo.h"
    9.11  #include "../SDL_pixels_c.h"
    9.12 -#include "../../events/SDL_events_c.h"
    9.13 -#include "../SDL_cursor_c.h"
    9.14 -
    9.15 -#include "../ataricommon/SDL_ataric2p_s.h"
    9.16 -#include "../ataricommon/SDL_atarieddi_s.h"
    9.17 -#include "../ataricommon/SDL_atarimxalloc_c.h"
    9.18 -#include "../ataricommon/SDL_atarigl_c.h"
    9.19  
    9.20  #include "SDL_gemvideo.h"
    9.21 -#include "SDL_gemevents_c.h"
    9.22 -#include "SDL_gemmouse_c.h"
    9.23 -#include "SDL_gemwm_c.h"
    9.24 -#include "../ataricommon/SDL_xbiosevents_c.h"
    9.25 -#include "../ataricommon/SDL_ataridevmouse_c.h"
    9.26 -
    9.27 -/* Defines */
    9.28 -
    9.29 -/*#define DEBUG_VIDEO_GEM	1*/
    9.30 -
    9.31 -#define GEM_VID_DRIVER_NAME "gem"
    9.32 -
    9.33 -#undef MIN
    9.34 -#define MIN(a,b) (((a)<(b)) ? (a) : (b))
    9.35 -#undef MAX
    9.36 -#define MAX(a,b) (((a)>(b)) ? (a) : (b))
    9.37 -
    9.38 -/* Variables */
    9.39 -
    9.40 -static unsigned char vdi_index[256] = {
    9.41 -    0, 2, 3, 6, 4, 7, 5, 8,
    9.42 -    9, 10, 11, 14, 12, 15, 13, 255
    9.43 -};
    9.44 -
    9.45 -static const unsigned char empty_name[] = "";
    9.46  
    9.47  /* Initialization/Query functions */
    9.48 -static int GEM_VideoInit(_THIS, SDL_PixelFormat * vformat);
    9.49 -static SDL_Rect **GEM_ListModes(_THIS, SDL_PixelFormat * format,
    9.50 -                                Uint32 flags);
    9.51 -static SDL_Surface *GEM_SetVideoMode(_THIS, SDL_Surface * current, int width,
    9.52 -                                     int height, int bpp, Uint32 flags);
    9.53 -static int GEM_SetColors(_THIS, int firstcolor, int ncolors,
    9.54 -                         SDL_Color * colors);
    9.55 +static int GEM_VideoInit(_THIS);
    9.56  static void GEM_VideoQuit(_THIS);
    9.57  
    9.58 -/* Hardware surface functions */
    9.59 -static int GEM_AllocHWSurface(_THIS, SDL_Surface * surface);
    9.60 -static int GEM_LockHWSurface(_THIS, SDL_Surface * surface);
    9.61 -static int GEM_FlipHWSurface(_THIS, SDL_Surface * surface);
    9.62 -static void GEM_UnlockHWSurface(_THIS, SDL_Surface * surface);
    9.63 -static void GEM_FreeHWSurface(_THIS, SDL_Surface * surface);
    9.64 -static void GEM_UpdateRects(_THIS, int numrects, SDL_Rect * rects);
    9.65 -#if 0
    9.66 -static int GEM_ToggleFullScreen(_THIS, int on);
    9.67 -#endif
    9.68 +static void GEM_GL_SwapBuffers(_THIS);
    9.69  
    9.70 -/* Internal functions */
    9.71 -static void GEM_FreeBuffers(_THIS);
    9.72 -static void GEM_ClearScreen(_THIS);
    9.73 -static void GEM_ClearRect(_THIS, short *rect);
    9.74 -static void GEM_SetNewPalette(_THIS, Uint16 newpal[256][3]);
    9.75 -static void GEM_LockScreen(_THIS);
    9.76 -static void GEM_UnlockScreen(_THIS);
    9.77 -static void refresh_window(_THIS, int winhandle, short *rect);
    9.78 -
    9.79 -#if SDL_VIDEO_OPENGL
    9.80 -/* OpenGL functions */
    9.81 -static void GEM_GL_SwapBuffers(_THIS);
    9.82 -#endif
    9.83 -
    9.84 -/* GEM driver bootstrap functions */
    9.85  
    9.86  static int
    9.87  GEM_Available(void)
    9.88 @@ -126,7 +63,9 @@
    9.89  static void
    9.90  GEM_DeleteDevice(SDL_VideoDevice * device)
    9.91  {
    9.92 -    SDL_free(device->hidden);
    9.93 +    SDL_VideoData *data = (SDL_VideoData *) device->driverdata;
    9.94 +
    9.95 +    SDL_free(device->driverdata);
    9.96      SDL_free(device);
    9.97  }
    9.98  
    9.99 @@ -134,186 +73,71 @@
   9.100  GEM_CreateDevice(int devindex)
   9.101  {
   9.102      SDL_VideoDevice *device;
   9.103 -    int vectors_mask;
   9.104 -    unsigned long dummy;
   9.105 +    SDL_VideoData *data;
   9.106  
   9.107      /* Initialize all variables that we clean on shutdown */
   9.108 -    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
   9.109 +    device = (SDL_VideoDevice *) SDL_calloc(1, sizeof(SDL_VideoDevice));
   9.110      if (device) {
   9.111 -        SDL_memset(device, 0, (sizeof *device));
   9.112 -        device->hidden = (struct SDL_PrivateVideoData *)
   9.113 -            SDL_malloc((sizeof *device->hidden));
   9.114 -        device->gl_data = (struct SDL_PrivateGLData *)
   9.115 -            SDL_malloc((sizeof *device->gl_data));
   9.116 +        data = (SDL_VideoData *) SDL_calloc(1, sizeof(SDL_VideoData));
   9.117      }
   9.118 -    if ((device == NULL) || (device->hidden == NULL)) {
   9.119 +    if (!device || !data) {
   9.120          SDL_OutOfMemory();
   9.121          if (device) {
   9.122              SDL_free(device);
   9.123          }
   9.124 -        return (0);
   9.125 +        return NULL;
   9.126      }
   9.127 -    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
   9.128 -    SDL_memset(device->gl_data, 0, sizeof(*device->gl_data));
   9.129 +    device->driverdata = data;
   9.130  
   9.131      /* Set the function pointers */
   9.132      device->VideoInit = GEM_VideoInit;
   9.133 -    device->ListModes = GEM_ListModes;
   9.134 -    device->SetVideoMode = GEM_SetVideoMode;
   9.135 -    device->SetColors = GEM_SetColors;
   9.136 -    device->UpdateRects = NULL /*GEM_UpdateRects */ ;
   9.137      device->VideoQuit = GEM_VideoQuit;
   9.138 -    device->AllocHWSurface = GEM_AllocHWSurface;
   9.139 -    device->LockHWSurface = GEM_LockHWSurface;
   9.140 -    device->UnlockHWSurface = GEM_UnlockHWSurface;
   9.141 -    device->FlipHWSurface = GEM_FlipHWSurface;
   9.142 -    device->FreeHWSurface = GEM_FreeHWSurface;
   9.143 -    device->ToggleFullScreen = NULL /*GEM_ToggleFullScreen */ ;
   9.144 -
   9.145 -    /* Window manager */
   9.146 -    device->SetCaption = GEM_SetCaption;
   9.147 -    device->SetIcon = GEM_SetIcon;
   9.148 -    device->IconifyWindow = GEM_IconifyWindow;
   9.149 -    device->GrabInput = GEM_GrabInput;
   9.150 -
   9.151 -    /* Events */
   9.152 -    device->InitOSKeymap = GEM_InitOSKeymap;
   9.153 +    device->GetDisplayModes = GEM_GetDisplayModes;
   9.154 +    device->SetDisplayMode = GEM_SetDisplayMode;
   9.155      device->PumpEvents = GEM_PumpEvents;
   9.156  
   9.157 -    /* Mouse */
   9.158 -    device->FreeWMCursor = GEM_FreeWMCursor;
   9.159 -    device->CreateWMCursor = GEM_CreateWMCursor;
   9.160 -    device->ShowWMCursor = GEM_ShowWMCursor;
   9.161 -    device->WarpWMCursor = NULL /*GEM_WarpWMCursor */ ;
   9.162 -    device->CheckMouseMode = GEM_CheckMouseMode;
   9.163 +    device->CreateWindow = GEM_CreateWindow;
   9.164 +    device->CreateWindowFrom = GEM_CreateWindowFrom;
   9.165 +    device->SetWindowTitle = GEM_SetWindowTitle;
   9.166 +    device->SetWindowPosition = GEM_SetWindowPosition;
   9.167 +    device->SetWindowSize = GEM_SetWindowSize;
   9.168 +    device->ShowWindow = GEM_ShowWindow;
   9.169 +    device->HideWindow = GEM_HideWindow;
   9.170 +    device->RaiseWindow = GEM_RaiseWindow;
   9.171 +    device->MaximizeWindow = GEM_MaximizeWindow;
   9.172 +    device->MinimizeWindow = GEM_MinimizeWindow;
   9.173 +    device->RestoreWindow = GEM_RestoreWindow;
   9.174 +    device->SetWindowGrab = GEM_SetWindowGrab;
   9.175 +    device->DestroyWindow = GEM_DestroyWindow;
   9.176 +    device->GetWindowWMInfo = GEM_GetWindowWMInfo;
   9.177  
   9.178  #if SDL_VIDEO_OPENGL
   9.179 -    /* OpenGL functions */
   9.180      device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
   9.181      device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
   9.182 -    device->GL_GetAttribute = SDL_AtariGL_GetAttribute;
   9.183 +    device->GL_CreateContext = SDL_AtariGL_CreateContext;
   9.184      device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
   9.185 -    device->GL_SwapBuffers = GEM_GL_SwapBuffers;
   9.186 +    device->GL_SetSwapInterval = SDL_AtariGL_SetSwapInterval;
   9.187 +    device->GL_GetSwapInterval = SDL_AtariGL_GetSwapInterval;
   9.188 +    device->GL_SwapWindow = GEM_GL_SwapWindow;
   9.189 +    device->GL_DeleteContext = SDL_AtariGL_DeleteContext;
   9.190  #endif
   9.191  
   9.192 -    device->hidden->use_dev_mouse =
   9.193 -        (SDL_AtariDevMouse_Open() != 0) ? SDL_TRUE : SDL_FALSE;
   9.194 -
   9.195 -    vectors_mask = ATARI_XBIOS_JOYSTICKEVENTS;  /* XBIOS joystick events */
   9.196 -    if (!(device->hidden->use_dev_mouse)) {
   9.197 -        vectors_mask |= ATARI_XBIOS_MOUSEEVENTS;        /* XBIOS mouse events */
   9.198 -    }
   9.199 -    /*if (Getcookie(C_MiNT, &dummy) == C_FOUND) {
   9.200 -       vectors_mask = 0;
   9.201 -       } */
   9.202 -
   9.203 -    SDL_AtariXbios_InstallVectors(vectors_mask);
   9.204 -
   9.205      device->free = GEM_DeleteDevice;
   9.206  
   9.207      return device;
   9.208  }
   9.209  
   9.210  VideoBootStrap GEM_bootstrap = {
   9.211 -    GEM_VID_DRIVER_NAME, "Atari GEM video driver",
   9.212 +    "gem", "Atari GEM video driver",
   9.213      GEM_Available, GEM_CreateDevice
   9.214  };
   9.215  
   9.216 -static void
   9.217 -VDI_ReadExtInfo(_THIS, short *work_out)
   9.218 +int
   9.219 +GEM_VideoInit(_THIS)
   9.220  {
   9.221 -    unsigned long EdDI_version;
   9.222 -    unsigned long cookie_EdDI;
   9.223 -    Uint32 num_colours;
   9.224 -    Uint16 clut_type, num_bits;
   9.225 -
   9.226 -    /* Read EdDI informations */
   9.227 -    if (Getcookie(C_EdDI, &cookie_EdDI) == C_NOTFOUND) {
   9.228 -        return;
   9.229 -    }
   9.230 -
   9.231 -    EdDI_version = Atari_get_EdDI_version((void *) cookie_EdDI);
   9.232 -
   9.233 -    vq_scrninfo(VDI_handle, work_out);
   9.234 -
   9.235 -    VDI_format = work_out[0];
   9.236 -    clut_type = work_out[1];
   9.237 -    num_bits = work_out[2];
   9.238 -    num_colours = *((Uint32 *) & work_out[3]);
   9.239 -
   9.240 -    /* With EdDI>=1.1, we can have screen pitch, address and format
   9.241 -     * so we can directly write to screen without using vro_cpyfm
   9.242 -     */
   9.243 -    if (EdDI_version >= EDDI_11) {
   9.244 -        VDI_pitch = work_out[5];
   9.245 -        VDI_screen = (void *) *((unsigned long *) &work_out[6]);
   9.246 -    }
   9.247 -
   9.248 -    switch (clut_type) {
   9.249 -    case VDI_CLUT_HARDWARE:
   9.250 -        {
   9.251 -            int i;
   9.252 -            Uint16 *tmp_p;
   9.253 -
   9.254 -            tmp_p = (Uint16 *) & work_out[16];
   9.255 -
   9.256 -            for (i = 0; i < 256; i++) {
   9.257 -                vdi_index[*tmp_p++] = i;
   9.258 -            }
   9.259 -        }
   9.260 -        break;
   9.261 -    case VDI_CLUT_SOFTWARE:
   9.262 -        {
   9.263 -            int component;      /* red, green, blue, alpha, overlay */
   9.264 -            int num_bit;
   9.265 -            unsigned short *tmp_p;
   9.266 -
   9.267 -            /* We can build masks with info here */
   9.268 -            tmp_p = (unsigned short *) &work_out[16];
   9.269 -            for (component = 0; component < 5; component++) {
   9.270 -                for (num_bit = 0; num_bit < 16; num_bit++) {
   9.271 -                    unsigned short valeur;
   9.272 -
   9.273 -                    valeur = *tmp_p++;
   9.274 -
   9.275 -                    if (valeur == 0xffff) {
   9.276 -                        continue;
   9.277 -                    }
   9.278 -
   9.279 -                    switch (component) {
   9.280 -                    case 0:
   9.281 -                        VDI_redmask |= 1 << valeur;
   9.282 -                        break;
   9.283 -                    case 1:
   9.284 -                        VDI_greenmask |= 1 << valeur;
   9.285 -                        break;
   9.286 -                    case 2:
   9.287 -                        VDI_bluemask |= 1 << valeur;
   9.288 -                        break;
   9.289 -                    case 3:
   9.290 -                        VDI_alphamask |= 1 << valeur;
   9.291 -                        break;
   9.292 -                    }
   9.293 -                }
   9.294 -            }
   9.295 -        }
   9.296 -
   9.297 -        /* Remove lower green bits for Intel endian screen */
   9.298 -        if ((VDI_greenmask == ((7 << 13) | 3))
   9.299 -            || (VDI_greenmask == ((7 << 13) | 7))) {
   9.300 -            VDI_greenmask &= ~(7 << 13);
   9.301 -        }
   9.302 -        break;
   9.303 -    case VDI_CLUT_NONE:
   9.304 -        break;
   9.305 -    }
   9.306 -}
   9.307 -
   9.308 -int
   9.309 -GEM_VideoInit(_THIS, SDL_PixelFormat * vformat)
   9.310 -{
   9.311 -    int i, menubar_size;
   9.312 +    int i;
   9.313      short work_in[12], work_out[272], dummy;
   9.314 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
   9.315  
   9.316      /* Open AES (Application Environment Services) */
   9.317      if (appl_init() == -1) {
   9.318 @@ -322,26 +146,18 @@
   9.319      }
   9.320  
   9.321      /* Read version and features */
   9.322 -    GEM_version = aes_global[0];
   9.323 -    if (GEM_version >= 0x0410) {
   9.324 -        short ap_gout[4], errorcode;
   9.325 +    if (aes_global[0] >= 0x0410) {
   9.326 +        short ap_gout[4];
   9.327  
   9.328 -        GEM_wfeatures = 0;
   9.329 -        errorcode =
   9.330 -            appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2],
   9.331 -                         &ap_gout[3]);
   9.332 -
   9.333 -        if (errorcode == 0) {
   9.334 -            GEM_wfeatures = ap_gout[0];
   9.335 +        data->wfeatures = 0;
   9.336 +        if (appl_getinfo(AES_WINDOW, &ap_gout[0], &ap_gout[1], &ap_gout[2],
   9.337 +	    &ap_gout[3]) == 0) {
   9.338 +            data->wfeatures = ap_gout[0];
   9.339          }
   9.340      }
   9.341  
   9.342      /* Ask VDI physical workstation handle opened by AES */
   9.343 -    VDI_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
   9.344 -    if (VDI_handle < 1) {
   9.345 -        fprintf(stderr, "Wrong VDI handle %d returned by AES\n", VDI_handle);
   9.346 -        return 1;
   9.347 -    }
   9.348 +    data->vdi_handle = graf_handle(&dummy, &dummy, &dummy, &dummy);
   9.349  
   9.350      /* Open virtual VDI workstation */
   9.351      work_in[0] = Getrez() + 2;
   9.352 @@ -349,1030 +165,44 @@
   9.353          work_in[i] = 1;
   9.354      work_in[10] = 2;
   9.355  
   9.356 -    v_opnvwk(work_in, &VDI_handle, work_out);
   9.357 -    if (VDI_handle == 0) {
   9.358 +    v_opnvwk(work_in, &(data->vdi_handle), work_out);
   9.359 +    if (data->vdi_handle == 0) {
   9.360          fprintf(stderr, "Can not open VDI virtual workstation\n");
   9.361          return 1;
   9.362      }
   9.363  
   9.364 -    /* Read fullscreen size */
   9.365 -    VDI_w = work_out[0] + 1;
   9.366 -    VDI_h = work_out[1] + 1;
   9.367 -
   9.368 -    /* Read desktop size and position */
   9.369 -    if (!wind_get
   9.370 -        (DESKTOP_HANDLE, WF_WORKXYWH, &GEM_desk_x, &GEM_desk_y, &GEM_desk_w,
   9.371 -         &GEM_desk_h)) {
   9.372 -        fprintf(stderr, "Can not read desktop properties\n");
   9.373 -        return 1;
   9.374 -    }
   9.375 -
   9.376 -    /* Read bit depth */
   9.377 -    vq_extnd(VDI_handle, 1, work_out);
   9.378 -    VDI_bpp = work_out[4];
   9.379 -    VDI_oldnumcolors = 0;
   9.380 -
   9.381 -    switch (VDI_bpp) {
   9.382 -    case 8:
   9.383 -        VDI_pixelsize = 1;
   9.384 -        break;
   9.385 -    case 15:
   9.386 -    case 16:
   9.387 -        VDI_pixelsize = 2;
   9.388 -        break;
   9.389 -    case 24:
   9.390 -        VDI_pixelsize = 3;
   9.391 -        break;
   9.392 -    case 32:
   9.393 -        VDI_pixelsize = 4;
   9.394 -        break;
   9.395 -    default:
   9.396 -        fprintf(stderr, "%d bits colour depth not supported\n", VDI_bpp);
   9.397 -        return 1;
   9.398 -    }
   9.399 -
   9.400 -    /* Setup hardware -> VDI palette mapping */
   9.401 -    for (i = 16; i < 255; i++) {
   9.402 -        vdi_index[i] = i;
   9.403 -    }
   9.404 -    vdi_index[255] = 1;
   9.405 -
   9.406 -    /* Save current palette */
   9.407 -    if (VDI_bpp > 8) {
   9.408 -        VDI_oldnumcolors = 1 << 8;
   9.409 -    } else {
   9.410 -        VDI_oldnumcolors = 1 << VDI_bpp;
   9.411 -    }
   9.412 -
   9.413 -    for (i = 0; i < VDI_oldnumcolors; i++) {
   9.414 -        short rgb[3];
   9.415 -
   9.416 -        vq_color(VDI_handle, i, 0, rgb);
   9.417 -
   9.418 -        VDI_oldpalette[i][0] = rgb[0];
   9.419 -        VDI_oldpalette[i][1] = rgb[1];
   9.420 -        VDI_oldpalette[i][2] = rgb[2];
   9.421 -    }
   9.422 -    VDI_setpalette = GEM_SetNewPalette;
   9.423 -    SDL_memcpy(VDI_curpalette, VDI_oldpalette, sizeof(VDI_curpalette));
   9.424 -
   9.425 -    /* Setup screen info */
   9.426 -    GEM_title_name = empty_name;
   9.427 -    GEM_icon_name = empty_name;
   9.428 -
   9.429 -    GEM_handle = -1;
   9.430 -    GEM_locked = SDL_FALSE;
   9.431 -    GEM_win_fulled = SDL_FALSE;
   9.432 -    GEM_fullscreen = SDL_FALSE;
   9.433 -    GEM_lock_redraw = SDL_TRUE; /* Prevent redraw till buffers are setup */
   9.434 -
   9.435 -    VDI_screen = NULL;
   9.436 -    VDI_pitch = VDI_w * VDI_pixelsize;
   9.437 -    VDI_format = ((VDI_bpp <= 8) ? VDI_FORMAT_INTER : VDI_FORMAT_PACK);
   9.438 -    VDI_redmask = VDI_greenmask = VDI_bluemask = VDI_alphamask = 0;
   9.439 -    VDI_ReadExtInfo(this, work_out);
   9.440 -
   9.441 -#ifdef DEBUG_VIDEO_GEM
   9.442 -    printf("sdl:video:gem: screen: address=0x%08x, pitch=%d\n", VDI_screen,
   9.443 -           VDI_pitch);
   9.444 -    printf("sdl:video:gem: format=%d\n", VDI_format);
   9.445 -    printf("sdl:video:gem: masks: 0x%08x, 0x%08x, 0x%08x, 0x%08x\n",
   9.446 -           VDI_alphamask, VDI_redmask, VDI_greenmask, VDI_bluemask);
   9.447 -#endif
   9.448 -
   9.449 -    /* Setup destination mfdb */
   9.450 -    VDI_dst_mfdb.fd_addr = NULL;
   9.451 -
   9.452 -    /* Determine the current screen size */
   9.453 -    this->info.current_w = VDI_w;
   9.454 -    this->info.current_h = VDI_h;
   9.455 -
   9.456 -    /* Determine the screen depth */
   9.457 -    /* we change this during the SDL_SetVideoMode implementation... */
   9.458 -    vformat->BitsPerPixel = VDI_bpp;
   9.459 -
   9.460      /* Set mouse cursor to arrow */
   9.461      graf_mouse(ARROW, NULL);
   9.462  
   9.463 -    /* Init chunky to planar routine */
   9.464 -    SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
   9.465 +    /* Setup VDI fill functions */
   9.466 +    vsf_color(data->vdi_handle, 0);
   9.467 +    vsf_interior(data->vdi_handle, 1);
   9.468 +    vsf_perimeter(data->vdi_handle, 0);
   9.469  
   9.470 -    /* Setup VDI fill functions */
   9.471 -    vsf_color(VDI_handle, 0);
   9.472 -    vsf_interior(VDI_handle, 1);
   9.473 -    vsf_perimeter(VDI_handle, 0);
   9.474 +    GEM_InitModes(_this);
   9.475  
   9.476 -    /* Menu bar save buffer */
   9.477 -    menubar_size = GEM_desk_w * GEM_desk_y * VDI_pixelsize;
   9.478 -    GEM_menubar = Atari_SysMalloc(menubar_size, MX_PREFTTRAM);
   9.479 -
   9.480 -    /* Fill video modes list */
   9.481 -    SDL_modelist[0] = SDL_malloc(sizeof(SDL_Rect));
   9.482 -    SDL_modelist[0]->x = 0;
   9.483 -    SDL_modelist[0]->y = 0;
   9.484 -    SDL_modelist[0]->w = VDI_w;
   9.485 -    SDL_modelist[0]->h = VDI_h;
   9.486 -
   9.487 -    SDL_modelist[1] = NULL;
   9.488 -
   9.489 -#if SDL_VIDEO_OPENGL
   9.490 -    SDL_AtariGL_InitPointers(this);
   9.491 -#endif
   9.492 -
   9.493 -    this->info.wm_available = 1;
   9.494 -
   9.495 -    /* We're done! */
   9.496 -    return (0);
   9.497 -}
   9.498 -
   9.499 -SDL_Rect **
   9.500 -GEM_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   9.501 -{
   9.502 -    if (format->BitsPerPixel != VDI_bpp) {
   9.503 -        return ((SDL_Rect **) NULL);
   9.504 -    }
   9.505 -
   9.506 -    if (flags & SDL_FULLSCREEN) {
   9.507 -        return (SDL_modelist);
   9.508 -    }
   9.509 -
   9.510 -    return ((SDL_Rect **) - 1);
   9.511 -}
   9.512 -
   9.513 -static void
   9.514 -GEM_FreeBuffers(_THIS)
   9.515 -{
   9.516 -    /* Release buffer */
   9.517 -    if (GEM_buffer2) {
   9.518 -        Mfree(GEM_buffer2);
   9.519 -        GEM_buffer2 = NULL;
   9.520 -    }
   9.521 -
   9.522 -    if (GEM_buffer1) {
   9.523 -        Mfree(GEM_buffer1);
   9.524 -        GEM_buffer1 = NULL;
   9.525 -    }
   9.526 -}
   9.527 -
   9.528 -static void
   9.529 -GEM_ClearRect(_THIS, short *rect)
   9.530 -{
   9.531 -    short oldrgb[3], rgb[3] = { 0, 0, 0 };
   9.532 -
   9.533 -    vq_color(VDI_handle, vdi_index[0], 0, oldrgb);
   9.534 -    vs_color(VDI_handle, vdi_index[0], rgb);
   9.535 -
   9.536 -    vsf_color(VDI_handle, 0);
   9.537 -    vsf_interior(VDI_handle, 1);
   9.538 -    vsf_perimeter(VDI_handle, 0);
   9.539 -    v_bar(VDI_handle, rect);
   9.540 -
   9.541 -    vs_color(VDI_handle, vdi_index[0], oldrgb);
   9.542 -}
   9.543 -
   9.544 -static void
   9.545 -GEM_ClearScreen(_THIS)
   9.546 -{
   9.547 -    short pxy[4];
   9.548 -
   9.549 -    v_hide_c(VDI_handle);
   9.550 -
   9.551 -    pxy[0] = pxy[1] = 0;
   9.552 -    pxy[2] = VDI_w - 1;
   9.553 -    pxy[3] = VDI_h - 1;
   9.554 -    GEM_ClearRect(this, pxy);
   9.555 -
   9.556 -    v_show_c(VDI_handle, 1);
   9.557 -}
   9.558 -
   9.559 -static void
   9.560 -GEM_SetNewPalette(_THIS, Uint16 newpal[256][3])
   9.561 -{
   9.562 -    int i;
   9.563 -    short rgb[3];
   9.564 -
   9.565 -    if (VDI_oldnumcolors == 0)
   9.566 -        return;
   9.567 -
   9.568 -    for (i = 0; i < VDI_oldnumcolors; i++) {
   9.569 -        rgb[0] = newpal[i][0];
   9.570 -        rgb[1] = newpal[i][1];
   9.571 -        rgb[2] = newpal[i][2];
   9.572 -
   9.573 -        vs_color(VDI_handle, i, rgb);
   9.574 -    }
   9.575 -}
   9.576 -
   9.577 -static void
   9.578 -GEM_LockScreen(_THIS)
   9.579 -{
   9.580 -    if (!GEM_locked) {
   9.581 -        /* Lock AES */
   9.582 -        wind_update(BEG_UPDATE);
   9.583 -        wind_update(BEG_MCTRL);
   9.584 -        /* Reserve memory space, used to be sure of compatibility */
   9.585 -        form_dial(FMD_START, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h);
   9.586 -
   9.587 -        /* Save menu bar */
   9.588 -        if (GEM_menubar) {
   9.589 -            MFDB mfdb_src;
   9.590 -            short blitcoords[8];
   9.591 -
   9.592 -            mfdb_src.fd_addr = GEM_menubar;
   9.593 -            mfdb_src.fd_w = GEM_desk_w;
   9.594 -            mfdb_src.fd_h = GEM_desk_y;
   9.595 -            mfdb_src.fd_wdwidth = GEM_desk_w >> 4;
   9.596 -            mfdb_src.fd_nplanes = VDI_bpp;
   9.597 -            mfdb_src.fd_stand =
   9.598 -                mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0;
   9.599 -
   9.600 -            blitcoords[0] = blitcoords[4] = 0;
   9.601 -            blitcoords[1] = blitcoords[5] = 0;
   9.602 -            blitcoords[2] = blitcoords[6] = GEM_desk_w - 1;
   9.603 -            blitcoords[3] = blitcoords[7] = GEM_desk_y - 1;
   9.604 -
   9.605 -            vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &VDI_dst_mfdb,
   9.606 -                      &mfdb_src);
   9.607 -        }
   9.608 -
   9.609 -        GEM_locked = SDL_TRUE;
   9.610 -    }
   9.611 -}
   9.612 -
   9.613 -static void
   9.614 -GEM_UnlockScreen(_THIS)
   9.615 -{
   9.616 -    if (GEM_locked) {
   9.617 -        /* Restore menu bar */
   9.618 -        if (GEM_menubar) {
   9.619 -            MFDB mfdb_src;
   9.620 -            short blitcoords[8];
   9.621 -
   9.622 -            mfdb_src.fd_addr = GEM_menubar;
   9.623 -            mfdb_src.fd_w = GEM_desk_w;
   9.624 -            mfdb_src.fd_h = GEM_desk_y;
   9.625 -            mfdb_src.fd_wdwidth = GEM_desk_w >> 4;
   9.626 -            mfdb_src.fd_nplanes = VDI_bpp;
   9.627 -            mfdb_src.fd_stand =
   9.628 -                mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0;
   9.629 -
   9.630 -            blitcoords[0] = blitcoords[4] = 0;
   9.631 -            blitcoords[1] = blitcoords[5] = 0;
   9.632 -            blitcoords[2] = blitcoords[6] = GEM_desk_w - 1;
   9.633 -            blitcoords[3] = blitcoords[7] = GEM_desk_y - 1;
   9.634 -
   9.635 -            vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src,
   9.636 -                      &VDI_dst_mfdb);
   9.637 -        }
   9.638 -
   9.639 -        /* Restore screen memory, and send REDRAW to all apps */
   9.640 -        form_dial(FMD_FINISH, 0, 0, 0, 0, 0, 0, VDI_w, VDI_h);
   9.641 -        /* Unlock AES */
   9.642 -        wind_update(END_MCTRL);
   9.643 -        wind_update(END_UPDATE);
   9.644 -
   9.645 -        GEM_locked = SDL_FALSE;
   9.646 -    }
   9.647 -}
   9.648 -
   9.649 -SDL_Surface *
   9.650 -GEM_SetVideoMode(_THIS, SDL_Surface * current,
   9.651 -                 int width, int height, int bpp, Uint32 flags)
   9.652 -{
   9.653 -    Uint32 modeflags, screensize;
   9.654 -    SDL_bool use_shadow1, use_shadow2;
   9.655 -
   9.656 -    /* width must be multiple of 16, for vro_cpyfm() and c2p_convert() */
   9.657 -    if ((width & 15) != 0) {
   9.658 -        width = (width | 15) + 1;
   9.659 -    }
   9.660 -
   9.661 -        /*--- Verify if asked mode can be used ---*/
   9.662 -    if (VDI_bpp != bpp) {
   9.663 -        SDL_SetError("%d bpp mode not supported", bpp);
   9.664 -        return (NULL);
   9.665 -    }
   9.666 -
   9.667 -    if (flags & SDL_FULLSCREEN) {
   9.668 -        if ((VDI_w < width) || (VDI_h < height)) {
   9.669 -            SDL_SetError("%dx%d mode is too large", width, height);
   9.670 -            return (NULL);
   9.671 -        }
   9.672 -    }
   9.673 -
   9.674 -        /*--- Allocate the new pixel format for the screen ---*/
   9.675 -    if (!SDL_ReallocFormat
   9.676 -        (current, VDI_bpp, VDI_redmask, VDI_greenmask, VDI_bluemask,
   9.677 -         VDI_alphamask)) {
   9.678 -        SDL_SetError("Couldn't allocate new pixel format for requested mode");
   9.679 -        return (NULL);
   9.680 -    }
   9.681 -
   9.682 -    screensize = width * height * VDI_pixelsize;
   9.683 -
   9.684 -#ifdef DEBUG_VIDEO_GEM
   9.685 -    printf("sdl:video:gem: setvideomode(): %dx%dx%d = %d\n", width, height,
   9.686 -           bpp, screensize);
   9.687 -#endif
   9.688 -
   9.689 -        /*--- Allocate shadow buffers if needed, and conversion operations ---*/
   9.690 -    GEM_FreeBuffers(this);
   9.691 -
   9.692 -    GEM_bufops = 0;
   9.693 -    use_shadow1 = use_shadow2 = SDL_FALSE;
   9.694 -    if (VDI_screen && (flags & SDL_FULLSCREEN)) {
   9.695 -        if (VDI_format == VDI_FORMAT_INTER) {
   9.696 -            use_shadow1 = SDL_TRUE;
   9.697 -            GEM_bufops = B2S_C2P_1TOS;
   9.698 -        }
   9.699 -    } else {
   9.700 -        use_shadow1 = SDL_TRUE;
   9.701 -        if (VDI_format == VDI_FORMAT_PACK) {
   9.702 -            GEM_bufops = B2S_VROCPYFM_1TOS;
   9.703 -        } else {
   9.704 -            use_shadow2 = SDL_TRUE;
   9.705 -            GEM_bufops = B2S_C2P_1TO2 | B2S_VROCPYFM_2TOS;
   9.706 -        }
   9.707 -    }
   9.708 -
   9.709 -    if (use_shadow1) {
   9.710 -        GEM_buffer1 = Atari_SysMalloc(screensize, MX_PREFTTRAM);
   9.711 -        if (GEM_buffer1 == NULL) {
   9.712 -            SDL_SetError("Can not allocate %d KB for frame buffer",
   9.713 -                         screensize >> 10);
   9.714 -            return NULL;
   9.715 -        }
   9.716 -        SDL_memset(GEM_buffer1, 0, screensize);
   9.717 -#ifdef DEBUG_VIDEO_GEM
   9.718 -        printf("sdl:video:gem: setvideomode(): allocated buffer 1\n");
   9.719 -#endif
   9.720 -    }
   9.721 -
   9.722 -    if (use_shadow2) {
   9.723 -        GEM_buffer2 = Atari_SysMalloc(screensize, MX_PREFTTRAM);
   9.724 -        if (GEM_buffer2 == NULL) {
   9.725 -            SDL_SetError("Can not allocate %d KB for shadow buffer",
   9.726 -                         screensize >> 10);
   9.727 -            return NULL;
   9.728 -        }
   9.729 -        SDL_memset(GEM_buffer2, 0, screensize);
   9.730 -#ifdef DEBUG_VIDEO_GEM
   9.731 -        printf("sdl:video:gem: setvideomode(): allocated buffer 2\n");
   9.732 -#endif
   9.733 -    }
   9.734 -
   9.735 -        /*--- Initialize screen ---*/
   9.736 -    modeflags = SDL_PREALLOC;
   9.737 -    if (VDI_bpp == 8) {
   9.738 -        modeflags |= SDL_HWPALETTE;
   9.739 -    }
   9.740 -
   9.741 -    if (flags & SDL_FULLSCREEN) {
   9.742 -        GEM_LockScreen(this);
   9.743 -
   9.744 -        GEM_ClearScreen(this);
   9.745 -
   9.746 -        modeflags |= SDL_FULLSCREEN;
   9.747 -        if (VDI_screen && (VDI_format == VDI_FORMAT_PACK) && !use_shadow1) {
   9.748 -            modeflags |= SDL_HWSURFACE;
   9.749 -        } else {
   9.750 -            modeflags |= SDL_SWSURFACE;
   9.751 -        }
   9.752 -
   9.753 -        GEM_fullscreen = SDL_TRUE;
   9.754 -    } else {
   9.755 -        int old_win_type;
   9.756 -        short x2, y2, w2, h2;
   9.757 -
   9.758 -        GEM_UnlockScreen(this);
   9.759 -
   9.760 -        /* Set window gadgets */
   9.761 -        old_win_type = GEM_win_type;
   9.762 -        if (!(flags & SDL_NOFRAME)) {
   9.763 -            GEM_win_type = NAME | MOVER | CLOSER | SMALLER;
   9.764 -            if (flags & SDL_RESIZABLE) {
   9.765 -                GEM_win_type |= FULLER | SIZER;
   9.766 -                modeflags |= SDL_RESIZABLE;
   9.767 -            }
   9.768 -        } else {
   9.769 -            GEM_win_type = 0;
   9.770 -            modeflags |= SDL_NOFRAME;
   9.771 -        }
   9.772 -        modeflags |= SDL_SWSURFACE;
   9.773 -
   9.774 -        /* Recreate window ? only for different widget or non-created window */
   9.775 -        if ((old_win_type != GEM_win_type) || (GEM_handle < 0)) {
   9.776 -            /* Calculate window size */
   9.777 -            if (!wind_calc
   9.778 -                (WC_BORDER, GEM_win_type, 0, 0, width, height, &x2, &y2,
   9.779 -                 &w2, &h2)) {
   9.780 -                GEM_FreeBuffers(this);
   9.781 -                SDL_SetError("Can not calculate window attributes");
   9.782 -                return NULL;
   9.783 -            }
   9.784 -
   9.785 -            /* Center window */
   9.786 -            x2 = (GEM_desk_w - w2) >> 1;
   9.787 -            y2 = (GEM_desk_h - h2) >> 1;
   9.788 -            if (x2 < 0) {
   9.789 -                x2 = 0;
   9.790 -            }
   9.791 -            if (y2 < 0) {
   9.792 -                y2 = 0;
   9.793 -            }
   9.794 -            x2 += GEM_desk_x;
   9.795 -            y2 += GEM_desk_y;
   9.796 -
   9.797 -            /* Destroy existing window */
   9.798 -            if (GEM_handle >= 0) {
   9.799 -                wind_close(GEM_handle);
   9.800 -                wind_delete(GEM_handle);
   9.801 -            }
   9.802 -
   9.803 -            /* Create window */
   9.804 -            GEM_handle = wind_create(GEM_win_type, x2, y2, w2, h2);
   9.805 -            if (GEM_handle < 0) {
   9.806 -                GEM_FreeBuffers(this);
   9.807 -                SDL_SetError("Can not create window");
   9.808 -                return NULL;
   9.809 -            }
   9.810 -#ifdef DEBUG_VIDEO_GEM
   9.811 -            printf("sdl:video:gem: handle=%d\n", GEM_handle);
   9.812 -#endif
   9.813 -
   9.814 -            /* Setup window name */
   9.815 -            wind_set(GEM_handle, WF_NAME,
   9.816 -                     (short) (((unsigned long) GEM_title_name) >> 16),
   9.817 -                     (short) (((unsigned long) GEM_title_name) & 0xffff),
   9.818 -                     0, 0);
   9.819 -            GEM_refresh_name = SDL_FALSE;
   9.820 -
   9.821 -            /* Open the window */
   9.822 -            wind_open(GEM_handle, x2, y2, w2, h2);
   9.823 -        } else {
   9.824 -            /* Resize window to fit asked video mode */
   9.825 -            wind_get(GEM_handle, WF_WORKXYWH, &x2, &y2, &w2, &h2);
   9.826 -            if (wind_calc
   9.827 -                (WC_BORDER, GEM_win_type, x2, y2, width, height, &x2, &y2,
   9.828 -                 &w2, &h2)) {
   9.829 -                wind_set(GEM_handle, WF_CURRXYWH, x2, y2, w2, h2);
   9.830 -            }
   9.831 -        }
   9.832 -
   9.833 -        GEM_fullscreen = SDL_FALSE;
   9.834 -    }
   9.835 -
   9.836 -    /* Set up the new mode framebuffer */
   9.837 -    current->w = width;
   9.838 -    current->h = height;
   9.839 -    if (use_shadow1) {
   9.840 -        current->pixels = GEM_buffer1;
   9.841 -        current->pitch = width * VDI_pixelsize;
   9.842 -    } else {
   9.843 -        current->pixels = VDI_screen;
   9.844 -        current->pitch = VDI_pitch;
   9.845 -    }
   9.846 -
   9.847 -#if SDL_VIDEO_OPENGL
   9.848 -    if (flags & SDL_INTERNALOPENGL) {
   9.849 -        if (!SDL_AtariGL_Init(this, current)) {
   9.850 -            GEM_FreeBuffers(this);
   9.851 -            SDL_SetError("Can not create OpenGL context");
   9.852 -            return NULL;
   9.853 -        }
   9.854 -
   9.855 -        modeflags |= SDL_INTERNALOPENGL;
   9.856 -    }
   9.857 -#endif
   9.858 -
   9.859 -    current->flags = modeflags;
   9.860 -
   9.861 -#ifdef DEBUG_VIDEO_GEM
   9.862 -    printf("sdl:video:gem: surface: %dx%d\n", current->w, current->h);
   9.863 -#endif
   9.864 -
   9.865 -    this->UpdateRects = GEM_UpdateRects;
   9.866 -    GEM_lock_redraw = SDL_FALSE;        /* Enable redraw */
   9.867 -
   9.868 -    /* We're done */
   9.869 -    return (current);
   9.870 -}
   9.871 -
   9.872 -static int
   9.873 -GEM_AllocHWSurface(_THIS, SDL_Surface * surface)
   9.874 -{
   9.875 -    return -1;
   9.876 -}
   9.877 -
   9.878 -static void
   9.879 -GEM_FreeHWSurface(_THIS, SDL_Surface * surface)
   9.880 -{
   9.881 -    return;
   9.882 -}
   9.883 -
   9.884 -static int
   9.885 -GEM_LockHWSurface(_THIS, SDL_Surface * surface)
   9.886 -{
   9.887 -    return (0);
   9.888 -}
   9.889 -
   9.890 -static void
   9.891 -GEM_UnlockHWSurface(_THIS, SDL_Surface * surface)
   9.892 -{
   9.893 -    return;
   9.894 -}
   9.895 -
   9.896 -static void
   9.897 -GEM_UpdateRectsFullscreen(_THIS, int numrects, SDL_Rect * rects)
   9.898 -{
   9.899 -    SDL_Surface *surface;
   9.900 -    int i, surf_width;
   9.901 -
   9.902 -    surface = this->screen;
   9.903 -    /* Need to be a multiple of 16 pixels */
   9.904 -    surf_width = surface->w;
   9.905 -    if ((surf_width & 15) != 0) {
   9.906 -        surf_width = (surf_width | 15) + 1;
   9.907 -    }
   9.908 -
   9.909 -    if (GEM_bufops & (B2S_C2P_1TO2 | B2S_C2P_1TOS)) {
   9.910 -        void *destscr;
   9.911 -        int destpitch;
   9.912 -
   9.913 -        if (GEM_bufops & B2S_C2P_1TOS) {
   9.914 -            destscr = VDI_screen;
   9.915 -            destpitch = VDI_pitch;
   9.916 -        } else {
   9.917 -            destscr = GEM_buffer2;
   9.918 -            destpitch = surface->pitch;
   9.919 -        }
   9.920 -
   9.921 -        for (i = 0; i < numrects; i++) {
   9.922 -            void *source, *destination;
   9.923 -            int x1, x2;
   9.924 -
   9.925 -            x1 = rects[i].x & ~15;
   9.926 -            x2 = rects[i].x + rects[i].w;
   9.927 -            if (x2 & 15) {
   9.928 -                x2 = (x2 | 15) + 1;
   9.929 -            }
   9.930 -
   9.931 -            source = surface->pixels;
   9.932 -            source += surface->pitch * rects[i].y;
   9.933 -            source += x1;
   9.934 -
   9.935 -            destination = destscr;
   9.936 -            destination += destpitch * rects[i].y;
   9.937 -            destination += x1;
   9.938 -
   9.939 -            SDL_Atari_C2pConvert(source, destination,
   9.940 -                                 x2 - x1, rects[i].h,
   9.941 -                                 SDL_FALSE, surface->pitch, destpitch);
   9.942 -        }
   9.943 -    }
   9.944 -
   9.945 -    if (GEM_bufops & (B2S_VROCPYFM_1TOS | B2S_VROCPYFM_2TOS)) {
   9.946 -        MFDB mfdb_src;
   9.947 -        short blitcoords[8];
   9.948 -
   9.949 -        mfdb_src.fd_addr = surface->pixels;
   9.950 -        mfdb_src.fd_w = surf_width;
   9.951 -        mfdb_src.fd_h = surface->h;
   9.952 -        mfdb_src.fd_wdwidth = (surface->pitch / VDI_pixelsize) >> 4;
   9.953 -        mfdb_src.fd_nplanes = surface->format->BitsPerPixel;
   9.954 -        mfdb_src.fd_stand =
   9.955 -            mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0;
   9.956 -        if (GEM_bufops & B2S_VROCPYFM_2TOS) {
   9.957 -            mfdb_src.fd_addr = GEM_buffer2;
   9.958 -        }
   9.959 -
   9.960 -        for (i = 0; i < numrects; ++i) {
   9.961 -            blitcoords[0] = blitcoords[4] = rects[i].x;
   9.962 -            blitcoords[1] = blitcoords[5] = rects[i].y;
   9.963 -            blitcoords[2] = blitcoords[6] = rects[i].x + rects[i].w - 1;
   9.964 -            blitcoords[3] = blitcoords[7] = rects[i].y + rects[i].h - 1;
   9.965 -
   9.966 -            vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src,
   9.967 -                      &VDI_dst_mfdb);
   9.968 -        }
   9.969 -    }
   9.970 -}
   9.971 -
   9.972 -static void
   9.973 -GEM_UpdateRectsWindowed(_THIS, int numrects, SDL_Rect * rects)
   9.974 -{
   9.975 -    short pxy[4], wind_pxy[4];
   9.976 -    int i;
   9.977 -
   9.978 -    if (wind_get
   9.979 -        (GEM_handle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2],
   9.980 -         &wind_pxy[3]) == 0) {
   9.981 -        return;
   9.982 -    }
   9.983 -
   9.984 -    for (i = 0; i < numrects; ++i) {
   9.985 -        pxy[0] = wind_pxy[0] + rects[i].x;
   9.986 -        pxy[1] = wind_pxy[1] + rects[i].y;
   9.987 -        pxy[2] = rects[i].w;
   9.988 -        pxy[3] = rects[i].h;
   9.989 -
   9.990 -        GEM_wind_redraw(this, GEM_handle, pxy);
   9.991 -    }
   9.992 -}
   9.993 -
   9.994 -static void
   9.995 -GEM_UpdateRects(_THIS, int numrects, SDL_Rect * rects)
   9.996 -{
   9.997 -    SDL_Surface *surface;
   9.998 -
   9.999 -    if (GEM_lock_redraw) {
  9.1000 -        return;
  9.1001 -    }
  9.1002 -
  9.1003 -    surface = this->screen;
  9.1004 -
  9.1005 -    if (surface->flags & SDL_FULLSCREEN) {
  9.1006 -        GEM_UpdateRectsFullscreen(this, numrects, rects);
  9.1007 -    } else {
  9.1008 -        GEM_UpdateRectsWindowed(this, numrects, rects);
  9.1009 -    }
  9.1010 -}
  9.1011 -
  9.1012 -static int
  9.1013 -GEM_FlipHWSurfaceFullscreen(_THIS, SDL_Surface * surface)
  9.1014 -{
  9.1015 -    int surf_width;
  9.1016 -
  9.1017 -    /* Need to be a multiple of 16 pixels */
  9.1018 -    surf_width = surface->w;
  9.1019 -    if ((surf_width & 15) != 0) {
  9.1020 -        surf_width = (surf_width | 15) + 1;
  9.1021 -    }
  9.1022 -
  9.1023 -    if (GEM_bufops & (B2S_C2P_1TO2 | B2S_C2P_1TOS)) {
  9.1024 -        void *destscr;
  9.1025 -        int destpitch;
  9.1026 -
  9.1027 -        if (GEM_bufops & B2S_C2P_1TOS) {
  9.1028 -            destscr = VDI_screen;
  9.1029 -            destpitch = VDI_pitch;
  9.1030 -        } else {
  9.1031 -            destscr = GEM_buffer2;
  9.1032 -            destpitch = surface->pitch;
  9.1033 -        }
  9.1034 -
  9.1035 -        SDL_Atari_C2pConvert(surface->pixels, destscr,
  9.1036 -                             surf_width, surface->h,
  9.1037 -                             SDL_FALSE, surface->pitch, destpitch);
  9.1038 -    }
  9.1039 -
  9.1040 -    if (GEM_bufops & (B2S_VROCPYFM_1TOS | B2S_VROCPYFM_2TOS)) {
  9.1041 -        MFDB mfdb_src;
  9.1042 -        short blitcoords[8];
  9.1043 -
  9.1044 -        mfdb_src.fd_w = surf_width;
  9.1045 -        mfdb_src.fd_h = surface->h;
  9.1046 -        mfdb_src.fd_wdwidth = mfdb_src.fd_w >> 4;
  9.1047 -        mfdb_src.fd_nplanes = surface->format->BitsPerPixel;
  9.1048 -        mfdb_src.fd_stand =
  9.1049 -            mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0;
  9.1050 -        if (GEM_bufops & B2S_VROCPYFM_1TOS) {
  9.1051 -            mfdb_src.fd_addr = surface->pixels;
  9.1052 -        } else {
  9.1053 -            mfdb_src.fd_addr = GEM_buffer2;
  9.1054 -        }
  9.1055 -
  9.1056 -        blitcoords[0] = blitcoords[4] = 0;
  9.1057 -        blitcoords[1] = blitcoords[5] = 0;
  9.1058 -        blitcoords[2] = blitcoords[6] = surface->w - 1;
  9.1059 -        blitcoords[3] = blitcoords[7] = surface->h - 1;
  9.1060 -
  9.1061 -        vro_cpyfm(VDI_handle, S_ONLY, blitcoords, &mfdb_src, &VDI_dst_mfdb);
  9.1062 -    }
  9.1063 +    GEM_InitKeyboard(_this);
  9.1064 +    GEM_InitMouse(_this);
  9.1065  
  9.1066      return (0);
  9.1067  }
  9.1068  
  9.1069 -static int
  9.1070 -GEM_FlipHWSurfaceWindowed(_THIS, SDL_Surface * surface)
  9.1071 -{
  9.1072 -    short pxy[8];
  9.1073 -
  9.1074 -    /* Update the whole window */
  9.1075 -    wind_get(GEM_handle, WF_WORKXYWH, &pxy[0], &pxy[1], &pxy[2], &pxy[3]);
  9.1076 -
  9.1077 -    GEM_wind_redraw(this, GEM_handle, pxy);
  9.1078 -
  9.1079 -    return (0);
  9.1080 -}
  9.1081 -
  9.1082 -static int
  9.1083 -GEM_FlipHWSurface(_THIS, SDL_Surface * surface)
  9.1084 -{
  9.1085 -    if (GEM_lock_redraw) {
  9.1086 -        return (0);
  9.1087 -    }
  9.1088 -
  9.1089 -    if (surface->flags & SDL_FULLSCREEN) {
  9.1090 -        return GEM_FlipHWSurfaceFullscreen(this, surface);
  9.1091 -    } else {
  9.1092 -        return GEM_FlipHWSurfaceWindowed(this, surface);
  9.1093 -    }
  9.1094 -}
  9.1095 -
  9.1096 -static int
  9.1097 -GEM_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
  9.1098 -{
  9.1099 -    int i;
  9.1100 -    SDL_Surface *surface;
  9.1101 -
  9.1102 -#ifdef DEBUG_VIDEO_GEM
  9.1103 -    printf("sdl:video:gem: setcolors()\n");
  9.1104 -#endif
  9.1105 -
  9.1106 -    /* Do not change palette in True Colour */
  9.1107 -    surface = this->screen;
  9.1108 -    if (surface->format->BitsPerPixel > 8) {
  9.1109 -        return 1;
  9.1110 -    }
  9.1111 -
  9.1112 -    for (i = 0; i < ncolors; i++) {
  9.1113 -        int r, g, b;
  9.1114 -        short rgb[3];
  9.1115 -
  9.1116 -        r = colors[i].r;
  9.1117 -        g = colors[i].g;
  9.1118 -        b = colors[i].b;
  9.1119 -
  9.1120 -        rgb[0] = VDI_curpalette[i][0] = (1000 * r) / 255;
  9.1121 -        rgb[1] = VDI_curpalette[i][1] = (1000 * g) / 255;
  9.1122 -        rgb[2] = VDI_curpalette[i][2] = (1000 * b) / 255;
  9.1123 -
  9.1124 -        vs_color(VDI_handle, vdi_index[firstcolor + i], rgb);
  9.1125 -    }
  9.1126 -
  9.1127 -    return (1);
  9.1128 -}
  9.1129 -
  9.1130 -#if 0
  9.1131 -static int
  9.1132 -GEM_ToggleFullScreen(_THIS, int on)
  9.1133 -{
  9.1134 -    if (on) {
  9.1135 -        GEM_LockScreen(this);
  9.1136 -    } else {
  9.1137 -        GEM_UnlockScreen(this);
  9.1138 -    }
  9.1139 -
  9.1140 -    return (1);
  9.1141 -}
  9.1142 -#endif
  9.1143 -
  9.1144 -/* Note:  If we are terminated, this could be called in the middle of
  9.1145 -   another SDL video routine -- notably UpdateRects.
  9.1146 -*/
  9.1147  void
  9.1148  GEM_VideoQuit(_THIS)
  9.1149  {
  9.1150 -    SDL_AtariXbios_RestoreVectors();
  9.1151 -    if (GEM_usedevmouse) {
  9.1152 -        SDL_AtariDevMouse_Close();
  9.1153 -    }
  9.1154 +    SDL_VideoData *data = (SDL_VideoData *) _this->driverdata;
  9.1155  
  9.1156 -    GEM_FreeBuffers(this);
  9.1157 +    GEM_QuitMouse(_this);
  9.1158 +    GEM_QuitKeyboard(_this);
  9.1159  
  9.1160 -#if SDL_VIDEO_OPENGL
  9.1161 -    if (gl_active) {
  9.1162 -        SDL_AtariGL_Quit(this, SDL_TRUE);
  9.1163 -    }
  9.1164 -#endif
  9.1165 +    GEM_QuitModes(_this);
  9.1166  
  9.1167 -    /* Destroy window */
  9.1168 -    if (GEM_handle >= 0) {
  9.1169 -        wind_close(GEM_handle);
  9.1170 -        wind_delete(GEM_handle);
  9.1171 -        GEM_handle = -1;
  9.1172 -    }
  9.1173 -
  9.1174 -    GEM_UnlockScreen(this);
  9.1175 -    if (GEM_menubar) {
  9.1176 -        Mfree(GEM_menubar);
  9.1177 -        GEM_menubar = NULL;
  9.1178 +    /* Close VDI workstation */
  9.1179 +    if (data->vdi_handle) {
  9.1180 +        v_clsvwk(data->vdi_handle);
  9.1181      }
  9.1182  
  9.1183      appl_exit();
  9.1184 -
  9.1185 -    GEM_SetNewPalette(this, VDI_oldpalette);
  9.1186 -
  9.1187 -    /* Close VDI workstation */
  9.1188 -    if (VDI_handle) {
  9.1189 -        v_clsvwk(VDI_handle);
  9.1190 -    }
  9.1191 -
  9.1192 -    /* Free mode list */
  9.1193 -    if (SDL_modelist[0]) {
  9.1194 -        SDL_free(SDL_modelist[0]);
  9.1195 -        SDL_modelist[0] = NULL;
  9.1196 -    }
  9.1197 -
  9.1198 -    this->screen->pixels = NULL;
  9.1199  }
  9.1200  
  9.1201 -void
  9.1202 -GEM_wind_redraw(_THIS, int winhandle, short *inside)
  9.1203 -{
  9.1204 -    short todo[4];
  9.1205 -
  9.1206 -    /* Tell AES we are going to update */
  9.1207 -    wind_update(BEG_UPDATE);
  9.1208 -
  9.1209 -    v_hide_c(VDI_handle);
  9.1210 -
  9.1211 -    /* Browse the rectangle list to redraw */
  9.1212 -    if (wind_get
  9.1213 -        (winhandle, WF_FIRSTXYWH, &todo[0], &todo[1], &todo[2],
  9.1214 -         &todo[3]) != 0) {
  9.1215 -
  9.1216 -        while (todo[2] && todo[3]) {
  9.1217 -
  9.1218 -            if (rc_intersect((GRECT *) inside, (GRECT *) todo)) {
  9.1219 -                todo[2] += todo[0] - 1;
  9.1220 -                todo[3] += todo[1] - 1;
  9.1221 -                refresh_window(this, winhandle, todo);
  9.1222 -            }
  9.1223 -
  9.1224 -            if (wind_get
  9.1225 -                (winhandle, WF_NEXTXYWH, &todo[0], &todo[1], &todo[2],
  9.1226 -                 &todo[3]) == 0) {
  9.1227 -                break;
  9.1228 -            }
  9.1229 -        }
  9.1230 -
  9.1231 -    }
  9.1232 -
  9.1233 -    /* Update finished */
  9.1234 -    wind_update(END_UPDATE);
  9.1235 -
  9.1236 -    v_show_c(VDI_handle, 1);
  9.1237 -}
  9.1238 -
  9.1239 -static void
  9.1240 -refresh_window(_THIS, int winhandle, short *rect)
  9.1241 -{
  9.1242 -    MFDB mfdb_src;
  9.1243 -    short pxy[8], wind_pxy[8];
  9.1244 -    SDL_Surface *surface;
  9.1245 -    int iconified;
  9.1246 -
  9.1247 -    /* Is window iconified ? */
  9.1248 -    iconified = 0;
  9.1249 -/*	if (GEM_wfeatures & (1<<WF_ICONIFY))*/
  9.1250 -    {
  9.1251 -        if (wind_get
  9.1252 -            (winhandle, WF_ICONIFY, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2],
  9.1253 -             &wind_pxy[3]) != 0) {
  9.1254 -            iconified = wind_pxy[0];
  9.1255 -        }
  9.1256 -    }
  9.1257 -
  9.1258 -    if (wind_get
  9.1259 -        (winhandle, WF_WORKXYWH, &wind_pxy[0], &wind_pxy[1], &wind_pxy[2],
  9.1260 -         &wind_pxy[3]) == 0) {
  9.1261 -        return;
  9.1262 -    }
  9.1263 -
  9.1264 -    if (iconified && GEM_icon) {
  9.1265 -        short icon_rect[4], dst_rect[4];
  9.1266 -        short iconx, icony;
  9.1267 -
  9.1268 -        surface = GEM_icon;
  9.1269 -
  9.1270 -        GEM_ClearRect(this, rect);
  9.1271 -
  9.1272 -        /* Calculate centered icon(x,y,w,h) relative to window */
  9.1273 -        iconx = (wind_pxy[2] - surface->w) >> 1;
  9.1274 -        icony = (wind_pxy[3] - surface->h) >> 1;
  9.1275 -
  9.1276 -        icon_rect[0] = iconx;
  9.1277 -        icon_rect[1] = icony;
  9.1278 -        icon_rect[2] = surface->w;
  9.1279 -        icon_rect[3] = surface->h;
  9.1280 -
  9.1281 -        /* Calculate redraw rectangle(x,y,w,h) relative to window */
  9.1282 -        dst_rect[0] = rect[0] - wind_pxy[0];
  9.1283 -        dst_rect[1] = rect[1] - wind_pxy[1];
  9.1284 -        dst_rect[2] = rect[2] - rect[0] + 1;
  9.1285 -        dst_rect[3] = rect[3] - rect[1] + 1;
  9.1286 -
  9.1287 -        /* Does the icon rectangle must be redrawn ? */
  9.1288 -        if (!rc_intersect((GRECT *) icon_rect, (GRECT *) dst_rect)) {
  9.1289 -            return;
  9.1290 -        }
  9.1291 -#if DEBUG_VIDEO_GEM
  9.1292 -        printf("sdl:video:gem:  clip(0,0,%d,%d) to (%d,%d,%d,%d)\n",
  9.1293 -               surface->w - 1, surface->h - 1, dst_rect[0], dst_rect[1],
  9.1294 -               dst_rect[2], dst_rect[3]);
  9.1295 -        printf("sdl:video:gem:  icon(%d,%d,%d,%d)\n", icon_rect[0],
  9.1296 -               icon_rect[1], icon_rect[2], icon_rect[3]);
  9.1297 -        printf("sdl:video:gem: refresh_window(): draw icon\n");
  9.1298 -#endif
  9.1299 -
  9.1300 -        /* Calculate icon(x1,y1,x2,y2) relative to screen */
  9.1301 -        icon_rect[0] += wind_pxy[0];
  9.1302 -        icon_rect[1] += wind_pxy[1];
  9.1303 -        icon_rect[2] += icon_rect[0] - 1;
  9.1304 -        icon_rect[3] += icon_rect[1] - 1;
  9.1305 -
  9.1306 -        /* Calculate intersection rectangle to redraw */
  9.1307 -        pxy[4] = pxy[0] = MAX(icon_rect[0], rect[0]);
  9.1308 -        pxy[5] = pxy[1] = MAX(icon_rect[1], rect[1]);
  9.1309 -        pxy[6] = pxy[2] = MIN(icon_rect[2], rect[2]);
  9.1310 -        pxy[7] = pxy[3] = MIN(icon_rect[3], rect[3]);
  9.1311 -
  9.1312 -        /* Calculate icon source image pos relative to window */
  9.1313 -        pxy[0] -= wind_pxy[0] + iconx;
  9.1314 -        pxy[1] -= wind_pxy[1] + icony;
  9.1315 -        pxy[2] -= wind_pxy[0] + iconx;
  9.1316 -        pxy[3] -= wind_pxy[1] + icony;
  9.1317 -
  9.1318 -    } else {
  9.1319 -        surface = this->screen;
  9.1320 -
  9.1321 -#if DEBUG_VIDEO_GEM
  9.1322 -        printf("sdl:video:gem: refresh_window(): draw frame buffer\n");
  9.1323 -#endif
  9.1324 -
  9.1325 -        /* Redraw all window content */
  9.1326 -        pxy[0] = rect[0] - wind_pxy[0];
  9.1327 -        pxy[1] = rect[1] - wind_pxy[1];
  9.1328 -        pxy[2] = rect[2] - wind_pxy[0];
  9.1329 -        pxy[3] = rect[3] - wind_pxy[1];
  9.1330 -
  9.1331 -        pxy[4] = rect[0];
  9.1332 -        pxy[5] = rect[1];
  9.1333 -        pxy[6] = rect[2];
  9.1334 -        pxy[7] = rect[3];
  9.1335 -    }
  9.1336 -
  9.1337 -    if (GEM_bufops & B2S_C2P_1TO2) {
  9.1338 -        void *src, *dest;
  9.1339 -        int x1, x2;
  9.1340 -
  9.1341 -        x1 = (rect[0] - wind_pxy[0]) & ~15;
  9.1342 -        x2 = rect[2] - wind_pxy[0];
  9.1343 -        if (x2 & 15) {
  9.1344 -            x2 = (x2 | 15) + 1;
  9.1345 -        }
  9.1346 -
  9.1347 -        src = surface->pixels;
  9.1348 -        src += surface->pitch * (rect[1] - wind_pxy[1]);
  9.1349 -        src += x1;
  9.1350 -
  9.1351 -        dest = GEM_buffer2;
  9.1352 -        dest += surface->pitch * (rect[1] - wind_pxy[1]);
  9.1353 -        dest += x1;
  9.1354 -
  9.1355 -        SDL_Atari_C2pConvert(src, dest,
  9.1356 -                             x2 - x1, rect[3] - rect[1] + 1,
  9.1357 -                             SDL_FALSE, surface->pitch, surface->pitch);
  9.1358 -    }
  9.1359 -
  9.1360 -    mfdb_src.fd_addr = surface->pixels;
  9.1361 -    {
  9.1362 -        int width;
  9.1363 -
  9.1364 -        /* Need to be a multiple of 16 pixels */
  9.1365 -        width = surface->w;
  9.1366 -        if ((width & 15) != 0) {
  9.1367 -            width = (width | 15) + 1;
  9.1368 -        }
  9.1369 -        mfdb_src.fd_w = width;
  9.1370 -    }
  9.1371 -    mfdb_src.fd_h = surface->h;
  9.1372 -    mfdb_src.fd_nplanes = surface->format->BitsPerPixel;
  9.1373 -    mfdb_src.fd_wdwidth = mfdb_src.fd_w >> 4;
  9.1374 -    mfdb_src.fd_stand = mfdb_src.fd_r1 = mfdb_src.fd_r2 = mfdb_src.fd_r3 = 0;
  9.1375 -
  9.1376 -    if (GEM_bufops & B2S_VROCPYFM_2TOS) {
  9.1377 -        mfdb_src.fd_addr = GEM_buffer2;
  9.1378 -    }
  9.1379 -#if DEBUG_VIDEO_GEM
  9.1380 -    printf("sdl:video:gem: redraw %dx%d: (%d,%d,%d,%d) to (%d,%d,%d,%d)\n",
  9.1381 -           surface->w, surface->h,
  9.1382 -           pxy[0], pxy[1], pxy[2], pxy[3], pxy[4], pxy[5], pxy[6], pxy[7]);
  9.1383 -#endif
  9.1384 -
  9.1385 -    vro_cpyfm(VDI_handle, S_ONLY, pxy, &mfdb_src, &VDI_dst_mfdb);
  9.1386 -}
  9.1387 -
  9.1388 -#if SDL_VIDEO_OPENGL
  9.1389 -
  9.1390 -static void
  9.1391 -GEM_GL_SwapBuffers(_THIS)
  9.1392 -{
  9.1393 -    SDL_AtariGL_SwapBuffers(this);
  9.1394 -    GEM_FlipHWSurface(this, this->screen);
  9.1395 -}
  9.1396 -
  9.1397 -#endif
  9.1398  /* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/video/gem/SDL_gemvideo.h	Fri Jul 13 22:52:53 2007 +0000
    10.2 +++ b/src/video/gem/SDL_gemvideo.h	Fri Jul 13 22:55:15 2007 +0000
    10.3 @@ -24,163 +24,28 @@
    10.4  #ifndef _SDL_gemvideo_h
    10.5  #define _SDL_gemvideo_h
    10.6  
    10.7 -#include "SDL_mutex.h"
    10.8  #include "../SDL_sysvideo.h"
    10.9  
   10.10 -/* Hidden "this" pointer for the video functions */
   10.11 -#define _THIS	SDL_VideoDevice *this
   10.12 -
   10.13 -/* Functions prototypes */
   10.14 -void GEM_wind_redraw(_THIS, int winhandle, short *inside);
   10.15 +#include "SDL_gemevents.h"
   10.16 +#include "SDL_gemkeyboard.h"
   10.17 +#include "SDL_gemmodes.h"
   10.18 +#include "SDL_gemmouse.h"
   10.19 +#include "SDL_gemwindow.h"
   10.20  
   10.21  /* Private display data */
   10.22  
   10.23 -#define B2S_C2P_1TO2		(1<<0)  /* C2P convert buffer 1 to buffer 2 */
   10.24 -#define B2S_C2P_1TOS		(1<<1)  /* C2P convert buffer 1 to screen */
   10.25 -#define B2S_VROCPYFM_1TOS	(1<<2)  /* vro_cpyfm() buffer 1 to screen */
   10.26 -#define B2S_VROCPYFM_2TOS	(1<<3)  /* vro_cpyfm() buffer 2 to screen */
   10.27 -
   10.28 -#define SDL_NUMMODES	1       /* Fullscreen */
   10.29 -
   10.30 -struct SDL_PrivateVideoData
   10.31 +typedef struct
   10.32  {
   10.33 -    Uint16 buf2scr_ops;         /* Operations to get buffer to screen */
   10.34 -    void *buffer1;              /* Our shadow buffers */
   10.35 -    void *buffer2;
   10.36 +    int mouse;
   10.37 +    int keyboard;
   10.38  
   10.39      /* VDI infos */
   10.40 -    short vdi_handle;           /* VDI handle */
   10.41 -    short full_w, full_h;       /* Fullscreen size */
   10.42 -    short bpp;                  /* Colour depth */
   10.43 -    short pixelsize;            /* Bytes per pixel */
   10.44 -    short old_numcolors;        /* Number of colors in saved palette */
   10.45 -    Uint16 pitch;               /* Line length */
   10.46 -    Uint16 format;              /* Screen format */
   10.47 -    void *screen;               /* Screen address */
   10.48 -    Uint32 red, green, blue, alpha;     /* Screen components */
   10.49 -    Uint32 screensize;
   10.50 -    short blit_coords[8];       /* Coordinates for bitblt */
   10.51 -    MFDB src_mfdb, dst_mfdb;    /* VDI MFDB for bitblt */
   10.52 -    Uint16 old_palette[256][3]; /* Saved current palette */
   10.53 -    Uint16 cur_palette[256][3]; /* SDL application palette */
   10.54 -    /* Function to set/restore palette */
   10.55 -    void (*setpalette) (_THIS, Uint16 newpal[256][3]);
   10.56 +    short vdi_handle;           /* workstation handle */
   10.57  
   10.58 -    /* GEM infos */
   10.59 -    short desk_x, desk_y;       /* Desktop properties */
   10.60 -    short desk_w, desk_h;
   10.61 -    short win_handle;           /* Our window handle */
   10.62 -    int window_type;            /* Window type */
   10.63 -    const char *title_name;     /* Window title */
   10.64 -    const char *icon_name;      /* Icon title */
   10.65 -    short version;              /* AES version */
   10.66 -    short wfeatures;            /* AES window features */
   10.67 -    SDL_bool refresh_name;      /* Change window title ? */
   10.68 -    SDL_bool window_fulled;     /* Window maximized ? */
   10.69 -    SDL_bool mouse_relative;    /* Report relative mouse movement */
   10.70 -    SDL_bool locked;            /* AES locked for fullscreen ? */
   10.71 -    SDL_bool lock_redraw;       /* Prevent redraw till buffers are setup */
   10.72 -    short message[8];           /* To self-send an AES message */
   10.73 -    void *menubar;              /* Menu bar save buffer when going fullscreen */
   10.74 -    SDL_bool use_dev_mouse;     /* Use /dev/mouse ? */
   10.75 -
   10.76 -    SDL_bool fullscreen;        /* Fullscreen or windowed mode ? */
   10.77 -    SDL_Rect *SDL_modelist[SDL_NUMMODES + 1];   /* Mode list */
   10.78 -    SDL_Surface *icon;          /* The icon */
   10.79 -};
   10.80 -
   10.81 -/* Hidden structure -> variables names */
   10.82 -#define VDI_handle			(this->hidden->vdi_handle)
   10.83 -#define VDI_w				(this->hidden->full_w)
   10.84 -#define VDI_h				(this->hidden->full_h)
   10.85 -#define VDI_bpp				(this->hidden->bpp)
   10.86 -#define VDI_pixelsize		(this->hidden->pixelsize)
   10.87 -#define VDI_oldnumcolors	(this->hidden->old_numcolors)
   10.88 -#define VDI_oldpalette		(this->hidden->old_palette)
   10.89 -#define VDI_curpalette		(this->hidden->cur_palette)
   10.90 -#define VDI_setpalette		(this->hidden->setpalette)
   10.91 -#define VDI_pitch			(this->hidden->pitch)
   10.92 -#define VDI_format			(this->hidden->format)
   10.93 -#define VDI_screen			(this->hidden->screen)
   10.94 -#define VDI_redmask			(this->hidden->red)
   10.95 -#define VDI_greenmask		(this->hidden->green)
   10.96 -#define VDI_bluemask		(this->hidden->blue)
   10.97 -#define VDI_alphamask		(this->hidden->alpha)
   10.98 -#define VDI_screensize		(this->hidden->screensize)
   10.99 -#define VDI_src_mfdb		(this->hidden->src_mfdb)
  10.100 -#define VDI_dst_mfdb		(this->hidden->dst_mfdb)
  10.101 -#define VDI_blit_coords		(this->hidden->blit_coords)
  10.102 -
  10.103 -#define GEM_desk_x			(this->hidden->desk_x)
  10.104 -#define GEM_desk_y			(this->hidden->desk_y)
  10.105 -#define GEM_desk_w			(this->hidden->desk_w)
  10.106 -#define GEM_desk_h			(this->hidden->desk_h)
  10.107 -#define GEM_handle			(this->hidden->win_handle)
  10.108 -#define GEM_win_type		(this->hidden->window_type)
  10.109 -#define GEM_title_name		(this->hidden->title_name)
  10.110 -#define GEM_icon_name		(this->hidden->icon_name)
  10.111 -#define GEM_refresh_name	(this->hidden->refresh_name)
  10.112 -#define GEM_version			(this->hidden->version)
  10.113 -#define GEM_wfeatures		(this->hidden->wfeatures)
  10.114 -#define GEM_win_fulled		(this->hidden->window_fulled)
  10.115 -#define GEM_mouse_relative	(this->hidden->mouse_relative)
  10.116 -#define GEM_locked			(this->hidden->locked)
  10.117 -#define GEM_lock_redraw		(this->hidden->lock_redraw)
  10.118 -#define GEM_message			(this->hidden->message)
  10.119 -#define SDL_modelist		(this->hidden->SDL_modelist)
  10.120 -#define GEM_icon			(this->hidden->icon)
  10.121 -#define GEM_fullscreen		(this->hidden->fullscreen)
  10.122 -#define GEM_menubar			(this->hidden->menubar)
  10.123 -#define GEM_usedevmouse		(this->hidden->use_dev_mouse)
  10.124 -
  10.125 -#define GEM_buffer1			(this->hidden->buffer1)
  10.126 -#define GEM_buffer2			(this->hidden->buffer2)
  10.127 -#define GEM_bufops			(this->hidden->buf2scr_ops)
  10.128 -
  10.129 -#define VDI_FBMASK(amask, rmask, gmask, bmask) \
  10.130 -	VDI_alphamask = (amask); \
  10.131 -	VDI_redmask = (rmask); \
  10.132 -	VDI_greenmask = (gmask); \
  10.133 -	VDI_bluemask = (bmask);
  10.134 -
  10.135 -/*
  10.136 -	Possible buffer to screen operations:
  10.137 -
  10.138 -	TC: 8 (chunky),15,16,24,32 bpp
  10.139 -	8I: 8 bpp planes
  10.140 -	FB: screen framebuffer address available
  10.141 -	FS: fullscreen
  10.142 -
  10.143 -	TC, FB, FS:
  10.144 -		- draw to screen
  10.145 -	8I, FB, FS:
  10.146 -		- draw to buffer 1
  10.147 -		- C2P from buffer 1 to screen
  10.148 -
  10.149 -	TC, !FB, FS:
  10.150 -		- draw to buffer 1
  10.151 -		- vro_cpyfm() from buffer 1 to screen
  10.152 -	8I, !FB, FS:
  10.153 -		- draw to buffer 1
  10.154 -		- C2P from buffer 1 to buffer 2
  10.155 -		- vro_cpyfm() from buffer 2 to screen
  10.156 -
  10.157 -	TC, FB, !FS:
  10.158 -		- draw to buffer 1
  10.159 -		- vro_cpyfm() from buffer 1 to screen
  10.160 -	8I, FB, !FS:
  10.161 -		- draw to buffer 1
  10.162 -		- C2P from buffer 1 to buffer 2
  10.163 -		- vro_cpyfm() from buffer 2 to screen
  10.164 -
  10.165 -	TC, !FB, !FS:
  10.166 -		- draw to buffer 1
  10.167 -		- vro_cpyfm() from buffer 1 to screen
  10.168 -	8I, !FB, !FS:
  10.169 -		- draw to buffer 1
  10.170 -		- C2P from buffer 1 to buffer 2
  10.171 -		- vro_cpyfm() from buffer 2 to screen
  10.172 -*/
  10.173 +    /* AES infos */
  10.174 +    int wfeatures;              /* window features */
  10.175 +} SDL_VideoData;
  10.176  
  10.177  #endif /* _SDL_gemvideo_h */
  10.178 +
  10.179  /* vi: set ts=4 sw=4 expandtab: */
    11.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    11.2 +++ b/src/video/gem/SDL_gemwindow.c	Fri Jul 13 22:55:15 2007 +0000
    11.3 @@ -0,0 +1,106 @@
    11.4 +/*
    11.5 +    SDL - Simple DirectMedia Layer
    11.6 +    Copyright (C) 1997-2006 Sam Lantinga
    11.7 +
    11.8 +    This library is free software; you can redistribute it and/or
    11.9 +    modify it under the terms of the GNU Lesser General Public
   11.10 +    License as published by the Free Software Foundation; either
   11.11 +    version 2.1 of the License, or (at your option) any later version.
   11.12 +
   11.13 +    This library is distributed in the hope that it will be useful,
   11.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   11.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   11.16 +    Lesser General Public License for more details.
   11.17 +
   11.18 +    You should have received a copy of the GNU Lesser General Public
   11.19 +    License along with this library; if not, write to the Free Software
   11.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   11.21 +
   11.22 +    Sam Lantinga
   11.23 +    slouken@libsdl.org
   11.24 +*/
   11.25 +#include "SDL_config.h"
   11.26 +
   11.27 +#include "../SDL_sysvideo.h"
   11.28 +#include "../../events/SDL_keyboard_c.h"
   11.29 +
   11.30 +#include "SDL_gemvideo.h"
   11.31 +
   11.32 +/* This is included after SDL_win32video.h, which includes windows.h */
   11.33 +#include "SDL_syswm.h"
   11.34 +
   11.35 +
   11.36 +int
   11.37 +GEM_CreateWindow(_THIS, SDL_Window * window)
   11.38 +{
   11.39 +    return -1;
   11.40 +}
   11.41 +
   11.42 +int
   11.43 +GEM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data)
   11.44 +{
   11.45 +    return -1;
   11.46 +}
   11.47 +
   11.48 +void
   11.49 +GEM_SetWindowTitle(_THIS, SDL_Window * window)
   11.50 +{
   11.51 +}
   11.52 +
   11.53 +void
   11.54 +GEM_SetWindowPosition(_THIS, SDL_Window * window)
   11.55 +{
   11.56 +}
   11.57 +
   11.58 +void
   11.59 +GEM_SetWindowSize(_THIS, SDL_Window * window)
   11.60 +{
   11.61 +}
   11.62 +
   11.63 +void
   11.64 +GEM_ShowWindow(_THIS, SDL_Window * window)
   11.65 +{
   11.66 +}
   11.67 +
   11.68 +void
   11.69 +GEM_HideWindow(_THIS, SDL_Window * window)
   11.70 +{
   11.71 +}
   11.72 +
   11.73 +void
   11.74 +GEM_RaiseWindow(_THIS, SDL_Window * window)
   11.75 +{
   11.76 +}
   11.77 +
   11.78 +void
   11.79 +GEM_MaximizeWindow(_THIS, SDL_Window * window)
   11.80 +{
   11.81 +}
   11.82 +
   11.83 +void
   11.84 +GEM_MinimizeWindow(_THIS, SDL_Window * window)
   11.85 +{
   11.86 +}
   11.87 +
   11.88 +void
   11.89 +GEM_RestoreWindow(_THIS, SDL_Window * window)
   11.90 +{
   11.91 +}
   11.92 +
   11.93 +void
   11.94 +GEM_SetWindowGrab(_THIS, SDL_Window * window)
   11.95 +{
   11.96 +}
   11.97 +
   11.98 +void
   11.99 +GEM_DestroyWindow(_THIS, SDL_Window * window)
  11.100 +{
  11.101 +}
  11.102 +
  11.103 +SDL_bool
  11.104 +GEM_GetWindowWMInfo(_THIS, SDL_Window * window, SDL_SysWMinfo * info)
  11.105 +{
  11.106 +    return SDL_FALSE;
  11.107 +}
  11.108 +
  11.109 +/* vi: set ts=4 sw=4 expandtab: */
    12.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    12.2 +++ b/src/video/gem/SDL_gemwindow.h	Fri Jul 13 22:55:15 2007 +0000
    12.3 @@ -0,0 +1,51 @@
    12.4 +/*
    12.5 +    SDL - Simple DirectMedia Layer
    12.6 +    Copyright (C) 1997-2006 Sam Lantinga
    12.7 +
    12.8 +    This library is free software; you can redistribute it and/or
    12.9 +    modify it under the terms of the GNU Lesser General Public
   12.10 +    License as published by the Free Software Foundation; either
   12.11 +    version 2.1 of the License, or (at your option) any later version.
   12.12 +
   12.13 +    This library is distributed in the hope that it will be useful,
   12.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
   12.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   12.16 +    Lesser General Public License for more details.
   12.17 +
   12.18 +    You should have received a copy of the GNU Lesser General Public
   12.19 +    License along with this library; if not, write to the Free Software
   12.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   12.21 +
   12.22 +    Sam Lantinga
   12.23 +    slouken@libsdl.org
   12.24 +*/
   12.25 +#include "SDL_config.h"
   12.26 +
   12.27 +#ifndef _SDL_gemwindow_h
   12.28 +#define _SDL_gemwindow_h
   12.29 +
   12.30 +typedef struct
   12.31 +{
   12.32 +    SDL_WindowID windowID;
   12.33 +    struct SDL_VideoData *videodata;
   12.34 +} SDL_WindowData;
   12.35 +
   12.36 +extern int GEM_CreateWindow(_THIS, SDL_Window * window);
   12.37 +extern int GEM_CreateWindowFrom(_THIS, SDL_Window * window, const void *data);
   12.38 +extern void GEM_SetWindowTitle(_THIS, SDL_Window * window);
   12.39 +extern void GEM_SetWindowPosition(_THIS, SDL_Window * window);
   12.40 +extern void GEM_SetWindowSize(_THIS, SDL_Window * window);
   12.41 +extern void GEM_ShowWindow(_THIS, SDL_Window * window);
   12.42 +extern void GEM_HideWindow(_THIS, SDL_Window * window);
   12.43 +extern void GEM_RaiseWindow(_THIS, SDL_Window * window);
   12.44 +extern void GEM_MaximizeWindow(_THIS, SDL_Window * window);
   12.45 +extern void GEM_MinimizeWindow(_THIS, SDL_Window * window);
   12.46 +extern void GEM_RestoreWindow(_THIS, SDL_Window * window);
   12.47 +extern void GEM_SetWindowGrab(_THIS, SDL_Window * window);
   12.48 +extern void GEM_DestroyWindow(_THIS, SDL_Window * window);
   12.49 +extern SDL_bool GEM_GetWindowWMInfo(_THIS, SDL_Window * window,
   12.50 +                                    struct SDL_SysWMinfo *info);
   12.51 +
   12.52 +#endif /* _SDL_gemwindow_h */
   12.53 +
   12.54 +/* vi: set ts=4 sw=4 expandtab: */