OSDN Git Service

Add load_music_prefs() for implementing BGM.
authordeskull <deskull@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 8 Feb 2014 08:02:49 +0000 (08:02 +0000)
committerdeskull <deskull@0568b783-4c39-0410-ac80-bf13821ea2a2>
Sat, 8 Feb 2014 08:02:49 +0000 (08:02 +0000)
lib/xtra/music/music.cfg [new file with mode: 0644]
src/defines.h
src/main-win.c
src/z-config.h

diff --git a/lib/xtra/music/music.cfg b/lib/xtra/music/music.cfg
new file mode 100644 (file)
index 0000000..04a0b03
--- /dev/null
@@ -0,0 +1,12 @@
+# BGM Setting\r
+#\r
+# Configuration file for the Angband BGM events\r
+#\r
+# The format is:\r
+# name of the Angband event = list of the available sample-names seperated by spaces.\r
+#\r
+# Example:\r
+# hit = hit.wav hit1.wav\r
+\r
+[BGM]\r
+\r
index 73f1a07..60dc9e3 100644 (file)
@@ -4587,9 +4587,10 @@ extern int PlayerUID;
 /*
  * Mega-Hack -- maximum known sounds
  */
-#define SOUND_MAX 66
+#define MUSIC_MAX 66 /*!< BGMÄêµÁ¤ÎºÇÂç¿ô */
+#define SOUND_MAX 66 /*!< ¸ú²Ì²»ÄêµÁ¤ÎºÇÂç¿ô */
 
-#define MAX_VIRTUE 18
+#define MAX_VIRTUE 18 /*!< ÆÁÄêµÁ¤ÎºÇÂç¿ô */
 
 #define V_COMPASSION       1
 #define V_HONOUR           2
index dc47103..9bf9bd6 100644 (file)
@@ -560,6 +560,7 @@ static cptr AngList = "AngList";
  */
 static cptr ANGBAND_DIR_XTRA_GRAF;
 static cptr ANGBAND_DIR_XTRA_SOUND;
+static cptr ANGBAND_DIR_XTRA_MUSIC;
 static cptr ANGBAND_DIR_XTRA_HELP;
 #if 0 /* #ifndef JP */
 static cptr ANGBAND_DIR_XTRA_FONT;
@@ -1343,7 +1344,7 @@ static void load_prefs(void)
        }
 }
 
-#ifdef USE_SOUND
+#if defined(USE_SOUND) || defined(USE_MUSIC)
 
 /*
  * XXX XXX XXX - Taken from files.c.
@@ -1395,6 +1396,10 @@ static s16b tokenize_whitespace(char *buf, s16b num, char **tokens)
        return (k);
 }
 
+#endif /* USE_SOUND || USE_MUSIC */
+
+#ifdef USE_SOUND
+
 static void load_sound_prefs(void)
 {
        int i, j, num;
@@ -1427,6 +1432,40 @@ static void load_sound_prefs(void)
 
 #endif /* USE_SOUND */
 
+#ifdef USE_MUSIC
+
+static void load_music_prefs(void)
+{
+       int i, j, num;
+       char tmp[1024];
+       char ini_path[1024];
+       char wav_path[1024];
+       char *zz[SAMPLE_MAX];
+
+       /* Access the music.cfg */
+
+       path_build(ini_path, 1024, ANGBAND_DIR_XTRA_MUSIC, "music.cfg");
+
+       for (i = 0; i < SOUND_MAX; i++)
+       {
+               GetPrivateProfileString("Music", angband_sound_name[i], "", tmp, 1024, ini_path);
+
+               num = tokenize_whitespace(tmp, SAMPLE_MAX, zz);
+
+               for (j = 0; j < num; j++)
+               {
+                       /* Access the sound */
+                       path_build(wav_path, 1024, ANGBAND_DIR_XTRA_MUSIC, zz[j]);
+
+                       /* Save the sound filename, if it exists */
+                       if (check_file(wav_path))
+                               sound_file[i][j] = string_make(zz[j]);
+               }
+       }
+}
+
+#endif /* USE_MUSIC */
+
 /*
  * Create the new global palette based on the bitmap palette
  * (if any), and the standard 16 entry palette derived from
index 2689941..0101b6a 100644 (file)
 /*
  * OPTION: Allow the use of "music" in various places
  */
-/* #define USE_MUSIC */
+#define USE_MUSIC
 
 #endif /* USE_SPECIAL */