Merge branch 'master' into releases 2.1.1
authorHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:38:06 +0000 (10:38 +0200)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:38:06 +0000 (10:38 +0200)
CHANGES
src/Makefile
src/conftime.h
src/libgame/misc.c
src/libgame/platform.h
src/libgame/sound.c
src/libgame/system.c
src/libgame/system.h
src/main.h

diff --git a/CHANGES b/CHANGES
index 6112c0b02cec3bd4e935b69af2632bef23dd93e3..3635776709fae4786c845201ec4e5726c37d49f4 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,13 @@
+Release Version 2.1.1 [13 AUG 2002]
+-----------------------------------
+       - sound bug (causing crashes) fixed (reported by Keith Peterston)
+       - support for /dev/sound/dsp (devfs) added (thanks to Christoph Bauer)
+       - small NetBSD compilation bug fixed (thanks to Adam Ciarcinski)
+       - default keys for "snap field" and "place bomb" fixed for Mac OS X
+       - added new contributed levels from the following players:
+         + Alan Bond
+         + Gerrit Holl
+
 Release Version 2.1.0 [05 AUG 2002]
 -----------------------------------
        - native Mac OS X port (finally!)
index e935b51d4715fd8bc1c6fababb8cbf01e98f710a..609d753f1d7de98efe5d015a2724117790ba0f0b 100644 (file)
@@ -171,7 +171,7 @@ libgame_dir:
 $(LIBGAME):
        @$(MAKE) -C $(LIBDIR)
 
-$(TIMESTAMP_FILE): $(SRCS)
+$(TIMESTAMP_FILE): $(SRCS) $(LIBGAME)
        @date '+"[%Y-%m-%d %H:%M]"' \
        | sed -e 's/^/#define COMPILE_DATE_STRING /' \
        > $(TIMESTAMP_FILE)
index 28ed84b5ef205e14ceb3a1a2927a797a39127ff6..5cfe6cf0b524a83f139ac455acac71dac979744c 100644 (file)
@@ -1 +1 @@
-#define COMPILE_DATE_STRING "[2002-08-05 02:26]"
+#define COMPILE_DATE_STRING "[2002-08-13 01:52]"
index acada2472e9754f5e15b775b0e74fae3832823f7..8bc69396cb464a0ad20b666dbced14501277c85e 100644 (file)
@@ -635,7 +635,7 @@ void Error(int mode, char *format, ...)
   if (mode & ERR_WARN && !options.verbose)
     return;
 
-#if !defined(PLATFORM_UNIX)
+#if defined(PLATFORM_MSDOS)
   newline = "\r\n";
 
   if ((error = openErrorFile()) == NULL)
@@ -1265,44 +1265,27 @@ boolean FileIsArtworkType(char *basename, int type)
 
 
 /* ========================================================================= */
-/* functions only needed for non-Unix (non-command-line) systems */
+/* functions only needed for non-Unix (non-command-line) systems             */
+/* (MS-DOS only; SDL/Windows creates files "stdout.txt" and "stderr.txt")    */
 /* ========================================================================= */
 
-#if !defined(PLATFORM_UNIX)
+#if defined(PLATFORM_MSDOS)
 
