rnd-20131228-1-src
authorHolger Schemel <info@artsoft.org>
Sat, 28 Dec 2013 22:19:55 +0000 (23:19 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 09:00:22 +0000 (11:00 +0200)
* fixed graphical bugs when using renderer/texture based graphics
* fixed playing certain sounds (menu navigation sound and counting
  score sound after solving a level) when "normal sounds" are disabled

ChangeLog
Makefile
src/conftime.h
src/libgame/misc.c
src/libgame/misc.h
src/libgame/sdl.c
src/libgame/sound.c
src/tools.c

index e3b6490bbfb635631bdb549fee9166fc6552c12c..1ae9adc1b69a52deeee2cc88d189bc212f145bca 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2013-12-28
+       * fixed graphical bugs when using renderer/texture based graphics
+
+2013-12-23
+       * fixed playing certain sounds (menu navigation sound and counting
+         score sound after solving a level) when "normal sounds" are disabled
+
 2013-12-16
        * continued porting Rocks'n'Diamonds to Android (levels now playable)
 
index 96e630396baff70bcf8dd2dd3a5e7e684061617d..e24743a52444abb6240e57463f5219b3f79966b9 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -167,7 +167,7 @@ dist-clean:
        @$(MAKE_CMD) dist-clean
 
 dist-build-unix:
-       @BUILD_DIST=TRUE $(MAKE) x11
+       @BUILD_DIST=TRUE $(MAKE)
 
 dist-build-msdos:
        @BUILD_DIST=TRUE $(MAKE) cross-msdos
index ee032df2a4f9ad7dac5af1859bb6aa62640bff87..bb5776296bcf5560cdc0ced032479b07d7c80af9 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "2013-12-17 18:30"
+#define COMPILE_DATE_STRING "2013-12-28 23:17"
index 710917a36376117cd12fe7fdb826e463780baa9b..d2b7b4e7d45a06420265ba20e3dee56d14af77ce 100644 (file)
@@ -1568,8 +1568,10 @@ void translate_keyname(Key *keysym, char **x11name, char **name, int mode)
     { KSYM_Page_Up,    "XK_Page_Up",           "page up" },
     { KSYM_Page_Down,  "XK_Page_Down",         "page down" },
 
+#if defined(TARGET_SDL2)
     { KSYM_Menu,       "XK_Menu",              "menu" },        /* menu key */
     { KSYM_Back,       "XK_Back",              "back" },        /* back key */
+#endif
 
     /* ASCII 0x20 to 0x40 keys (except numbers) */
     { KSYM_space,      "XK_space",             "space" },
@@ -2055,7 +2057,7 @@ int closeFile(File *file)
   if (file == NULL)
     return -1;
 
-  int result;
+  int result = 0;
 
 #if defined(PLATFORM_ANDROID)
   if (file->asset_file)
@@ -2215,7 +2217,7 @@ int closeDirectory(Directory *dir)
   if (dir == NULL)
     return -1;
 
-  int result;
+  int result = 0;
 
 #if defined(PLATFORM_ANDROID)
   if (dir->asset_toc_file)
@@ -3782,6 +3784,8 @@ void debug_print_parent_only(char *format, ...)
   }
 }
 
