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