-#define ERROR_FILENAME         "error.out"
+#define ERROR_FILENAME         "stderr.txt"
 
 void initErrorFile()
 {
-  char *filename;
-
-  InitUserDataDirectory();
-
-  filename = getPath2(getUserDataDir(), ERROR_FILENAME);
-  unlink(filename);
-  free(filename);
+  unlink(ERROR_FILENAME);
 }
 
 FILE *openErrorFile()
 {
-  char *filename;
-  FILE *error_file;
-
-  filename = getPath2(getUserDataDir(), ERROR_FILENAME);
-  error_file = fopen(filename, MODE_APPEND);
-  free(filename);
-
-  return error_file;
+  return fopen(ERROR_FILENAME, MODE_APPEND);
 }
 
 void dumpErrorFile()
 {
-  char *filename;
-  FILE *error_file;
-
-  filename = getPath2(getUserDataDir(), ERROR_FILENAME);
-  error_file = fopen(filename, MODE_READ);
-  free(filename);
+  FILE *error_file = fopen(ERROR_FILENAME, MODE_READ);
 
   if (error_file != NULL)
   {
index 94c5c4a8bc994d0785b49e359f4c46ed67fdf14d..61ab27f6a59d9b365b87b7b85eaceb0621524579 100644 (file)
@@ -66,8 +66,8 @@
 #define PLATFORM_BSDI
 #endif
 
-#if defined(sparc) || defined(sun)
-#define PLATFORM_SOLARIS
+#if defined(sparc) && defined(sun)
+#define PLATFORM_SUNOS
 #endif
 
 #if defined(__APPLE__) && defined(__MACH__)
index cd34b284473e3126a0191fc3074f7005793fd0e0..6f48576667caf33254d8960e3338e51b9a55cf9c 100644 (file)
@@ -66,6 +66,7 @@
 #define MUS_TYPE_MOD                   2
 
 #define DEVICENAME_DSP                 "/dev/dsp"
+#define DEVICENAME_SOUND_DSP           "/dev/sound/dsp"
 #define DEVICENAME_AUDIO               "/dev/audio"
 #define DEVICENAME_AUDIOCTL            "/dev/audioCtl"
 
@@ -234,6 +235,7 @@ static boolean TestAudioDevices(void)
   static char *audio_device_name[] =
   {
     DEVICENAME_DSP,
+    DEVICENAME_SOUND_DSP,
     DEVICENAME_AUDIO
   };
   int audio_device_fd = -1;
@@ -350,7 +352,7 @@ static void InitAudioDevice_Linux(struct AudioFormatInfo *afmt)
 
   if (ioctl(audio.device_fd, SNDCTL_DSP_SETFRAGMENT, &fragment_spec) < 0)
     Error(ERR_EXIT_SOUND_SERVER,
-         "cannot set fragment size of /dev/dsp -- no sounds");
+         "cannot set fragment size of audio device -- no sounds");
 
   i = 0;
   afmt->format = 0;
@@ -366,7 +368,7 @@ static void InitAudioDevice_Linux(struct AudioFormatInfo *afmt)
 
   if (afmt->format == 0)       /* no supported audio format found */
     Error(ERR_EXIT_SOUND_SERVER,
-         "cannot set audio format of /dev/dsp -- no sounds");
+         "cannot set audio format of audio device -- no sounds");
 
   /* try if we can use stereo sound */
   afmt->stereo = TRUE;
@@ -375,15 +377,15 @@ static void InitAudioDevice_Linux(struct AudioFormatInfo *afmt)
 
   if (ioctl(audio.device_fd, SNDCTL_DSP_SPEED, &afmt->sample_rate) < 0)
     Error(ERR_EXIT_SOUND_SERVER,
-         "cannot set sample rate of /dev/dsp -- no sounds");
+         "cannot set sample rate of audio device -- no sounds");
 
   /* get the real fragmentation size; this should return 512 */
   if (ioctl(audio.device_fd, SNDCTL_DSP_GETBLKSIZE, &fragment_size_query) < 0)
     Error(ERR_EXIT_SOUND_SERVER,
-         "cannot get fragment size of /dev/dsp -- no sounds");
+         "cannot get fragment size of audio device -- no sounds");
   if (fragment_size_query != afmt->fragment_size)
     Error(ERR_EXIT_SOUND_SERVER,
-         "cannot set fragment size of /dev/dsp -- no sounds");
+         "cannot set fragment size of audio device -- no sounds");
 }
 #endif /* AUDIO_LINUX_IOCTL */
 
@@ -397,8 +399,8 @@ static void InitAudioDevice_NetBSD(struct AudioFormatInfo *afmt)
   a_info.play.encoding = AUDIO_ENCODING_LINEAR8;
   a_info.play.precision = 8;
   a_info.play.channels = 2;
