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:
@@ -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)
|
||||
|
||||
@@ -149,4 +149,24 @@ Description of modifications made to the original:
|
||||
- .572 seconds
|
||||
|
||||
|
||||
File: sa2_xplevelup.wav
|
||||
Source: https://freesound.org/people/UsuarioLeal/sounds/446464/
|
||||
Original: download/446464__usuarioleal__21-xilofono.wav
|
||||
By: https://freesound.org/people/UsuarioLeal/
|
||||
License: http://creativecommons.org/publicdomain/zero/1.0/
|
||||
Download Date: February 4, 2023
|
||||
Description of modifications made to the original:
|
||||
- No changes
|
||||
- 1.204 seconds
|
||||
|
||||
|
||||
File: sa2_xpleveldown.wav
|
||||
Source: https://freesound.org/people/Casonika/sounds/546734/download/
|
||||
Original: 546734__casonika__violin-pluck-starting-c2-fast-descending-effect.wav
|
||||
By: https://freesound.org/people/Casonika/
|
||||
License: https://creativecommons.org/licenses/by/4.0/
|
||||
Download Date: February 4, 2023
|
||||
Description of modifications made to the original:
|
||||
- 00h00m02.182s to 00h00m03.008s as selection.
|
||||
- Saved selection to file named sa2_xpleveldown.wav
|
||||
- .826 seconds
|
||||
|
||||
3244
sound/wav/sa2_xpleveldown.uu
Normal file
3244
sound/wav/sa2_xpleveldown.uu
Normal file
File diff suppressed because it is too large
Load Diff
10276
sound/wav/sa2_xplevelup.uu
Normal file
10276
sound/wav/sa2_xplevelup.uu
Normal file
File diff suppressed because it is too large
Load Diff
@@ -63,6 +63,8 @@ set UU=..\..\util\uudecode.exe
|
||||
%UU% sound_Wooden_Harp_E.uu
|
||||
%UU% sound_Wooden_Harp_F.uu
|
||||
%UU% sound_Wooden_Harp_G.uu
|
||||
%UU% sa2_xpleveldown.uu
|
||||
%UU% sa2_xplevelup.uu
|
||||
|
||||
set UU=
|
||||
|
||||
|
||||
@@ -60,4 +60,6 @@ uudecode sound_Wooden_Harp_D.uu
|
||||
uudecode sound_Wooden_Harp_E.uu
|
||||
uudecode sound_Wooden_Harp_F.uu
|
||||
uudecode sound_Wooden_Harp_G.uu
|
||||
uudecode sa2_xpleveldown.uu
|
||||
uudecode sa2_xplevelup.uu
|
||||
|
||||
|
||||
@@ -33,7 +33,8 @@ static void maybe_preinsert_directory(int32_t, char *, char *, size_t);
|
||||
struct sound_procs windsound_procs = {
|
||||
SOUNDID(windsound),
|
||||
SOUND_TRIGGER_USERSOUNDS | SOUND_TRIGGER_SOUNDEFFECTS
|
||||
| SOUND_TRIGGER_HEROMUSIC | SOUND_TRIGGER_AMBIENCE,
|
||||
| SOUND_TRIGGER_HEROMUSIC | SOUND_TRIGGER_AMBIENCE
|
||||
| SOUND_TRIGGER_ACHIEVEMENTS,
|
||||
windsound_init_nhsound,
|
||||
windsound_exit_nhsound,
|
||||
windsound_achievement,
|
||||
@@ -57,6 +58,54 @@ windsound_exit_nhsound(const char *reason)
|
||||
static void
|
||||
windsound_achievement(schar ach1, schar ach2, int32_t repeat)
|
||||
{
|
||||
int reslt = 0;
|
||||
const char *filename;
|
||||
char resourcename[120], buf[PATHLEN];
|
||||
int findsound_approach = sff_base_only;
|
||||
DWORD fdwsound = SND_NODEFAULT;
|
||||
char *exedir = (char *) 0;
|
||||
|
||||
adjust_soundargs_for_compiler(&findsound_approach, &fdwsound, &exedir);
|
||||
maybe_preinsert_directory(findsound_approach, exedir, buf, sizeof buf);
|
||||
fdwsound |= SND_ASYNC;
|
||||
|
||||
if (ach1 == 0 && ach2 == 0)
|
||||
return;
|
||||
|
||||
resourcename[0] = '\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;
|
||||
adjust_soundargs_for_compiler(&findsound_approach, &fdwsound, &exedir);
|
||||
/* the final, or only, one is played ASYNC */
|
||||
maybe_preinsert_directory(findsound_approach, exedir, buf, sizeof buf);
|
||||
filename = base_soundname_to_filename(resourcename,
|
||||
buf, sizeof buf, findsound_approach);
|
||||
if (filename) {
|
||||
reslt = PlaySound(filename, NULL, fdwsound);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -239,7 +288,7 @@ adjust_soundargs_for_compiler(
|
||||
static void
|
||||
maybe_preinsert_directory(int32_t findsound_approach, char *exedir, char *buf, size_t sz)
|
||||
{
|
||||
int largest_se_basename = 35;
|
||||
int largest_basename = 35;
|
||||
|
||||
/* findsound_approach = sff_havdir_append_rest means a directory name will be
|
||||
* inserted into the begining of buf and the remaining parts of the
|
||||
@@ -250,7 +299,7 @@ maybe_preinsert_directory(int32_t findsound_approach, char *exedir, char *buf, s
|
||||
|
||||
if (findsound_approach == sff_havedir_append_rest) {
|
||||
if (exedir) {
|
||||
if (strlen(exedir) < (sz - largest_se_basename))
|
||||
if (strlen(exedir) < (sz - largest_basename))
|
||||
Strcpy(buf, exedir);
|
||||
else
|
||||
*buf = '\0';
|
||||
|
||||
Reference in New Issue
Block a user