]> git.jsancho.org Git - gacela.git/blob - src/sdl.c
Preparing new version 0.6
[gacela.git] / src / sdl.c
1 /* Gacela, a GNU Guile extension for fast games development
2    Copyright (C) 2009 by Javier Sancho Fernandez <jsf at jsancho dot org>
3
4    This program is free software: you can redistribute it and/or modify
5    it under the terms of the GNU General Public License as published by
6    the Free Software Foundation, either version 3 of the License, or
7    (at your option) any later version.
8
9    This program is distributed in the hope that it will be useful,
10    but WITHOUT ANY WARRANTY; without even the implied warranty of
11    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12    GNU General Public License for more details.
13
14    You should have received a copy of the GNU General Public License
15    along with this program.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18 #include <libguile.h>
19 #include <SDL/SDL.h>
20 #include <SDL/SDL_events.h>
21 #include <SDL/SDL_image.h>
22 #include <SDL/SDL_mixer.h>
23 #include <SDL/SDL_rotozoom.h>
24
25 struct surface
26 {
27   SCM filename;
28   SDL_Surface *surface_address;
29 };
30
31 static scm_t_bits surface_tag;
32
33 SCM
34 make_surface (SCM file, SDL_Surface *surface_address)
35 {
36   SCM smob;
37   struct surface *surface;
38
39   surface = (struct surface *) scm_gc_malloc (sizeof (struct surface), "surface");
40
41   surface->filename = SCM_BOOL_F;
42   surface->surface_address = NULL;
43
44   SCM_NEWSMOB (smob, surface_tag, surface);
45
46   surface->filename = file;
47   surface->surface_address = surface_address;
48
49   return smob;
50 }
51
52 SDL_Surface *
53 get_surface_address (SCM surface_smob)
54 {
55   struct surface *surface;
56
57   scm_assert_smob_type (surface_tag, surface_smob);
58   surface = (struct surface *) SCM_SMOB_DATA (surface_smob);
59   return surface->surface_address;
60 }
61
62 SCM
63 get_surface_filename (SCM surface_smob)
64 {
65   struct surface *surface;
66
67   scm_assert_smob_type (surface_tag, surface_smob);
68   surface = (struct surface *) SCM_SMOB_DATA (surface_smob);
69   return surface->filename;
70 }
71
72 SCM
73 get_surface_width (SCM surface_smob)
74 {
75   SDL_Surface *surface = get_surface_address (surface_smob);
76
77   return scm_from_int (surface->w);
78 }
79
80 SCM
81 get_surface_height (SCM surface_smob)
82 {
83   SDL_Surface *surface = get_surface_address (surface_smob);
84
85   return scm_from_int (surface->h);
86 }
87
88 SCM
89 get_surface_pixels (SCM surface_smob)
90 {
91   SDL_Surface *surface = get_surface_address (surface_smob);
92
93   return scm_from_int ((int)surface->pixels);
94 }
95
96 SCM
97 get_surface_format_BytesPerPixel (SCM surface_smob)
98 {
99   SDL_Surface *surface = get_surface_address (surface_smob);
100
101   return scm_from_int (surface->format->BytesPerPixel);
102 }
103
104 SCM
105 mark_surface (SCM surface_smob)
106 {
107   struct surface *surface = (struct surface *) SCM_SMOB_DATA (surface_smob);
108
109   scm_gc_mark (surface->filename);
110      
111   return SCM_BOOL_F;
112 }
113
114 size_t
115 free_surface (SCM surface_smob)
116 {
117   struct surface *surface = (struct surface *) SCM_SMOB_DATA (surface_smob);
118
119   SDL_FreeSurface (surface->surface_address);
120   scm_gc_free (surface, sizeof (struct surface), "surface");
121
122   return 0;
123 }
124
125 static int
126 print_surface (SCM surface_smob, SCM port, scm_print_state *pstate)
127 {
128   struct surface *surface = (struct surface *) SCM_SMOB_DATA (surface_smob);
129
130   scm_puts ("#<surface \"", port);
131   scm_display (surface->filename, port);
132   scm_puts ("\">", port);
133
134   /* non-zero means success */
135   return 1;
136 }
137
138
139 SCM
140 gacela_SDL_Init (SCM flags)
141 {
142   return scm_from_int (SDL_Init (scm_to_int (flags)));
143 }
144
145 SCM
146 gacela_SDL_Quit (void)
147 {
148   SDL_Quit ();
149   return SCM_UNSPECIFIED;
150 }
151
152 SCM
153 gacela_SDL_SetVideoMode (SCM width, SCM height, SCM bpp, SCM flags)
154 {
155   SDL_Surface *screen = SDL_SetVideoMode (scm_to_int (width), scm_to_int (height), \
156                                           scm_to_int (bpp), scm_to_int (flags));
157
158   if (screen) {
159     return make_surface (scm_from_locale_string ("screen"), screen);
160   }
161   else {
162     return SCM_BOOL_F;
163   }
164 }
165
166 SCM
167 gacela_SDL_FreeSurface (SCM surface)
168 {
169   return scm_from_int (free_surface (surface));
170 }
171
172 SCM
173 gacela_SDL_WM_SetCaption (SCM title, SCM icon)
174 {
175   SDL_WM_SetCaption (scm_to_locale_string(title), scm_to_locale_string(icon));
176   return SCM_UNSPECIFIED;
177 }
178
179 SCM
180 gacela_SDL_WM_ToggleFullScreen(SCM surface)
181 {
182   return scm_from_int (SDL_WM_ToggleFullScreen (get_surface_address (surface)));
183 }
184
185 SCM
186 gacela_SDL_Flip (SCM screen)
187 {
188   return scm_from_int (SDL_Flip (get_surface_address (screen)));
189 }
190
191 SCM
192 gacela_SDL_Delay (SCM ms)
193 {
194   SDL_Delay ((int)scm_to_double (ms));
195   return SCM_UNSPECIFIED;
196 }
197
198 SCM
199 gacela_SDL_GetTicks (void)
200 {
201   return scm_from_int (SDL_GetTicks ());
202 }
203
204 SCM
205 gacela_SDL_GetError (void)
206 {
207   return scm_from_locale_string (SDL_GetError ());
208 }
209
210 SCM
211 gacela_SDL_DisplayFormat (SCM surface)
212 {
213   SDL_Surface *new = SDL_DisplayFormat (get_surface_address (surface));
214
215   if (new) {
216     return make_surface (get_surface_filename (surface), new);
217   }
218   else {
219     return SCM_BOOL_F;
220   }
221 }
222
223 SCM
224 gacela_SDL_DisplayFormatAlpha (SCM surface)
225 {
226   SDL_Surface *new = SDL_DisplayFormatAlpha (get_surface_address (surface));
227
228   if (new) {
229     return make_surface (get_surface_filename (surface), new);
230   }
231   else {
232     return SCM_BOOL_F;
233   }
234 }
235
236 SCM
237 gacela_SDL_MapRGB (SCM format, SCM r, SCM g, SCM b)
238 {
239   return scm_from_int (SDL_MapRGB ((SDL_PixelFormat *)scm_to_int (format), scm_to_int (r), scm_to_int (g), scm_to_int (b)));
240 }
241
242 SCM
243 gacela_SDL_SetColorKey (SCM surface, SCM flag, SCM key)
244 {
245   return scm_from_int (SDL_SetColorKey (get_surface_address (surface), scm_to_int (flag), scm_to_int (key)));
246 }
247
248 SCM
249 gacela_SDL_SetAlpha (SCM surface, SCM flag, SCM alpha)
250 {
251   return scm_from_int (SDL_SetAlpha (get_surface_address (surface), scm_to_int (flag), scm_to_int (alpha)));
252 }
253
254 SCM
255 gacela_SDL_LoadBMP (SCM file)
256 {
257   SDL_Surface *image = SDL_LoadBMP (scm_to_locale_string (file));
258
259   if (image) {
260     return make_surface (file, image);
261   }
262   else {
263     return SCM_BOOL_F;
264   }
265 }
266
267 SCM
268 gacela_IMG_Load (SCM filename)
269 {
270   SDL_Surface *image = IMG_Load (scm_to_locale_string (filename));
271
272   if (image) {
273     return make_surface (filename, image);
274   }
275   else {
276     return SCM_BOOL_F;
277   }
278 }
279
280 SCM
281 gacela_SDL_GetVideoInfo (void)
282 {
283   const SDL_VideoInfo *info;
284   SCM vi;
285
286   info = SDL_GetVideoInfo ();
287   vi = scm_list_n (SCM_UNDEFINED);
288
289   vi = scm_cons (scm_cons (scm_from_utf8_symbol ("blit_hw"), scm_from_int (info->blit_hw)), vi);
290   vi = scm_cons (scm_cons (scm_from_utf8_symbol ("hw_available"), scm_from_int (info->hw_available)), vi);
291
292   return vi;
293 }
294
295 SCM
296 gacela_SDL_GL_SetAttribute (SCM attr, SCM value)
297 {
298   return scm_from_int (SDL_GL_SetAttribute (scm_to_int (attr), scm_to_int (value)));
299 }
300
301 SCM
302 gacela_SDL_PollEvent (void)
303 {
304   SDL_Event sdl_event;
305   SCM event;
306
307   event = scm_list_n (SCM_UNDEFINED);
308
309   if (SDL_PollEvent (&sdl_event)) {
310     switch (sdl_event.type) {
311     case SDL_KEYDOWN:
312     case SDL_KEYUP:
313       event = scm_cons (scm_cons (scm_from_locale_symbol ("key.keysym.sym"), scm_from_int (sdl_event.key.keysym.sym)), event);
314       break;
315     }
316     event = scm_cons (scm_cons (scm_from_locale_symbol ("type"), scm_from_int (sdl_event.type)), event);
317   }
318
319   return event;
320 }
321
322 SCM
323 gacela_SDL_GL_SwapBuffers (void)
324 {
325   SDL_GL_SwapBuffers ();
326   return SCM_UNSPECIFIED;
327 }
328
329 SCM
330 gacela_SDL_EnableKeyRepeat (SCM delay, SCM interval)
331 {
332   return scm_from_int (SDL_EnableKeyRepeat (scm_to_int (delay), scm_to_int (interval)));
333 }
334
335 SCM
336 gacela_zoomSurface (SCM src, SCM zoomx, SCM zoomy, SCM smooth)
337 {
338   SDL_Surface *image = zoomSurface (get_surface_address (src), scm_to_double (zoomx), scm_to_double (zoomy), scm_to_int (smooth));
339
340   if (image) {
341     return make_surface (get_surface_filename (src), image);
342   }
343   else {
344     return SCM_BOOL_F;
345   }
346 }
347
348 SCM
349 gacela_Mix_OpenAudio (SCM frequency, SCM format, SCM channels, SCM chunksize)
350 {
351   return scm_from_int (Mix_OpenAudio (scm_to_int (frequency), scm_to_int (format), scm_to_int (channels), scm_to_int (chunksize)));
352 }
353
354 SCM
355 gacela_Mix_LoadMUS (SCM file)
356 {
357   return scm_from_int ((int)Mix_LoadMUS (scm_to_locale_string (file)));
358 }
359
360 SCM
361 gacela_Mix_LoadWAV (SCM file)
362 {
363   return scm_from_int ((int)Mix_LoadWAV (scm_to_locale_string (file)));
364 }
365
366 SCM
367 gacela_Mix_PlayChannel (SCM channel, SCM chunk, SCM loops)
368 {
369   return scm_from_int (Mix_PlayChannel (scm_to_int (channel), (Mix_Chunk *)scm_to_int (chunk), scm_to_int (loops)));
370 }
371
372 SCM
373 gacela_Mix_PlayMusic (SCM music, SCM loops)
374 {
375   return scm_from_int (Mix_PlayMusic ((Mix_Music *)scm_to_int (music), scm_to_int (loops)));
376 }
377
378 SCM
379 gacela_Mix_PlayingMusic (void)
380 {
381   return scm_from_int (Mix_PlayingMusic ());
382 }
383
384 SCM
385 gacela_Mix_PausedMusic (void)
386 {
387   return scm_from_int (Mix_PausedMusic ());
388 }
389
390 SCM
391 gacela_Mix_PauseMusic (void)
392 {
393   Mix_PauseMusic ();
394   return SCM_UNSPECIFIED;
395 }
396
397 SCM
398 gacela_Mix_ResumeMusic (void)
399 {
400   Mix_ResumeMusic ();
401   return SCM_UNSPECIFIED;
402 }
403
404 SCM
405 gacela_Mix_HaltMusic (void)
406 {
407   return scm_from_int (Mix_HaltMusic ());
408 }
409
410 SCM
411 gacela_Mix_FreeMusic (SCM music)
412 {
413   Mix_FreeMusic ((Mix_Music *)scm_to_int (music));
414   return SCM_UNSPECIFIED;
415 }
416
417 SCM
418 gacela_Mix_FreeChunk (SCM chunk)
419 {
420   Mix_FreeChunk ((Mix_Chunk *)scm_to_int (chunk));
421   return SCM_UNSPECIFIED;
422 }
423
424 SCM
425 gacela_Mix_CloseAudio (void)
426 {
427   Mix_CloseAudio ();
428   return SCM_UNSPECIFIED;
429 }
430
431
432 void
433 init_gacela_sdl (void *data)
434 {
435   surface_tag = scm_make_smob_type ("surface", sizeof (struct surface));
436   scm_set_smob_mark (surface_tag, mark_surface);
437   scm_set_smob_free (surface_tag, free_surface);
438   scm_set_smob_print (surface_tag, print_surface);
439   scm_c_define_gsubr ("surface-file", 1, 0, 0, get_surface_filename);
440   scm_c_define_gsubr ("surface-w", 1, 0, 0, get_surface_width);
441   scm_c_define_gsubr ("surface-h", 1, 0, 0, get_surface_height);
442   scm_c_define_gsubr ("surface-pixels", 1, 0, 0, get_surface_pixels);
443   scm_c_define_gsubr ("surface-format-BytesPerPixel", 1, 0, 0, get_surface_format_BytesPerPixel);
444
445   scm_c_define ("SDL_INIT_TIMER", scm_from_int (SDL_INIT_TIMER));
446   scm_c_define ("SDL_INIT_AUDIO", scm_from_int (SDL_INIT_AUDIO));
447   scm_c_define ("SDL_INIT_VIDEO", scm_from_int (SDL_INIT_VIDEO));
448   scm_c_define ("SDL_INIT_CDROM", scm_from_int (SDL_INIT_CDROM));
449   scm_c_define ("SDL_INIT_JOYSTICK", scm_from_int (SDL_INIT_JOYSTICK));
450   scm_c_define ("SDL_INIT_NOPARACHUTE", scm_from_int (SDL_INIT_NOPARACHUTE));
451   scm_c_define ("SDL_INIT_EVENTTHREAD", scm_from_int (SDL_INIT_EVENTTHREAD));
452   scm_c_define ("SDL_INIT_EVERYTHING", scm_from_int (SDL_INIT_EVERYTHING));
453
454   scm_c_define ("SDL_SWSURFACE", scm_from_int (SDL_SWSURFACE));
455   scm_c_define ("SDL_HWSURFACE", scm_from_int (SDL_HWSURFACE));
456   scm_c_define ("SDL_ASYNCBLIT", scm_from_int (SDL_ASYNCBLIT));
457
458   scm_c_define ("SDL_ANYFORMAT", scm_from_int (SDL_ANYFORMAT));
459   scm_c_define ("SDL_HWPALETTE", scm_from_int (SDL_HWPALETTE));
460   scm_c_define ("SDL_DOUBLEBUF", scm_from_int (SDL_DOUBLEBUF));
461   scm_c_define ("SDL_FULLSCREEN", scm_from_int (SDL_FULLSCREEN));
462   scm_c_define ("SDL_OPENGL", scm_from_int (SDL_OPENGL));
463   scm_c_define ("SDL_OPENGLBLIT", scm_from_int (SDL_OPENGLBLIT));
464   scm_c_define ("SDL_RESIZABLE", scm_from_int (SDL_RESIZABLE));
465   scm_c_define ("SDL_NOFRAME", scm_from_int (SDL_NOFRAME));
466
467   scm_c_define ("SDL_HWACCEL", scm_from_int (SDL_HWACCEL));
468   scm_c_define ("SDL_SRCCOLORKEY", scm_from_int (SDL_SRCCOLORKEY));
469
470   scm_c_define ("SDL_GL_DOUBLEBUFFER", scm_from_int (SDL_GL_DOUBLEBUFFER));
471
472   scm_c_define ("SDL_DEFAULT_REPEAT_DELAY", scm_from_int (SDL_DEFAULT_REPEAT_DELAY));
473   scm_c_define ("SDL_DEFAULT_REPEAT_INTERVAL", scm_from_int (SDL_DEFAULT_REPEAT_INTERVAL));
474
475   scm_c_define ("SDL_LIL_ENDIAN", scm_from_int (SDL_LIL_ENDIAN));
476   scm_c_define ("SDL_BIG_ENDIAN", scm_from_int (SDL_BIG_ENDIAN));
477   scm_c_define ("SDL_BYTEORDER", scm_from_int (SDL_BYTEORDER));
478
479   scm_c_define ("MIX_DEFAULT_FORMAT", scm_from_int (MIX_DEFAULT_FORMAT));
480
481   scm_c_define ("SDL_NOEVENT", scm_from_int (SDL_NOEVENT));
482   scm_c_define ("SDL_ACTIVEEVENT", scm_from_int (SDL_ACTIVEEVENT));
483   scm_c_define ("SDL_KEYDOWN", scm_from_int (SDL_KEYDOWN));
484   scm_c_define ("SDL_KEYUP", scm_from_int (SDL_KEYUP));
485   scm_c_define ("SDL_MOUSEMOTION", scm_from_int (SDL_MOUSEMOTION));
486   scm_c_define ("SDL_MOUSEBUTTONDOWN", scm_from_int (SDL_MOUSEBUTTONDOWN));
487   scm_c_define ("SDL_MOUSEBUTTONUP", scm_from_int (SDL_MOUSEBUTTONUP));
488   scm_c_define ("SDL_JOYAXISMOTION", scm_from_int (SDL_JOYAXISMOTION));
489   scm_c_define ("SDL_JOYBALLMOTION", scm_from_int (SDL_JOYBALLMOTION));
490   scm_c_define ("SDL_JOYHATMOTION", scm_from_int (SDL_JOYHATMOTION));
491   scm_c_define ("SDL_JOYBUTTONDOWN", scm_from_int (SDL_JOYBUTTONDOWN));
492   scm_c_define ("SDL_JOYBUTTONUP", scm_from_int (SDL_JOYBUTTONUP));
493   scm_c_define ("SDL_QUIT", scm_from_int (SDL_QUIT));
494   scm_c_define ("SDL_SYSWMEVENT", scm_from_int (SDL_SYSWMEVENT));
495   scm_c_define ("SDL_EVENT_RESERVEDA", scm_from_int (SDL_EVENT_RESERVEDA));
496   scm_c_define ("SDL_EVENT_RESERVEDB", scm_from_int (SDL_EVENT_RESERVEDB));
497   scm_c_define ("SDL_VIDEORESIZE", scm_from_int (SDL_VIDEORESIZE));
498   scm_c_define ("SDL_VIDEOEXPOSE", scm_from_int (SDL_VIDEOEXPOSE));
499   scm_c_define ("SDL_EVENT_RESERVED2", scm_from_int (SDL_EVENT_RESERVED2));
500   scm_c_define ("SDL_EVENT_RESERVED3", scm_from_int (SDL_EVENT_RESERVED3));
501   scm_c_define ("SDL_EVENT_RESERVED4", scm_from_int (SDL_EVENT_RESERVED4));
502   scm_c_define ("SDL_EVENT_RESERVED5", scm_from_int (SDL_EVENT_RESERVED5));
503   scm_c_define ("SDL_EVENT_RESERVED6", scm_from_int (SDL_EVENT_RESERVED6));
504   scm_c_define ("SDL_EVENT_RESERVED7", scm_from_int (SDL_EVENT_RESERVED7));
505   scm_c_define ("SDL_USEREVENT", scm_from_int (SDL_USEREVENT));
506   scm_c_define ("SDL_NUMEVENTS", scm_from_int (SDL_NUMEVENTS));
507
508   scm_c_define_gsubr ("SDL_Init", 1, 0, 0, gacela_SDL_Init);
509   scm_c_define_gsubr ("SDL_Quit", 0, 0, 0, gacela_SDL_Quit);
510   scm_c_define_gsubr ("SDL_SetVideoMode", 4, 0, 0, gacela_SDL_SetVideoMode);
511   scm_c_define_gsubr ("SDL_FreeSurface", 1, 0, 0, gacela_SDL_FreeSurface);
512   scm_c_define_gsubr ("SDL_WM_SetCaption", 2, 0, 0, gacela_SDL_WM_SetCaption);
513   scm_c_define_gsubr ("SDL_WM_ToggleFullScreen", 1, 0, 0, gacela_SDL_WM_ToggleFullScreen);
514   scm_c_define_gsubr ("SDL_Flip", 1, 0, 0, gacela_SDL_Flip);
515   scm_c_define_gsubr ("SDL_Delay", 1, 0, 0, gacela_SDL_Delay);
516   scm_c_define_gsubr ("SDL_GetTicks", 0, 0, 0, gacela_SDL_GetTicks);
517   scm_c_define_gsubr ("SDL_GetError", 0, 0, 0, gacela_SDL_GetError);
518   scm_c_define_gsubr ("SDL_DisplayFormat", 1, 0, 0, gacela_SDL_DisplayFormat);
519   scm_c_define_gsubr ("SDL_DisplayFormatAlpha", 1, 0, 0, gacela_SDL_DisplayFormatAlpha);
520   scm_c_define_gsubr ("SDL_MapRGB", 4, 0, 0, gacela_SDL_MapRGB);
521   scm_c_define_gsubr ("SDL_SetColorKey", 3, 0, 0, gacela_SDL_SetColorKey);
522   scm_c_define_gsubr ("SDL_SetAlpha", 3, 0, 0, gacela_SDL_SetAlpha);
523   scm_c_define_gsubr ("SDL_LoadBMP", 1, 0, 0, gacela_SDL_LoadBMP);
524   scm_c_define_gsubr ("IMG_Load", 1, 0, 0, gacela_IMG_Load);
525   scm_c_define_gsubr ("SDL_GetVideoInfo", 0, 0, 0, gacela_SDL_GetVideoInfo);
526   scm_c_define_gsubr ("SDL_GL_SetAttribute", 2, 0, 0, gacela_SDL_GL_SetAttribute);
527   scm_c_define_gsubr ("SDL_PollEvent", 0, 0, 0, gacela_SDL_PollEvent);
528   scm_c_define_gsubr ("SDL_GL_SwapBuffers", 0, 0, 0, gacela_SDL_GL_SwapBuffers);
529   scm_c_define_gsubr ("SDL_EnableKeyRepeat", 2, 0, 0, gacela_SDL_EnableKeyRepeat);
530   scm_c_define_gsubr ("zoomSurface", 4, 0, 0, gacela_zoomSurface);
531   scm_c_define_gsubr ("Mix_OpenAudio", 4, 0, 0, gacela_Mix_OpenAudio);
532   scm_c_define_gsubr ("Mix_LoadMUS", 1, 0, 0, gacela_Mix_LoadMUS);
533   scm_c_define_gsubr ("Mix_LoadWAV", 1, 0, 0, gacela_Mix_LoadWAV);
534   scm_c_define_gsubr ("Mix_PlayChannel", 3, 0, 0, gacela_Mix_PlayChannel);
535   scm_c_define_gsubr ("Mix_PlayMusic", 2, 0, 0, gacela_Mix_PlayMusic);
536   scm_c_define_gsubr ("Mix_PlayingMusic", 0, 0, 0, gacela_Mix_PlayingMusic);
537   scm_c_define_gsubr ("Mix_PausedMusic", 0, 0, 0, gacela_Mix_PausedMusic);
538   scm_c_define_gsubr ("Mix_PauseMusic", 0, 0, 0, gacela_Mix_PauseMusic);
539   scm_c_define_gsubr ("Mix_ResumeMusic", 0, 0, 0, gacela_Mix_ResumeMusic);
540   scm_c_define_gsubr ("Mix_HaltMusic", 0, 0, 0, gacela_Mix_HaltMusic);
541   scm_c_define_gsubr ("Mix_FreeMusic", 1, 0, 0, gacela_Mix_FreeMusic);
542   scm_c_define_gsubr ("Mix_FreeChunk", 1, 0, 0, gacela_Mix_FreeChunk);
543   scm_c_define_gsubr ("Mix_CloseAudio", 0, 0, 0, gacela_Mix_CloseAudio);
544 }
545
546 void
547 scm_init_gacela_sdl ()
548 {
549   init_gacela_sdl (NULL);
550 }