-  a_info.play.sample_rate = sample_rate;
-  a_info.blocksize = fragment_size;
+  a_info.play.sample_rate = afmt->sample_rate;
+  a_info.blocksize = afmt->fragment_size;
 
   afmt->format = AUDIO_FORMAT_U8;
   afmt->stereo = TRUE;
@@ -412,7 +414,7 @@ static void InitAudioDevice_NetBSD(struct AudioFormatInfo *afmt)
 
     if (ioctl(audio.device_fd, AUDIO_SETINFO, &a_info) < 0)
       Error(ERR_EXIT_SOUND_SERVER,
-           "cannot set sample rate of /dev/audio -- no sounds");
+           "cannot set sample rate of audio device -- no sounds");
   }
 }
 #endif /* PLATFORM_NETBSD */
@@ -425,7 +427,7 @@ static void InitAudioDevice_HPUX(struct AudioFormatInfo *afmt)
 
   audio_ctl = open("/dev/audioCtl", O_WRONLY | O_NDELAY);
   if (audio_ctl == -1)
-    Error(ERR_EXIT_SOUND_SERVER, "cannot open /dev/audioCtl -- no sounds");
+    Error(ERR_EXIT_SOUND_SERVER, "cannot open audio device -- no sounds");
 
   if (ioctl(audio_ctl, AUDIO_DESCRIBE, &ainfo) == -1)
     Error(ERR_EXIT_SOUND_SERVER, "no audio info -- no sounds");
@@ -803,11 +805,8 @@ static void Mixer_InsertSound(SoundControl snd_ctrl)
   int i, k;
 
 #if 0
-  printf("NEW SOUND %d HAS ARRIVED [%d]\n", snd_ctrl.nr, num_sounds);
-#endif
-
-#if 0
-  printf("%d ACTIVE CHANNELS\n", mixer_active_channels);
+  printf("NEW SOUND %d ARRIVED [%d] [%d ACTIVE CHANNELS]\n",
+        snd_ctrl.nr, num_sounds, mixer_active_channels);
 #endif
 
   if (IS_MUSIC(snd_ctrl))
