The AAlib driver is fun, but not worth rewriting for SDL 1.3
authorSam Lantinga
Wed, 26 Jul 2006 03:24:27 +0000
changeset 194491f41fc124a7
parent 1943 7d642361ef0f
child 1945 3182150b470f
The AAlib driver is fun, but not worth rewriting for SDL 1.3
configure.in
include/SDL_config.h.in
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/aalib/SDL_aaevents.c
src/video/aalib/SDL_aaevents_c.h
src/video/aalib/SDL_aamouse.c
src/video/aalib/SDL_aamouse_c.h
src/video/aalib/SDL_aavideo.c
src/video/aalib/SDL_aavideo.h
     1.1 --- a/configure.in	Wed Jul 26 03:15:41 2006 +0000
     1.2 +++ b/configure.in	Wed Jul 26 03:24:27 2006 +0000
     1.3 @@ -1268,32 +1268,6 @@
     1.4      fi
     1.5  }
     1.6  
     1.7 -
     1.8 -dnl Find the AAlib includes
     1.9 -CheckAAlib()
    1.10 -{
    1.11 -    AC_ARG_ENABLE(video-aalib,
    1.12 -AC_HELP_STRING([--enable-video-aalib], [use AAlib video driver [[default=no]]]),
    1.13 -                  , enable_video_aalib=no)
    1.14 -    if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then
    1.15 -        AC_MSG_CHECKING(for AAlib support)
    1.16 -        video_aalib=no
    1.17 -        AC_TRY_COMPILE([
    1.18 -         #include <aalib.h>
    1.19 -        ],[
    1.20 -        ],[
    1.21 -        video_aalib=yes
    1.22 -        ])
    1.23 -        AC_MSG_RESULT($video_aalib)
    1.24 -        if test x$video_aalib = xyes; then
    1.25 -            AC_DEFINE(SDL_VIDEO_DRIVER_AALIB)
    1.26 -            SOURCES="$SOURCES $srcdir/src/video/aalib/*.c"
    1.27 -            EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laa"
    1.28 -            have_video=yes
    1.29 -        fi
    1.30 -    fi
    1.31 -}
    1.32 -
    1.33  dnl Set up the QTopia video driver if enabled
    1.34  CheckQtopia()
    1.35  {
    1.36 @@ -2088,7 +2062,6 @@
    1.37          CheckSVGA
    1.38          CheckVGL
    1.39          CheckWscons
    1.40 -        CheckAAlib
    1.41          CheckQtopia
    1.42          CheckPicoGUI
    1.43          CheckOpenGLX11
     2.1 --- a/include/SDL_config.h.in	Wed Jul 26 03:15:41 2006 +0000
     2.2 +++ b/include/SDL_config.h.in	Wed Jul 26 03:24:27 2006 +0000
     2.3 @@ -249,7 +249,6 @@
     2.4  #undef SDL_TIMER_WINCE
     2.5  
     2.6  /* Enable various video drivers */
     2.7 -#undef SDL_VIDEO_DRIVER_AALIB
     2.8  #undef SDL_VIDEO_DRIVER_BWINDOW
     2.9  #undef SDL_VIDEO_DRIVER_COCOA
    2.10  #undef SDL_VIDEO_DRIVER_CYBERGRAPHICS
     3.1 --- a/src/video/SDL_sysvideo.h	Wed Jul 26 03:15:41 2006 +0000
     3.2 +++ b/src/video/SDL_sysvideo.h	Wed Jul 26 03:24:27 2006 +0000
     3.3 @@ -372,9 +372,6 @@
     3.4  #if SDL_VIDEO_DRIVER_OS2FS
     3.5  extern VideoBootStrap OS2FSLib_bootstrap;
     3.6  #endif
     3.7 -#if SDL_VIDEO_DRIVER_AALIB
     3.8 -extern VideoBootStrap AALIB_bootstrap;
     3.9 -#endif
    3.10  #if SDL_VIDEO_DRIVER_DUMMY
    3.11  extern VideoBootStrap DUMMY_bootstrap;
    3.12  #endif
     4.1 --- a/src/video/SDL_video.c	Wed Jul 26 03:15:41 2006 +0000
     4.2 +++ b/src/video/SDL_video.c	Wed Jul 26 03:24:27 2006 +0000
     4.3 @@ -121,9 +121,6 @@
     4.4  #if SDL_VIDEO_DRIVER_OS2FS
     4.5      &OS2FSLib_bootstrap,
     4.6  #endif
     4.7 -#if SDL_VIDEO_DRIVER_AALIB
     4.8 -    &AALIB_bootstrap,
     4.9 -#endif
    4.10  #if SDL_VIDEO_DRIVER_DUMMY
    4.11      &DUMMY_bootstrap,
    4.12  #endif
     5.1 --- a/src/video/aalib/SDL_aaevents.c	Wed Jul 26 03:15:41 2006 +0000
     5.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.3 @@ -1,213 +0,0 @@
     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 -/* Handle the event stream, converting AA events into SDL events */
    5.28 -
    5.29 -#include <stdio.h>
    5.30 -
    5.31 -#include <aalib.h>
    5.32 -
    5.33 -#include "SDL.h"
    5.34 -#include "../../events/SDL_sysevents.h"
    5.35 -#include "../../events/SDL_events_c.h"
    5.36 -#include "SDL_aavideo.h"
    5.37 -#include "SDL_aaevents_c.h"
    5.38 -
    5.39 -/* The translation tables from a console scancode to a SDL keysym */
    5.40 -static SDLKey keymap[401];
    5.41 -
    5.42 -static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym);
    5.43 -
    5.44 -
    5.45 -void
    5.46 -AA_PumpEvents(_THIS)
    5.47 -{
    5.48 -    int posted = 0;
    5.49 -    int mouse_button, mouse_x, mouse_y;
    5.50 -    int evt;
    5.51 -    SDL_keysym keysym;
    5.52 -
    5.53 -    static int prev_button = -1, prev_x = -1, prev_y = -1;
    5.54 -
    5.55 -    if (!this->screen)          /* Wait till we got the screen initialized */
    5.56 -        return;
    5.57 -
    5.58 -    do {
    5.59 -        posted = 0;
    5.60 -        /* Gather events */
    5.61 -
    5.62 -        /* Get mouse status */
    5.63 -        SDL_mutexP(AA_mutex);
    5.64 -        aa_getmouse(AA_context, &mouse_x, &mouse_y, &mouse_button);
    5.65 -        SDL_mutexV(AA_mutex);
    5.66 -        mouse_x = mouse_x * this->screen->w / aa_scrwidth(AA_context);
    5.67 -        mouse_y = mouse_y * this->screen->h / aa_scrheight(AA_context);
    5.68 -
    5.69 -        /* Compare against previous state and generate events */
    5.70 -        if (prev_button != mouse_button) {
    5.71 -            if (mouse_button & AA_BUTTON1) {
    5.72 -                if (!(prev_button & AA_BUTTON1)) {
    5.73 -                    posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0);
    5.74 -                }
    5.75 -            } else {
    5.76 -                if (prev_button & AA_BUTTON1) {
    5.77 -                    posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0);
    5.78 -                }
    5.79 -            }
    5.80 -            if (mouse_button & AA_BUTTON2) {
    5.81 -                if (!(prev_button & AA_BUTTON2)) {
    5.82 -                    posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0);
    5.83 -                }
    5.84 -            } else {
    5.85 -                if (prev_button & AA_BUTTON2) {
    5.86 -                    posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0);
    5.87 -                }
    5.88 -            }
    5.89 -            if (mouse_button & AA_BUTTON3) {
    5.90 -                if (!(prev_button & AA_BUTTON3)) {
    5.91 -                    posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0);
    5.92 -                }
    5.93 -            } else {
    5.94 -                if (prev_button & AA_BUTTON3) {
    5.95 -                    posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0);
    5.96 -                }
    5.97 -            }
    5.98 -        }
    5.99 -        if (prev_x != mouse_x || prev_y != mouse_y) {
   5.100 -            posted += SDL_PrivateMouseMotion(0, 0, mouse_x, mouse_y);
   5.101 -        }
   5.102 -
   5.103 -        prev_button = mouse_button;
   5.104 -        prev_x = mouse_x;
   5.105 -        prev_y = mouse_y;
   5.106 -
   5.107 -        /* Get keyboard event */
   5.108 -        SDL_mutexP(AA_mutex);
   5.109 -        evt = aa_getevent(AA_context, 0);
   5.110 -        SDL_mutexV(AA_mutex);
   5.111 -        if ((evt > AA_NONE) && (evt < AA_RELEASE) && (evt != AA_MOUSE)
   5.112 -            && (evt != AA_RESIZE)) {
   5.113 -            /* Key pressed */
   5.114 -/*    			printf("Key pressed: %d (%c)\n", evt, evt); */
   5.115 -            posted +=
   5.116 -                SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(evt, &keysym));
   5.117 -        } else if (evt >= AA_RELEASE) {
   5.118 -            /* Key released */
   5.119 -            evt &= ~AA_RELEASE;
   5.120 -/*  			printf("Key released: %d (%c)\n", evt, evt); */
   5.121 -            posted +=
   5.122 -                SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(evt, &keysym));
   5.123 -        }
   5.124 -    }
   5.125 -    while (posted);
   5.126 -}
   5.127 -
   5.128 -void
   5.129 -AA_InitOSKeymap(_THIS)
   5.130 -{
   5.131 -    int i;
   5.132 -    static const char *std_keys =
   5.133 -        " 01234567890&#'()_-|$*+-=/\\:;.,!?<>{}[]@~%^\x9";
   5.134 -    const char *std;
   5.135 -
   5.136 -    /* Initialize the AAlib key translation table */
   5.137 -    for (i = 0; i < SDL_arraysize(keymap); ++i)
   5.138 -        keymap[i] = SDLK_UNKNOWN;
   5.139 -
   5.140 -    /* Alphabet keys */
   5.141 -    for (i = 0; i < 26; ++i) {
   5.142 -        keymap['a' + i] = SDLK_a + i;
   5.143 -        keymap['A' + i] = SDLK_a + i;
   5.144 -    }
   5.145 -    /* Function keys */
   5.146 -    for (i = 0; i < 12; ++i) {
   5.147 -        keymap[334 + i] = SDLK_F1 + i;
   5.148 -    }
   5.149 -    /* Keys that have the same symbols and don't have to be translated */
   5.150 -    for (std = std_keys; *std; std++) {
   5.151 -        keymap[*std] = *std;
   5.152 -    }
   5.153 -
   5.154 -    keymap[13] = SDLK_RETURN;
   5.155 -    keymap[AA_BACKSPACE] = SDLK_BACKSPACE;
   5.156 -
   5.157 -    keymap[369] = SDLK_LSHIFT;
   5.158 -    keymap[370] = SDLK_RSHIFT;
   5.159 -    keymap[371] = SDLK_LCTRL;
   5.160 -    keymap[372] = SDLK_RCTRL;
   5.161 -    keymap[377] = SDLK_LALT;
   5.162 -    keymap[270] = SDLK_RALT;
   5.163 -    keymap[271] = SDLK_NUMLOCK;
   5.164 -    keymap[373] = SDLK_CAPSLOCK;
   5.165 -    keymap[164] = SDLK_SCROLLOCK;
   5.166 -
   5.167 -    keymap[243] = SDLK_INSERT;
   5.168 -    keymap[304] = SDLK_DELETE;
   5.169 -    keymap[224] = SDLK_HOME;
   5.170 -    keymap[231] = SDLK_END;
   5.171 -    keymap[229] = SDLK_PAGEUP;
   5.172 -    keymap[230] = SDLK_PAGEDOWN;
   5.173 -
   5.174 -    keymap[241] = SDLK_PRINT;
   5.175 -    keymap[163] = SDLK_BREAK;
   5.176 -
   5.177 -    keymap[302] = SDLK_KP0;
   5.178 -    keymap[300] = SDLK_KP1;
   5.179 -    keymap[297] = SDLK_KP2;
   5.180 -    keymap[299] = SDLK_KP3;
   5.181 -    keymap[294] = SDLK_KP4;
   5.182 -    keymap[301] = SDLK_KP5;
   5.183 -    keymap[296] = SDLK_KP6;
   5.184 -    keymap[293] = SDLK_KP7;
   5.185 -    keymap[295] = SDLK_KP8;
   5.186 -    keymap[298] = SDLK_KP9;
   5.187 -
   5.188 -    keymap[AA_ESC] = SDLK_ESCAPE;
   5.189 -    keymap[AA_UP] = SDLK_UP;
   5.190 -    keymap[AA_DOWN] = SDLK_DOWN;
   5.191 -    keymap[AA_LEFT] = SDLK_LEFT;
   5.192 -    keymap[AA_RIGHT] = SDLK_RIGHT;
   5.193 -}
   5.194 -
   5.195 -static SDL_keysym *
   5.196 -TranslateKey(int scancode, SDL_keysym * keysym)
   5.197 -{
   5.198 -    /* Sanity check */
   5.199 -    if (scancode >= SDL_arraysize(keymap))
   5.200 -        scancode = AA_UNKNOWN;
   5.201 -
   5.202 -    /* Set the keysym information */
   5.203 -    keysym->scancode = scancode;
   5.204 -    keysym->sym = keymap[scancode];
   5.205 -    keysym->mod = KMOD_NONE;
   5.206 -
   5.207 -    /* If UNICODE is on, get the UNICODE value for the key */
   5.208 -    keysym->unicode = 0;
   5.209 -    if (SDL_TranslateUNICODE) {
   5.210 -        /* Populate the unicode field with the ASCII value */
   5.211 -        keysym->unicode = scancode;
   5.212 -    }
   5.213 -    return (keysym);
   5.214 -}
   5.215 -
   5.216 -/* vi: set ts=4 sw=4 expandtab: */
     6.1 --- a/src/video/aalib/SDL_aaevents_c.h	Wed Jul 26 03:15:41 2006 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,36 +0,0 @@
     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 -#include "SDL_aavideo.h"
    6.28 -
    6.29 -/* Variables and functions exported by SDL_sysevents.c to other parts 
    6.30 -   of the native video subsystem (SDL_sysvideo.c)
    6.31 -*/
    6.32 -extern void AA_initkeymaps(int fd);
    6.33 -extern void AA_mousecallback(int button, int dx, int dy,
    6.34 -                             int u1, int u2, int u3, int u4);
    6.35 -extern void AA_keyboardcallback(int scancode, int pressed);
    6.36 -
    6.37 -extern void AA_InitOSKeymap(_THIS);
    6.38 -extern void AA_PumpEvents(_THIS);
    6.39 -/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/aalib/SDL_aamouse.c	Wed Jul 26 03:15:41 2006 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,37 +0,0 @@
     7.4 -/*
     7.5 -    SDL - Simple DirectMedia Layer
     7.6 -    Copyright (C) 1997-2006 Sam Lantinga
     7.7 -
     7.8 -    This library is free software; you can redistribute it and/or
     7.9 -    modify it under the terms of the GNU Lesser General Public
    7.10 -    License as published by the Free Software Foundation; either
    7.11 -    version 2.1 of the License, or (at your option) any later version.
    7.12 -
    7.13 -    This library is distributed in the hope that it will be useful,
    7.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    7.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    7.16 -    Lesser General Public License for more details.
    7.17 -
    7.18 -    You should have received a copy of the GNU Lesser General Public
    7.19 -    License along with this library; if not, write to the Free Software
    7.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    7.21 -
    7.22 -    Sam Lantinga
    7.23 -    slouken@libsdl.org
    7.24 -*/
    7.25 -#include "SDL_config.h"
    7.26 -
    7.27 -#include <stdio.h>
    7.28 -
    7.29 -#include "SDL_mouse.h"
    7.30 -#include "../../events/SDL_events_c.h"
    7.31 -
    7.32 -#include "SDL_aamouse_c.h"
    7.33 -
    7.34 -
    7.35 -/* The implementation dependent data for the window manager cursor */
    7.36 -struct WMcursor
    7.37 -{
    7.38 -    int unused;
    7.39 -};
    7.40 -/* vi: set ts=4 sw=4 expandtab: */
     8.1 --- a/src/video/aalib/SDL_aamouse_c.h	Wed Jul 26 03:15:41 2006 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,27 +0,0 @@
     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 -#include "SDL_aavideo.h"
    8.28 -
    8.29 -/* Functions to be exported */
    8.30 -/* vi: set ts=4 sw=4 expandtab: */
     9.1 --- a/src/video/aalib/SDL_aavideo.c	Wed Jul 26 03:15:41 2006 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,425 +0,0 @@
     9.4 -/*
     9.5 -    SDL - Simple DirectMedia Layer
     9.6 -    Copyright (C) 1997-2006 Sam Lantinga
     9.7 -
     9.8 -    This library is free software; you can redistribute it and/or
     9.9 -    modify it under the terms of the GNU Lesser General Public
    9.10 -    License as published by the Free Software Foundation; either
    9.11 -    version 2.1 of the License, or (at your option) any later version.
    9.12 -
    9.13 -    This library is distributed in the hope that it will be useful,
    9.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
    9.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    9.16 -    Lesser General Public License for more details.
    9.17 -
    9.18 -    You should have received a copy of the GNU Lesser General Public
    9.19 -    License along with this library; if not, write to the Free Software
    9.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    9.21 -
    9.22 -    Sam Lantinga
    9.23 -    slouken@libsdl.org
    9.24 -*/
    9.25 -#include "SDL_config.h"
    9.26 -
    9.27 -/* AAlib based SDL video driver implementation.
    9.28 -*/
    9.29 -
    9.30 -#include <unistd.h>
    9.31 -#include <sys/stat.h>
    9.32 -
    9.33 -
    9.34 -#include "SDL_video.h"
    9.35 -#include "SDL_mouse.h"
    9.36 -#include "../SDL_sysvideo.h"
    9.37 -#include "../SDL_pixels_c.h"
    9.38 -#include "../../events/SDL_events_c.h"
    9.39 -
    9.40 -#include "SDL_aavideo.h"
    9.41 -#include "SDL_aaevents_c.h"
    9.42 -#include "SDL_aamouse_c.h"
    9.43 -
    9.44 -#include <aalib.h>
    9.45 -
    9.46 -/* Initialization/Query functions */
    9.47 -static int AA_VideoInit(_THIS, SDL_PixelFormat * vformat);
    9.48 -static SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags);
    9.49 -static SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface * current, int width,
    9.50 -                                    int height, int bpp, Uint32 flags);
    9.51 -static int AA_SetColors(_THIS, int firstcolor, int ncolors,
    9.52 -                        SDL_Color * colors);
    9.53 -static void AA_VideoQuit(_THIS);
    9.54 -
    9.55 -/* Hardware surface functions */
    9.56 -static int AA_AllocHWSurface(_THIS, SDL_Surface * surface);
    9.57 -static int AA_LockHWSurface(_THIS, SDL_Surface * surface);
    9.58 -static int AA_FlipHWSurface(_THIS, SDL_Surface * surface);
    9.59 -static void AA_UnlockHWSurface(_THIS, SDL_Surface * surface);
    9.60 -static void AA_FreeHWSurface(_THIS, SDL_Surface * surface);
    9.61 -
    9.62 -/* Cache the VideoDevice struct */
    9.63 -static struct SDL_VideoDevice *local_this;
    9.64 -
    9.65 -/* AAlib driver bootstrap functions */
    9.66 -
    9.67 -static int
    9.68 -AA_Available(void)
    9.69 -{
    9.70 -    return 1;                   /* Always available ! */
    9.71 -}
    9.72 -
    9.73 -static void
    9.74 -AA_DeleteDevice(SDL_VideoDevice * device)
    9.75 -{
    9.76 -    SDL_free(device->hidden);
    9.77 -    SDL_free(device);
    9.78 -}
    9.79 -
    9.80 -static SDL_VideoDevice *
    9.81 -AA_CreateDevice(int devindex)
    9.82 -{
    9.83 -    SDL_VideoDevice *device;
    9.84 -
    9.85 -    /* Initialize all variables that we clean on shutdown */
    9.86 -    device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice));
    9.87 -    if (device) {
    9.88 -        SDL_memset(device, 0, (sizeof *device));
    9.89 -        device->hidden = (struct SDL_PrivateVideoData *)
    9.90 -            SDL_malloc((sizeof *device->hidden));
    9.91 -    }
    9.92 -    if ((device == NULL) || (device->hidden == NULL)) {
    9.93 -        SDL_OutOfMemory();
    9.94 -        if (device) {
    9.95 -            SDL_free(device);
    9.96 -        }
    9.97 -        return (0);
    9.98 -    }
    9.99 -    SDL_memset(device->hidden, 0, (sizeof *device->hidden));
   9.100 -
   9.101 -    /* Set the function pointers */
   9.102 -    device->VideoInit = AA_VideoInit;
   9.103 -    device->ListModes = AA_ListModes;
   9.104 -    device->SetVideoMode = AA_SetVideoMode;
   9.105 -    device->CreateYUVOverlay = NULL;
   9.106 -    device->SetColors = AA_SetColors;
   9.107 -    device->UpdateRects = NULL;
   9.108 -    device->VideoQuit = AA_VideoQuit;
   9.109 -    device->AllocHWSurface = AA_AllocHWSurface;
   9.110 -    device->CheckHWBlit = NULL;
   9.111 -    device->FillHWRect = NULL;
   9.112 -    device->SetHWColorKey = NULL;
   9.113 -    device->SetHWAlpha = NULL;
   9.114 -    device->LockHWSurface = AA_LockHWSurface;
   9.115 -    device->UnlockHWSurface = AA_UnlockHWSurface;
   9.116 -    device->FlipHWSurface = NULL;
   9.117 -    device->FreeHWSurface = AA_FreeHWSurface;
   9.118 -    device->SetCaption = NULL;
   9.119 -    device->SetIcon = NULL;
   9.120 -    device->IconifyWindow = NULL;
   9.121 -    device->GrabInput = NULL;
   9.122 -    device->GetWMInfo = NULL;
   9.123 -    device->InitOSKeymap = AA_InitOSKeymap;
   9.124 -    device->PumpEvents = AA_PumpEvents;
   9.125 -
   9.126 -    device->free = AA_DeleteDevice;
   9.127 -
   9.128 -    return device;
   9.129 -}
   9.130 -
   9.131 -VideoBootStrap AALIB_bootstrap = {
   9.132 -    "aalib", "ASCII Art Library",
   9.133 -    AA_Available, AA_CreateDevice
   9.134 -};
   9.135 -
   9.136 -static void AA_ResizeHandler(aa_context *);
   9.137 -
   9.138 -int
   9.139 -AA_VideoInit(_THIS, SDL_PixelFormat * vformat)
   9.140 -{
   9.141 -    int keyboard;
   9.142 -    int i;
   9.143 -
   9.144 -    /* Initialize all variables that we clean on shutdown */
   9.145 -    for (i = 0; i < SDL_NUMMODES; ++i) {
   9.146 -        SDL_modelist[i] = SDL_malloc(sizeof(SDL_Rect));
   9.147 -        SDL_modelist[i]->x = SDL_modelist[i]->y = 0;
   9.148 -    }
   9.149 -    /* Modes sorted largest to smallest */
   9.150 -    SDL_modelist[0]->w = 1024;
   9.151 -    SDL_modelist[0]->h = 768;
   9.152 -    SDL_modelist[1]->w = 800;
   9.153 -    SDL_modelist[1]->h = 600;
   9.154 -    SDL_modelist[2]->w = 640;
   9.155 -    SDL_modelist[2]->h = 480;
   9.156 -    SDL_modelist[3]->w = 320;
   9.157 -    SDL_modelist[3]->h = 400;
   9.158 -    SDL_modelist[4]->w = 320;
   9.159 -    SDL_modelist[4]->h = 240;
   9.160 -    SDL_modelist[5]->w = 320;
   9.161 -    SDL_modelist[5]->h = 200;
   9.162 -    SDL_modelist[6] = NULL;
   9.163 -
   9.164 -    /* Initialize the library */
   9.165 -
   9.166 -    AA_mutex = SDL_CreateMutex();
   9.167 -
   9.168 -    aa_parseoptions(NULL, NULL, NULL, NULL);
   9.169 -
   9.170 -    AA_context = aa_autoinit(&aa_defparams);
   9.171 -    if (!AA_context) {
   9.172 -        SDL_SetError("Unable to initialize AAlib");
   9.173 -        return (-1);
   9.174 -    }
   9.175 -
   9.176 -    /* Enable mouse and keyboard support */
   9.177 -
   9.178 -    if (!aa_autoinitkbd(AA_context, AA_SENDRELEASE)) {
   9.179 -        SDL_SetError("Unable to initialize AAlib keyboard");
   9.180 -        return (-1);
   9.181 -    }
   9.182 -    if (!aa_autoinitmouse(AA_context, AA_SENDRELEASE)) {
   9.183 -        fprintf(stderr, "Warning: Unable to initialize AAlib mouse");
   9.184 -    }
   9.185 -    AA_rparams = aa_getrenderparams();
   9.186 -
   9.187 -    local_this = this;
   9.188 -
   9.189 -    aa_resizehandler(AA_context, AA_ResizeHandler);
   9.190 -
   9.191 -    fprintf(stderr, "Using AAlib driver: %s (%s)\n",
   9.192 -            AA_context->driver->name, AA_context->driver->shortname);
   9.193 -
   9.194 -    AA_in_x11 = (SDL_strcmp(AA_context->driver->shortname, "X11") == 0);
   9.195 -    /* Determine the screen depth (use default 8-bit depth) */
   9.196 -    vformat->BitsPerPixel = 8;
   9.197 -    vformat->BytesPerPixel = 1;
   9.198 -
   9.199 -    /* We're done! */
   9.200 -    return (0);
   9.201 -}
   9.202 -
   9.203 -SDL_Rect **
   9.204 -AA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags)
   9.205 -{
   9.206 -    if (format->BitsPerPixel != 8)
   9.207 -        return NULL;
   9.208 -
   9.209 -    if (flags & SDL_FULLSCREEN) {
   9.210 -        return SDL_modelist;
   9.211 -    } else {
   9.212 -        return (SDL_Rect **) - 1;
   9.213 -    }
   9.214 -}
   9.215 -
   9.216 -/* From aavga.c
   9.217 -   AAlib does not give us the choice of the actual resolution, thus we have to simulate additional
   9.218 -   resolution by scaling down manually each frame
   9.219 -*/
   9.220 -static void
   9.221 -fastscale(register char *b1, register char *b2, int x1, int x2, int y1,
   9.222 -          int y2)
   9.223 -{
   9.224 -    register int ex, spx = 0, ddx, ddx1;
   9.225 -    int ddy1, ddy, spy = 0, ey;
   9.226 -    int x;
   9.227 -    char *bb1 = b1;
   9.228 -    if (!x1 || !x2 || !y1 || !y2)
   9.229 -        return;
   9.230 -    ddx = x1 + x1;
   9.231 -    ddx1 = x2 + x2;
   9.232 -    if (ddx1 < ddx)
   9.233 -        spx = ddx / ddx1, ddx %= ddx1;
   9.234 -    ddy = y1 + y1;
   9.235 -    ddy1 = y2 + y2;
   9.236 -    if (ddy1 < ddy)
   9.237 -        spy = (ddy / ddy1) * x1, ddy %= ddy1;
   9.238 -    ey = -ddy1;
   9.239 -    for (; y2; y2--) {
   9.240 -        ex = -ddx1;
   9.241 -        for (x = x2; x; x--) {
   9.242 -            *b2 = *b1;
   9.243 -            b2++;
   9.244 -            b1 += spx;
   9.245 -            ex += ddx;
   9.246 -            if (ex > 0) {
   9.247 -                b1++;
   9.248 -                ex -= ddx1;
   9.249 -            }
   9.250 -        }
   9.251 -        bb1 += spy;
   9.252 -        ey += ddy;
   9.253 -        if (ey > 0) {
   9.254 -            bb1 += x1;
   9.255 -            ey -= ddy1;
   9.256 -        }
   9.257 -        b1 = bb1;
   9.258 -    }
   9.259 -}
   9.260 -
   9.261 -/* Various screen update functions available */
   9.262 -static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects);
   9.263 -
   9.264 -SDL_Surface *
   9.265 -AA_SetVideoMode(_THIS, SDL_Surface * current,
   9.266 -                int width, int height, int bpp, Uint32 flags)
   9.267 -{
   9.268 -    int mode;
   9.269 -
   9.270 -    if (AA_buffer) {
   9.271 -        SDL_free(AA_buffer);
   9.272 -    }
   9.273 -
   9.274 -    AA_buffer = SDL_malloc(width * height);
   9.275 -    if (!AA_buffer) {
   9.276 -        SDL_SetError("Couldn't allocate buffer for requested mode");
   9.277 -        return (NULL);
   9.278 -    }
   9.279 -
   9.280 -/* 	printf("Setting mode %dx%d\n", width, height); */
   9.281 -
   9.282 -    SDL_memset(aa_image(AA_context), 0,
   9.283 -               aa_imgwidth(AA_context) * aa_imgheight(AA_context));
   9.284 -    SDL_memset(AA_buffer, 0, width * height);
   9.285 -
   9.286 -    /* Allocate the new pixel format for the screen */
   9.287 -    if (!SDL_ReallocFormat(current, 8, 0, 0, 0, 0)) {
   9.288 -        return (NULL);
   9.289 -    }
   9.290 -
   9.291 -    /* Set up the new mode framebuffer */
   9.292 -    current->flags = SDL_FULLSCREEN;
   9.293 -    AA_w = current->w = width;
   9.294 -    AA_h = current->h = height;
   9.295 -    current->pitch = current->w;
   9.296 -    current->pixels = AA_buffer;
   9.297 -
   9.298 -    AA_x_ratio = ((double) aa_imgwidth(AA_context)) / ((double) width);
   9.299 -    AA_y_ratio = ((double) aa_imgheight(AA_context)) / ((double) height);
   9.300 -
   9.301 -    /* Set the blit function */
   9.302 -    this->UpdateRects = AA_DirectUpdate;
   9.303 -
   9.304 -    /* We're done */
   9.305 -    return (current);
   9.306 -}
   9.307 -
   9.308 -static void
   9.309 -AA_ResizeHandler(aa_context * context)
   9.310 -{
   9.311 -    aa_resize(context);
   9.312 -    local_this->hidden->x_ratio =
   9.313 -        ((double) aa_imgwidth(context)) / ((double) local_this->screen->w);
   9.314 -    local_this->hidden->y_ratio =
   9.315 -        ((double) aa_imgheight(context)) / ((double) local_this->screen->h);
   9.316 -
   9.317 -    fastscale(local_this->hidden->buffer, aa_image(context),
   9.318 -              local_this->hidden->w, aa_imgwidth(context),
   9.319 -              local_this->hidden->h, aa_imgheight(context));
   9.320 -    aa_renderpalette(context, local_this->hidden->palette,
   9.321 -                     local_this->hidden->rparams, 0, 0,
   9.322 -                     aa_scrwidth(context), aa_scrheight(context));
   9.323 -    aa_flush(context);
   9.324 -}
   9.325 -
   9.326 -/* We don't actually allow hardware surfaces other than the main one */
   9.327 -static int
   9.328 -AA_AllocHWSurface(_THIS, SDL_Surface * surface)
   9.329 -{
   9.330 -    return (-1);
   9.331 -}
   9.332 -static void
   9.333 -AA_FreeHWSurface(_THIS, SDL_Surface * surface)
   9.334 -{
   9.335 -    return;
   9.336 -}
   9.337 -
   9.338 -/* We need to wait for vertical retrace on page flipped displays */
   9.339 -static int
   9.340 -AA_LockHWSurface(_THIS, SDL_Surface * surface)
   9.341 -{
   9.342 -    /* TODO ? */
   9.343 -    return (0);
   9.344 -}
   9.345 -static void
   9.346 -AA_UnlockHWSurface(_THIS, SDL_Surface * surface)
   9.347 -{
   9.348 -    return;
   9.349 -}
   9.350 -
   9.351 -/* FIXME: How is this done with AAlib? */
   9.352 -static int
   9.353 -AA_FlipHWSurface(_THIS, SDL_Surface * surface)
   9.354 -{
   9.355 -    SDL_mutexP(AA_mutex);
   9.356 -    aa_flush(AA_context);
   9.357 -    SDL_mutexV(AA_mutex);
   9.358 -    return (0);
   9.359 -}
   9.360 -
   9.361 -static void
   9.362 -AA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects)
   9.363 -{
   9.364 -    int i;
   9.365 -    SDL_Rect *rect;
   9.366 -
   9.367 -    fastscale(AA_buffer, aa_image(AA_context), AA_w,
   9.368 -              aa_imgwidth(AA_context), AA_h, aa_imgheight(AA_context));
   9.369 -#if 1
   9.370 -    aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0,
   9.371 -                     aa_scrwidth(AA_context), aa_scrheight(AA_context));
   9.372 -#else
   9.373 -    /* Render only the rectangles in the list */
   9.374 -    printf("Update rects : ");
   9.375 -    for (i = 0; i < numrects; ++i) {
   9.376 -        rect = &rects[i];
   9.377 -        printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h);
   9.378 -        aa_renderpalette(AA_context, AA_palette, AA_rparams,
   9.379 -                         rect->x * AA_x_ratio, rect->y * AA_y_ratio,
   9.380 -                         rect->w * AA_x_ratio, rect->h * AA_y_ratio);
   9.381 -    }
   9.382 -    printf("\n");
   9.383 -#endif
   9.384 -    SDL_mutexP(AA_mutex);
   9.385 -    aa_flush(AA_context);
   9.386 -    SDL_mutexV(AA_mutex);
   9.387 -    return;
   9.388 -}
   9.389 -
   9.390 -int
   9.391 -AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors)
   9.392 -{
   9.393 -    int i;
   9.394 -
   9.395 -    for (i = 0; i < ncolors; i++) {
   9.396 -        aa_setpalette(AA_palette, firstcolor + i,
   9.397 -                      colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2);
   9.398 -    }
   9.399 -    return (1);
   9.400 -}
   9.401 -
   9.402 -/* Note:  If we are terminated, this could be called in the middle of
   9.403 -   another SDL video routine -- notably UpdateRects.
   9.404 -*/
   9.405 -void
   9.406 -AA_VideoQuit(_THIS)
   9.407 -{
   9.408 -    int i;
   9.409 -
   9.410 -    aa_uninitkbd(AA_context);
   9.411 -    aa_uninitmouse(AA_context);
   9.412 -
   9.413 -    /* Free video mode lists */
   9.414 -    for (i = 0; i < SDL_NUMMODES; ++i) {
   9.415 -        if (SDL_modelist[i] != NULL) {
   9.416 -            SDL_free(SDL_modelist[i]);
   9.417 -            SDL_modelist[i] = NULL;
   9.418 -        }
   9.419 -    }
   9.420 -
   9.421 -    aa_close(AA_context);
   9.422 -
   9.423 -    SDL_DestroyMutex(AA_mutex);
   9.424 -
   9.425 -    this->screen->pixels = NULL;
   9.426 -}
   9.427 -
   9.428 -/* vi: set ts=4 sw=4 expandtab: */
    10.1 --- a/src/video/aalib/SDL_aavideo.h	Wed Jul 26 03:15:41 2006 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,68 +0,0 @@
    10.4 -/*
    10.5 -    SDL - Simple DirectMedia Layer
    10.6 -    Copyright (C) 1997-2006 Sam Lantinga
    10.7 -
    10.8 -    This library is free software; you can redistribute it and/or
    10.9 -    modify it under the terms of the GNU Lesser General Public
   10.10 -    License as published by the Free Software Foundation; either
   10.11 -    version 2.1 of the License, or (at your option) any later version.
   10.12 -
   10.13 -    This library is distributed in the hope that it will be useful,
   10.14 -    but WITHOUT ANY WARRANTY; without even the implied warranty of
   10.15 -    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
   10.16 -    Lesser General Public License for more details.
   10.17 -
   10.18 -    You should have received a copy of the GNU Lesser General Public
   10.19 -    License along with this library; if not, write to the Free Software
   10.20 -    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
   10.21 -
   10.22 -    Sam Lantinga
   10.23 -    slouken@libsdl.org
   10.24 -*/
   10.25 -#include "SDL_config.h"
   10.26 -
   10.27 -#ifndef _SDL_aavideo_h
   10.28 -#define _SDL_aavideo_h
   10.29 -
   10.30 -#include "SDL_mouse.h"
   10.31 -#include "SDL_mutex.h"
   10.32 -#include "../SDL_sysvideo.h"
   10.33 -
   10.34 -#include <aalib.h>
   10.35 -
   10.36 -/* Hidden "this" pointer for the video functions */
   10.37 -#define _THIS	SDL_VideoDevice *this
   10.38 -
   10.39 -#define SDL_NUMMODES 6
   10.40 -
   10.41 -/* Private display data */
   10.42 -struct SDL_PrivateVideoData
   10.43 -{
   10.44 -    SDL_Rect *SDL_modelist[SDL_NUMMODES + 1];
   10.45 -    aa_context *context;
   10.46 -    aa_palette palette;
   10.47 -    aa_renderparams *rparams;
   10.48 -    double x_ratio, y_ratio;
   10.49 -    int w, h;
   10.50 -    SDL_mutex *mutex;
   10.51 -    int in_x11;
   10.52 -    void *buffer;
   10.53 -};
   10.54 -
   10.55 -/* Old variable names */
   10.56 -#define SDL_modelist		(this->hidden->SDL_modelist)
   10.57 -#define AA_context		    (this->hidden->context)
   10.58 -#define AA_palette		    (this->hidden->palette)
   10.59 -#define AA_rparams		    (this->hidden->rparams)
   10.60 -#define AA_buffer		    (this->hidden->buffer)
   10.61 -
   10.62 -#define AA_x_ratio		    (this->hidden->x_ratio)
   10.63 -#define AA_y_ratio		    (this->hidden->y_ratio)
   10.64 -
   10.65 -#define AA_mutex		    (this->hidden->mutex)
   10.66 -#define AA_in_x11		    (this->hidden->in_x11)
   10.67 -#define AA_w                (this->hidden->w)
   10.68 -#define AA_h                (this->hidden->h)
   10.69 -
   10.70 -#endif /* _SDL_aavideo_h */
   10.71 -/* vi: set ts=4 sw=4 expandtab: */