source: scripts/untested/blfs-patches/patch-libsdl1.2-libcaca0.7.patch@ fcf217f

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since fcf217f was fd5b1fe, checked in by Jim Gifford <clfs@…>, 19 years ago

r588@server (orig r586): ryan | 2005-08-05 22:47:43 -0700
Add pile of new patches for blfs packages



  • Property mode set to 100644
File size: 21.4 KB
RevLine 
[fd5b1fe]1Submitted By: Ryan Oliver <ryan.oliver@pha.com.au>
2Date: 2005-05-22
3Initial Package Version: 1.2.6
4Upstream Status: unknown
5Origin: libcaca website
6 http://sam.zoy.org/libcaca/patch-libsdl1.2-libcaca0.7.diff
7Description: Adds libcaca support to SDL
8
9$Id: patch-libsdl1.2-libcaca0.7.diff 809 2005-03-23 11:07:40Z sam $
10diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/configure.in libsdl1.2-1.2.6-caca/configure.in
11--- libsdl1.2-1.2.6/configure.in 2003-11-16 23:51:54.000000000 +0100
12+++ libsdl1.2-1.2.6-caca/configure.in 2003-11-21 15:50:49.000000000 +0100
13@@ -952,6 +952,32 @@ CheckAAlib()
14 fi
15 }
16
17+dnl Find the libcaca includes
18+CheckCaca()
19+{
20+ AC_ARG_ENABLE(video-caca,
21+[ --enable-video-caca use libcaca video driver [default=no]],
22+ , enable_video_caca=no)
23+ if test x$enable_video = xyes -a x$enable_video_caca = xyes; then
24+ AC_MSG_CHECKING(for libcaca support)
25+ video_caca=no
26+ AC_TRY_COMPILE([
27+ #include <caca.h>
28+ ],[
29+ ],[
30+ video_caca=yes
31+ ])
32+ AC_MSG_RESULT($video_caca)
33+ if test x$video_caca = xyes; then
34+ CFLAGS="$CFLAGS -DENABLE_CACA `caca-config --cflags`"
35+ SYSTEM_LIBS="$SYSTEM_LIBS `caca-config --plugin-libs`"
36+
37+ VIDEO_SUBDIRS="$VIDEO_SUBDIRS caca"
38+ VIDEO_DRIVERS="$VIDEO_DRIVERS caca/libvideo_caca.la"
39+ fi
40+ fi
41+}
42+
43 dnl Set up the Atari Xbios driver
44 CheckAtariXbiosVideo()
45 {
46@@ -1738,6 +1764,7 @@ case "$target" in
47 CheckGGI
48 CheckSVGA
49 CheckAAlib
50+ CheckCaca
51 CheckQtopia
52 CheckPicoGUI
53 CheckOpenGL
54@@ -1819,6 +1846,7 @@ case "$target" in
55 CheckDGA
56 CheckSVGA
57 CheckAAlib
58+ CheckCaca
59 CheckOpenGL
60 CheckPTHREAD
61 # Set up files for the main() stub
62@@ -1865,6 +1893,7 @@ case "$target" in
63 CheckDGA
64 CheckSVGA
65 CheckAAlib
66+ CheckCaca
67 CheckOpenGL
68 CheckPTHREAD
69 CheckUSBHID
70@@ -1903,6 +1932,7 @@ case "$target" in
71 CheckNAS
72 CheckX11
73 CheckAAlib
74+ CheckCaca
75 CheckOpenGL
76 CheckPTHREAD
77 CheckUSBHID
78@@ -1945,6 +1975,7 @@ case "$target" in
79 CheckNAS
80 CheckX11
81 CheckAAlib
82+ CheckCaca
83 CheckOpenGL
84 CheckPTHREAD
85 CheckUSBHID
86@@ -1988,6 +2019,7 @@ case "$target" in
87 CheckNAS
88 CheckX11
89 CheckAAlib
90+ CheckCaca
91 CheckOpenGL
92 CheckPTHREAD
93 # Set up files for the main() stub
94@@ -2031,6 +2063,7 @@ case "$target" in
95 CheckNAS
96 CheckX11
97 CheckAAlib
98+ CheckCaca
99 CheckOpenGL
100 CheckPTHREAD
101 # Set up files for the main() stub
102@@ -2071,6 +2104,7 @@ case "$target" in
103 CheckNAS
104 CheckX11
105 CheckAAlib
106+ CheckCaca
107 CheckOpenGL
108 CheckPTHREAD
109 # Set up files for the main() stub
110@@ -2123,6 +2157,7 @@ case "$target" in
111 CheckX11
112 CheckGGI
113 CheckAAlib
114+ CheckCaca
115 CheckOpenGL
116 CheckPTHREAD
117 # Set up files for the main() stub
118@@ -2164,6 +2199,7 @@ case "$target" in
119 CheckX11
120 CheckGGI
121 CheckAAlib
122+ CheckCaca
123 CheckOpenGL
124 CheckPTHREAD
125 # Set up files for the main() stub
126@@ -2202,6 +2238,7 @@ case "$target" in
127 CheckX11
128 CheckGGI
129 CheckAAlib
130+ CheckCaca
131 CheckOpenGL
132 CheckPTHREAD
133 SDL_LIBS="$SDL_LIBS -lrt"
134@@ -2709,6 +2746,7 @@ src/video/Makefile
135 src/video/aalib/Makefile
136 src/video/ataricommon/Makefile
137 src/video/bwindow/Makefile
138+src/video/caca/Makefile
139 src/video/cybergfx/Makefile
140 src/video/dc/Makefile
141 src/video/dga/Makefile
142diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/Makefile.am libsdl1.2-1.2.6-caca/src/video/Makefile.am
143--- libsdl1.2-1.2.6/src/video/Makefile.am 2003-08-30 21:13:06.000000000 +0200
144+++ libsdl1.2-1.2.6-caca/src/video/Makefile.am 2003-11-17 00:36:40.000000000 +0100
145@@ -5,7 +5,7 @@ noinst_LTLIBRARIES = libvideo.la
146
147 # Define which subdirectories need to be built
148 SUBDIRS = @VIDEO_SUBDIRS@
149-DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib \
150+DIST_SUBDIRS = dummy x11 dga nanox fbcon directfb vgl svga ggi aalib caca \
151 wincommon windib windx5 \
152 maccommon macdsp macrom riscos quartz \
153 bwindow ps2gs photon cybergfx epoc picogui \
154diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/SDL_sysvideo.h libsdl1.2-1.2.6-caca/src/video/SDL_sysvideo.h
155--- libsdl1.2-1.2.6/src/video/SDL_sysvideo.h 2003-08-30 21:13:07.000000000 +0200
156+++ libsdl1.2-1.2.6-caca/src/video/SDL_sysvideo.h 2003-11-17 02:23:43.000000000 +0100
157@@ -359,6 +359,9 @@ extern VideoBootStrap SVGALIB_bootstrap;
158 #ifdef ENABLE_AALIB
159 extern VideoBootStrap AALIB_bootstrap;
160 #endif
161+#ifdef ENABLE_CACA
162+extern VideoBootStrap Caca_bootstrap;
163+#endif
164 #ifdef ENABLE_WINDIB
165 extern VideoBootStrap WINDIB_bootstrap;
166 #endif
167diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/SDL_video.c libsdl1.2-1.2.6-caca/src/video/SDL_video.c
168--- libsdl1.2-1.2.6/src/video/SDL_video.c 2003-08-30 21:13:07.000000000 +0200
169+++ libsdl1.2-1.2.6-caca/src/video/SDL_video.c 2003-11-17 02:23:15.000000000 +0100
170@@ -78,6 +78,9 @@ static VideoBootStrap *bootstrap[] = {
171 #ifdef ENABLE_AALIB
172 &AALIB_bootstrap,
173 #endif
174+#ifdef ENABLE_CACA
175+ &Caca_bootstrap,
176+#endif
177 #ifdef ENABLE_DIRECTX
178 &DIRECTX_bootstrap,
179 #endif
180diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/caca/Makefile.am libsdl1.2-1.2.6-caca/src/video/caca/Makefile.am
181--- libsdl1.2-1.2.6/src/video/caca/Makefile.am 1970-01-01 01:00:00.000000000 +0100
182+++ libsdl1.2-1.2.6-caca/src/video/caca/Makefile.am 2003-11-17 01:24:38.000000000 +0100
183@@ -0,0 +1,13 @@
184+
185+## Makefile.am for SDL using the libcaca video driver
186+
187+noinst_LTLIBRARIES = libvideo_caca.la
188+libvideo_caca_la_SOURCES = $(CACA_SRCS)
189+
190+# The SDL libcaca video driver sources
191+CACA_SRCS = \
192+ SDL_cacavideo.h \
193+ SDL_cacaevents.c \
194+ SDL_cacaevents_c.h \
195+ SDL_cacavideo.c
196+
197diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/caca/SDL_cacaevents.c libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacaevents.c
198--- libsdl1.2-1.2.6/src/video/caca/SDL_cacaevents.c 1970-01-01 01:00:00.000000000 +0100
199+++ libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacaevents.c 2004-01-08 02:51:07.000000000 +0100
200@@ -0,0 +1,97 @@
201+/*
202+ SDL - Simple DirectMedia Layer
203+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
204+
205+ This library is free software; you can redistribute it and/or
206+ modify it under the terms of the GNU Library General Public
207+ License as published by the Free Software Foundation; either
208+ version 2 of the License, or (at your option) any later version.
209+
210+ This library is distributed in the hope that it will be useful,
211+ but WITHOUT ANY WARRANTY; without even the implied warranty of
212+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
213+ Library General Public License for more details.
214+
215+ You should have received a copy of the GNU Library General Public
216+ License along with this library; if not, write to the Free
217+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
218+
219+ Sam Lantinga
220+ slouken@libsdl.org
221+*/
222+
223+#ifdef SAVE_RCSID
224+static char rcsid =
225+ "@(#) $Id: patch-libsdl1.2-libcaca0.7.diff 809 2005-03-23 11:07:40Z sam $";
226+#endif
227+
228+#include <stdio.h>
229+
230+#include <caca.h>
231+
232+#include "SDL.h"
233+#include "SDL_sysevents.h"
234+#include "SDL_events_c.h"
235+#include "SDL_cacavideo.h"
236+#include "SDL_cacaevents_c.h"
237+
238+void Caca_PumpEvents(_THIS)
239+{
240+ int posted = 0;
241+ int event;
242+ SDL_keysym keysym;
243+
244+ if( ! this->screen ) /* Wait till we got the screen initialised */
245+ return;
246+
247+ do {
248+ posted = 0;
249+
250+ /* Get libcaca event */
251+ SDL_mutexP(Caca_mutex);
252+ event = caca_get_event(CACA_EVENT_ANY);
253+ SDL_mutexV(Caca_mutex);
254+
255+ if ( event & (CACA_EVENT_KEY_PRESS | CACA_EVENT_KEY_RELEASE)) {
256+ int key;
257+ switch ( event & 0xffffff )
258+ {
259+ case CACA_KEY_LEFT: key = SDLK_LEFT; break;
260+ case CACA_KEY_RIGHT: key = SDLK_RIGHT; break;
261+ case CACA_KEY_UP: key = SDLK_UP; break;
262+ case CACA_KEY_DOWN: key = SDLK_DOWN; break;
263+ default: key = event & 0xff; break;
264+ }
265+ /* Key pressed */
266+/* printf("Key pressed: %d (%c)\n", key, key); */
267+ keysym.scancode = key;
268+ keysym.sym = key;
269+ keysym.mod = KMOD_NONE;
270+ keysym.unicode = 0;
271+ if ( SDL_TranslateUNICODE ) {
272+ keysym.unicode = key;
273+ }
274+ posted += SDL_PrivateKeyboard((event & CACA_EVENT_KEY_PRESS) ? SDL_PRESSED : SDL_RELEASED, &keysym);
275+ }
276+ else if ( event & (CACA_EVENT_MOUSE_PRESS | CACA_EVENT_MOUSE_RELEASE) ) {
277+ /* FIXME: we currently ignore the button type! */
278+ int button = event & 0x00ffffff;
279+ if ( button > 3 ) {
280+ button = 1;
281+ }
282+ posted += SDL_PrivateMouseButton((event & CACA_EVENT_MOUSE_PRESS) ? SDL_PRESSED : SDL_RELEASED, button, 0, 0);
283+ }
284+ else if ( event & CACA_EVENT_MOUSE_MOTION ) {
285+ int new_x = 0, new_y = 0;
286+ new_x = ((event & 0x00fff000) >> 12) * Caca_w / caca_get_width();
287+ new_y = ((event & 0x00000fff) >> 0) * Caca_h / caca_get_height();
288+ posted += SDL_PrivateMouseMotion(0, 0, new_x, new_y);
289+ }
290+ } while ( posted );
291+}
292+
293+void Caca_InitOSKeymap(_THIS)
294+{
295+ return;
296+}
297+
298diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/caca/SDL_cacaevents_c.h libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacaevents_c.h
299--- libsdl1.2-1.2.6/src/video/caca/SDL_cacaevents_c.h 1970-01-01 01:00:00.000000000 +0100
300+++ libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacaevents_c.h 2003-11-17 03:04:31.000000000 +0100
301@@ -0,0 +1,34 @@
302+/*
303+ SDL - Simple DirectMedia Layer
304+ Copyright (C) 1997, 1998, 1999, 2000, 2001, 2002 Sam Lantinga
305+
306+ This library is free software; you can redistribute it and/or
307+ modify it under the terms of the GNU Library General Public
308+ License as published by the Free Software Foundation; either
309+ version 2 of the License, or (at your option) any later version.
310+
311+ This library is distributed in the hope that it will be useful,
312+ but WITHOUT ANY WARRANTY; without even the implied warranty of
313+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
314+ Library General Public License for more details.
315+
316+ You should have received a copy of the GNU Library General Public
317+ License along with this library; if not, write to the Free
318+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
319+
320+ Sam Lantinga
321+ slouken@libsdl.org
322+*/
323+
324+#ifdef SAVE_RCSID
325+static char rcsid =
326+ "@(#) $Id: patch-libsdl1.2-libcaca0.7.diff 809 2005-03-23 11:07:40Z sam $";
327+#endif
328+
329+#include "SDL_cacavideo.h"
330+
331+/* Variables and functions exported by SDL_sysevents.c to other parts
332+ of the native video subsystem (SDL_sysvideo.c)
333+*/
334+extern void Caca_PumpEvents(_THIS);
335+extern void Caca_InitOSKeymap(_THIS);
336diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/caca/SDL_cacavideo.c libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacavideo.c
337--- libsdl1.2-1.2.6/src/video/caca/SDL_cacavideo.c 1970-01-01 01:00:00.000000000 +0100
338+++ libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacavideo.c 2003-12-18 13:11:06.000000000 +0100
339@@ -0,0 +1,301 @@
340+/*
341+ SDL - Simple DirectMedia Layer
342+ Copyright (C) 2003 Sam Hocevar
343+
344+ This library is free software; you can redistribute it and/or
345+ modify it under the terms of the GNU Library General Public
346+ License as published by the Free Software Foundation; either
347+ version 2 of the License, or (at your option) any later version.
348+
349+ This library is distributed in the hope that it will be useful,
350+ but WITHOUT ANY WARRANTY; without even the implied warranty of
351+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
352+ Library General Public License for more details.
353+
354+ You should have received a copy of the GNU Library General Public
355+ License along with this library; if not, write to the Free
356+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
357+
358+ Sam Hocevar
359+ sam@zoy.org
360+*/
361+
362+#ifdef SAVE_RCSID
363+static char rcsid =
364+ "@(#) $Id: patch-libsdl1.2-libcaca0.7.diff 809 2005-03-23 11:07:40Z sam $";
365+#endif
366+
367+/* libcaca based SDL video driver implementation.
368+*/
369+
370+#include <stdlib.h>
371+#include <stdio.h>
372+#include <string.h>
373+#include <unistd.h>
374+#include <sys/stat.h>
375+
376+
377+#include "SDL.h"
378+#include "SDL_error.h"
379+#include "SDL_video.h"
380+#include "SDL_mouse.h"
381+#include "SDL_sysvideo.h"
382+#include "SDL_pixels_c.h"
383+#include "SDL_events_c.h"
384+
385+#include "SDL_cacavideo.h"
386+#include "SDL_cacaevents_c.h"
387+
388+#include <caca.h>
389+
390+/* Initialization/Query functions */
391+static int Caca_VideoInit(_THIS, SDL_PixelFormat *vformat);
392+static SDL_Rect **Caca_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags);
393+static SDL_Surface *Caca_SetVideoMode(_THIS, SDL_Surface *current, int width, int height, int bpp, Uint32 flags);
394+static void Caca_VideoQuit(_THIS);
395+
396+/* Hardware surface functions */
397+static int Caca_AllocHWSurface(_THIS, SDL_Surface *surface);
398+static int Caca_LockHWSurface(_THIS, SDL_Surface *surface);
399+static int Caca_FlipHWSurface(_THIS, SDL_Surface *surface);
400+static void Caca_UnlockHWSurface(_THIS, SDL_Surface *surface);
401+static void Caca_FreeHWSurface(_THIS, SDL_Surface *surface);
402+
403+/* Cache the VideoDevice struct */
404+static struct SDL_VideoDevice *local_this;
405+
406+/* libcaca driver bootstrap functions */
407+
408+static int Caca_Available(void)
409+{
410+ return 1; /* Always available ! */
411+}
412+
413+static void Caca_DeleteDevice(SDL_VideoDevice *device)
414+{
415+ free(device->hidden);
416+ free(device);
417+}
418+
419+static SDL_VideoDevice *Caca_CreateDevice(int devindex)
420+{
421+ SDL_VideoDevice *device;
422+
423+ /* Initialize all variables that we clean on shutdown */
424+ device = (SDL_VideoDevice *)malloc(sizeof(SDL_VideoDevice));
425+ if ( device ) {
426+ memset(device, 0, (sizeof *device));
427+ device->hidden = (struct SDL_PrivateVideoData *)
428+ malloc((sizeof *device->hidden));
429+ }
430+ if ( (device == NULL) || (device->hidden == NULL) ) {
431+ SDL_OutOfMemory();
432+ if ( device ) {
433+ free(device);
434+ }
435+ return(0);
436+ }
437+ memset(device->hidden, 0, (sizeof *device->hidden));
438+
439+ /* Set the function pointers */
440+ device->VideoInit = Caca_VideoInit;
441+ device->ListModes = Caca_ListModes;
442+ device->SetVideoMode = Caca_SetVideoMode;
443+ device->CreateYUVOverlay = NULL;
444+ device->SetColors = NULL;
445+ device->UpdateRects = NULL;
446+ device->VideoQuit = Caca_VideoQuit;
447+ device->AllocHWSurface = Caca_AllocHWSurface;
448+ device->CheckHWBlit = NULL;
449+ device->FillHWRect = NULL;
450+ device->SetHWColorKey = NULL;
451+ device->SetHWAlpha = NULL;
452+ device->LockHWSurface = Caca_LockHWSurface;
453+ device->UnlockHWSurface = Caca_UnlockHWSurface;
454+ device->FlipHWSurface = NULL;
455+ device->FreeHWSurface = Caca_FreeHWSurface;
456+ device->SetCaption = NULL;
457+ device->SetIcon = NULL;
458+ device->IconifyWindow = NULL;
459+ device->GrabInput = NULL;
460+ device->GetWMInfo = NULL;
461+ device->InitOSKeymap = Caca_InitOSKeymap;
462+ device->PumpEvents = Caca_PumpEvents;
463+
464+ device->free = Caca_DeleteDevice;
465+
466+ return device;
467+}
468+
469+VideoBootStrap Caca_bootstrap = {
470+ "caca", "Color ASCII Art Library",
471+ Caca_Available, Caca_CreateDevice
472+};
473+
474+int Caca_VideoInit(_THIS, SDL_PixelFormat *vformat)
475+{
476+ int i;
477+
478+ /* Initialize all variables that we clean on shutdown */
479+ for ( i=0; i<SDL_NUMMODES; ++i ) {
480+ SDL_modelist[i] = malloc(sizeof(SDL_Rect));
481+ SDL_modelist[i]->x = SDL_modelist[i]->y = 0;
482+ }
483+ /* Modes sorted largest to smallest */
484+ SDL_modelist[0]->w = 1024; SDL_modelist[0]->h = 768;
485+ SDL_modelist[1]->w = 800; SDL_modelist[1]->h = 600;
486+ SDL_modelist[2]->w = 640; SDL_modelist[2]->h = 480;
487+ SDL_modelist[3]->w = 320; SDL_modelist[3]->h = 400;
488+ SDL_modelist[4]->w = 320; SDL_modelist[4]->h = 240;
489+ SDL_modelist[5]->w = 320; SDL_modelist[5]->h = 200;
490+ SDL_modelist[6] = NULL;
491+
492+ Caca_mutex = SDL_CreateMutex();
493+
494+ /* Initialize the library */
495+ if ( caca_init() != 0 ) {
496+ SDL_SetError("Unable to initialize libcaca");
497+ return(-1);
498+ }
499+
500+ /* Initialize private variables */
501+ Caca_lastkey = 0;
502+ Caca_bitmap = NULL;
503+ Caca_buffer = NULL;
504+
505+ local_this = this;
506+
507+ /* Determine the screen depth (use default 8-bit depth) */
508+ vformat->BitsPerPixel = 8;
509+ vformat->BytesPerPixel = 1;
510+
511+ /* We're done! */
512+ return(0);
513+}
514+
515+SDL_Rect **Caca_ListModes(_THIS, SDL_PixelFormat *format, Uint32 flags)
516+{
517+ if(format->BitsPerPixel != 8)
518+ return NULL;
519+
520+ if ( flags & SDL_FULLSCREEN ) {
521+ return SDL_modelist;
522+ } else {
523+ return (SDL_Rect **) -1;
524+ }
525+}
526+
527+/* Various screen update functions available */
528+static void Caca_DirectUpdate(_THIS, int numrects, SDL_Rect *rects);
529+
530+SDL_Surface *Caca_SetVideoMode(_THIS, SDL_Surface *current,
531+ int width, int height, int bpp, Uint32 flags)
532+{
533+ if ( Caca_buffer ) {
534+ free( Caca_buffer );
535+ Caca_buffer = NULL;
536+ }
537+
538+ if ( Caca_bitmap ) {
539+ caca_free_bitmap( Caca_bitmap );
540+ Caca_bitmap = NULL;
541+ }
542+
543+ Caca_buffer = malloc(2 * ((width + 15) & ~15) * height);
544+ if ( ! Caca_buffer ) {
545+ SDL_SetError("Couldn't allocate buffer for requested mode");
546+ return(NULL);
547+ }
548+
549+ memset(Caca_buffer, 0, 2 * ((width + 15) & ~15) * height);
550+
551+ /* Allocate the new pixel format for the screen */
552+ if ( ! SDL_ReallocFormat(current, 16, 0xf800, 0x07e0, 0x001f, 0) ) {
553+ return(NULL);
554+ }
555+
556+ /* Set up the new mode framebuffer */
557+ current->flags = SDL_FULLSCREEN;
558+ Caca_w = current->w = width;
559+ Caca_h = current->h = height;
560+ current->pitch = 2 * ((width + 15) & ~15);
561+ current->pixels = Caca_buffer;
562+
563+ /* Create the libcaca bitmap */
564+ Caca_bitmap = caca_create_bitmap( 16, width, height, current->pitch, 0xf800, 0x07e0, 0x001f, 0x0000 );
565+ if ( ! Caca_bitmap ) {
566+ SDL_SetError("Couldn't allocate libcaca bitmap");
567+ return(NULL);
568+ }
569+
570+ /* Set the blit function */
571+ this->UpdateRects = Caca_DirectUpdate;
572+
573+ /* We're done */
574+ return(current);
575+}
576+
577+/* We don't actually allow hardware surfaces other than the main one */
578+static int Caca_AllocHWSurface(_THIS, SDL_Surface *surface)
579+{
580+ return(-1);
581+}
582+static void Caca_FreeHWSurface(_THIS, SDL_Surface *surface)
583+{
584+ return;
585+}
586+
587+/* We need to wait for vertical retrace on page flipped displays */
588+static int Caca_LockHWSurface(_THIS, SDL_Surface *surface)
589+{
590+ /* TODO ? */
591+ return(0);
592+}
593+static void Caca_UnlockHWSurface(_THIS, SDL_Surface *surface)
594+{
595+ return;
596+}
597+
598+/* FIXME: How is this done with libcaca? */
599+static int Caca_FlipHWSurface(_THIS, SDL_Surface *surface)
600+{
601+ SDL_mutexP(Caca_mutex);
602+ caca_refresh();
603+ SDL_mutexV(Caca_mutex);
604+ return(0);
605+}
606+
607+static void Caca_DirectUpdate(_THIS, int numrects, SDL_Rect *rects)
608+{
609+ SDL_mutexP(Caca_mutex);
610+ caca_draw_bitmap( 0, 0, caca_get_width() - 1, caca_get_height() - 1,
611+ Caca_bitmap, Caca_buffer );
612+ caca_refresh();
613+ SDL_mutexV(Caca_mutex);
614+ return;
615+}
616+
617+/* Note: If we are terminated, this could be called in the middle of
618+ another SDL video routine -- notably UpdateRects.
619+*/
620+void Caca_VideoQuit(_THIS)
621+{
622+ int i;
623+
624+ /* Free video mode lists */
625+ for ( i=0; i<SDL_NUMMODES; ++i ) {
626+ if ( SDL_modelist[i] != NULL ) {
627+ free(SDL_modelist[i]);
628+ SDL_modelist[i] = NULL;
629+ }
630+ }
631+
632+ if ( Caca_bitmap ) {
633+ caca_free_bitmap( Caca_bitmap );
634+ Caca_bitmap = NULL;
635+ }
636+
637+ caca_end();
638+
639+ SDL_DestroyMutex(Caca_mutex);
640+}
641diff -puriN -x Makefile -x '*.la' libsdl1.2-1.2.6/src/video/caca/SDL_cacavideo.h libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacavideo.h
642--- libsdl1.2-1.2.6/src/video/caca/SDL_cacavideo.h 1970-01-01 01:00:00.000000000 +0100
643+++ libsdl1.2-1.2.6-caca/src/video/caca/SDL_cacavideo.h 2003-11-21 16:03:00.000000000 +0100
644@@ -0,0 +1,72 @@
645+/*
646+ SDL - Simple DirectMedia Layer
647+ Copyright (C) 2003 Sam Hocevar
648+
649+ This library is free software; you can redistribute it and/or
650+ modify it under the terms of the GNU Library General Public
651+ License as published by the Free Software Foundation; either
652+ version 2 of the License, or (at your option) any later version.
653+
654+ This library is distributed in the hope that it will be useful,
655+ but WITHOUT ANY WARRANTY; without even the implied warranty of
656+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
657+ Library General Public License for more details.
658+
659+ You should have received a copy of the GNU Library General Public
660+ License along with this library; if not, write to the Free
661+ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
662+
663+ Sam Hocevar
664+ sam@zoy.org
665+*/
666+
667+#ifdef SAVE_RCSID
668+static char rcsid =
669+ "@(#) $Id: patch-libsdl1.2-libcaca0.7.diff 809 2005-03-23 11:07:40Z sam $";
670+#endif
671+
672+#ifndef _SDL_cacavideo_h
673+#define _SDL_cacavideo_h
674+
675+#include "SDL_mouse.h"
676+#include "SDL_sysvideo.h"
677+#include "SDL_mutex.h"
678+
679+#include <sys/time.h>
680+#include <time.h>
681+
682+#include <caca.h>
683+
684+/* Hidden "this" pointer for the video functions */
685+#define _THIS SDL_VideoDevice *this
686+
687+#define SDL_NUMMODES 6
688+
689+/* Private display data */
690+struct SDL_PrivateVideoData {
691+ SDL_Rect *SDL_modelist[SDL_NUMMODES+1];
692+ SDL_mutex *mutex;
693+
694+ struct caca_bitmap *bitmap;
695+ void *buffer;
696+ int w, h;
697+
698+ int lastkey;
699+ struct timeval lasttime;
700+};
701+
702+/* Old variable names */
703+#define SDL_modelist (this->hidden->SDL_modelist)
704+#define Caca_palette (this->hidden->palette)
705+#define Caca_bitmap (this->hidden->bitmap)
706+#define Caca_buffer (this->hidden->buffer)
707+
708+#define Caca_w (this->hidden->w)
709+#define Caca_h (this->hidden->h)
710+
711+#define Caca_lastkey (this->hidden->lastkey)
712+#define Caca_lasttime (this->hidden->lasttime)
713+
714+#define Caca_mutex (this->hidden->mutex)
715+
716+#endif /* _SDL_cacavideo_h */
Note: See TracBrowser for help on using the repository browser.