Annotation of /trunk/libsdl/patches/libsdl-1.2.11-libcaca-new-api.patch
Parent Directory | Revision Log
Revision 144 -
(hide annotations)
(download)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 18310 byte(s)
Tue May 8 20:06:05 2007 UTC (17 years, 4 months ago) by niro
File size: 18310 byte(s)
-import
1 | niro | 144 | diff -Naur SDL-1.2.11-vanilla/configure.in SDL-1.2.11/configure.in |
2 | --- SDL-1.2.11-vanilla/configure.in 2006-06-27 06:48:33.000000000 +0200 | ||
3 | +++ SDL-1.2.11/configure.in 2006-09-28 00:59:04.485910345 +0200 | ||
4 | @@ -1338,6 +1338,38 @@ | ||
5 | fi | ||
6 | } | ||
7 | |||
8 | +dnl Find the libcaca includes | ||
9 | +CheckCaca() | ||
10 | +{ | ||
11 | + AC_ARG_ENABLE(video-caca, | ||
12 | +AC_HELP_STRING([--enable-video-caca], [use libcaca video driver [[default=no]]]), | ||
13 | + , enable_video_caca=no) | ||
14 | + if test x$enable_video = xyes -a x$enable_video_caca = xyes; then | ||
15 | + video_caca=no | ||
16 | + AC_PATH_PROG(CACACONFIG, caca-config, no) | ||
17 | + if test x$CACACONFIG != xno; then | ||
18 | + AC_MSG_CHECKING(for libcaca support) | ||
19 | + CACA_CFLAGS=`$CACACONFIG --cflags` | ||
20 | + CACA_LDFLAGS=`$CACACONFIG --libs` | ||
21 | + save_CFLAGS="$CFLAGS" | ||
22 | + AC_TRY_COMPILE([ | ||
23 | + #include <caca.h> | ||
24 | + ],[ | ||
25 | + ],[ | ||
26 | + video_caca=yes | ||
27 | + ]) | ||
28 | + CFLAGS="$save_CFLAGS" | ||
29 | + AC_MSG_RESULT($video_caca) | ||
30 | + if test x$video_caca = xyes; then | ||
31 | + AC_DEFINE(SDL_VIDEO_DRIVER_CACA) | ||
32 | + EXTRA_CFLAGS="$EXTRA_CFLAGS $CACA_CFLAGS" | ||
33 | + EXTRA_LDFLAGS="$EXTRA_LDFLAGS $CACA_LDFLAGS" | ||
34 | + SOURCES="$SOURCES $srcdir/src/video/caca/*.c" | ||
35 | + fi | ||
36 | + fi | ||
37 | + fi | ||
38 | +} | ||
39 | + | ||
40 | dnl Set up the QTopia video driver if enabled | ||
41 | CheckQtopia() | ||
42 | { | ||
43 | @@ -2152,6 +2184,7 @@ | ||
44 | CheckVGL | ||
45 | CheckWscons | ||
46 | CheckAAlib | ||
47 | + CheckCaca | ||
48 | CheckQtopia | ||
49 | CheckPicoGUI | ||
50 | CheckOpenGLX11 | ||
51 | diff -Naur SDL-1.2.11-vanilla/src/video/caca/SDL_cacaevents.c SDL-1.2.11/src/video/caca/SDL_cacaevents.c | ||
52 | --- SDL-1.2.11-vanilla/src/video/caca/SDL_cacaevents.c 1970-01-01 01:00:00.000000000 +0100 | ||
53 | +++ SDL-1.2.11/src/video/caca/SDL_cacaevents.c 2006-09-28 01:00:37.750731937 +0200 | ||
54 | @@ -0,0 +1,101 @@ | ||
55 | +/* | ||
56 | + SDL - Simple DirectMedia Layer | ||
57 | + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga | ||
58 | + | ||
59 | + This library is free software; you can redistribute it and/or | ||
60 | + modify it under the terms of the GNU Library General Public | ||
61 | + License as published by the Free Software Foundation; either | ||
62 | + version 2 of the License, or (at your option) any later version. | ||
63 | + | ||
64 | + This library is distributed in the hope that it will be useful, | ||
65 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
66 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
67 | + Library General Public License for more details. | ||
68 | + | ||
69 | + You should have received a copy of the GNU Library General Public | ||
70 | + License along with this library; if not, write to the Free | ||
71 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
72 | + | ||
73 | + Sam Lantinga | ||
74 | + slouken@libsdl.org | ||
75 | +*/ | ||
76 | + | ||
77 | +#ifdef SAVE_RCSID | ||
78 | +static char rcsid = | ||
79 | + "@(#) $Id: libsdl-1.2.11-libcaca-new-api.patch,v 1.1 2007-05-08 19:57:41 niro Exp $"; | ||
80 | +#endif | ||
81 | + | ||
82 | +#include <stdio.h> | ||
83 | + | ||
84 | +#include <caca.h> | ||
85 | +#ifdef CACA_API_VERSION_1 | ||
86 | +#include <caca0.h> | ||
87 | +#endif | ||
88 | + | ||
89 | +#include "SDL.h" | ||
90 | +#include "../../events/SDL_sysevents.h" | ||
91 | +#include "../../events/SDL_events_c.h" | ||
92 | +#include "SDL_cacavideo.h" | ||
93 | +#include "SDL_cacaevents_c.h" | ||
94 | + | ||
95 | +void Caca_PumpEvents(_THIS) | ||
96 | +{ | ||
97 | + int posted = 0; | ||
98 | + int event; | ||
99 | + SDL_keysym keysym; | ||
100 | + | ||
101 | + if( ! this->screen ) /* Wait till we got the screen initialised */ | ||
102 | + return; | ||
103 | + | ||
104 | + do { | ||
105 | + posted = 0; | ||
106 | + | ||
107 | + /* Get libcaca event */ | ||
108 | + SDL_mutexP(Caca_mutex); | ||
109 | + event = caca_get_event(CACA_EVENT_ANY); | ||
110 | + SDL_mutexV(Caca_mutex); | ||
111 | + | ||
112 | + if ( event & (CACA_EVENT_KEY_PRESS | CACA_EVENT_KEY_RELEASE)) { | ||
113 | + int key; | ||
114 | + switch ( event & 0xffffff ) | ||
115 | + { | ||
116 | + case CACA_KEY_LEFT: key = SDLK_LEFT; break; | ||
117 | + case CACA_KEY_RIGHT: key = SDLK_RIGHT; break; | ||
118 | + case CACA_KEY_UP: key = SDLK_UP; break; | ||
119 | + case CACA_KEY_DOWN: key = SDLK_DOWN; break; | ||
120 | + default: key = event & 0xff; break; | ||
121 | + } | ||
122 | + /* Key pressed */ | ||
123 | +/* printf("Key pressed: %d (%c)\n", key, key); */ | ||
124 | + keysym.scancode = key; | ||
125 | + keysym.sym = key; | ||
126 | + keysym.mod = KMOD_NONE; | ||
127 | + keysym.unicode = 0; | ||
128 | + if ( SDL_TranslateUNICODE ) { | ||
129 | + keysym.unicode = key; | ||
130 | + } | ||
131 | + posted += SDL_PrivateKeyboard((event & CACA_EVENT_KEY_PRESS) ? SDL_PRESSED : SDL_RELEASED, &keysym); | ||
132 | + } | ||
133 | + else if ( event & (CACA_EVENT_MOUSE_PRESS | CACA_EVENT_MOUSE_RELEASE) ) { | ||
134 | + /* FIXME: we currently ignore the button type! */ | ||
135 | + int button = event & 0x00ffffff; | ||
136 | + if ( button > 3 ) { | ||
137 | + button = 1; | ||
138 | + } | ||
139 | + posted += SDL_PrivateMouseButton((event & CACA_EVENT_MOUSE_PRESS) ? SDL_PRESSED : SDL_RELEASED, button, 0, 0); | ||
140 | + } | ||
141 | + else if ( event & CACA_EVENT_MOUSE_MOTION ) { | ||
142 | + int new_x = 0, new_y = 0; | ||
143 | + new_x = ((event & 0x00fff000) >> 12) * Caca_w / caca_get_width(); | ||
144 | + new_y = ((event & 0x00000fff) >> 0) * Caca_h / caca_get_height(); | ||
145 | + posted += SDL_PrivateMouseMotion(0, 0, new_x, new_y); | ||
146 | + } | ||
147 | + } while ( posted ); | ||
148 | +} | ||
149 | + | ||
150 | +void Caca_InitOSKeymap(_THIS) | ||
151 | +{ | ||
152 | + return; | ||
153 | +} | ||
154 | + | ||
155 | + | ||
156 | diff -Naur SDL-1.2.11-vanilla/src/video/caca/SDL_cacaevents_c.h SDL-1.2.11/src/video/caca/SDL_cacaevents_c.h | ||
157 | --- SDL-1.2.11-vanilla/src/video/caca/SDL_cacaevents_c.h 1970-01-01 01:00:00.000000000 +0100 | ||
158 | +++ SDL-1.2.11/src/video/caca/SDL_cacaevents_c.h 2006-09-28 00:59:04.516905633 +0200 | ||
159 | @@ -0,0 +1,35 @@ | ||
160 | +/* | ||
161 | + SDL - Simple DirectMedia Layer | ||
162 | + Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga | ||
163 | + | ||
164 | + This library is free software; you can redistribute it and/or | ||
165 | + modify it under the terms of the GNU Library General Public | ||
166 | + License as published by the Free Software Foundation; either | ||
167 | + version 2 of the License, or (at your option) any later version. | ||
168 | + | ||
169 | + This library is distributed in the hope that it will be useful, | ||
170 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
171 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
172 | + Library General Public License for more details. | ||
173 | + | ||
174 | + You should have received a copy of the GNU Library General Public | ||
175 | + License along with this library; if not, write to the Free | ||
176 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
177 | + | ||
178 | + Sam Lantinga | ||
179 | + slouken@libsdl.org | ||
180 | +*/ | ||
181 | + | ||
182 | +#ifdef SAVE_RCSID | ||
183 | +static char rcsid = | ||
184 | + "@(#) $Id: libsdl-1.2.11-libcaca-new-api.patch,v 1.1 2007-05-08 19:57:41 niro Exp $"; | ||
185 | +#endif | ||
186 | + | ||
187 | +#include "SDL_cacavideo.h" | ||
188 | + | ||
189 | +/* Variables and functions exported by SDL_sysevents.c to other parts. | ||
190 | + of the native video subsystem (SDL_sysvideo.c) | ||
191 | +*/ | ||
192 | +extern void Caca_PumpEvents(_THIS); | ||
193 | +extern void Caca_InitOSKeymap(_THIS); | ||
194 | + | ||
195 | diff -Naur SDL-1.2.11-vanilla/src/video/caca/SDL_cacavideo.c SDL-1.2.11/src/video/caca/SDL_cacavideo.c | ||
196 | --- SDL-1.2.11-vanilla/src/video/caca/SDL_cacavideo.c 1970-01-01 01:00:00.000000000 +0100 | ||
197 | +++ SDL-1.2.11/src/video/caca/SDL_cacavideo.c 2006-09-28 01:00:37.994694849 +0200 | ||
198 | @@ -0,0 +1,304 @@ | ||
199 | +/* | ||
200 | + SDL - Simple DirectMedia Layer | ||
201 | + Copyright (C) 2003 Sam Hocevar | ||
202 | + | ||
203 | + This library is free software; you can redistribute it and/or | ||
204 | + modify it under the terms of the GNU Library General Public | ||
205 | + License as published by the Free Software Foundation; either | ||
206 | + version 2 of the License, or (at your option) any later version. | ||
207 | + | ||
208 | + This library is distributed in the hope that it will be useful, | ||
209 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
210 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
211 | + Library General Public License for more details. | ||
212 | + | ||
213 | + You should have received a copy of the GNU Library General Public | ||
214 | + License along with this library; if not, write to the Free | ||
215 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
216 | + | ||
217 | + Sam Hocevar | ||
218 | + sam@zoy.org | ||
219 | +*/ | ||
220 | + | ||
221 | +#ifdef SAVE_RCSID | ||
222 | +static char rcsid = | ||
223 | + "@(#) $Id: libsdl-1.2.11-libcaca-new-api.patch,v 1.1 2007-05-08 19:57:41 niro Exp $"; | ||
224 | +#endif | ||
225 | + | ||
226 | +/* libcaca based SDL video driver implementation. | ||
227 | +*/ | ||
228 | + | ||
229 | +#include <stdlib.h> | ||
230 | +#include <stdio.h> | ||
231 | +#include <string.h> | ||
232 | +#include <unistd.h> | ||
233 | +#include <sys/stat.h> | ||
234 | + | ||
235 | + | ||
236 | +#include "SDL.h" | ||
237 | +#include "SDL_error.h" | ||
238 | +#include "SDL_video.h" | ||
239 | +#include "SDL_mouse.h" | ||
240 | +#include "../SDL_sysvideo.h" | ||
241 | +#include "../SDL_pixels_c.h" | ||
242 | +#include "../../events/SDL_events_c.h" | ||
243 | + | ||
244 | +#include "SDL_cacavideo.h" | ||
245 | +#include "SDL_cacaevents_c.h" | ||
246 | + | ||
247 | +#include <caca.h> | ||
248 | +#ifdef CACA_API_VERSION_1 | ||
249 | +#include <caca0.h> | ||
250 | +#endif | ||
251 | + | ||
252 | +/* Initialization/Query functions */ | ||
253 | +static int Caca_VideoInit(_THIS, SDL_PixelFormat *vformat); | ||
254 | +static SDL_Rect **Caca_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags); | ||
255 | +static SDL_Surface *Caca_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags); | ||
256 | +static void Caca_VideoQuit(_THIS); | ||
257 | + | ||
258 | +/* Hardware surface functions */ | ||
259 | +static int Caca_AllocHWSurface(_THIS, SDL_Surface *surface); | ||
260 | +static int Caca_LockHWSurface(_THIS, SDL_Surface *surface); | ||
261 | +static int Caca_FlipHWSurface(_THIS, SDL_Surface *surface); | ||
262 | +static void Caca_UnlockHWSurface(_THIS, SDL_Surface *surface); | ||
263 | +static void Caca_FreeHWSurface(_THIS, SDL_Surface *surface); | ||
264 | + | ||
265 | +/* Cache the VideoDevice struct */ | ||
266 | +static struct SDL_VideoDevice *local_this; | ||
267 | + | ||
268 | +/* libcaca driver bootstrap functions */ | ||
269 | + | ||
270 | +static int Caca_Available(void) | ||
271 | +{ | ||
272 | + return 1; /* Always available ! */ | ||
273 | +} | ||
274 | + | ||
275 | +static void Caca_DeleteDevice(SDL_VideoDevice *device) | ||
276 | +{ | ||
277 | + free(device->hidden); | ||
278 | + free(device); | ||
279 | +} | ||
280 | +static SDL_VideoDevice *Caca_CreateDevice(int devindex) | ||
281 | +{ | ||
282 | + SDL_VideoDevice *device; | ||
283 | + | ||
284 | + /* Initialize all variables that we clean on shutdown */ | ||
285 | + device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice)); | ||
286 | + if ( device ) { | ||
287 | + memset(device, 0, (sizeof *device)); | ||
288 | + device->hidden = (struct SDL_PrivateVideoData *) | ||
289 | + malloc((sizeof *device->hidden)); | ||
290 | + } | ||
291 | + if ( (device == NULL) || (device->hidden == NULL) ) { | ||
292 | + SDL_OutOfMemory(); | ||
293 | + if ( device ) { | ||
294 | + free(device); | ||
295 | + } | ||
296 | + return(0); | ||
297 | + } | ||
298 | + memset(device->hidden, 0, (sizeof *device->hidden)); | ||
299 | + | ||
300 | + /* Set the function pointers */ | ||
301 | + device->VideoInit = Caca_VideoInit; | ||
302 | + device->ListModes = Caca_ListModes; | ||
303 | + device->SetVideoMode = Caca_SetVideoMode; | ||
304 | + device->CreateYUVOverlay = NULL; | ||
305 | + device->SetColors = NULL; | ||
306 | + device->UpdateRects = NULL; | ||
307 | + device->VideoQuit = Caca_VideoQuit; | ||
308 | + device->AllocHWSurface = Caca_AllocHWSurface; | ||
309 | + device->CheckHWBlit = NULL; | ||
310 | + device->FillHWRect = NULL; | ||
311 | + device->SetHWColorKey = NULL; | ||
312 | + device->SetHWAlpha = NULL; | ||
313 | + device->LockHWSurface = Caca_LockHWSurface; | ||
314 | + device->UnlockHWSurface = Caca_UnlockHWSurface; | ||
315 | + device->FlipHWSurface = NULL; | ||
316 | + device->FreeHWSurface = Caca_FreeHWSurface; | ||
317 | + device->SetCaption = NULL; | ||
318 | + device->SetIcon = NULL; | ||
319 | + device->IconifyWindow = NULL; | ||
320 | + device->GrabInput = NULL; | ||
321 | + device->GetWMInfo = NULL; | ||
322 | + device->InitOSKeymap = Caca_InitOSKeymap; | ||
323 | + device->PumpEvents = Caca_PumpEvents; | ||
324 | + | ||
325 | + device->free = Caca_DeleteDevice; | ||
326 | + | ||
327 | + return device; | ||
328 | +} | ||
329 | + | ||
330 | +VideoBootStrap Caca_bootstrap = { | ||
331 | + "caca", "Color ASCII Art Library", | ||
332 | + Caca_Available, Caca_CreateDevice | ||
333 | +}; | ||
334 | + | ||
335 | +int Caca_VideoInit(_THIS, SDL_PixelFormat *vformat) | ||
336 | +{ | ||
337 | + int i; | ||
338 | + | ||
339 | + /* Initialize all variables that we clean on shutdown */ | ||
340 | + for ( i=0; i<SDL_NUMMODES; ++i ) { | ||
341 | + SDL_modelist[i] = malloc(sizeof(SDL_Rect)); | ||
342 | + SDL_modelist[i]->x = SDL_modelist[i]->y = 0; | ||
343 | + } | ||
344 | + /* Modes sorted largest to smallest */ | ||
345 | + SDL_modelist[0]->w = 1024; SDL_modelist[0]->h = 768; | ||
346 | + SDL_modelist[1]->w = 800; SDL_modelist[1]->h = 600; | ||
347 | + SDL_modelist[2]->w = 640; SDL_modelist[2]->h = 480; | ||
348 | + SDL_modelist[3]->w = 320; SDL_modelist[3]->h = 400; | ||
349 | + SDL_modelist[4]->w = 320; SDL_modelist[4]->h = 240; | ||
350 | + SDL_modelist[5]->w = 320; SDL_modelist[5]->h = 200; | ||
351 | + SDL_modelist[6] = NULL; | ||
352 | + | ||
353 | + Caca_mutex = SDL_CreateMutex(); | ||
354 | + | ||
355 | + /* Initialize the library */ | ||
356 | + if ( caca_init() != 0 ) { | ||
357 | + SDL_SetError("Unable to initialize libcaca"); | ||
358 | + return(-1); | ||
359 | + } | ||
360 | + | ||
361 | + /* Initialize private variables */ | ||
362 | + Caca_lastkey = 0; | ||
363 | + Caca_bitmap = NULL; | ||
364 | + Caca_buffer = NULL; | ||
365 | + | ||
366 | + local_this = this; | ||
367 | + | ||
368 | + /* Determine the screen depth (use default 8-bit depth) */ | ||
369 | + vformat->BitsPerPixel = 8; | ||
370 | + vformat->BytesPerPixel = 1; | ||
371 | + | ||
372 | + /* We're done! */ | ||
373 | + return(0); | ||
374 | +} | ||
375 | + | ||
376 | +SDL_Rect **Caca_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags) | ||
377 | +{ | ||
378 | + if(format->BitsPerPixel != 8) | ||
379 | + return NULL; | ||
380 | + | ||
381 | + if ( flags & SDL_FULLSCREEN ) { | ||
382 | + return SDL_modelist; | ||
383 | + } else { | ||
384 | + return (SDL_Rect **) -1; | ||
385 | + } | ||
386 | +} | ||
387 | + | ||
388 | +/* Various screen update functions available */ | ||
389 | +static void Caca_DirectUpdate(_THIS, int numrects, SDL_Rect *rects); | ||
390 | + | ||
391 | +SDL_Surface *Caca_SetVideoMode(_THIS, SDL_Surface *current, | ||
392 | + int width, int height, int bpp, Uint32 flags) | ||
393 | +{ | ||
394 | + if ( Caca_buffer ) { | ||
395 | + free( Caca_buffer ); | ||
396 | + Caca_buffer = NULL; | ||
397 | + } | ||
398 | + | ||
399 | + if ( Caca_bitmap ) { | ||
400 | + caca_free_bitmap( Caca_bitmap ); | ||
401 | + Caca_bitmap = NULL; | ||
402 | + } | ||
403 | + | ||
404 | + Caca_buffer = malloc(2 * ((width + 15) & ~15) * height); | ||
405 | + if ( ! Caca_buffer ) { | ||
406 | + SDL_SetError("Couldn't allocate buffer for requested mode"); | ||
407 | + return(NULL); | ||
408 | + } | ||
409 | + | ||
410 | + memset(Caca_buffer, 0, 2 * ((width + 15) & ~15) * height); | ||
411 | + | ||
412 | + /* Allocate the new pixel format for the screen */ | ||
413 | + if ( ! SDL_ReallocFormat(current, 16, 0xf800, 0x07e0, 0x001f, 0) ) { | ||
414 | + return(NULL); | ||
415 | + } | ||
416 | + | ||
417 | + /* Set up the new mode framebuffer */ | ||
418 | + current->flags = SDL_FULLSCREEN; | ||
419 | + Caca_w = current->w = width; | ||
420 | + Caca_h = current->h = height; | ||
421 | + current->pitch = 2 * ((width + 15) & ~15); | ||
422 | + current->pixels = Caca_buffer; | ||
423 | + | ||
424 | + /* Create the libcaca bitmap */ | ||
425 | + Caca_bitmap = caca_create_bitmap( 16, width, height, current->pitch, 0xf800, 0x07e0, 0x001f, 0x0000 ); | ||
426 | + if ( ! Caca_bitmap ) { | ||
427 | + SDL_SetError("Couldn't allocate libcaca bitmap"); | ||
428 | + return(NULL); | ||
429 | + } | ||
430 | + | ||
431 | + /* Set the blit function */ | ||
432 | + this->UpdateRects = Caca_DirectUpdate; | ||
433 | + | ||
434 | + /* We're done */ | ||
435 | + return(current); | ||
436 | +} | ||
437 | + | ||
438 | +/* We don't actually allow hardware surfaces other than the main one */ | ||
439 | +static int Caca_AllocHWSurface(_THIS, SDL_Surface *surface) | ||
440 | +{ | ||
441 | + return(-1); | ||
442 | +} | ||
443 | +static void Caca_FreeHWSurface(_THIS, SDL_Surface *surface) | ||
444 | +{ | ||
445 | + return; | ||
446 | +} | ||
447 | + | ||
448 | +/* We need to wait for vertical retrace on page flipped displays */ | ||
449 | +static int Caca_LockHWSurface(_THIS, SDL_Surface *surface) | ||
450 | +{ | ||
451 | + /* TODO ? */ | ||
452 | + return(0); | ||
453 | +} | ||
454 | +static void Caca_UnlockHWSurface(_THIS, SDL_Surface *surface) | ||
455 | +{ | ||
456 | + return; | ||
457 | +} | ||
458 | + | ||
459 | +/* FIXME: How is this done with libcaca? */ | ||
460 | +static int Caca_FlipHWSurface(_THIS, SDL_Surface *surface) | ||
461 | +{ | ||
462 | + SDL_mutexP(Caca_mutex); | ||
463 | + caca_refresh(); | ||
464 | + SDL_mutexV(Caca_mutex); | ||
465 | + return(0); | ||
466 | +} | ||
467 | + | ||
468 | +static void Caca_DirectUpdate(_THIS, int numrects, SDL_Rect *rects) | ||
469 | +{ | ||
470 | + SDL_mutexP(Caca_mutex); | ||
471 | + caca_draw_bitmap( 0, 0, caca_get_width() - 1, caca_get_height() - 1, | ||
472 | + Caca_bitmap, Caca_buffer ); | ||
473 | + caca_refresh(); | ||
474 | + SDL_mutexV(Caca_mutex); | ||
475 | + return; | ||
476 | +} | ||
477 | + | ||
478 | +/* Note: If we are terminated, this could be called in the middle of | ||
479 | + another SDL video routine -- notably UpdateRects. | ||
480 | +*/ | ||
481 | +void Caca_VideoQuit(_THIS) | ||
482 | +{ | ||
483 | + int i; | ||
484 | + | ||
485 | + /* Free video mode lists */ | ||
486 | + for ( i=0; i<SDL_NUMMODES; ++i ) { | ||
487 | + if ( SDL_modelist[i] != NULL ) { | ||
488 | + free(SDL_modelist[i]); | ||
489 | + SDL_modelist[i] = NULL; | ||
490 | + } | ||
491 | + } | ||
492 | + | ||
493 | + if ( Caca_bitmap ) { | ||
494 | + caca_free_bitmap( Caca_bitmap ); | ||
495 | + Caca_bitmap = NULL; | ||
496 | + } | ||
497 | + | ||
498 | + caca_end(); | ||
499 | + | ||
500 | + SDL_DestroyMutex(Caca_mutex); | ||
501 | +} | ||
502 | + | ||
503 | diff -Naur SDL-1.2.11-vanilla/src/video/caca/SDL_cacavideo.h SDL-1.2.11/src/video/caca/SDL_cacavideo.h | ||
504 | --- SDL-1.2.11-vanilla/src/video/caca/SDL_cacavideo.h 1970-01-01 01:00:00.000000000 +0100 | ||
505 | +++ SDL-1.2.11/src/video/caca/SDL_cacavideo.h 2006-09-28 01:00:38.360639217 +0200 | ||
506 | @@ -0,0 +1,76 @@ | ||
507 | +/* | ||
508 | + SDL - Simple DirectMedia Layer | ||
509 | + Copyright (C) 2003 Sam Hocevar | ||
510 | + | ||
511 | + This library is free software; you can redistribute it and/or | ||
512 | + modify it under the terms of the GNU Library General Public | ||
513 | + License as published by the Free Software Foundation; either | ||
514 | + version 2 of the License, or (at your option) any later version. | ||
515 | + | ||
516 | + This library is distributed in the hope that it will be useful, | ||
517 | + but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
518 | + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
519 | + Library General Public License for more details. | ||
520 | + | ||
521 | + You should have received a copy of the GNU Library General Public | ||
522 | + License along with this library; if not, write to the Free | ||
523 | + Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||
524 | + | ||
525 | + Sam Hocevar | ||
526 | + sam@zoy.org | ||
527 | +*/ | ||
528 | + | ||
529 | +#ifdef SAVE_RCSID | ||
530 | +static char rcsid = | ||
531 | + "@(#) $Id: libsdl-1.2.11-libcaca-new-api.patch,v 1.1 2007-05-08 19:57:41 niro Exp $"; | ||
532 | +#endif | ||
533 | + | ||
534 | +#ifndef _SDL_cacavideo_h | ||
535 | +#define _SDL_cacavideo_h | ||
536 | + | ||
537 | +#include "SDL_mouse.h" | ||
538 | +#include "../SDL_sysvideo.h" | ||
539 | +#include "SDL_mutex.h" | ||
540 | + | ||
541 | +#include <sys/time.h> | ||
542 | +#include <time.h> | ||
543 | + | ||
544 | +#include <caca.h> | ||
545 | +#ifdef CACA_API_VERSION_1 | ||
546 | +#include <caca0.h> | ||
547 | +#endif | ||
548 | + | ||
549 | +/* Hidden "this" pointer for the video functions */ | ||
550 | +#define _THIS SDL_VideoDevice *this | ||
551 | + | ||
552 | +#define SDL_NUMMODES 6 | ||
553 | + | ||
554 | +/* Private display data */ | ||
555 | +struct SDL_PrivateVideoData { | ||
556 | + SDL_Rect *SDL_modelist[SDL_NUMMODES+1]; | ||
557 | + SDL_mutex *mutex; | ||
558 | + | ||
559 | + struct caca_bitmap *bitmap; | ||
560 | + void *buffer; | ||
561 | + int w, h; | ||
562 | + | ||
563 | + int lastkey; | ||
564 | + struct timeval lasttime; | ||
565 | +}; | ||
566 | + | ||
567 | +/* Old variable names */ | ||
568 | +#define SDL_modelist (this->hidden->SDL_modelist) | ||
569 | +#define Caca_palette (this->hidden->palette) | ||
570 | +#define Caca_bitmap (this->hidden->bitmap) | ||
571 | +#define Caca_buffer (this->hidden->buffer) | ||
572 | + | ||
573 | +#define Caca_w (this->hidden->w) | ||
574 | +#define Caca_h (this->hidden->h) | ||
575 | + | ||
576 | +#define Caca_lastkey (this->hidden->lastkey) | ||
577 | +#define Caca_lasttime (this->hidden->lasttime) | ||
578 | + | ||
579 | +#define Caca_mutex (this->hidden->mutex) | ||
580 | + | ||
581 | +#endif /* _SDL_cacavideo_h */ | ||
582 | + | ||
583 | diff -Naur SDL-1.2.11-vanilla/src/video/SDL_sysvideo.h SDL-1.2.11/src/video/SDL_sysvideo.h | ||
584 | --- SDL-1.2.11-vanilla/src/video/SDL_sysvideo.h 2006-05-01 10:02:48.000000000 +0200 | ||
585 | +++ SDL-1.2.11/src/video/SDL_sysvideo.h 2006-09-28 00:59:04.519905177 +0200 | ||
586 | @@ -404,6 +404,9 @@ | ||
587 | #if SDL_VIDEO_DRIVER_AALIB | ||
588 | extern VideoBootStrap AALIB_bootstrap; | ||
589 | #endif | ||
590 | +#if SDL_VIDEO_DRIVER_CACA | ||
591 | +extern VideoBootStrap CACA_bootstrap; | ||
592 | +#endif | ||
593 | #if SDL_VIDEO_DRIVER_DUMMY | ||
594 | extern VideoBootStrap DUMMY_bootstrap; | ||
595 | #endif | ||
596 | diff -Naur SDL-1.2.11-vanilla/src/video/SDL_video.c SDL-1.2.11/src/video/SDL_video.c | ||
597 | --- SDL-1.2.11-vanilla/src/video/SDL_video.c 2006-05-01 10:02:48.000000000 +0200 | ||
598 | +++ SDL-1.2.11/src/video/SDL_video.c 2006-09-28 00:59:04.522904721 +0200 | ||
599 | @@ -120,6 +120,9 @@ | ||
600 | #if SDL_VIDEO_DRIVER_AALIB | ||
601 | &AALIB_bootstrap, | ||
602 | #endif | ||
603 | +#if SDL_VIDEO_DRIVER_CACA | ||
604 | + &CACA_bootstrap, | ||
605 | +#endif | ||
606 | #if SDL_VIDEO_DRIVER_DUMMY | ||
607 | &DUMMY_bootstrap, | ||
608 | #endif |