ACS: add Music_Dim function, API to g_musicfade

This commit is contained in:
James R 2024-04-04 05:10:27 -07:00
parent de651b6d6c
commit 78da8bb816
3 changed files with 33 additions and 0 deletions

View file

@ -2399,6 +2399,37 @@ bool CallFunc_MusicRemap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::
return false;
}
/*--------------------------------------------------
bool CallFunc_MusicDim(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
Fade level music into or out of silence.
--------------------------------------------------*/
bool CallFunc_MusicDim(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)
{
// 0: int fade time (tics) - time to fade between full volume and silence
// 1: [int duration (tics)] - silent duration (not including fade in and fade out), -1 = infinite (default if omitted)
// If a dim is ongoing, do not interrupt it
if (g_musicfade.start < leveltime && g_musicfade.end < leveltime)
{
g_musicfade.start = leveltime;
}
tic_t fade = argV[0];
tic_t duration = INFTICS;
if (argC > 1 && argV[1] >= 0)
{
duration = argV[1];
}
g_musicfade.end = duration != INFTICS ? leveltime + duration + 2*fade : INFTICS;
g_musicfade.fade = fade;
g_musicfade.ticked = false;
return false;
}
/*--------------------------------------------------
bool CallFunc_Freeze(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC)

View file

@ -103,6 +103,7 @@ bool CallFunc_ExitLevel(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::W
bool CallFunc_MusicPlay(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
bool CallFunc_MusicStopAll(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
bool CallFunc_MusicRemap(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
bool CallFunc_MusicDim(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
bool CallFunc_DialogueSetSpeaker(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);
bool CallFunc_DialogueSetCustomSpeaker(ACSVM::Thread *thread, const ACSVM::Word *argV, ACSVM::Word argC);

View file

@ -187,6 +187,7 @@ Environment::Environment()
addFuncDataACS0( 509, addCallFunc(CallFunc_MusicStopAll));
addFuncDataACS0( 510, addCallFunc(CallFunc_MusicRemap));
addFuncDataACS0( 511, addCallFunc(CallFunc_Freeze));
addFuncDataACS0( 512, addCallFunc(CallFunc_MusicDim));
addFuncDataACS0( 600, addCallFunc(CallFunc_DialogueSetSpeaker));
addFuncDataACS0( 601, addCallFunc(CallFunc_DialogueSetCustomSpeaker));