+#endif /* DEBUG */
+
 void print_timestamp_ext(char *message, char *mode)
 {
 #if DEBUG_PRINT_INIT_TIMESTAMPS
@@ -3845,5 +3849,3 @@ void print_timestamp_done(char *message)
 {
   print_timestamp_ext(message, "DONE");
 }
-
-#endif /* DEBUG */
index 465d30ebae992f7c6568c32d134109df0c71dd9b..b2d84573b16e19e4d7161707dd4b1bac3e899f88 100644 (file)
@@ -297,11 +297,10 @@ void NotifyUserAboutErrorFile();
 
 #if DEBUG
 void debug_print_timestamp(int, char *);
+#endif
 void print_timestamp_init(char *);
 void print_timestamp_time(char *);
 void print_timestamp_done(char *);
-#endif /* DEBUG */
-
 
 
 #endif /* MISC_H */
index f02264d9d27ef0fe5a9c997230bf9aecc3bb1379..a72bdcc0cc80e5c52df9c2267c70f36802e714a5 100644 (file)
@@ -29,6 +29,8 @@
 static SDL_Window *sdl_window = NULL;
 static SDL_Renderer *sdl_renderer = NULL;
 static SDL_Texture *sdl_texture = NULL;
+
+#define USE_RENDERER   1
 #endif
 
 /* stuff needed to work around SDL/Windows fullscreen drawing bug */
@@ -42,12 +44,29 @@ static int video_yoffset;
 /* functions from SGE library */
 void sge_Line(SDL_Surface *, Sint16, Sint16, Sint16, Sint16, Uint32);
 
+#if defined(TARGET_SDL2)
 static void UpdateScreen(SDL_Rect *rect)
 {
-#if 1
+#if USE_RENDERER
   SDL_Surface *screen = backbuffer->surface;
 
+#if 1
+  if (rect)
+  {
+    int bytes_x = screen->pitch / video.width;
+    int bytes_y = screen->pitch;
+
+    SDL_UpdateTexture(sdl_texture, rect,
+                     screen->pixels + rect->x * bytes_x + rect->y * bytes_y,
+                     screen->pitch);
+  }
+  else
+  {
+    SDL_UpdateTexture(sdl_texture, NULL, screen->pixels, screen->pitch);
+  }
+#else
   SDL_UpdateTexture(sdl_texture, NULL, screen->pixels, screen->pitch);
+#endif
   SDL_RenderClear(sdl_renderer);
   SDL_RenderCopy(sdl_renderer, sdl_texture, NULL, NULL);
   SDL_RenderPresent(sdl_renderer);
@@ -58,6 +77,7 @@ static void UpdateScreen(SDL_Rect *rect)
     SDL_UpdateWindowSurface(sdl_window);
 #endif
 }
+#endif
 
 static void setFullscreenParameters(char *fullscreen_mode_string)
 {
@@ -343,7 +363,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
       new_surface = SDL_GetWindowSurface(sdl_window);
 
       // SDL_UpdateWindowSurface(sdl_window);  // immediately map window
-      UpdateScreen(NULL);      // immediately map window
+      // UpdateScreen(NULL);   // immediately map window
     }
 #else
     new_surface = SDL_SetVideoMode(fullscreen_width, fullscreen_height,
@@ -379,8 +399,8 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
     /* switch display to window mode */
 #if defined(TARGET_SDL2)
 
-#if 1
-    float scale_factor = 1;
+#if USE_RENDERER
+    float scale_factor = 1.2;
     int test_fullscreen = 0;
     int surface_flags = (test_fullscreen ? surface_flags_fullscreen :
                         surface_flags_window);
@@ -408,11 +428,23 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
 
        if (sdl_texture != NULL)
        {
+#if 1
+         // (do not use alpha channel)
+         new_surface = SDL_CreateRGBSurface(0, video.width, video.height, 32,
+                                            0x00FF0000,
+                                            0x0000FF00,
+                                            0x000000FF,
+                                            0x00000000);
+#else
+         // (this uses an alpha channel, which we don't want here)
          new_surface = SDL_CreateRGBSurface(0, video.width, video.height, 32,
                                             0x00FF0000,
                                             0x0000FF00,
                                             0x000000FF,
                                             0xFF000000);
+#endif
+
+         printf("::: pitch == %d\n", new_surface->pitch);
 
          if (new_surface == NULL)
            Error(ERR_WARN, "SDL_CreateRGBSurface() failed: %s",
@@ -444,7 +476,7 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
       new_surface = SDL_GetWindowSurface(sdl_window);
 
       // SDL_UpdateWindowSurface(sdl_window);  // immediately map window
-      UpdateScreen(NULL);      // immediately map window
+      // UpdateScreen(NULL);           // immediately map window
     }
 #endif
 
@@ -470,6 +502,10 @@ boolean SDLSetVideoMode(DrawBuffer **backbuffer, boolean fullscreen)
     }
   }
 
+#if defined(TARGET_SDL2)
+  UpdateScreen(NULL);          // map window
+#endif
+
 #if 1
   SDL_EventState(SDL_SYSWMEVENT, SDL_ENABLE);
 
@@ -549,7 +585,8 @@ void SDLCopyArea(Bitmap *src_bitmap, Bitmap *dst_bitmap,
   dst_rect.w = width;
   dst_rect.h = height;
 
-  if (src_bitmap != backbuffer || dst_bitmap != window)
+  // if (src_bitmap != backbuffer || dst_bitmap != window)
+  if (!(src_bitmap == backbuffer && dst_bitmap == window))
     SDL_BlitSurface((mask_mode == BLIT_MASKED ?
                     src_bitmap->surface_masked : src_bitmap->surface),
                    &src_rect, real_dst_bitmap->surface, &dst_rect);
index 83abf606718bc956f52f7002e7f86b998e9d0720..adfb8147f8cb3f19076a8cd87e32eb9c5997d9a9 100644 (file)
@@ -2190,21 +2190,33 @@ void PlayMusic(int nr)
 
 void PlaySound(int nr)
 {
+  if (!setup.sound_simple)
+    return;
+
   PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_SOUND);
 }
 
 void PlaySoundStereo(int nr, int stereo_position)
 {
+  if (!setup.sound_simple)
+    return;
+
   PlaySoundExt(nr, SOUND_MAX_VOLUME, stereo_position, SND_CTRL_PLAY_SOUND);
 }
 
 void PlaySoundLoop(int nr)
 {
+  if (!setup.sound_loops)
+    return;
+
   PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_LOOP);
 }
 
 void PlaySoundMusic(int nr)
 {
+  if (!setup.sound_music)
+    return;
+
   PlaySoundExt(nr, SOUND_MAX_VOLUME, SOUND_MIDDLE, SND_CTRL_PLAY_MUSIC);
 }
 
index abde1cc7b311b5bb60b7f1562f79c55b181de9ab..bd71d0c5a3f275e71a3397a7b8f9fd0d4166d989 100644 (file)
@@ -4172,7 +4172,9 @@ boolean Request(char *text, unsigned int req_state)
              break;
 
            case KSYM_Escape:
+#if defined(TARGET_SDL2)
            case KSYM_Back:
+#endif
              result = 0;
              break;