Mercurial > sdl-ios-xcode
changeset 1944:91f41fc124a7
The AAlib driver is fun, but not worth rewriting for SDL 1.3
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 26 Jul 2006 03:24:27 +0000 |
parents | 7d642361ef0f |
children | 3182150b470f |
files | 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 |
diffstat | 10 files changed, 0 insertions(+), 840 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.in Wed Jul 26 03:15:41 2006 +0000 +++ b/configure.in Wed Jul 26 03:24:27 2006 +0000 @@ -1268,32 +1268,6 @@ fi } - -dnl Find the AAlib includes -CheckAAlib() -{ - AC_ARG_ENABLE(video-aalib, -AC_HELP_STRING([--enable-video-aalib], [use AAlib video driver [[default=no]]]), - , enable_video_aalib=no) - if test x$enable_video = xyes -a x$enable_video_aalib = xyes; then - AC_MSG_CHECKING(for AAlib support) - video_aalib=no - AC_TRY_COMPILE([ - #include <aalib.h> - ],[ - ],[ - video_aalib=yes - ]) - AC_MSG_RESULT($video_aalib) - if test x$video_aalib = xyes; then - AC_DEFINE(SDL_VIDEO_DRIVER_AALIB) - SOURCES="$SOURCES $srcdir/src/video/aalib/*.c" - EXTRA_LDFLAGS="$EXTRA_LDFLAGS -laa" - have_video=yes - fi - fi -} - dnl Set up the QTopia video driver if enabled CheckQtopia() { @@ -2088,7 +2062,6 @@ CheckSVGA CheckVGL CheckWscons - CheckAAlib CheckQtopia CheckPicoGUI CheckOpenGLX11
--- a/include/SDL_config.h.in Wed Jul 26 03:15:41 2006 +0000 +++ b/include/SDL_config.h.in Wed Jul 26 03:24:27 2006 +0000 @@ -249,7 +249,6 @@ #undef SDL_TIMER_WINCE /* Enable various video drivers */ -#undef SDL_VIDEO_DRIVER_AALIB #undef SDL_VIDEO_DRIVER_BWINDOW #undef SDL_VIDEO_DRIVER_COCOA #undef SDL_VIDEO_DRIVER_CYBERGRAPHICS
--- a/src/video/SDL_sysvideo.h Wed Jul 26 03:15:41 2006 +0000 +++ b/src/video/SDL_sysvideo.h Wed Jul 26 03:24:27 2006 +0000 @@ -372,9 +372,6 @@ #if SDL_VIDEO_DRIVER_OS2FS extern VideoBootStrap OS2FSLib_bootstrap; #endif -#if SDL_VIDEO_DRIVER_AALIB -extern VideoBootStrap AALIB_bootstrap; -#endif #if SDL_VIDEO_DRIVER_DUMMY extern VideoBootStrap DUMMY_bootstrap; #endif
--- a/src/video/SDL_video.c Wed Jul 26 03:15:41 2006 +0000 +++ b/src/video/SDL_video.c Wed Jul 26 03:24:27 2006 +0000 @@ -121,9 +121,6 @@ #if SDL_VIDEO_DRIVER_OS2FS &OS2FSLib_bootstrap, #endif -#if SDL_VIDEO_DRIVER_AALIB - &AALIB_bootstrap, -#endif #if SDL_VIDEO_DRIVER_DUMMY &DUMMY_bootstrap, #endif
--- a/src/video/aalib/SDL_aaevents.c Wed Jul 26 03:15:41 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,213 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* Handle the event stream, converting AA events into SDL events */ - -#include <stdio.h> - -#include <aalib.h> - -#include "SDL.h" -#include "../../events/SDL_sysevents.h" -#include "../../events/SDL_events_c.h" -#include "SDL_aavideo.h" -#include "SDL_aaevents_c.h" - -/* The translation tables from a console scancode to a SDL keysym */ -static SDLKey keymap[401]; - -static SDL_keysym *TranslateKey(int scancode, SDL_keysym * keysym); - - -void -AA_PumpEvents(_THIS) -{ - int posted = 0; - int mouse_button, mouse_x, mouse_y; - int evt; - SDL_keysym keysym; - - static int prev_button = -1, prev_x = -1, prev_y = -1; - - if (!this->screen) /* Wait till we got the screen initialized */ - return; - - do { - posted = 0; - /* Gather events */ - - /* Get mouse status */ - SDL_mutexP(AA_mutex); - aa_getmouse(AA_context, &mouse_x, &mouse_y, &mouse_button); - SDL_mutexV(AA_mutex); - mouse_x = mouse_x * this->screen->w / aa_scrwidth(AA_context); - mouse_y = mouse_y * this->screen->h / aa_scrheight(AA_context); - - /* Compare against previous state and generate events */ - if (prev_button != mouse_button) { - if (mouse_button & AA_BUTTON1) { - if (!(prev_button & AA_BUTTON1)) { - posted += SDL_PrivateMouseButton(SDL_PRESSED, 1, 0, 0); - } - } else { - if (prev_button & AA_BUTTON1) { - posted += SDL_PrivateMouseButton(SDL_RELEASED, 1, 0, 0); - } - } - if (mouse_button & AA_BUTTON2) { - if (!(prev_button & AA_BUTTON2)) { - posted += SDL_PrivateMouseButton(SDL_PRESSED, 2, 0, 0); - } - } else { - if (prev_button & AA_BUTTON2) { - posted += SDL_PrivateMouseButton(SDL_RELEASED, 2, 0, 0); - } - } - if (mouse_button & AA_BUTTON3) { - if (!(prev_button & AA_BUTTON3)) { - posted += SDL_PrivateMouseButton(SDL_PRESSED, 3, 0, 0); - } - } else { - if (prev_button & AA_BUTTON3) { - posted += SDL_PrivateMouseButton(SDL_RELEASED, 3, 0, 0); - } - } - } - if (prev_x != mouse_x || prev_y != mouse_y) { - posted += SDL_PrivateMouseMotion(0, 0, mouse_x, mouse_y); - } - - prev_button = mouse_button; - prev_x = mouse_x; - prev_y = mouse_y; - - /* Get keyboard event */ - SDL_mutexP(AA_mutex); - evt = aa_getevent(AA_context, 0); - SDL_mutexV(AA_mutex); - if ((evt > AA_NONE) && (evt < AA_RELEASE) && (evt != AA_MOUSE) - && (evt != AA_RESIZE)) { - /* Key pressed */ -/* printf("Key pressed: %d (%c)\n", evt, evt); */ - posted += - SDL_PrivateKeyboard(SDL_PRESSED, TranslateKey(evt, &keysym)); - } else if (evt >= AA_RELEASE) { - /* Key released */ - evt &= ~AA_RELEASE; -/* printf("Key released: %d (%c)\n", evt, evt); */ - posted += - SDL_PrivateKeyboard(SDL_RELEASED, TranslateKey(evt, &keysym)); - } - } - while (posted); -} - -void -AA_InitOSKeymap(_THIS) -{ - int i; - static const char *std_keys = - " 01234567890&#'()_-|$*+-=/\\:;.,!?<>{}[]@~%^\x9"; - const char *std; - - /* Initialize the AAlib key translation table */ - for (i = 0; i < SDL_arraysize(keymap); ++i) - keymap[i] = SDLK_UNKNOWN; - - /* Alphabet keys */ - for (i = 0; i < 26; ++i) { - keymap['a' + i] = SDLK_a + i; - keymap['A' + i] = SDLK_a + i; - } - /* Function keys */ - for (i = 0; i < 12; ++i) { - keymap[334 + i] = SDLK_F1 + i; - } - /* Keys that have the same symbols and don't have to be translated */ - for (std = std_keys; *std; std++) { - keymap[*std] = *std; - } - - keymap[13] = SDLK_RETURN; - keymap[AA_BACKSPACE] = SDLK_BACKSPACE; - - keymap[369] = SDLK_LSHIFT; - keymap[370] = SDLK_RSHIFT; - keymap[371] = SDLK_LCTRL; - keymap[372] = SDLK_RCTRL; - keymap[377] = SDLK_LALT; - keymap[270] = SDLK_RALT; - keymap[271] = SDLK_NUMLOCK; - keymap[373] = SDLK_CAPSLOCK; - keymap[164] = SDLK_SCROLLOCK; - - keymap[243] = SDLK_INSERT; - keymap[304] = SDLK_DELETE; - keymap[224] = SDLK_HOME; - keymap[231] = SDLK_END; - keymap[229] = SDLK_PAGEUP; - keymap[230] = SDLK_PAGEDOWN; - - keymap[241] = SDLK_PRINT; - keymap[163] = SDLK_BREAK; - - keymap[302] = SDLK_KP0; - keymap[300] = SDLK_KP1; - keymap[297] = SDLK_KP2; - keymap[299] = SDLK_KP3; - keymap[294] = SDLK_KP4; - keymap[301] = SDLK_KP5; - keymap[296] = SDLK_KP6; - keymap[293] = SDLK_KP7; - keymap[295] = SDLK_KP8; - keymap[298] = SDLK_KP9; - - keymap[AA_ESC] = SDLK_ESCAPE; - keymap[AA_UP] = SDLK_UP; - keymap[AA_DOWN] = SDLK_DOWN; - keymap[AA_LEFT] = SDLK_LEFT; - keymap[AA_RIGHT] = SDLK_RIGHT; -} - -static SDL_keysym * -TranslateKey(int scancode, SDL_keysym * keysym) -{ - /* Sanity check */ - if (scancode >= SDL_arraysize(keymap)) - scancode = AA_UNKNOWN; - - /* Set the keysym information */ - keysym->scancode = scancode; - keysym->sym = keymap[scancode]; - keysym->mod = KMOD_NONE; - - /* If UNICODE is on, get the UNICODE value for the key */ - keysym->unicode = 0; - if (SDL_TranslateUNICODE) { - /* Populate the unicode field with the ASCII value */ - keysym->unicode = scancode; - } - return (keysym); -} - -/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/aalib/SDL_aaevents_c.h Wed Jul 26 03:15:41 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,36 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_aavideo.h" - -/* Variables and functions exported by SDL_sysevents.c to other parts - of the native video subsystem (SDL_sysvideo.c) -*/ -extern void AA_initkeymaps(int fd); -extern void AA_mousecallback(int button, int dx, int dy, - int u1, int u2, int u3, int u4); -extern void AA_keyboardcallback(int scancode, int pressed); - -extern void AA_InitOSKeymap(_THIS); -extern void AA_PumpEvents(_THIS); -/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/aalib/SDL_aamouse.c Wed Jul 26 03:15:41 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,37 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include <stdio.h> - -#include "SDL_mouse.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_aamouse_c.h" - - -/* The implementation dependent data for the window manager cursor */ -struct WMcursor -{ - int unused; -}; -/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/aalib/SDL_aamouse_c.h Wed Jul 26 03:15:41 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,27 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#include "SDL_aavideo.h" - -/* Functions to be exported */ -/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/aalib/SDL_aavideo.c Wed Jul 26 03:15:41 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,425 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -/* AAlib based SDL video driver implementation. -*/ - -#include <unistd.h> -#include <sys/stat.h> - - -#include "SDL_video.h" -#include "SDL_mouse.h" -#include "../SDL_sysvideo.h" -#include "../SDL_pixels_c.h" -#include "../../events/SDL_events_c.h" - -#include "SDL_aavideo.h" -#include "SDL_aaevents_c.h" -#include "SDL_aamouse_c.h" - -#include <aalib.h> - -/* Initialization/Query functions */ -static int AA_VideoInit(_THIS, SDL_PixelFormat * vformat); -static SDL_Rect **AA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags); -static SDL_Surface *AA_SetVideoMode(_THIS, SDL_Surface * current, int width, - int height, int bpp, Uint32 flags); -static int AA_SetColors(_THIS, int firstcolor, int ncolors, - SDL_Color * colors); -static void AA_VideoQuit(_THIS); - -/* Hardware surface functions */ -static int AA_AllocHWSurface(_THIS, SDL_Surface * surface); -static int AA_LockHWSurface(_THIS, SDL_Surface * surface); -static int AA_FlipHWSurface(_THIS, SDL_Surface * surface); -static void AA_UnlockHWSurface(_THIS, SDL_Surface * surface); -static void AA_FreeHWSurface(_THIS, SDL_Surface * surface); - -/* Cache the VideoDevice struct */ -static struct SDL_VideoDevice *local_this; - -/* AAlib driver bootstrap functions */ - -static int -AA_Available(void) -{ - return 1; /* Always available ! */ -} - -static void -AA_DeleteDevice(SDL_VideoDevice * device) -{ - SDL_free(device->hidden); - SDL_free(device); -} - -static SDL_VideoDevice * -AA_CreateDevice(int devindex) -{ - SDL_VideoDevice *device; - - /* Initialize all variables that we clean on shutdown */ - device = (SDL_VideoDevice *) SDL_malloc(sizeof(SDL_VideoDevice)); - if (device) { - SDL_memset(device, 0, (sizeof *device)); - device->hidden = (struct SDL_PrivateVideoData *) - SDL_malloc((sizeof *device->hidden)); - } - if ((device == NULL) || (device->hidden == NULL)) { - SDL_OutOfMemory(); - if (device) { - SDL_free(device); - } - return (0); - } - SDL_memset(device->hidden, 0, (sizeof *device->hidden)); - - /* Set the function pointers */ - device->VideoInit = AA_VideoInit; - device->ListModes = AA_ListModes; - device->SetVideoMode = AA_SetVideoMode; - device->CreateYUVOverlay = NULL; - device->SetColors = AA_SetColors; - device->UpdateRects = NULL; - device->VideoQuit = AA_VideoQuit; - device->AllocHWSurface = AA_AllocHWSurface; - device->CheckHWBlit = NULL; - device->FillHWRect = NULL; - device->SetHWColorKey = NULL; - device->SetHWAlpha = NULL; - device->LockHWSurface = AA_LockHWSurface; - device->UnlockHWSurface = AA_UnlockHWSurface; - device->FlipHWSurface = NULL; - device->FreeHWSurface = AA_FreeHWSurface; - device->SetCaption = NULL; - device->SetIcon = NULL; - device->IconifyWindow = NULL; - device->GrabInput = NULL; - device->GetWMInfo = NULL; - device->InitOSKeymap = AA_InitOSKeymap; - device->PumpEvents = AA_PumpEvents; - - device->free = AA_DeleteDevice; - - return device; -} - -VideoBootStrap AALIB_bootstrap = { - "aalib", "ASCII Art Library", - AA_Available, AA_CreateDevice -}; - -static void AA_ResizeHandler(aa_context *); - -int -AA_VideoInit(_THIS, SDL_PixelFormat * vformat) -{ - int keyboard; - int i; - - /* Initialize all variables that we clean on shutdown */ - for (i = 0; i < SDL_NUMMODES; ++i) { - SDL_modelist[i] = SDL_malloc(sizeof(SDL_Rect)); - SDL_modelist[i]->x = SDL_modelist[i]->y = 0; - } - /* Modes sorted largest to smallest */ - SDL_modelist[0]->w = 1024; - SDL_modelist[0]->h = 768; - SDL_modelist[1]->w = 800; - SDL_modelist[1]->h = 600; - SDL_modelist[2]->w = 640; - SDL_modelist[2]->h = 480; - SDL_modelist[3]->w = 320; - SDL_modelist[3]->h = 400; - SDL_modelist[4]->w = 320; - SDL_modelist[4]->h = 240; - SDL_modelist[5]->w = 320; - SDL_modelist[5]->h = 200; - SDL_modelist[6] = NULL; - - /* Initialize the library */ - - AA_mutex = SDL_CreateMutex(); - - aa_parseoptions(NULL, NULL, NULL, NULL); - - AA_context = aa_autoinit(&aa_defparams); - if (!AA_context) { - SDL_SetError("Unable to initialize AAlib"); - return (-1); - } - - /* Enable mouse and keyboard support */ - - if (!aa_autoinitkbd(AA_context, AA_SENDRELEASE)) { - SDL_SetError("Unable to initialize AAlib keyboard"); - return (-1); - } - if (!aa_autoinitmouse(AA_context, AA_SENDRELEASE)) { - fprintf(stderr, "Warning: Unable to initialize AAlib mouse"); - } - AA_rparams = aa_getrenderparams(); - - local_this = this; - - aa_resizehandler(AA_context, AA_ResizeHandler); - - fprintf(stderr, "Using AAlib driver: %s (%s)\n", - AA_context->driver->name, AA_context->driver->shortname); - - AA_in_x11 = (SDL_strcmp(AA_context->driver->shortname, "X11") == 0); - /* Determine the screen depth (use default 8-bit depth) */ - vformat->BitsPerPixel = 8; - vformat->BytesPerPixel = 1; - - /* We're done! */ - return (0); -} - -SDL_Rect ** -AA_ListModes(_THIS, SDL_PixelFormat * format, Uint32 flags) -{ - if (format->BitsPerPixel != 8) - return NULL; - - if (flags & SDL_FULLSCREEN) { - return SDL_modelist; - } else { - return (SDL_Rect **) - 1; - } -} - -/* From aavga.c - AAlib does not give us the choice of the actual resolution, thus we have to simulate additional - resolution by scaling down manually each frame -*/ -static void -fastscale(register char *b1, register char *b2, int x1, int x2, int y1, - int y2) -{ - register int ex, spx = 0, ddx, ddx1; - int ddy1, ddy, spy = 0, ey; - int x; - char *bb1 = b1; - if (!x1 || !x2 || !y1 || !y2) - return; - ddx = x1 + x1; - ddx1 = x2 + x2; - if (ddx1 < ddx) - spx = ddx / ddx1, ddx %= ddx1; - ddy = y1 + y1; - ddy1 = y2 + y2; - if (ddy1 < ddy) - spy = (ddy / ddy1) * x1, ddy %= ddy1; - ey = -ddy1; - for (; y2; y2--) { - ex = -ddx1; - for (x = x2; x; x--) { - *b2 = *b1; - b2++; - b1 += spx; - ex += ddx; - if (ex > 0) { - b1++; - ex -= ddx1; - } - } - bb1 += spy; - ey += ddy; - if (ey > 0) { - bb1 += x1; - ey -= ddy1; - } - b1 = bb1; - } -} - -/* Various screen update functions available */ -static void AA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects); - -SDL_Surface * -AA_SetVideoMode(_THIS, SDL_Surface * current, - int width, int height, int bpp, Uint32 flags) -{ - int mode; - - if (AA_buffer) { - SDL_free(AA_buffer); - } - - AA_buffer = SDL_malloc(width * height); - if (!AA_buffer) { - SDL_SetError("Couldn't allocate buffer for requested mode"); - return (NULL); - } - -/* printf("Setting mode %dx%d\n", width, height); */ - - SDL_memset(aa_image(AA_context), 0, - aa_imgwidth(AA_context) * aa_imgheight(AA_context)); - SDL_memset(AA_buffer, 0, width * height); - - /* Allocate the new pixel format for the screen */ - if (!SDL_ReallocFormat(current, 8, 0, 0, 0, 0)) { - return (NULL); - } - - /* Set up the new mode framebuffer */ - current->flags = SDL_FULLSCREEN; - AA_w = current->w = width; - AA_h = current->h = height; - current->pitch = current->w; - current->pixels = AA_buffer; - - AA_x_ratio = ((double) aa_imgwidth(AA_context)) / ((double) width); - AA_y_ratio = ((double) aa_imgheight(AA_context)) / ((double) height); - - /* Set the blit function */ - this->UpdateRects = AA_DirectUpdate; - - /* We're done */ - return (current); -} - -static void -AA_ResizeHandler(aa_context * context) -{ - aa_resize(context); - local_this->hidden->x_ratio = - ((double) aa_imgwidth(context)) / ((double) local_this->screen->w); - local_this->hidden->y_ratio = - ((double) aa_imgheight(context)) / ((double) local_this->screen->h); - - fastscale(local_this->hidden->buffer, aa_image(context), - local_this->hidden->w, aa_imgwidth(context), - local_this->hidden->h, aa_imgheight(context)); - aa_renderpalette(context, local_this->hidden->palette, - local_this->hidden->rparams, 0, 0, - aa_scrwidth(context), aa_scrheight(context)); - aa_flush(context); -} - -/* We don't actually allow hardware surfaces other than the main one */ -static int -AA_AllocHWSurface(_THIS, SDL_Surface * surface) -{ - return (-1); -} -static void -AA_FreeHWSurface(_THIS, SDL_Surface * surface) -{ - return; -} - -/* We need to wait for vertical retrace on page flipped displays */ -static int -AA_LockHWSurface(_THIS, SDL_Surface * surface) -{ - /* TODO ? */ - return (0); -} -static void -AA_UnlockHWSurface(_THIS, SDL_Surface * surface) -{ - return; -} - -/* FIXME: How is this done with AAlib? */ -static int -AA_FlipHWSurface(_THIS, SDL_Surface * surface) -{ - SDL_mutexP(AA_mutex); - aa_flush(AA_context); - SDL_mutexV(AA_mutex); - return (0); -} - -static void -AA_DirectUpdate(_THIS, int numrects, SDL_Rect * rects) -{ - int i; - SDL_Rect *rect; - - fastscale(AA_buffer, aa_image(AA_context), AA_w, - aa_imgwidth(AA_context), AA_h, aa_imgheight(AA_context)); -#if 1 - aa_renderpalette(AA_context, AA_palette, AA_rparams, 0, 0, - aa_scrwidth(AA_context), aa_scrheight(AA_context)); -#else - /* Render only the rectangles in the list */ - printf("Update rects : "); - for (i = 0; i < numrects; ++i) { - rect = &rects[i]; - printf("(%d,%d-%d,%d)", rect->x, rect->y, rect->w, rect->h); - aa_renderpalette(AA_context, AA_palette, AA_rparams, - rect->x * AA_x_ratio, rect->y * AA_y_ratio, - rect->w * AA_x_ratio, rect->h * AA_y_ratio); - } - printf("\n"); -#endif - SDL_mutexP(AA_mutex); - aa_flush(AA_context); - SDL_mutexV(AA_mutex); - return; -} - -int -AA_SetColors(_THIS, int firstcolor, int ncolors, SDL_Color * colors) -{ - int i; - - for (i = 0; i < ncolors; i++) { - aa_setpalette(AA_palette, firstcolor + i, - colors[i].r >> 2, colors[i].g >> 2, colors[i].b >> 2); - } - return (1); -} - -/* Note: If we are terminated, this could be called in the middle of - another SDL video routine -- notably UpdateRects. -*/ -void -AA_VideoQuit(_THIS) -{ - int i; - - aa_uninitkbd(AA_context); - aa_uninitmouse(AA_context); - - /* Free video mode lists */ - for (i = 0; i < SDL_NUMMODES; ++i) { - if (SDL_modelist[i] != NULL) { - SDL_free(SDL_modelist[i]); - SDL_modelist[i] = NULL; - } - } - - aa_close(AA_context); - - SDL_DestroyMutex(AA_mutex); - - this->screen->pixels = NULL; -} - -/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/aalib/SDL_aavideo.h Wed Jul 26 03:15:41 2006 +0000 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,68 +0,0 @@ -/* - SDL - Simple DirectMedia Layer - Copyright (C) 1997-2006 Sam Lantinga - - This library is free software; you can redistribute it and/or - modify it under the terms of the GNU Lesser General Public - License as published by the Free Software Foundation; either - version 2.1 of the License, or (at your option) any later version. - - This library is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - Lesser General Public License for more details. - - You should have received a copy of the GNU Lesser General Public - License along with this library; if not, write to the Free Software - Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA - - Sam Lantinga - slouken@libsdl.org -*/ -#include "SDL_config.h" - -#ifndef _SDL_aavideo_h -#define _SDL_aavideo_h - -#include "SDL_mouse.h" -#include "SDL_mutex.h" -#include "../SDL_sysvideo.h" - -#include <aalib.h> - -/* Hidden "this" pointer for the video functions */ -#define _THIS SDL_VideoDevice *this - -#define SDL_NUMMODES 6 - -/* Private display data */ -struct SDL_PrivateVideoData -{ - SDL_Rect *SDL_modelist[SDL_NUMMODES + 1]; - aa_context *context; - aa_palette palette; - aa_renderparams *rparams; - double x_ratio, y_ratio; - int w, h; - SDL_mutex *mutex; - int in_x11; - void *buffer; -}; - -/* Old variable names */ -#define SDL_modelist (this->hidden->SDL_modelist) -#define AA_context (this->hidden->context) -#define AA_palette (this->hidden->palette) -#define AA_rparams (this->hidden->rparams) -#define AA_buffer (this->hidden->buffer) - -#define AA_x_ratio (this->hidden->x_ratio) -#define AA_y_ratio (this->hidden->y_ratio) - -#define AA_mutex (this->hidden->mutex) -#define AA_in_x11 (this->hidden->in_x11) -#define AA_w (this->hidden->w) -#define AA_h (this->hidden->h) - -#endif /* _SDL_aavideo_h */ -/* vi: set ts=4 sw=4 expandtab: */