rnd-20001210-2-src
authorHolger Schemel <info@artsoft.org>
Sun, 10 Dec 2000 02:54:51 +0000 (03:54 +0100)
committerHolger Schemel <info@artsoft.org>
Sat, 30 Aug 2014 08:35:35 +0000 (10:35 +0200)
src/game.c
src/init.c
src/libgame/misc.c
src/libgame/misc.h
src/libgame/sound.c
src/libgame/sound.h
src/libgame/system.c
src/libgame/system.h
src/main.c
src/main.h
src/screens.c

index 031fd7856672a76d8f08a64bded579cd7e9ae54f..f6e10265b6e5387dde3f85f6a0d233debf7bbaed 100644 (file)
@@ -761,8 +761,8 @@ void InitGame()
 
   OpenDoor(DOOR_OPEN_ALL);
 
 
   OpenDoor(DOOR_OPEN_ALL);
 
-  if (setup.sound_music)
-    PlayMusic(background_loop[level_nr % num_bg_loops]);
+  if (setup.sound_music && num_bg_loops)
+    PlayMusic(level_nr % num_bg_loops);
 
   KeyboardAutoRepeatOff();
 
 
   KeyboardAutoRepeatOff();
 
@@ -6232,7 +6232,8 @@ static void HandleGameButtons(struct GadgetInfo *gi)
       else if (audio.loops_available)
       { 
        setup.sound = setup.sound_music = TRUE;
       else if (audio.loops_available)
       { 
        setup.sound = setup.sound_music = TRUE;
-       PlayMusic(background_loop[level_nr % num_bg_loops]);
+       if (num_bg_loops)
+         PlayMusic(level_nr % num_bg_loops);
       }
       break;
 
       }
       break;
 
index b4efdc4e7cc90d6b8ea73f2cb108fa9fd8ddaae6..dbe878cd7063942f299061ba83186f00eb3b10d5 100644 (file)
@@ -134,11 +134,9 @@ void InitSound()
 
   OpenAudio();
 
 
   OpenAudio();
 
-  AllocSoundArray(NUM_SOUNDS);
-
   for(i=0; i<NUM_SOUNDS; i++)
   {
   for(i=0; i<NUM_SOUNDS; i++)
   {
-    if (!LoadSound(i, sound_name[i]))
+    if (!LoadSound(sound_name[i]))
     {
       audio.sound_available = FALSE;
       audio.loops_available = FALSE;
     {
       audio.sound_available = FALSE;
       audio.loops_available = FALSE;
@@ -147,6 +145,8 @@ void InitSound()
       return;
     }
   }
       return;
     }
   }
+
+  num_bg_loops = LoadMusic();
 }
 
 void InitSoundServer()
 }
 
 void InitSoundServer()
index e62229a42ec902ee55d3cc5411dee7f68d49f7b6..b72fa146cd684385f84190b654cfd66b8a784233 100644 (file)
@@ -630,6 +630,16 @@ void *checked_calloc(unsigned long size)
   return ptr;
 }
 
   return ptr;
 }
 
