rnd-20030403-2-src
[rocksndiamonds.git] / src / libgame / sdl.c
index 46e41d78a3e0524a1b2710102cee0ccbaa6d7cb5..85dbab9491f953079216802a95079b775a66e0c5 100644 (file)
@@ -40,6 +40,8 @@ static int video_yoffset;
 
 inline void SDLInitVideoDisplay(void)
 {
+  putenv("SDL_VIDEO_CENTERED=1");
+
   /* initialize SDL video */
   if (SDL_InitSubSystem(SDL_INIT_VIDEO) < 0)
     Error(ERR_EXIT, "SDL_InitSubSystem() failed: %s", SDL_GetError());
@@ -1107,12 +1109,21 @@ SDL_Surface *zoomSurface(SDL_Surface *src, int dst_width, int dst_height)
 
 void SDLZoomBitmap(Bitmap *src_bitmap, Bitmap *dst_bitmap)
 {
+  SDL_Surface *sdl_surface_tmp;
   int dst_width = dst_bitmap->width;
   int dst_height = dst_bitmap->height;
 
+  /* throw away old destination surface */
   SDL_FreeSurface(dst_bitmap->surface);
 
-  dst_bitmap->surface = zoomSurface(src_bitmap->surface, dst_width,dst_height);
+  /* create zoomed temporary surface from source surface */
+  sdl_surface_tmp = zoomSurface(src_bitmap->surface, dst_width, dst_height);
+
+  /* create native format destination surface from zoomed temporary surface */
+  dst_bitmap->surface = SDL_DisplayFormat(sdl_surface_tmp);
+
+  /* free temporary surface */
+  SDL_FreeSurface(sdl_surface_tmp);
 }
 
 
@@ -1164,6 +1175,9 @@ Bitmap *SDLLoadImage(char *filename)
 
 inline void SDLOpenAudio(void)
 {
+  if (strcmp(setup.system.sdl_audiodriver, ARG_DEFAULT) != 0)
+    putenv(getStringCat2("SDL_AUDIODRIVER=", setup.system.sdl_audiodriver));
+
   if (SDL_InitSubSystem(SDL_INIT_AUDIO) < 0)
   {
     Error(ERR_WARN, "SDL_InitSubSystem() failed: %s", SDL_GetError());
@@ -1172,7 +1186,7 @@ inline void SDLOpenAudio(void)
 
   if (Mix_OpenAudio(DEFAULT_AUDIO_SAMPLE_RATE, MIX_DEFAULT_FORMAT,
                    AUDIO_NUM_CHANNELS_STEREO,
-                   DEFAULT_AUDIO_FRAGMENT_SIZE) < 0)
+                   setup.system.audio_fragment_size) < 0)
   {
     Error(ERR_WARN, "Mix_OpenAudio() failed: %s", SDL_GetError());
     return;