@@ -833,10 +832,7 @@ static void Mixer_InsertSound(SoundControl snd_ctrl)
   /* play music samples on a dedicated music channel */
   if (IS_MUSIC(snd_ctrl))
   {
-#if 0
-    printf("PLAY MUSIC WITH VOLUME/STEREO %d/%d\n",
-          snd_ctrl.volume, snd_ctrl.stereo_position);
-#endif
+    Mixer_StopMusicChannel();
 
     mixer[audio.music_channel] = snd_ctrl;
     Mixer_PlayMusicChannel();
@@ -921,12 +917,36 @@ static void Mixer_InsertSound(SoundControl snd_ctrl)
      of the channel's sound sample when compiling with the SDL mixer
      library, we use the current playing time (in milliseconds) instead. */
 
+#if DEBUG
+  /* channel allocation sanity check -- should not be needed */
+  if (mixer_active_channels ==
+      audio.num_channels - (mixer[audio.music_channel].active ? 0 : 1))
+  {
+    for (i=audio.first_sound_channel; i<audio.num_channels; i++)
+    {
+      if (!mixer[i].active)
+      {
+       Error(ERR_RETURN, "Mixer_InsertSound: Channel %d inactive", i);
+       Error(ERR_RETURN, "Mixer_InsertSound: This should never happen!");
+
+       mixer_active_channels--;
+      }
+    }
+  }
+#endif
+
   if (mixer_active_channels ==
       audio.num_channels - (mixer[audio.music_channel].active ? 0 : 1))
   {
     unsigned long playing_current = Counter();
     int longest = 0, longest_nr = audio.first_sound_channel;
 
+    for (i=audio.first_sound_channel; i<audio.num_channels; i++)
+    {
+      Error(ERR_RETURN, "Mixer_InsertSound: %d [%d]: %ld (%ld)",
+           i, mixer[i].active, mixer[i].data_len, (long)mixer[i].data_ptr);
+    }
+
     for (i=audio.first_sound_channel; i<audio.num_channels; i++)
     {
       int playing_time = playing_current - mixer[i].playing_starttime;
@@ -943,42 +963,24 @@ static void Mixer_InsertSound(SoundControl snd_ctrl)
   }
 
   /* add the new sound to the mixer */
-  for(i=0; i<audio.num_channels; i++)
+  for(i=audio.first_sound_channel; i<audio.num_channels; i++)
   {
 #if 0
     printf("CHECKING CHANNEL %d FOR SOUND %d ...\n", i, snd_ctrl.nr);
 #endif
 
-    /*
-    if (!mixer[i].active ||
-       (IS_MUSIC(snd_ctrl) && i == audio.music_channel))
-    */
-    if ((i == audio.music_channel && IS_MUSIC(snd_ctrl)) ||
-       (i != audio.music_channel && !mixer[i].active))
+    if (!mixer[i].active)
     {
 #if 0
       printf("ADDING NEW SOUND %d TO MIXER\n", snd_ctrl.nr);
 #endif
 
-#if 1
 #if defined(AUDIO_UNIX_NATIVE)
       if (snd_info->data_len == 0)
       {
        printf("THIS SHOULD NEVER HAPPEN! [snd_info->data_len == 0]\n");
       }
 #endif
-#endif
-
-#if 1
-      if (IS_MUSIC(snd_ctrl) && i == audio.music_channel && mixer[i].active)
-      {
-       printf("THIS SHOULD NEVER HAPPEN! [adding music twice]\n");
-
-#if 1
-       Mixer_StopChannel(i);
-#endif
-      }
-#endif
 
       mixer[i] = snd_ctrl;
       Mixer_PlayChannel(i);
index cc7dc2aa33fb4111ff5f737ca76a4a731437960c..5c0b4fbe9aeb81e1602c6bf6bed9efa6ced49d6f 100644 (file)
@@ -94,6 +94,9 @@ void InitPlatformDependantStuff(void)
 
 #if !defined(PLATFORM_UNIX)
   program.userdata_directory = "userdata";
+#endif
+
+#if defined(PLATFORM_MSDOS)
   initErrorFile();
 #endif
 
@@ -105,7 +108,7 @@ void InitPlatformDependantStuff(void)
 
 void ClosePlatformDependantStuff(void)
 {
-#if !defined(PLATFORM_UNIX)
+#if defined(PLATFORM_MSDOS)
   dumpErrorFile();
 #endif
 }
index 0f6d5e2b897b9387ce753301b57ca8e2d5025ef9..743a8b9bfd013d47940fce121c5fe20edd431f97 100644 (file)
 #define DEFAULT_KEY_RIGHT      KSYM_Right
 #define DEFAULT_KEY_UP         KSYM_Up
 #define DEFAULT_KEY_DOWN       KSYM_Down
+#if defined(PLATFORM_MACOSX)
+#define DEFAULT_KEY_SNAP       KSYM_Control_L
+#define DEFAULT_KEY_BOMB       KSYM_KP_Enter
+#else
 #define DEFAULT_KEY_SNAP       KSYM_Shift_L
 #define DEFAULT_KEY_BOMB       KSYM_Shift_R
+#endif
 #define DEFAULT_KEY_OKAY       KSYM_Return
 #define DEFAULT_KEY_CANCEL     KSYM_Escape
 
index 17136765340ef86cc56b8c5368f4a9af4452b3cd..71cfcdf9402604d4342fa48810b122a28fd8fcdc 100644 (file)
@@ -1632,8 +1632,8 @@ extern struct SoundEffectInfo     sound_effects[];
 
 #define PROGRAM_VERSION_MAJOR  2
 #define PROGRAM_VERSION_MINOR  1
-#define PROGRAM_VERSION_PATCH  0
-#define PROGRAM_VERSION_STRING "2.1.0"
+#define PROGRAM_VERSION_PATCH  1
+#define PROGRAM_VERSION_STRING "2.1.1"
 
 #define PROGRAM_TITLE_STRING   "Rocks'n'Diamonds"
 #define PROGRAM_AUTHOR_STRING  "Holger Schemel"