Remove g_SndDisabled and g_SndMp3Enabled
This commit is contained in:
parent
bb4d3458c5
commit
01ce3dc218
|
|
@ -118,67 +118,59 @@ static s32 func0f16d124(s32 tracktype)
|
|||
|
||||
void musicQueueStartEvent(u32 tracktype, u32 tracknum, f32 arg2, u16 volume)
|
||||
{
|
||||
if (!g_SndDisabled) {
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracktype = tracktype;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracknum = tracknum;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].unk0c = arg2;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].volume = volume;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].eventtype = MUSICEVENTTYPE_PLAY;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].id = g_MusicNextEventId++;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].numattempts = 0;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].failcount = 0;
|
||||
g_MusicEventQueueLength++;
|
||||
}
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracktype = tracktype;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracknum = tracknum;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].unk0c = arg2;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].volume = volume;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].eventtype = MUSICEVENTTYPE_PLAY;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].id = g_MusicNextEventId++;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].numattempts = 0;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].failcount = 0;
|
||||
g_MusicEventQueueLength++;
|
||||
}
|
||||
|
||||
void musicQueueStopEvent(s32 tracktype)
|
||||
{
|
||||
if (!g_SndDisabled) {
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracktype = tracktype;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].eventtype = MUSICEVENTTYPE_STOP;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].id = g_MusicNextEventId++;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].numattempts = 0;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].failcount = 0;
|
||||
g_MusicEventQueueLength++;
|
||||
}
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracktype = tracktype;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].eventtype = MUSICEVENTTYPE_STOP;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].id = g_MusicNextEventId++;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].numattempts = 0;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].failcount = 0;
|
||||
g_MusicEventQueueLength++;
|
||||
}
|
||||
|
||||
void musicQueueFadeEvent(s32 tracktype, f32 arg1, bool fadetopause)
|
||||
{
|
||||
if (!g_SndDisabled) {
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracktype = tracktype;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].unk0c = arg1;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].fadetopause = fadetopause;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].eventtype = MUSICEVENTTYPE_FADE;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].id = g_MusicNextEventId++;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].numattempts = 0;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].failcount = 0;
|
||||
g_MusicEventQueueLength++;
|
||||
}
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].tracktype = tracktype;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].unk0c = arg1;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].fadetopause = fadetopause;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].eventtype = MUSICEVENTTYPE_FADE;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].id = g_MusicNextEventId++;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].numattempts = 0;
|
||||
g_MusicEventQueue[g_MusicEventQueueLength].failcount = 0;
|
||||
g_MusicEventQueueLength++;
|
||||
}
|
||||
|
||||
void musicReset(void)
|
||||
{
|
||||
s32 i;
|
||||
|
||||
if (!g_SndDisabled) {
|
||||
for (i = 0; i < 4; i++) {
|
||||
g_AudioXReasonsActive[i] = 0;
|
||||
g_MusicXReasonMinDurations[i] = 0;
|
||||
g_MusicXReasonMaxDurations[i] = 0;
|
||||
}
|
||||
|
||||
func0f16d430();
|
||||
musicQueueStopAllEvent();
|
||||
musicQueueType5Event();
|
||||
|
||||
g_MusicSoloDeathIsPlaying = false;
|
||||
g_MusicDeathTimer240 = 0;
|
||||
g_MenuTrack = -1;
|
||||
g_TemporaryPrimaryTrack = -1;
|
||||
g_TemporaryAmbientTrack = -1;
|
||||
g_MusicNrgIsActive = false;
|
||||
for (i = 0; i < 4; i++) {
|
||||
g_AudioXReasonsActive[i] = 0;
|
||||
g_MusicXReasonMinDurations[i] = 0;
|
||||
g_MusicXReasonMaxDurations[i] = 0;
|
||||
}
|
||||
|
||||
func0f16d430();
|
||||
musicQueueStopAllEvent();
|
||||
musicQueueType5Event();
|
||||
|
||||
g_MusicSoloDeathIsPlaying = false;
|
||||
g_MusicDeathTimer240 = 0;
|
||||
g_MenuTrack = -1;
|
||||
g_TemporaryPrimaryTrack = -1;
|
||||
g_TemporaryAmbientTrack = -1;
|
||||
g_MusicNrgIsActive = false;
|
||||
}
|
||||
|
||||
void musicQueueStopAllEvent(void)
|
||||
|
|
|
|||
|
|
@ -79,7 +79,6 @@ extern u8 g_LoadType;
|
|||
extern s32 g_MainIsEndscreen;
|
||||
extern s32 var8005dd18;
|
||||
extern bool g_MainIsDebugMenuOpen;
|
||||
extern bool g_SndDisabled;
|
||||
extern u16 g_SfxVolume;
|
||||
extern s32 g_SoundMode;
|
||||
extern s32 var8005ddd4;
|
||||
|
|
|
|||
|
|
@ -19,7 +19,6 @@ void snd0000fe18(void);
|
|||
void snd0000fe20(void);
|
||||
void snd0000fe50(void);
|
||||
void sndTick(void);
|
||||
bool sndIsDisabled(void);
|
||||
void sndStartMp3ByFilenum(u32 filenum);
|
||||
void sndAdjust(struct sndstate **handle, s32 arg1, s32 arg2, s32 pan, s32 soundnum, f32 arg5, s32 arg6, s32 arg7, s32 arg8);
|
||||
struct sndstate *snd00010718(struct sndstate **handle, s32 arg1, s32 arg2, s32 arg3, s32 arg4, f32 arg5, s32 arg6, s32 arg7, s32 arg8);
|
||||
|
|
|
|||
388
src/lib/music.c
388
src/lib/music.c
|
|
@ -194,148 +194,144 @@ void musicTickEvents(void)
|
|||
s32 result;
|
||||
struct musicevent *event;
|
||||
|
||||
if (!g_SndDisabled) {
|
||||
if (g_MusicEventQueueLength);
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (var800aaa38[i].unk04 == 0 && n_alCSPGetState(g_SeqInstances[i].seqp) == AL_PLAYING) {
|
||||
if (g_SeqInstances[i].seqp->chanState[0].unk0d <= var70053ca0[var800aaa38[i].tracktype]) {
|
||||
n_alSeqpStop((N_ALSeqPlayer *)g_SeqInstances[i].seqp);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
if (var800aaa38[i].unk04 == 0 && n_alCSPGetState(g_SeqInstances[i].seqp) == AL_PLAYING) {
|
||||
if (g_SeqInstances[i].seqp->chanState[0].unk0d <= var70053ca0[var800aaa38[i].tracktype]) {
|
||||
n_alSeqpStop((N_ALSeqPlayer *)g_SeqInstances[i].seqp);
|
||||
var800aaa38[i].tracktype = TRACKTYPE_NONE;
|
||||
var800aaa38[i].unk04 = 0;
|
||||
var800aaa38[i].unk08 = 0;
|
||||
var800aaa38[i].unk0c = 0;
|
||||
} else if (g_SeqInstances[i].seqp->chanState[0].unk0d == var800aaa38[i].unk0c) {
|
||||
n_alSeqpStop((N_ALSeqPlayer *)g_SeqInstances[i].seqp);
|
||||
|
||||
var800aaa38[i].tracktype = TRACKTYPE_NONE;
|
||||
var800aaa38[i].unk04 = 0;
|
||||
var800aaa38[i].unk08 = 0;
|
||||
var800aaa38[i].unk0c = 0;
|
||||
} else if (g_SeqInstances[i].seqp->chanState[0].unk0d == var800aaa38[i].unk0c) {
|
||||
n_alSeqpStop((N_ALSeqPlayer *)g_SeqInstances[i].seqp);
|
||||
|
||||
var800aaa38[i].tracktype = TRACKTYPE_NONE;
|
||||
var800aaa38[i].unk04 = 0;
|
||||
var800aaa38[i].unk08 = 0;
|
||||
var800aaa38[i].unk0c = 0;
|
||||
}
|
||||
var800aaa38[i].tracktype = TRACKTYPE_NONE;
|
||||
var800aaa38[i].unk04 = 0;
|
||||
var800aaa38[i].unk08 = 0;
|
||||
var800aaa38[i].unk0c = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Figure out which events can be removed from the queue due to later
|
||||
// events superseding them. This loop just marks those events as
|
||||
// removable by setting their tracktype to none.
|
||||
for (i = g_MusicEventQueueLength - 1; i >= 0; i--) {
|
||||
event = &g_MusicEventQueue[i];
|
||||
// Figure out which events can be removed from the queue due to later
|
||||
// events superseding them. This loop just marks those events as
|
||||
// removable by setting their tracktype to none.
|
||||
for (i = g_MusicEventQueueLength - 1; i >= 0; i--) {
|
||||
event = &g_MusicEventQueue[i];
|
||||
|
||||
if (event->eventtype == MUSICEVENTTYPE_5) {
|
||||
if (event->eventtype == MUSICEVENTTYPE_5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event->tracktype == TRACKTYPE_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = i - 1; j >= 0; j--) {
|
||||
struct musicevent *earlier = &g_MusicEventQueue[j];
|
||||
|
||||
if (event->eventtype == MUSICEVENTTYPE_STOPALL) {
|
||||
earlier->tracktype = TRACKTYPE_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event->tracktype == TRACKTYPE_NONE) {
|
||||
if (earlier->eventtype == MUSICEVENTTYPE_5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (j = i - 1; j >= 0; j--) {
|
||||
struct musicevent *earlier = &g_MusicEventQueue[j];
|
||||
if (earlier->tracktype == TRACKTYPE_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (event->eventtype == MUSICEVENTTYPE_STOPALL) {
|
||||
if (earlier->tracktype == event->tracktype) {
|
||||
switch (event->eventtype) {
|
||||
case MUSICEVENTTYPE_STOP:
|
||||
earlier->tracktype = TRACKTYPE_NONE;
|
||||
continue;
|
||||
}
|
||||
|
||||
if (earlier->eventtype == MUSICEVENTTYPE_5) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (earlier->tracktype == TRACKTYPE_NONE) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (earlier->tracktype == event->tracktype) {
|
||||
switch (event->eventtype) {
|
||||
case MUSICEVENTTYPE_STOP:
|
||||
break;
|
||||
case MUSICEVENTTYPE_PLAY:
|
||||
switch (earlier->eventtype) {
|
||||
case MUSICEVENTTYPE_PLAY:
|
||||
case MUSICEVENTTYPE_FADE:
|
||||
earlier->tracktype = TRACKTYPE_NONE;
|
||||
break;
|
||||
case MUSICEVENTTYPE_PLAY:
|
||||
switch (earlier->eventtype) {
|
||||
case MUSICEVENTTYPE_PLAY:
|
||||
case MUSICEVENTTYPE_FADE:
|
||||
earlier->tracktype = TRACKTYPE_NONE;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case MUSICEVENTTYPE_FADE:
|
||||
if (earlier->eventtype == MUSICEVENTTYPE_FADE) {
|
||||
earlier->tracktype = TRACKTYPE_NONE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove the marked events from the queue, shift the remaining
|
||||
// events forward and recount the queue length.
|
||||
for (i = 0, j = 0; i < g_MusicEventQueueLength; i++) {
|
||||
if (g_MusicEventQueue[i].tracktype) {
|
||||
g_MusicEventQueue[j] = g_MusicEventQueue[i];
|
||||
j++;
|
||||
|
||||
g_MusicEventQueueLength += 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_MusicEventQueueLength = j;
|
||||
|
||||
event = &g_MusicEventQueue[0];
|
||||
|
||||
if (var800840e0 == 0 || var800840e4 < g_Vars.diffframe240) {
|
||||
var800840e4 = var800840e0;
|
||||
|
||||
while (g_MusicEventQueueLength) {
|
||||
event->numattempts++;
|
||||
|
||||
result = RESULT_FAIL;
|
||||
|
||||
switch (event->eventtype) {
|
||||
case MUSICEVENTTYPE_PLAY:
|
||||
result = musicHandlePlayEvent(event, 0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_STOP:
|
||||
result = musicHandleStopEvent(event, 0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_FADE:
|
||||
result = musicHandleFadeEvent(event, 0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_STOPALL:
|
||||
result = musicHandleStopAllEvent(0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_5:
|
||||
result = musicHandleEvent5(event, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (result != RESULT_FAIL) {
|
||||
// Remove the item from the queue
|
||||
g_MusicEventQueueLength--;
|
||||
|
||||
for (i = 0; i < g_MusicEventQueueLength; i++) {
|
||||
g_MusicEventQueue[i] = g_MusicEventQueue[i + 1];
|
||||
if (earlier->eventtype == MUSICEVENTTYPE_FADE) {
|
||||
earlier->tracktype = TRACKTYPE_NONE;
|
||||
}
|
||||
|
||||
// Break from processing further events on this frame
|
||||
// if requested
|
||||
if (result == RESULT_OK_BREAK) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var800840e0) {
|
||||
var800840e4 -= g_Vars.diffframe240;
|
||||
} else {
|
||||
var800840e4 = 0;
|
||||
// Remove the marked events from the queue, shift the remaining
|
||||
// events forward and recount the queue length.
|
||||
for (i = 0, j = 0; i < g_MusicEventQueueLength; i++) {
|
||||
if (g_MusicEventQueue[i].tracktype) {
|
||||
g_MusicEventQueue[j] = g_MusicEventQueue[i];
|
||||
j++;
|
||||
|
||||
g_MusicEventQueueLength += 0;
|
||||
}
|
||||
}
|
||||
|
||||
g_MusicEventQueueLength = j;
|
||||
|
||||
event = &g_MusicEventQueue[0];
|
||||
|
||||
if (var800840e0 == 0 || var800840e4 < g_Vars.diffframe240) {
|
||||
var800840e4 = var800840e0;
|
||||
|
||||
while (g_MusicEventQueueLength) {
|
||||
event->numattempts++;
|
||||
|
||||
result = RESULT_FAIL;
|
||||
|
||||
switch (event->eventtype) {
|
||||
case MUSICEVENTTYPE_PLAY:
|
||||
result = musicHandlePlayEvent(event, 0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_STOP:
|
||||
result = musicHandleStopEvent(event, 0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_FADE:
|
||||
result = musicHandleFadeEvent(event, 0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_STOPALL:
|
||||
result = musicHandleStopAllEvent(0);
|
||||
break;
|
||||
case MUSICEVENTTYPE_5:
|
||||
result = musicHandleEvent5(event, 0);
|
||||
break;
|
||||
}
|
||||
|
||||
if (result != RESULT_FAIL) {
|
||||
// Remove the item from the queue
|
||||
g_MusicEventQueueLength--;
|
||||
|
||||
for (i = 0; i < g_MusicEventQueueLength; i++) {
|
||||
g_MusicEventQueue[i] = g_MusicEventQueue[i + 1];
|
||||
}
|
||||
|
||||
// Break from processing further events on this frame
|
||||
// if requested
|
||||
if (result == RESULT_OK_BREAK) {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (var800840e0) {
|
||||
var800840e4 -= g_Vars.diffframe240;
|
||||
} else {
|
||||
var800840e4 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void musicTick(void)
|
||||
|
|
@ -343,100 +339,98 @@ void musicTick(void)
|
|||
s32 i;
|
||||
bool playnrg = false;
|
||||
|
||||
if (!g_SndDisabled) {
|
||||
if (g_MusicDeathTimer240 > 0
|
||||
&& (g_Vars.normmplayerisrunning
|
||||
|| (g_Vars.antiplayernum >= 0 && !g_Vars.bond->isdead)
|
||||
|| (g_Vars.coopplayernum >= 0 && (!g_Vars.bond->isdead || !g_Vars.coop->isdead)))) {
|
||||
// Someone is dying in MP, or anti is dying, or *one* person is dying in coop
|
||||
g_MusicSilenceTimer60 = 0;
|
||||
g_MusicDeathTimer240 -= g_Vars.lvupdate240;
|
||||
if (g_MusicDeathTimer240 > 0
|
||||
&& (g_Vars.normmplayerisrunning
|
||||
|| (g_Vars.antiplayernum >= 0 && !g_Vars.bond->isdead)
|
||||
|| (g_Vars.coopplayernum >= 0 && (!g_Vars.bond->isdead || !g_Vars.coop->isdead)))) {
|
||||
// Someone is dying in MP, or anti is dying, or *one* person is dying in coop
|
||||
g_MusicSilenceTimer60 = 0;
|
||||
g_MusicDeathTimer240 -= g_Vars.lvupdate240;
|
||||
|
||||
if (g_MusicDeathTimer240 <= 0) {
|
||||
musicEndDeath();
|
||||
if (g_MusicDeathTimer240 <= 0) {
|
||||
musicEndDeath();
|
||||
|
||||
// The death is complete. Are we due to start a new track?
|
||||
if (g_MpEnableMusicSwitching && g_Vars.normmplayerisrunning && g_MusicLife60 < g_MusicAge60) {
|
||||
g_MusicAge60 = 0;
|
||||
musicQueueStopEvent(TRACKTYPE_MENU);
|
||||
musicQueueStopEvent(TRACKTYPE_DEATH);
|
||||
musicQueueStopEvent(TRACKTYPE_PRIMARY);
|
||||
musicQueueStartEvent(TRACKTYPE_PRIMARY, stageGetPrimaryTrack(g_MusicStageNum), 0, musicGetVolume());
|
||||
}
|
||||
}
|
||||
} else if (g_MpEnableMusicSwitching && g_Vars.normmplayerisrunning && g_MusicLife60 < g_MusicAge60) {
|
||||
// Due to start a new track. Fade out the old one,
|
||||
// then start a 2 second time before starting the new one.
|
||||
g_MusicAge60 = 0;
|
||||
musicQueueFadeEvent(TRACKTYPE_PRIMARY, 2, 1);
|
||||
g_MusicSilenceTimer60 = TICKS(120);
|
||||
}
|
||||
|
||||
if (g_MpEnableMusicSwitching && g_Vars.normmplayerisrunning) {
|
||||
g_MusicAge60 += g_Vars.diffframe60;
|
||||
|
||||
// If the silence timer is set, it means we're transitioning between
|
||||
// songs in multiplayer. Tick the timer down, and when it reaches
|
||||
// zero start a new track.
|
||||
if (g_MusicSilenceTimer60 > 0) {
|
||||
g_MusicSilenceTimer60 -= g_Vars.diffframe60;
|
||||
|
||||
if (g_MusicSilenceTimer60 <= 0) {
|
||||
musicQueueStopEvent(TRACKTYPE_MENU);
|
||||
musicQueueStopEvent(TRACKTYPE_DEATH);
|
||||
musicQueueStopEvent(TRACKTYPE_PRIMARY);
|
||||
musicQueueStartEvent(TRACKTYPE_PRIMARY, stageGetPrimaryTrack(g_MusicStageNum), 0, musicGetVolume());
|
||||
}
|
||||
// The death is complete. Are we due to start a new track?
|
||||
if (g_MpEnableMusicSwitching && g_Vars.normmplayerisrunning && g_MusicLife60 < g_MusicAge60) {
|
||||
g_MusicAge60 = 0;
|
||||
musicQueueStopEvent(TRACKTYPE_MENU);
|
||||
musicQueueStopEvent(TRACKTYPE_DEATH);
|
||||
musicQueueStopEvent(TRACKTYPE_PRIMARY);
|
||||
musicQueueStartEvent(TRACKTYPE_PRIMARY, stageGetPrimaryTrack(g_MusicStageNum), 0, musicGetVolume());
|
||||
}
|
||||
}
|
||||
} else if (g_MpEnableMusicSwitching && g_Vars.normmplayerisrunning && g_MusicLife60 < g_MusicAge60) {
|
||||
// Due to start a new track. Fade out the old one,
|
||||
// then start a 2 second time before starting the new one.
|
||||
g_MusicAge60 = 0;
|
||||
musicQueueFadeEvent(TRACKTYPE_PRIMARY, 2, 1);
|
||||
g_MusicSilenceTimer60 = TICKS(120);
|
||||
}
|
||||
|
||||
// Handle stopping of NRG tune
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (g_AudioXReasonsActive[i] || g_MusicXReasonMinDurations[i] > 0) {
|
||||
if (g_MusicXReasonMinDurations[i] >= g_Vars.lvupdate240) {
|
||||
g_MusicXReasonMinDurations[i] -= g_Vars.lvupdate240;
|
||||
if (g_MpEnableMusicSwitching && g_Vars.normmplayerisrunning) {
|
||||
g_MusicAge60 += g_Vars.diffframe60;
|
||||
|
||||
// If the silence timer is set, it means we're transitioning between
|
||||
// songs in multiplayer. Tick the timer down, and when it reaches
|
||||
// zero start a new track.
|
||||
if (g_MusicSilenceTimer60 > 0) {
|
||||
g_MusicSilenceTimer60 -= g_Vars.diffframe60;
|
||||
|
||||
if (g_MusicSilenceTimer60 <= 0) {
|
||||
musicQueueStopEvent(TRACKTYPE_MENU);
|
||||
musicQueueStopEvent(TRACKTYPE_DEATH);
|
||||
musicQueueStopEvent(TRACKTYPE_PRIMARY);
|
||||
musicQueueStartEvent(TRACKTYPE_PRIMARY, stageGetPrimaryTrack(g_MusicStageNum), 0, musicGetVolume());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handle stopping of NRG tune
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (g_AudioXReasonsActive[i] || g_MusicXReasonMinDurations[i] > 0) {
|
||||
if (g_MusicXReasonMinDurations[i] >= g_Vars.lvupdate240) {
|
||||
g_MusicXReasonMinDurations[i] -= g_Vars.lvupdate240;
|
||||
} else {
|
||||
g_MusicXReasonMinDurations[i] = 0;
|
||||
}
|
||||
|
||||
if (g_MusicXReasonMaxDurations[i] != 0) {
|
||||
if (g_MusicXReasonMaxDurations[i] >= g_Vars.lvupdate240) {
|
||||
g_MusicXReasonMaxDurations[i] -= g_Vars.lvupdate240;
|
||||
} else {
|
||||
g_MusicXReasonMinDurations[i] = 0;
|
||||
g_MusicXReasonMaxDurations[i] = 0;
|
||||
}
|
||||
|
||||
if (g_MusicXReasonMaxDurations[i] != 0) {
|
||||
if (g_MusicXReasonMaxDurations[i] >= g_Vars.lvupdate240) {
|
||||
g_MusicXReasonMaxDurations[i] -= g_Vars.lvupdate240;
|
||||
} else {
|
||||
g_MusicXReasonMaxDurations[i] = 0;
|
||||
}
|
||||
|
||||
if (g_MusicXReasonMaxDurations[i] != 0) {
|
||||
if (g_AudioXReasonsActive[i] || g_MusicXReasonMinDurations[i]) {
|
||||
playnrg = true;
|
||||
}
|
||||
} else {
|
||||
g_AudioXReasonsActive[i] = 0;
|
||||
if (g_AudioXReasonsActive[i] || g_MusicXReasonMinDurations[i]) {
|
||||
playnrg = true;
|
||||
}
|
||||
} else {
|
||||
g_AudioXReasonsActive[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (g_Vars.lvupdate240 != 0) {
|
||||
if (g_MusicNrgIsActive) {
|
||||
if (!playnrg) {
|
||||
musicDeactivateNrg();
|
||||
}
|
||||
} else {
|
||||
if (playnrg && !g_Vars.dontplaynrg) {
|
||||
musicActivateNrg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the player is in an ambient room every 0.25 seconds
|
||||
if (g_Vars.lvupdate240 > g_MusicNextAmbientTick240) {
|
||||
musicTickAmbient();
|
||||
g_MusicNextAmbientTick240 = TICKS(60);
|
||||
} else {
|
||||
g_MusicNextAmbientTick240 -= g_Vars.lvupdate240;
|
||||
}
|
||||
|
||||
musicTickEvents();
|
||||
}
|
||||
|
||||
if (g_Vars.lvupdate240 != 0) {
|
||||
if (g_MusicNrgIsActive) {
|
||||
if (!playnrg) {
|
||||
musicDeactivateNrg();
|
||||
}
|
||||
} else {
|
||||
if (playnrg && !g_Vars.dontplaynrg) {
|
||||
musicActivateNrg();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Check if the player is in an ambient room every 0.25 seconds
|
||||
if (g_Vars.lvupdate240 > g_MusicNextAmbientTick240) {
|
||||
musicTickAmbient();
|
||||
g_MusicNextAmbientTick240 = TICKS(60);
|
||||
} else {
|
||||
g_MusicNextAmbientTick240 -= g_Vars.lvupdate240;
|
||||
}
|
||||
|
||||
musicTickEvents();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -680,10 +680,6 @@ struct sndstate *func00033820(s32 arg0, s16 soundnum, u16 vol, ALPan pan, f32 pi
|
|||
N_ALEvent evt;
|
||||
N_ALEvent evt2;
|
||||
|
||||
if (sndIsDisabled()) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (soundnum != 0) {
|
||||
do {
|
||||
sound = sndLoadSound(soundnum);
|
||||
|
|
|
|||
480
src/lib/snd.c
480
src/lib/snd.c
|
|
@ -45,10 +45,6 @@ struct seqtable *g_SeqTable;
|
|||
u32 g_SeqBufferSize;
|
||||
ALIGNED16 struct sndcache g_SndCache;
|
||||
|
||||
const char g_SndGuardString[] = "RUSSES SOUND GUARD STRING";
|
||||
|
||||
bool g_SndDisabled = false;
|
||||
|
||||
s32 g_SndNosediveVolume = 0;
|
||||
s32 g_SndNosediveAge240 = -1;
|
||||
s32 g_SndNosediveDuration240 = 0;
|
||||
|
|
@ -62,13 +58,10 @@ struct sndstate *g_SndUfoHandle = NULL;
|
|||
|
||||
u16 g_SfxVolume = 32767;
|
||||
s32 g_SoundMode = SOUNDMODE_STEREO;
|
||||
bool g_SndMp3Enabled = false;
|
||||
|
||||
s32 var8005ddd4 = 0;
|
||||
s32 var8005ddd8 = 0;
|
||||
|
||||
u8 *g_SndGuardStringPtr = NULL;
|
||||
|
||||
enum audioconfig_e {
|
||||
AUDIOCONFIG_00,
|
||||
AUDIOCONFIG_01,
|
||||
|
|
@ -1277,101 +1270,89 @@ void sndInit(void)
|
|||
|
||||
g_Vars.langfilteron = false;
|
||||
|
||||
g_SndMp3Enabled = true;
|
||||
g_SndMaxFxBusses = 2;
|
||||
|
||||
if (!g_SndDisabled) {
|
||||
// Allocate memory for the audio heap,
|
||||
// clear it and give it to the audio library
|
||||
u32 len = &_seqctlSegmentRomEnd - &_seqctlSegmentRomStart;
|
||||
u8 *ptr = mempAlloc(heaplen, MEMPOOL_PERMANENT);
|
||||
s32 i;
|
||||
u8 *heapstart = ptr;
|
||||
u8 *end = heapstart + heaplen;
|
||||
ALBankFile *bankfile;
|
||||
// Allocate memory for the audio heap,
|
||||
// clear it and give it to the audio library
|
||||
u32 len = &_seqctlSegmentRomEnd - &_seqctlSegmentRomStart;
|
||||
u8 *ptr = mempAlloc(heaplen, MEMPOOL_PERMANENT);
|
||||
s32 i;
|
||||
u8 *heapstart = ptr;
|
||||
u8 *end = heapstart + heaplen;
|
||||
ALBankFile *bankfile;
|
||||
|
||||
while (ptr < end) {
|
||||
*ptr = 0;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
alHeapInit(&g_SndHeap, heapstart, heaplen);
|
||||
|
||||
// Allocate some space at the start of the heap for a string identifier.
|
||||
// This might be used to determine if the heap has overflowed.
|
||||
g_SndGuardStringPtr = alHeapAlloc(&g_SndHeap, 1, 32);
|
||||
strcpy(g_SndGuardStringPtr, g_SndGuardString);
|
||||
|
||||
// Load sfx.ctl
|
||||
sndLoadSfxCtl();
|
||||
|
||||
// Load seq.ctl
|
||||
var80095200 = 0xffffffff;
|
||||
bankfile = alHeapAlloc(&g_SndHeap, 1, len);
|
||||
dmaExec(bankfile, (u32) &_seqctlSegmentRomStart, len);
|
||||
|
||||
// Load seq.tbl
|
||||
alBnkfNew(bankfile, &_seqtblSegmentRomStart);
|
||||
|
||||
// Load the sequences table. To do this, load the header of the
|
||||
// sequences segment and read the number of sequences, then allocate
|
||||
// enough space for the table and load it.
|
||||
var80095204 = bankfile->bankArray[0];
|
||||
g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, 0x10);
|
||||
dmaExec(g_SeqTable, (u32) &_sequencesSegmentRomStart, 0x10);
|
||||
|
||||
len = g_SeqTable->count * sizeof(struct seqtableentry) + 4;
|
||||
g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, len);
|
||||
dmaExec(g_SeqTable, (u32) &_sequencesSegmentRomStart, (len + 0xf) & 0xfffffff0);
|
||||
|
||||
// Promote segment-relative offsets to ROM addresses
|
||||
for (i = 0; i < g_SeqTable->count; i++) {
|
||||
g_SeqTable->entries[i].romaddr += (u32) &_sequencesSegmentRomStart;
|
||||
}
|
||||
|
||||
synconfig.maxVVoices = 44;
|
||||
synconfig.maxPVoices = 30;
|
||||
synconfig.maxUpdates = 64;
|
||||
synconfig.dmaproc = NULL;
|
||||
synconfig.outputRate = 0;
|
||||
synconfig.heap = &g_SndHeap;
|
||||
synconfig.maxFXbusses = g_SndMaxFxBusses;
|
||||
|
||||
for (i = 0; i < g_SndMaxFxBusses; i++) {
|
||||
synconfig.fxTypes[i] = 6;
|
||||
}
|
||||
|
||||
sndpconfig.maxEvents = 64;
|
||||
sndpconfig.maxStates = 64;
|
||||
sndpconfig.maxSounds = 20;
|
||||
sndpconfig.unk10 = 9;
|
||||
sndpconfig.heap = &g_SndHeap;
|
||||
|
||||
amgrCreate(&synconfig);
|
||||
|
||||
if (g_SndMp3Enabled) {
|
||||
|
||||
mp3Init(&g_SndHeap);
|
||||
func00037f08(0x7fff, 1);
|
||||
func00037f5c(0, true);
|
||||
|
||||
}
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
seqInit(&g_SeqInstances[i]);
|
||||
}
|
||||
|
||||
|
||||
n_alSndpNew(&sndpconfig);
|
||||
|
||||
|
||||
sndpSetAddRefCallback(sndAddRef);
|
||||
sndpSetRemoveRefCallback(sndRemoveRef);
|
||||
|
||||
amgrStartThread();
|
||||
|
||||
sndSetSoundMode(g_SoundMode);
|
||||
while (ptr < end) {
|
||||
*ptr = 0;
|
||||
ptr++;
|
||||
}
|
||||
|
||||
alHeapInit(&g_SndHeap, heapstart, heaplen);
|
||||
|
||||
// Load sfx.ctl
|
||||
sndLoadSfxCtl();
|
||||
|
||||
// Load seq.ctl
|
||||
var80095200 = 0xffffffff;
|
||||
bankfile = alHeapAlloc(&g_SndHeap, 1, len);
|
||||
dmaExec(bankfile, (u32) &_seqctlSegmentRomStart, len);
|
||||
|
||||
// Load seq.tbl
|
||||
alBnkfNew(bankfile, &_seqtblSegmentRomStart);
|
||||
|
||||
// Load the sequences table. To do this, load the header of the
|
||||
// sequences segment and read the number of sequences, then allocate
|
||||
// enough space for the table and load it.
|
||||
var80095204 = bankfile->bankArray[0];
|
||||
g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, 0x10);
|
||||
dmaExec(g_SeqTable, (u32) &_sequencesSegmentRomStart, 0x10);
|
||||
|
||||
len = g_SeqTable->count * sizeof(struct seqtableentry) + 4;
|
||||
g_SeqTable = alHeapDBAlloc(0, 0, &g_SndHeap, 1, len);
|
||||
dmaExec(g_SeqTable, (u32) &_sequencesSegmentRomStart, (len + 0xf) & 0xfffffff0);
|
||||
|
||||
// Promote segment-relative offsets to ROM addresses
|
||||
for (i = 0; i < g_SeqTable->count; i++) {
|
||||
g_SeqTable->entries[i].romaddr += (u32) &_sequencesSegmentRomStart;
|
||||
}
|
||||
|
||||
synconfig.maxVVoices = 44;
|
||||
synconfig.maxPVoices = 30;
|
||||
synconfig.maxUpdates = 64;
|
||||
synconfig.dmaproc = NULL;
|
||||
synconfig.outputRate = 0;
|
||||
synconfig.heap = &g_SndHeap;
|
||||
synconfig.maxFXbusses = g_SndMaxFxBusses;
|
||||
|
||||
for (i = 0; i < g_SndMaxFxBusses; i++) {
|
||||
synconfig.fxTypes[i] = 6;
|
||||
}
|
||||
|
||||
sndpconfig.maxEvents = 64;
|
||||
sndpconfig.maxStates = 64;
|
||||
sndpconfig.maxSounds = 20;
|
||||
sndpconfig.unk10 = 9;
|
||||
sndpconfig.heap = &g_SndHeap;
|
||||
|
||||
amgrCreate(&synconfig);
|
||||
|
||||
mp3Init(&g_SndHeap);
|
||||
func00037f08(0x7fff, 1);
|
||||
func00037f5c(0, true);
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
seqInit(&g_SeqInstances[i]);
|
||||
}
|
||||
|
||||
|
||||
n_alSndpNew(&sndpconfig);
|
||||
|
||||
|
||||
sndpSetAddRefCallback(sndAddRef);
|
||||
sndpSetRemoveRefCallback(sndRemoveRef);
|
||||
|
||||
amgrStartThread();
|
||||
|
||||
sndSetSoundMode(g_SoundMode);
|
||||
}
|
||||
|
||||
bool sndIsMp3(s16 soundnum)
|
||||
|
|
@ -1384,17 +1365,15 @@ bool sndIsMp3(s16 soundnum)
|
|||
|
||||
bool snd0000fbc4(s16 arg0)
|
||||
{
|
||||
if (!g_SndDisabled && g_SndMp3Enabled) {
|
||||
if (func00037ea4() && g_SndCurMp3.unk08 != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
func00037e1c();
|
||||
|
||||
g_SndCurMp3.playing = false;
|
||||
g_SndCurMp3.responsetimer240 = -1;
|
||||
if (func00037ea4() && g_SndCurMp3.unk08 != 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
func00037e1c();
|
||||
|
||||
g_SndCurMp3.playing = false;
|
||||
g_SndCurMp3.responsetimer240 = -1;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
@ -1409,10 +1388,6 @@ bool seqPlay(struct seqinstance *seq, s32 tracknum)
|
|||
|
||||
s32 state = n_alCSPGetState(seq->seqp);
|
||||
|
||||
if (g_SndDisabled) {
|
||||
return false;
|
||||
}
|
||||
|
||||
seq->tracknum = tracknum;
|
||||
|
||||
if (g_SeqTable && tracknum);
|
||||
|
|
@ -1449,37 +1424,31 @@ bool seqPlay(struct seqinstance *seq, s32 tracknum)
|
|||
|
||||
static u16 seqGetVolume(struct seqinstance *seq)
|
||||
{
|
||||
return g_SndDisabled ? 0x7fff : seq->volume;
|
||||
return seq->volume;
|
||||
}
|
||||
|
||||
void seqSetVolume(struct seqinstance *seq, u16 volume)
|
||||
{
|
||||
if (!g_SndDisabled) {
|
||||
u32 tmp = var8005ecf8[seq->tracknum] * volume;
|
||||
tmp >>= 15;
|
||||
u32 tmp = var8005ecf8[seq->tracknum] * volume;
|
||||
tmp >>= 15;
|
||||
|
||||
seq->volume = volume;
|
||||
seq->volume = volume;
|
||||
|
||||
if (tmp > 0x7fff) {
|
||||
tmp = 0x7fff;
|
||||
}
|
||||
|
||||
n_alCSPSetVol(seq->seqp, tmp);
|
||||
if (tmp > 0x7fff) {
|
||||
tmp = 0x7fff;
|
||||
}
|
||||
|
||||
n_alCSPSetVol(seq->seqp, tmp);
|
||||
}
|
||||
|
||||
void snd0000fe20(void)
|
||||
{
|
||||
if (g_SndMp3Enabled) {
|
||||
func00037e38();
|
||||
}
|
||||
func00037e38();
|
||||
}
|
||||
|
||||
void snd0000fe50(void)
|
||||
{
|
||||
if (g_SndMp3Enabled) {
|
||||
func00037e68();
|
||||
}
|
||||
func00037e68();
|
||||
}
|
||||
|
||||
void sndTick(void)
|
||||
|
|
@ -1537,114 +1506,105 @@ void sndTick(void)
|
|||
var8005edec = var8005ddd8;
|
||||
}
|
||||
|
||||
if (!g_SndDisabled && g_SndMp3Enabled) {
|
||||
if (g_Vars.stagenum == STAGE_AIRFORCEONE) {
|
||||
sndTickNosedive();
|
||||
} else if (g_Vars.stagenum == STAGE_ESCAPE) {
|
||||
sndTickUfo();
|
||||
if (g_Vars.stagenum == STAGE_AIRFORCEONE) {
|
||||
sndTickNosedive();
|
||||
} else if (g_Vars.stagenum == STAGE_ESCAPE) {
|
||||
sndTickUfo();
|
||||
}
|
||||
|
||||
if (g_Vars.tickmode == TICKMODE_CUTSCENE) {
|
||||
s0 = musicGetVolume() > g_SfxVolume ? musicGetVolume() : g_SfxVolume;
|
||||
|
||||
if (s0 != snd0000e9dc()) {
|
||||
snd0000ea80(s0);
|
||||
}
|
||||
|
||||
if (g_Vars.tickmode == TICKMODE_CUTSCENE) {
|
||||
s0 = musicGetVolume() > g_SfxVolume ? musicGetVolume() : g_SfxVolume;
|
||||
|
||||
if (s0 != snd0000e9dc()) {
|
||||
snd0000ea80(s0);
|
||||
}
|
||||
} else {
|
||||
if (g_SfxVolume != snd0000e9dc()) {
|
||||
snd0000ea80(g_SfxVolume);
|
||||
}
|
||||
} else {
|
||||
if (g_SfxVolume != snd0000e9dc()) {
|
||||
snd0000ea80(g_SfxVolume);
|
||||
}
|
||||
}
|
||||
|
||||
if (func00037ea4() == 0 && g_SndCurMp3.playing) {
|
||||
if (g_SndCurMp3.unk08) {
|
||||
mp3PlayFile(g_SndCurMp3.romaddr, g_SndCurMp3.romsize);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (g_SndCurMp3.responsetype) {
|
||||
case MP3RESPONSETYPE_ACKNOWLEDGE:
|
||||
case MP3RESPONSETYPE_WHISPER:
|
||||
g_SndCurMp3.responsetimer240 = TICKS(60);
|
||||
break;
|
||||
case MP3RESPONSETYPE_GREETING:
|
||||
g_SndCurMp3.responsetimer240 = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
g_SndCurMp3.playing = false;
|
||||
if (func00037ea4() == 0 && g_SndCurMp3.playing) {
|
||||
if (g_SndCurMp3.unk08) {
|
||||
mp3PlayFile(g_SndCurMp3.romaddr, g_SndCurMp3.romsize);
|
||||
return;
|
||||
}
|
||||
|
||||
if (g_SndCurMp3.responsetimer240 > 0) {
|
||||
g_SndCurMp3.responsetimer240 -= g_Vars.lvupdate240;
|
||||
switch (g_SndCurMp3.responsetype) {
|
||||
case MP3RESPONSETYPE_ACKNOWLEDGE:
|
||||
case MP3RESPONSETYPE_WHISPER:
|
||||
g_SndCurMp3.responsetimer240 = TICKS(60);
|
||||
break;
|
||||
case MP3RESPONSETYPE_GREETING:
|
||||
g_SndCurMp3.responsetimer240 = 1;
|
||||
break;
|
||||
}
|
||||
|
||||
if (g_SndCurMp3.responsetimer240 <= 0) {
|
||||
if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_WHISPER) {
|
||||
do {
|
||||
index = random() % 4;
|
||||
} while (index == g_SndCurMp3.prevwhisper);
|
||||
g_SndCurMp3.playing = false;
|
||||
return;
|
||||
}
|
||||
|
||||
g_SndCurMp3.prevwhisper = index;
|
||||
if (g_SndCurMp3.responsetimer240 > 0) {
|
||||
g_SndCurMp3.responsetimer240 -= g_Vars.lvupdate240;
|
||||
|
||||
switch (index) {
|
||||
case 0: sp50.packed = MP3_JO_WHISPER_RECEIVED; break;
|
||||
case 1: sp50.packed = MP3_JO_WHISPER_UNDERSTOOD; break;
|
||||
case 2: sp50.packed = MP3_JO_WHISPER_AFFIRMATIVE; break;
|
||||
case 3: sp50.packed = MP3_JO_WHISPER_CONFIRMED; break;
|
||||
}
|
||||
} else if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_ACKNOWLEDGE) {
|
||||
do {
|
||||
index = random() % 4;
|
||||
} while (index == g_SndCurMp3.prevacknowledge);
|
||||
if (g_SndCurMp3.responsetimer240 <= 0) {
|
||||
if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_WHISPER) {
|
||||
do {
|
||||
index = random() % 4;
|
||||
} while (index == g_SndCurMp3.prevwhisper);
|
||||
|
||||
g_SndCurMp3.prevacknowledge = index;
|
||||
g_SndCurMp3.prevwhisper = index;
|
||||
|
||||
switch (index) {
|
||||
case 0: sp50.packed = MP3_JO_ACKNOWLEDGE_CONFIRMED; break;
|
||||
case 1: sp50.packed = MP3_JO_ACKNOWLEDGE_UNDERSTOOD; break;
|
||||
case 2: sp50.packed = MP3_JO_ACKNOWLEDGE_AFFIRMATIVE; break;
|
||||
case 3: sp50.packed = MP3_JO_ACKNOWLEDGE_RECEIVED; break;
|
||||
}
|
||||
} else if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_GREETING) {
|
||||
do {
|
||||
index = random() % 4;
|
||||
} while (index == g_SndCurMp3.prevgreeting);
|
||||
|
||||
g_SndCurMp3.prevgreeting = index;
|
||||
|
||||
switch (index) {
|
||||
case 0: sp50.packed = MP3_JO_GREETING_HELLO; break;
|
||||
case 1: sp50.packed = MP3_JO_GREETING_HI; break;
|
||||
case 2: sp50.packed = MP3_JO_GREETING_HEY; break;
|
||||
case 3: sp50.packed = MP3_JO_GREETING_HIYA; break;
|
||||
}
|
||||
switch (index) {
|
||||
case 0: sp50.packed = MP3_JO_WHISPER_RECEIVED; break;
|
||||
case 1: sp50.packed = MP3_JO_WHISPER_UNDERSTOOD; break;
|
||||
case 2: sp50.packed = MP3_JO_WHISPER_AFFIRMATIVE; break;
|
||||
case 3: sp50.packed = MP3_JO_WHISPER_CONFIRMED; break;
|
||||
}
|
||||
} else if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_ACKNOWLEDGE) {
|
||||
do {
|
||||
index = random() % 4;
|
||||
} while (index == g_SndCurMp3.prevacknowledge);
|
||||
|
||||
g_SndCurMp3.responsetimer240 = -1;
|
||||
sndStart(0, sp50.packed, 0, -1, -1, -1.0f, -1, -1);
|
||||
g_SndCurMp3.prevacknowledge = index;
|
||||
|
||||
switch (index) {
|
||||
case 0: sp50.packed = MP3_JO_ACKNOWLEDGE_CONFIRMED; break;
|
||||
case 1: sp50.packed = MP3_JO_ACKNOWLEDGE_UNDERSTOOD; break;
|
||||
case 2: sp50.packed = MP3_JO_ACKNOWLEDGE_AFFIRMATIVE; break;
|
||||
case 3: sp50.packed = MP3_JO_ACKNOWLEDGE_RECEIVED; break;
|
||||
}
|
||||
} else if (g_SndCurMp3.responsetype == MP3RESPONSETYPE_GREETING) {
|
||||
do {
|
||||
index = random() % 4;
|
||||
} while (index == g_SndCurMp3.prevgreeting);
|
||||
|
||||
g_SndCurMp3.prevgreeting = index;
|
||||
|
||||
switch (index) {
|
||||
case 0: sp50.packed = MP3_JO_GREETING_HELLO; break;
|
||||
case 1: sp50.packed = MP3_JO_GREETING_HI; break;
|
||||
case 2: sp50.packed = MP3_JO_GREETING_HEY; break;
|
||||
case 3: sp50.packed = MP3_JO_GREETING_HIYA; break;
|
||||
}
|
||||
}
|
||||
|
||||
g_SndCurMp3.responsetimer240 = -1;
|
||||
sndStart(0, sp50.packed, 0, -1, -1, -1.0f, -1, -1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool sndIsDisabled(void)
|
||||
{
|
||||
return g_SndDisabled;
|
||||
}
|
||||
|
||||
void sndStartMp3ByFilenum(u32 filenum)
|
||||
{
|
||||
union soundnumhack sfxref;
|
||||
|
||||
if (!g_SndDisabled && g_SndMp3Enabled) {
|
||||
sfxref.packed = 0;
|
||||
sfxref.unk02 = 0;
|
||||
sfxref.mp3priority = 1; // high priority
|
||||
sfxref.id = filenum;
|
||||
sfxref.packed = 0;
|
||||
sfxref.unk02 = 0;
|
||||
sfxref.mp3priority = 1; // high priority
|
||||
sfxref.id = filenum;
|
||||
|
||||
sndStart(0, sfxref.packed, NULL, -1, -1, -1, -1, -1);
|
||||
}
|
||||
sndStart(0, sfxref.packed, NULL, -1, -1, -1, -1, -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -1831,10 +1791,6 @@ struct sndstate *sndStart(s32 arg0, s16 sound, struct sndstate **handle, s32 arg
|
|||
|
||||
sp44.packed = sound;
|
||||
|
||||
if (g_SndDisabled) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
sp40.packed = sp44.hasconfig ? g_AudioRussMappings[sp44.confignum].soundnum : sp44.packed;
|
||||
|
||||
if (sp40.id == SFX_0037 || sp40.id == SFX_0009) {
|
||||
|
|
@ -1866,63 +1822,61 @@ void sndStartMp3(s16 soundnum, s32 arg1, s32 arg2, s32 arg3)
|
|||
|
||||
sp24.packed = soundnum;
|
||||
|
||||
if (!g_SndDisabled) {
|
||||
if (sp24.hasconfig) {
|
||||
sp20.packed = g_AudioRussMappings[sp24.confignum].soundnum;
|
||||
sp20.hasconfig = false;
|
||||
} else {
|
||||
sp20.packed = soundnum;
|
||||
}
|
||||
|
||||
if (!g_SndCurMp3.playing
|
||||
|| ((sp20.mp3priority != 1 || g_SndCurMp3.sfxref.mp3priority != 1)
|
||||
&& sp20.mp3priority <= g_SndCurMp3.sfxref.mp3priority)) {
|
||||
if (sp24.hasconfig) {
|
||||
sp20.packed = g_AudioRussMappings[sp24.confignum].soundnum;
|
||||
sp20.hasconfig = false;
|
||||
} else {
|
||||
sp20.packed = soundnum;
|
||||
if (g_AudioConfigs[sp24.confignum].unk10 != -1) {
|
||||
arg1 = g_AudioConfigs[sp24.confignum].unk10 * 32767 / 100;
|
||||
}
|
||||
|
||||
if (g_AudioConfigs[sp24.confignum].unk14 != -1) {
|
||||
arg2 = g_AudioConfigs[sp24.confignum].unk14;
|
||||
}
|
||||
|
||||
// This is the same thing again
|
||||
if (g_AudioConfigs[sp24.confignum].unk14 != -1) {
|
||||
arg2 = g_AudioConfigs[sp24.confignum].unk14;
|
||||
}
|
||||
|
||||
if (g_Vars.langfilteron && (g_AudioConfigs[sp24.confignum].flags & AUDIOCONFIGFLAG_OFFENSIVE)) {
|
||||
arg1 = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!g_SndCurMp3.playing
|
||||
|| ((sp20.mp3priority != 1 || g_SndCurMp3.sfxref.mp3priority != 1)
|
||||
&& sp20.mp3priority <= g_SndCurMp3.sfxref.mp3priority)) {
|
||||
if (sp24.hasconfig) {
|
||||
if (g_AudioConfigs[sp24.confignum].unk10 != -1) {
|
||||
arg1 = g_AudioConfigs[sp24.confignum].unk10 * 32767 / 100;
|
||||
}
|
||||
arg1 = arg1 * snd0000e9dc() / 0x7fff;
|
||||
|
||||
if (g_AudioConfigs[sp24.confignum].unk14 != -1) {
|
||||
arg2 = g_AudioConfigs[sp24.confignum].unk14;
|
||||
}
|
||||
g_SndCurMp3.romaddr = fileGetRomAddress(sp20.id);
|
||||
g_SndCurMp3.romsize = fileGetRomSize(sp20.id);
|
||||
|
||||
// This is the same thing again
|
||||
if (g_AudioConfigs[sp24.confignum].unk14 != -1) {
|
||||
arg2 = g_AudioConfigs[sp24.confignum].unk14;
|
||||
}
|
||||
func00037f08(arg1, true);
|
||||
func00037f5c(arg2, true);
|
||||
|
||||
if (g_Vars.langfilteron && (g_AudioConfigs[sp24.confignum].flags & AUDIOCONFIGFLAG_OFFENSIVE)) {
|
||||
arg1 = 0;
|
||||
}
|
||||
}
|
||||
mp3PlayFile(g_SndCurMp3.romaddr, g_SndCurMp3.romsize);
|
||||
|
||||
arg1 = arg1 * snd0000e9dc() / 0x7fff;
|
||||
func00037f08(arg1, true);
|
||||
func00037f5c(arg2, true);
|
||||
|
||||
g_SndCurMp3.romaddr = fileGetRomAddress(sp20.id);
|
||||
g_SndCurMp3.romsize = fileGetRomSize(sp20.id);
|
||||
g_SndCurMp3.sfxref.packed = sp20.packed;
|
||||
g_SndCurMp3.playing = true;
|
||||
g_SndCurMp3.responsetimer240 = -1;
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_NONE;
|
||||
|
||||
func00037f08(arg1, true);
|
||||
func00037f5c(arg2, true);
|
||||
if (g_SndCurMp3.sfxref.unk02 == 2) {
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_ACKNOWLEDGE;
|
||||
} else if (g_SndCurMp3.sfxref.unk02 == 1) {
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_WHISPER;
|
||||
}
|
||||
|
||||
mp3PlayFile(g_SndCurMp3.romaddr, g_SndCurMp3.romsize);
|
||||
|
||||
func00037f08(arg1, true);
|
||||
func00037f5c(arg2, true);
|
||||
|
||||
g_SndCurMp3.sfxref.packed = sp20.packed;
|
||||
g_SndCurMp3.playing = true;
|
||||
g_SndCurMp3.responsetimer240 = -1;
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_NONE;
|
||||
|
||||
if (g_SndCurMp3.sfxref.unk02 == 2) {
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_ACKNOWLEDGE;
|
||||
} else if (g_SndCurMp3.sfxref.unk02 == 1) {
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_WHISPER;
|
||||
}
|
||||
|
||||
if ((sp24.hasconfig && (g_AudioConfigs[sp24.confignum].flags & AUDIOCONFIGFLAG_04)) || (arg3 & 1)) {
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_GREETING;
|
||||
}
|
||||
if ((sp24.hasconfig && (g_AudioConfigs[sp24.confignum].flags & AUDIOCONFIGFLAG_04)) || (arg3 & 1)) {
|
||||
g_SndCurMp3.responsetype = MP3RESPONSETYPE_GREETING;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue