Merge branch 'macsound' into NetHack-3.7

This commit is contained in:
nhmall
2023-01-23 23:52:07 -05:00
14 changed files with 524 additions and 50 deletions

View File

@@ -1175,6 +1175,7 @@ use_bell(struct obj **optr)
&& invocation_pos(u.ux, u.uy)
&& !On_stairs(u.ux, u.uy));
Hero_playnotes(obj_to_instr(obj), "C", 100);
You("ring %s.", the(xname(obj)));
if (Underwater || (u.uswallow && ordinary)) {

View File

@@ -207,7 +207,7 @@ const struct instance_globals_a g_init_a = {
/* shk.c */
FALSE, /* auto_credit */
/* sounds.c */
soundlib_unassigned, /* enum soundlib_ids active_soundlib */
soundlib_nosound, /* enum soundlib_ids active_soundlib */
/* trap.c */
{ 0, 0, FALSE }, /* acid_ctx */

View File

@@ -506,7 +506,6 @@ do_improvisation(struct obj* instr)
itmp.otyp -= 1;
mundane = TRUE;
}
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
#define PLAY_NORMAL 0x00
#define PLAY_STUNNED 0x01
@@ -575,6 +574,7 @@ do_improvisation(struct obj* instr)
case MAGIC_FLUTE: /* Make monster fall asleep */
consume_obj_charge(instr, TRUE);
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
You("%sproduce %s music.", !Deaf ? "" : "seem to ",
Hallucination ? "piped" : "soft");
put_monsters_to_sleep(u.ulevel * 5);
@@ -582,6 +582,7 @@ do_improvisation(struct obj* instr)
break;
case WOODEN_FLUTE: /* May charm snakes */
do_spec &= (rn2(ACURR(A_DEX)) + u.ulevel > 25);
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
if (!Deaf)
pline("%s.", Tobjnam(instr, do_spec ? "trill" : "toot"));
else
@@ -601,12 +602,14 @@ do_improvisation(struct obj* instr)
if ((damage = zapyourself(instr, TRUE)) != 0) {
char buf[BUFSZ];
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
Sprintf(buf, "using a magical horn on %sself", uhim());
losehp(damage, buf, KILLED_BY); /* fire or frost damage */
}
} else {
int type = BZ_OFS_AD((instr->otyp == FROST_HORN) ? AD_COLD : AD_FIRE);
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
if (!Blind)
pline("A %s blasts out of the horn!", flash_str(type, FALSE));
ubuzz(BZ_U_WAND(type), rn1(6, 6));
@@ -614,6 +617,7 @@ do_improvisation(struct obj* instr)
makeknown(instr->otyp);
break;
case TOOLED_HORN: /* Awaken or scare monsters */
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
if (!Deaf)
You("produce a frightful, grave sound.");
else
@@ -622,6 +626,7 @@ do_improvisation(struct obj* instr)
exercise(A_WIS, FALSE);
break;
case BUGLE: /* Awaken & attract soldiers */
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
if (!Deaf)
You("extract a loud noise from %s.", yname(instr));
else
@@ -632,6 +637,7 @@ do_improvisation(struct obj* instr)
case MAGIC_HARP: /* Charm monsters */
consume_obj_charge(instr, TRUE);
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
if (!Deaf)
pline("%s very attractive music.", Tobjnam(instr, "produce"));
else
@@ -641,6 +647,7 @@ do_improvisation(struct obj* instr)
break;
case WOODEN_HARP: /* May calm Nymph */
do_spec &= (rn2(ACURR(A_DEX)) + u.ulevel > 25);
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
if (!Deaf)
pline("%s %s.", Yname2(instr),
do_spec ? "produces a lilting melody" : "twangs");
@@ -657,6 +664,7 @@ do_improvisation(struct obj* instr)
mundane is flagged */
consume_obj_charge(instr, TRUE);
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
You("produce a heavy, thunderous rolling!");
pline_The("entire %s is shaking around you!", generic_lvl_desc());
do_earthquake((u.ulevel - 1) / 3 + 1);
@@ -666,6 +674,7 @@ do_improvisation(struct obj* instr)
break;
case LEATHER_DRUM: /* Awaken monsters */
if (!mundane) {
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
if (!Deaf) {
You("beat a deafening row!");
incr_itimeout(&HDeaf, rn1(20, 30));
@@ -674,6 +683,8 @@ do_improvisation(struct obj* instr)
}
exercise(A_WIS, FALSE);
} else
/* TODO maybe: sound effects for these riffs */
Hero_playnotes(obj_to_instr(&itmp), "C", 50);
You("%s %s.",
rn2(2) ? "butcher" : rn2(2) ? "manage" : "pull off",
an(beats[rn2(SIZE(beats))]));
@@ -862,6 +873,7 @@ obj_to_instr(struct obj *obj) {
break;
case MAGIC_HARP:
ret_instr = ins_cello;
break;
case BELL:
case BELL_OF_OPENING:
ret_instr = ins_tinkle_bell;

View File

@@ -1583,7 +1583,20 @@ extern struct sound_procs vissound_procs;
#ifdef SND_LIB_WINDSOUND
extern struct sound_procs windsound_procs;
#endif
extern struct sound_procs nosound_procs;
#ifdef SND_LIB_MACSOUND
extern struct sound_procs macsound_procs;
#endif
struct sound_procs nosound_procs = {
SOUNDID(nosound),
0L,
(void (*)(void)) 0, /* init_nhsound */
(void (*)(const char *)) 0, /* exit_nhsound */
(void (*)(schar, schar, int32_t)) 0, /* achievement */
(void (*)(char *, int32_t, int32_t)) 0, /* sound effect */
(void (*)(int32_t, const char *, int32_t)) 0, /* hero_playnotes */
(void (*)(char *, int32_t, int32_t)) 0, /* play_usersound */
};
/* The order of these array entries must match the
order of the enum soundlib_ids in sndprocs.h */
@@ -1591,7 +1604,7 @@ extern struct sound_procs nosound_procs;
static struct sound_choices {
struct sound_procs *sndprocs;
} soundlib_choices[] = {
{ (struct sound_procs *) 0 },
{ &nosound_procs }, /* default, built-in */
#ifdef SND_LIB_QTSOUND
{ &qtsound_procs },
#endif
@@ -1613,13 +1626,15 @@ static struct sound_choices {
#ifdef SND_LIB_SOUND_ESCCODES
{ &esccodes_procs },
#endif
#ifdef SND_LIB_WINDSOUND
{ &windsound_procs },
#endif
#ifdef SND_LIB_VISSOUND
{ &vissound_procs },
#endif
{ &nosound_procs }, /* default, built-in */
#ifdef SND_LIB_WINDSOUND
{ &windsound_procs },
#endif
#ifdef SND_LIB_MACSOUND
{ &macsound_procs },
#endif
};
void
@@ -1627,33 +1642,27 @@ activate_chosen_soundlib(void)
{
enum soundlib_ids idx = gc.chosen_soundlib;
if (idx <= soundlib_unassigned || idx > soundlib_nosound)
if (idx < soundlib_nosound || idx >= SIZE(soundlib_choices))
idx = soundlib_nosound;
if (ga.active_soundlib != soundlib_unassigned
|| ga.active_soundlib != idx) {
if (ga.active_soundlib != soundlib_nosound || idx != soundlib_nosound) {
if (soundprocs.sound_exit_nhsound)
(*soundprocs.sound_exit_nhsound)("assigning a new sound library");
ga.active_soundlib = soundlib_unassigned;
}
soundprocs = *soundlib_choices[idx].sndprocs;
if (soundprocs.sound_init_nhsound)
(*soundprocs.sound_init_nhsound)();
ga.active_soundlib = soundprocs.soundlib_id;
gc.chosen_soundlib = ga.active_soundlib;
}
void
assign_soundlib(int idx)
{
if (idx <= soundlib_unassigned || idx > soundlib_nosound)
if (idx < soundlib_nosound || idx >= SIZE(soundlib_choices))
idx = soundlib_nosound;
if (ga.active_soundlib != soundlib_unassigned) {
if (soundprocs.sound_exit_nhsound)
(*soundprocs.sound_exit_nhsound)("assigning a new sound library");
ga.active_soundlib = soundlib_unassigned;
}
gc.chosen_soundlib = soundlib_choices[idx].sndprocs->soundlib_id;
gc.chosen_soundlib = (uint32_t) soundlib_choices[idx].sndprocs->soundlib_id;
}
#if 0
@@ -1718,7 +1727,7 @@ get_soundlib_name(char *dest, int maxlen)
const char *src;
idx = ga.active_soundlib;
if (idx > soundlib_unassigned && idx <= soundlib_nosound) {
if (idx >= soundlib_nosound && idx < SIZE(soundlib_choices)) {
src = soundlib_choices[idx].sndprocs->soundname;
for (count = 1; count < maxlen; count++) {
if (*src == ',' || *src == '\0')
@@ -1744,20 +1753,7 @@ static void nosound_resume_nhsound(void);
static void nosound_achievement(schar, schar, int32_t);
static void nosound_soundeffect(int32_t, int32_t);
static void nosound_play_usersound(char *, int32_t, int32_t);
#endif
struct sound_procs nosound_procs = {
SOUNDID(nosound),
0L,
(void (*)(void)) 0, /* init_nhsound */
(void (*)(const char *)) 0, /* exit_nhsound */
(void (*)(schar, schar, int32_t)) 0, /* achievement */
(void (*)(char *, int32_t, int32_t)) 0, /* sound effect */
(void (*)(int32_t, const char *, int32_t)) 0, /* hero_playnotes */
(void (*)(char *, int32_t, int32_t)) 0, /* play_usersound */
};
#if 0
static void
nosound_init_nhsound(void)
{
@@ -1778,6 +1774,11 @@ nosound_soundeffect(int32_t seid, int volume)
{
}
static void
nosound_hero_playnotes(int32_t instr, const char *notes, int32_t vol)
{
}
static void
nosound_play_usersound(char *filename, int volume, int idx)
{