start to add some SOUND_TRIGGER_ACHIEVEMENTS code

Start to add supporting code to windsound and macsound. The latter
remains commented out because I haven't had a chance to try
it on macOS yet.

In order to test it out, I added two more stock sounds:
sa2_xplevelup and sa2_xpleveldown.
This commit is contained in:
nhmall
2023-02-04 14:28:59 -05:00
parent 9fd87db543
commit 36ca64acdb
17 changed files with 13684 additions and 21 deletions
+62 -10
View File
@@ -39,7 +39,8 @@ static int affiliate(int32_t seid, const char *soundname);
struct sound_procs macsound_procs = {
SOUNDID(macsound),
SOUND_TRIGGER_HEROMUSIC | SOUND_TRIGGER_SOUNDEFFECTS,
SOUND_TRIGGER_HEROMUSIC | SOUND_TRIGGER_SOUNDEFFECTS
| SOUND_TRIGGER_ACHIEVEMENTS,
macsound_init_nhsound,
macsound_exit_nhsound,
macsound_achievement,
@@ -60,14 +61,6 @@ macsound_exit_nhsound(const char *reason UNUSED)
{
/* Close / Terminate external sound library */
}
/* fulfill SOUND_TRIGGER_ACHIEVEMENTS */
static void
macsound_achievement(schar ach1 UNUSED, schar ach2 UNUSED, int32_t repeat UNUSED)
{
}
static void
@@ -77,7 +70,7 @@ macsound_ambience(int32_t ambienceid UNUSED, int32_t ambience_action UNUSED,
}
/* magic number 47 is the current number of sound_ files to include */
#define EXTRA_SOUNDS 47
#define EXTRA_SOUNDS (47 + number_of_sa2_entries)
static int32_t affiliation[number_of_se_entries + EXTRA_SOUNDS] = { 0 };
static NSString *soundstring[number_of_se_entries + EXTRA_SOUNDS];
@@ -119,6 +112,9 @@ macsound_soundeffect(char *desc UNUSED, int32_t seid, int volume UNUSED)
#define WAVEMUSIC_SOUNDS
/* This is the number of sound_ files that support WAVEMUSIC_SOUNDS */
static const int wavemusic_sound_count = 94;
/* fulfill SOUND_TRIGGER_HEROMUSIC */
static void macsound_hero_playnotes(int32_t instrument,
const char *str, int32_t vol UNUSED)
@@ -221,6 +217,62 @@ static void macsound_hero_playnotes(int32_t instrument,
#endif
}
/* #define ACHIEVEMENT_SOUNDS */
/* fulfill SOUND_TRIGGER_ACHIEVEMENTS */
static void
macsound_achievement(schar ach1 UNUSED, schar ach2 UNUSED, int32_t repeat UNUSED)
{
#ifdef ACHIEVEMENT_SOUNDS
char resourcename[120];
uint32_t pseudo_seid, pseudo_seid_base;
if (ach1 == 0 && ach2 == 0)
return;
resourcename[0] = '\0';
pseudo_seid_base = 0;
if (ach1 == 0) {
int sa2 = (int) ach2;
if (sa2 > sa2_zero_invalid && sa2 < number_of_sa2_entries) {
switch(sa2) {
case sa2_splashscreen:
Strcpy(resourcename, "sa2_splashscreen");
break;
case sa2_newgame_nosplash:
Strcpy(resourcename, "sa2_newgame_nosplash");
break;
case sa2_restoregame:
Strcpy(resourcename, "sa2_restoregame");
break;
case sa2_xplevelup:
Strcpy(resourcename, "sa2_xplevelup");
break;
case sa2_xpleveldown:
Strcpy(resourcename, "sa2_xpleveldown");
break;
}
if (resourcename[0] == '\0')
return;
/* get past se_ entries and the wavemusic entries */
pseudo_seid_base += (number_of_se_entries + wavemusic_sound_count);
pseudo_seid = pseudo_seid_base + sa2;
if (!affiliation[pseudo_seid]) {
affiliate(pseudo_seid, resourcename);
}
if (affiliation[pseudo_seid]) {
if ([seSound[pseudo_seid] isPlaying])
[seSound[pseudo_seid] stop];
[seSound[pseudo_seid] play];
}
}
}
#endif
}
/* fulfill SOUND_TRIGGER_USERSOUNDS */
static void
macsound_play_usersound(char *filename UNUSED, int volume UNUSED, int idx UNUSED)