+void *checked_realloc(void *ptr, unsigned long size)
+{
+  ptr = realloc(ptr, size);
+
+  if (ptr == NULL)
+    Error(ERR_EXIT, "cannot allocate %d bytes -- out of memory", size);
+
+  return ptr;
+}
+
 short getFile16BitInteger(FILE *file, int byte_order)
 {
   if (byte_order == BYTE_ORDER_BIG_ENDIAN)
 short getFile16BitInteger(FILE *file, int byte_order)
 {
   if (byte_order == BYTE_ORDER_BIG_ENDIAN)
index 08d667bfee2cf81a0ff0c864e268a88a7a5532b9..880c83e4b4858f897ff29a0d8a1dcca99a259833 100644 (file)
@@ -66,6 +66,7 @@ void GetOptions(char **);
 void Error(int, char *, ...);
 void *checked_malloc(unsigned long);
 void *checked_calloc(unsigned long);
 void Error(int, char *, ...);
 void *checked_malloc(unsigned long);
 void *checked_calloc(unsigned long);
+void *checked_realloc(void *, unsigned long);
 short getFile16BitInteger(FILE *, int);
 void putFile16BitInteger(FILE *, short, int);
 int getFile32BitInteger(FILE *, int);
 short getFile16BitInteger(FILE *, int);
 void putFile16BitInteger(FILE *, short, int);
 int getFile32BitInteger(FILE *, int);
index c690993ca6b39921f1536f53a0407e3b7e6fae07..5f32e98efd131e51cef03f7aeecc6987a2cf7c0b 100644 (file)
 * sound.c                                                  *
 ***********************************************************/
 
 * sound.c                                                  *
 ***********************************************************/
 
+#include <string.h>
 #include <sys/time.h>
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/time.h>
 #include <unistd.h>
 #include <fcntl.h>
+#include <dirent.h>
 
 #include "system.h"
 #include "sound.h"
 #include "misc.h"
 
 
 
 #include "system.h"
 #include "sound.h"
 #include "misc.h"
 
 
-static int num_sounds = 0;
+static int num_sounds = 0, num_music = 0, num_mods = 0;
 static struct SampleInfo *Sound = NULL;
 static struct SampleInfo *Sound = NULL;
+static struct SampleInfo *Mod = NULL;
 
 
 /*** THE STUFF BELOW IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
 
 
 /*** THE STUFF BELOW IS ONLY USED BY THE SOUND SERVER CHILD PROCESS ***/
@@ -801,48 +804,39 @@ static int ulaw_to_linear(unsigned char ulawbyte)
 
 /*** THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS ***/
 
 
 /*** THE STUFF BELOW IS ONLY USED BY THE MAIN PROCESS ***/
 
-void AllocSoundArray(int num)
-{
-  num_sounds = num;
-  Sound = checked_calloc(num_sounds * sizeof(struct SampleInfo));
-}
-
 #define CHUNK_ID_LEN            4       /* IFF style chunk id length */
 #define WAV_HEADER_SIZE                20      /* size of WAV file header */
 
 #define CHUNK_ID_LEN            4       /* IFF style chunk id length */
 #define WAV_HEADER_SIZE                20      /* size of WAV file header */
 
-boolean LoadSound(int sound_nr, char *sound_name)
+static boolean LoadSoundExt(char *sound_name, boolean is_music)
 {
 {
-  struct SampleInfo *snd_info = &Sound[sound_nr];
+  struct SampleInfo *snd_info;
   char filename[256];
   char filename[256];
-  char *sound_ext = "wav";
-#if !defined(TARGET_SDL)
-#if !defined(PLATFORM_MSDOS)
+#if !defined(TARGET_SDL) && !defined(PLATFORM_MSDOS)
   byte sound_header_buffer[WAV_HEADER_SIZE];
   char chunk[CHUNK_ID_LEN + 1];
   int chunk_length, dummy;
   FILE *file;
   int i;
 #endif
   byte sound_header_buffer[WAV_HEADER_SIZE];
   char chunk[CHUNK_ID_LEN + 1];
   int chunk_length, dummy;
   FILE *file;
   int i;
 #endif
-#endif
 
 
+  num_sounds++;
+  Sound = checked_realloc(Sound, num_sounds * sizeof(struct SampleInfo));
+
+  snd_info = &Sound[num_sounds - 1];
   snd_info->name = sound_name;
 
   snd_info->name = sound_name;
 
-  sprintf(filename, "%s/%s/%s.%s",
-         options.ro_base_directory, SOUNDS_DIRECTORY,
-         snd_info->name, sound_ext);
+  sprintf(filename, "%s/%s/%s", options.ro_base_directory,
+         (is_music ? MUSIC_DIRECTORY : SOUNDS_DIRECTORY), snd_info->name);
 
 #if defined(TARGET_SDL)
 
 
 #if defined(TARGET_SDL)
 
-  snd_info->mix_chunk = Mix_LoadWAV(filename);
-  if (snd_info->mix_chunk == NULL)
+  if ((snd_info->mix_chunk = Mix_LoadWAV(filename)) == NULL)
   {
     Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename);
     return FALSE;
   }
 
   {
     Error(ERR_WARN, "cannot read sound file '%s' - no sounds", filename);
     return FALSE;
   }
 
-#else /* !TARGET_SDL */
-
-#if !defined(PLATFORM_MSDOS)
+#elif defined(PLATFORM_UNIX)
 
   if ((file = fopen(filename, MODE_READ)) == NULL)
   {
 
   if ((file = fopen(filename, MODE_READ)) == NULL)
   {
@@ -907,22 +901,119 @@ boolean LoadSound(int sound_nr, char *sound_name)
     return FALSE;
   }
 
     return FALSE;
   }
 
-#endif /* PLATFORM_MSDOS */
-#endif /* !TARGET_SDL */
+#endif
+
+  return TRUE;
+}
+
+boolean LoadSound(char *sound_name)
+{
+  return LoadSoundExt(sound_name, FALSE);
+}
+
+boolean LoadMod(char *mod_name)
+{
+  struct SampleInfo *mod_info;
+  char filename[256];
+
+  num_mods++;
+  Mod = checked_realloc(Mod, num_mods * sizeof(struct SampleInfo));
+
+  mod_info = &Mod[num_mods - 1];
+  mod_info->name = mod_name;
+
+  sprintf(filename, "%s/%s/%s", options.ro_base_directory,
+         MUSIC_DIRECTORY, mod_info->name);
+
+#if defined(TARGET_SDL)
+  if ((mod_info->mix_music = Mix_LoadMUS(filename)) == NULL)
+  {
+    Error(ERR_WARN, "cannot read music file '%s' - no sounds", filename);
+    return FALSE;
+  }
+#endif
+
+  audio.mods_available = TRUE;
 
   return TRUE;
 }
 
 
   return TRUE;
 }
 
+int LoadMusic(void)
+{
+  DIR *dir;
+  struct dirent *dir_entry;
+  char *music_directory = getPath2(options.ro_base_directory, MUSIC_DIRECTORY);
+
+  num_music = 0;
+
+  if ((dir = opendir(music_directory)) == NULL)
+  {
+    Error(ERR_WARN, "cannot read music directory '%s'", music_directory);
+    audio.music_available = FALSE;
+    free(music_directory);
+    return 0;
+  }
+
+  while ((dir_entry = readdir(dir)) != NULL)   /* loop until last dir entry */
+  {
+    char *filename = dir_entry->d_name;
+
+    if (strlen(filename) > 4 &&
+       strcmp(&filename[strlen(filename) - 4], ".wav") == 0)
+    {
+      if (!LoadSoundExt(filename, TRUE))
+      {
+       audio.music_available = FALSE;
+       free(music_directory);
+       return num_music;
+      }
+
+      num_music++;
+    }
+    else if (strlen(filename) > 4 &&
+            (strcmp(&filename[strlen(filename) - 4], ".mod") == 0 ||
+             strcmp(&filename[strlen(filename) - 4], ".MOD") == 0 ||
+             strncmp(filename, "mod.", 4) == 0 ||
+             strncmp(filename, "MOD.", 4) == 0))
+    {
+      if (!LoadMod(filename))
+      {
+       audio.music_available = FALSE;
+       free(music_directory);
+       return num_music;
+      }
+
+      num_music++;
+    }
+  }
+
+  closedir(dir);
+
+  if (num_music == 0)
+    Error(ERR_WARN, "cannot find any valid music files in directory '%s'",
+         music_directory);
+
+  free(music_directory);
+
+  if (num_mods > 0)
+    num_music = num_mods;
+
+  return num_music;
+}
+
 void PlayMusic(int nr)
 {
   if (!audio.music_available)
     return;
 
 void PlayMusic(int nr)
 {
   if (!audio.music_available)
     return;
 
+  if (num_mods == 0)
+    nr = num_sounds - num_music + nr;
+
 #if defined(TARGET_SDL)
   if (audio.mods_available)
   {
     Mix_VolumeMusic(SOUND_MAX_VOLUME);
 #if defined(TARGET_SDL)
   if (audio.mods_available)
   {
     Mix_VolumeMusic(SOUND_MAX_VOLUME);
-    /* start playing module */
+    Mix_PlayMusic(Mod[nr].mix_music, -1);
   }
   else /* play music loop */
   {
   }
   else /* play music loop */
   {
@@ -1097,7 +1188,9 @@ void FreeSounds(int num_sounds)
     return;
 
   for(i=0; i<num_sounds; i++)
     return;
 
   for(i=0; i<num_sounds; i++)
-#if !defined(PLATFORM_MSDOS)
+#if defined(TARGET_SDL)
+    free(Sound[i].mix_chunk);
+#elif !defined(PLATFORM_MSDOS)
     free(Sound[i].data_ptr);
 #else
     destroy_sample(Sound[i].sample_ptr);
     free(Sound[i].data_ptr);
 #else
     destroy_sample(Sound[i].sample_ptr);
index d2c94f23dfe3c917d98ab88bc8f30b75ce3bb840..f9ace4043e68ab5772b25789c33845f333146631 100644 (file)
@@ -156,6 +156,7 @@ struct SampleInfo
 
 #if defined(TARGET_SDL)
   Mix_Chunk *mix_chunk;
 
 #if defined(TARGET_SDL)
   Mix_Chunk *mix_chunk;
+  Mix_Music *mix_music;
 #endif
 };
 
 #endif
 };
 
@@ -187,8 +188,9 @@ void UnixCloseAudio(void);
 void SoundServer(void);
 
 /* sound client functions */
 void SoundServer(void);
 
 /* sound client functions */
-void AllocSoundArray(int);
-boolean LoadSound(int, char *);
+boolean LoadSound(char *);
+boolean LoadMod(char *);
+int LoadMusic(void);
 void PlayMusic(int);
 void PlaySound(int);
 void PlaySoundStereo(int, int);
 void PlayMusic(int);
 void PlaySound(int);
 void PlaySoundStereo(int, int);
index 8a5feabea7f532cc343c83acc8e1661b72f14c87..5217460d47f80ed11a9dc3dcb4b14b7de09790cf 100644 (file)
@@ -555,10 +555,8 @@ inline boolean ChangeVideoModeIfNeeded(boolean fullscreen)
 Bitmap *LoadImage(char *basename)
 {
   Bitmap *new_bitmap;
 Bitmap *LoadImage(char *basename)
 {
   Bitmap *new_bitmap;
-  char filename[256];
-
-  sprintf(filename, "%s/%s/%s",
-         options.ro_base_directory, GRAPHICS_DIRECTORY, basename);
+  char *filename = getPath3(options.ro_base_directory, GRAPHICS_DIRECTORY,
+                           basename);
 
 #if defined(TARGET_SDL)
   new_bitmap = SDLLoadImage(filename);
 
 #if defined(TARGET_SDL)
   new_bitmap = SDLLoadImage(filename);
@@ -566,6 +564,8 @@ Bitmap *LoadImage(char *basename)
   new_bitmap = X11LoadImage(filename);
 #endif
 
   new_bitmap = X11LoadImage(filename);
 #endif
 
+  free(filename);
+
   return new_bitmap;
 }
 
   return new_bitmap;
 }
 
index e9a6d19052a28bae3b7d5f79f99bf1a4e0253029..55201a9f2fe8d81f9c6ea2c9b3880fa283128518 100644 (file)
@@ -99,6 +99,7 @@
 #define RW_BASE_PATH           RW_GAME_DIR
 
 #define GRAPHICS_DIRECTORY     "graphics"
 #define RW_BASE_PATH           RW_GAME_DIR
 
 #define GRAPHICS_DIRECTORY     "graphics"
+#define MUSIC_DIRECTORY                "music"
 #define SOUNDS_DIRECTORY       "sounds"
 #define LEVELS_DIRECTORY       "levels"
 #define TAPES_DIRECTORY                "tapes"
 #define SOUNDS_DIRECTORY       "sounds"
 #define LEVELS_DIRECTORY       "levels"
 #define TAPES_DIRECTORY                "tapes"
index 4d2ca8f0f9a6d1a42e716ab353ec81a516615fbc..0ef3af3bf416752680d24a6bf2b7bc030059b613 100644 (file)
@@ -88,76 +88,70 @@ struct SetupInfo    setup;
 struct GameInfo                game;
 struct GlobalInfo      global;
 
 struct GameInfo                game;
 struct GlobalInfo      global;
 
-/* data needed for playing sounds */
+/* filenames of sound effects */
 char *sound_name[NUM_SOUNDS] =
 {
 char *sound_name[NUM_SOUNDS] =
 {
-  "alchemy",
-  "amoebe",
-  "antigrav",
-  "autsch",
-  "blurb",
-  "bong",
-  "buing",
-  "chase",
-  "czardasz",
-  "deng",
-  "fuel",
-  "gong",
-  "halloffame",
-  "holz",
-  "hui",
-  "kabumm",
-  "kink",
-  "klapper",
-  "kling",
-  "klopf",
-  "klumpf",
-  "knack",
-  "knurk",
-  "krach",
-  "lachen",
-  "laser",
-  "miep",
-  "network",
-  "njam",
-  "oeffnen",
-  "pling",
-  "pong",
-  "pusch",
-  "quiek",
-  "quirk",
-  "rhythmloop",
-  "roaaar",
-  "roehr",
-  "rumms",
-  "schlopp",
-  "schlurf",
-  "schrff",
-  "schwirr",
-  "sirr",
-  "slurp",
-  "sproing",
-  "twilight",
-  "tyger",
-  "voyager",
-  "warnton",
-  "whoosh",
-  "zisch",
-  "base",
-  "infotron",
-  "zonkdown",
-  "zonkpush",
-  "bug",
-  "boom",
-  "booom",
-  "exit",
-  "empty",
-  "gate"
+  "amoebe.wav",
+  "antigrav.wav",
+  "autsch.wav",
+  "blurb.wav",
+  "bong.wav",
+  "buing.wav",
+  "deng.wav",
+  "fuel.wav",
+  "gong.wav",
+  "halloffame.wav",
+  "holz.wav",
+  "hui.wav",
+  "kabumm.wav",
+  "kink.wav",
+  "klapper.wav",
+  "kling.wav",
+  "klopf.wav",
+  "klumpf.wav",
+  "knack.wav",
+  "knurk.wav",
+  "krach.wav",
+  "lachen.wav",
+  "laser.wav",
+  "miep.wav",
+  "njam.wav",
+  "oeffnen.wav",
+  "pling.wav",
+  "pong.wav",
+  "pusch.wav",
+  "quiek.wav",
+  "quirk.wav",
+  "rhythmloop.wav",
+  "roaaar.wav",
+  "roehr.wav",
+  "rumms.wav",
+  "schlopp.wav",
+  "schlurf.wav",
+  "schrff.wav",
+  "schwirr.wav",
+  "sirr.wav",
+  "slurp.wav",
+  "sproing.wav",
+  "warnton.wav",
+  "whoosh.wav",
+  "zisch.wav",
+  "base.wav",
+  "infotron.wav",
+  "zonkdown.wav",
+  "zonkpush.wav",
+  "bug.wav",
+  "boom.wav",
+  "booom.wav",
+  "exit.wav",
+  "empty.wav",
+  "gate.wav"
 };
 
 /* background music */
 int background_loop[] =
 {
 };
 
 /* background music */
 int background_loop[] =
 {
+#if 0
   SND_ALCHEMY,
   SND_CHASE,
   SND_NETWORK,
   SND_ALCHEMY,
   SND_CHASE,
   SND_NETWORK,
@@ -165,6 +159,7 @@ int background_loop[] =
   SND_TYGER,
   SND_VOYAGER,
   SND_TWILIGHT
   SND_TYGER,
   SND_VOYAGER,
   SND_TWILIGHT
+#endif
 };
 int num_bg_loops = sizeof(background_loop)/sizeof(int);
 
 };
 int num_bg_loops = sizeof(background_loop)/sizeof(int);
 
index e1539d281eef9c5348934be43d27900a332e5177..f25cd826b9a7555d0dfa8aae731237a7bdf3345e 100644 (file)
@@ -1422,70 +1422,63 @@ extern int              num_element_info;
 
 
 /* the names of the sounds */
 
 
 /* the names of the sounds */
-#define SND_ALCHEMY            0
-#define SND_AMOEBE             1
-#define SND_ANTIGRAV           2
-#define SND_AUTSCH             3
-#define SND_BLURB              4
-#define SND_BONG               5
-#define SND_BUING              6
-#define SND_CHASE              7
-#define SND_CZARDASZ           8
-#define SND_DENG               9
-#define SND_FUEL               10
-#define SND_GONG               11
-#define SND_HALLOFFAME         12
-#define SND_HOLZ               13
-#define SND_HUI                        14
-#define SND_KABUMM             15
-#define SND_KINK               16
-#define SND_KLAPPER            17
-#define SND_KLING              18
-#define SND_KLOPF              19
-#define SND_KLUMPF             20
-#define SND_KNACK              21
-#define SND_KNURK              22
-#define SND_KRACH              23
-#define SND_LACHEN             24
-#define SND_LASER              25
-#define SND_MIEP               26
-#define SND_NETWORK            27
-#define SND_NJAM               28
-#define SND_OEFFNEN            29
-#define SND_PLING              30
-#define SND_PONG               31
-#define SND_PUSCH              32
-#define SND_QUIEK              33
-#define SND_QUIRK              34
-#define SND_RHYTHMLOOP         35
-#define SND_ROAAAR             36
-#define SND_ROEHR              37
-#define SND_RUMMS              38
-#define SND_SCHLOPP            39
-#define SND_SCHLURF            40
-#define SND_SCHRFF             41
-#define SND_SCHWIRR            42
-#define SND_SIRR               43
-#define SND_SLURP              44
-#define SND_SPROING            45
-#define SND_TWILIGHT           46
-#define SND_TYGER              47
-#define SND_VOYAGER            48
-#define SND_WARNTON            49
-#define SND_WHOOSH             50
-#define SND_ZISCH              51
-#define SND_SP_BASE            52
-#define SND_SP_INFOTRON                53
-#define SND_SP_ZONKDOWN                54
-#define SND_SP_ZONKPUSH                55
-#define SND_SP_BUG             56
-#define SND_SP_BOOM            57
-#define SND_SP_BOOOM           58
-#define SND_SP_EXIT            59
-#define SND_EMPTY              60
-#define SND_GATE               61
-
-#define NUM_SOUNDS             62
+#define SND_AMOEBE             0
+#define SND_ANTIGRAV           1
+#define SND_AUTSCH             2
+#define SND_BLURB              3
+#define SND_BONG               4
+#define SND_BUING              5
+#define SND_DENG               6
+#define SND_FUEL               7
+#define SND_GONG               8
+#define SND_HALLOFFAME         9
+#define SND_HOLZ               10
+#define SND_HUI                        11
+#define SND_KABUMM             12
+#define SND_KINK               13
+#define SND_KLAPPER            14
+#define SND_KLING              15
+#define SND_KLOPF              16
+#define SND_KLUMPF             17
+#define SND_KNACK              18
+#define SND_KNURK              19
+#define SND_KRACH              20
+#define SND_LACHEN             21
+#define SND_LASER              22
+#define SND_MIEP               23
+#define SND_NJAM               24
+#define SND_OEFFNEN            25
+#define SND_PLING              26
+#define SND_PONG               27
+#define SND_PUSCH              28
+#define SND_QUIEK              29
+#define SND_QUIRK              30
+#define SND_RHYTHMLOOP         31
+#define SND_ROAAAR             32
+#define SND_ROEHR              33
+#define SND_RUMMS              34
+#define SND_SCHLOPP            35
+#define SND_SCHLURF            36
+#define SND_SCHRFF             37
+#define SND_SCHWIRR            38
+#define SND_SIRR               39
+#define SND_SLURP              40
+#define SND_SPROING            41
+#define SND_WARNTON            42
+#define SND_WHOOSH             43
+#define SND_ZISCH              44
+#define SND_SP_BASE            45
+#define SND_SP_INFOTRON                46
+#define SND_SP_ZONKDOWN                47
+#define SND_SP_ZONKPUSH                48
+#define SND_SP_BUG             49
+#define SND_SP_BOOM            50
+#define SND_SP_BOOOM           51
+#define SND_SP_EXIT            52
+#define SND_EMPTY              53
+#define SND_GATE               54
+
+#define NUM_SOUNDS             55
 
 /* default input keys */
 #define DEFAULT_KEY_LEFT       KSYM_Left
 
 /* default input keys */
 #define DEFAULT_KEY_LEFT       KSYM_Left
index 91aa31b8d2cfad6e6683773c5cd4a3b5b43d6986..c593ac8fd62230ec19b4852c877f0a4ad40ebc26 100644 (file)
@@ -562,6 +562,7 @@ static char *helpscreen_music[][3] =
   { "Voyager",                 "The Alan Parsons Project","Pyramid" },
   { "Twilight Painter",                "Tangerine Dream",      "Heartbreakers" }
 };
   { "Voyager",                 "The Alan Parsons Project","Pyramid" },
   { "Twilight Painter",                "Tangerine Dream",      "Heartbreakers" }
 };
+static int num_helpscreen_music = 7;
 static int helpscreen_musicpos;
 
 void DrawHelpScreenElAction(int start)
 static int helpscreen_musicpos;
 
 void DrawHelpScreenElAction(int start)
@@ -780,17 +781,20 @@ void HandleHelpScreen(int button)
       DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
       DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
     }
       DrawHelpScreenElText(helpscreen_state*MAX_HELPSCREEN_ELS);
       DrawHelpScreenElAction(helpscreen_state*MAX_HELPSCREEN_ELS);
     }
-    else if (helpscreen_state < num_helpscreen_els_pages + num_bg_loops - 1)
+    else if (helpscreen_state <
+            num_helpscreen_els_pages + num_helpscreen_music - 1)
     {
       helpscreen_state++;
       DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
     }
     {
       helpscreen_state++;
       DrawHelpScreenMusicText(helpscreen_state - num_helpscreen_els_pages);
     }
-    else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops - 1)
+    else if (helpscreen_state ==
+            num_helpscreen_els_pages + num_helpscreen_music - 1)
     {
       helpscreen_state++;
       DrawHelpScreenCreditsText();
     }
     {
       helpscreen_state++;
       DrawHelpScreenCreditsText();
     }
-    else if (helpscreen_state == num_helpscreen_els_pages + num_bg_loops)
+    else if (helpscreen_state ==
+            num_helpscreen_els_pages + num_helpscreen_music)
     {
       helpscreen_state++;
       DrawHelpScreenContactText();
     {
       helpscreen_state++;
       DrawHelpScreenContactText();