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