Allow custom music to be added

Additional music can be added by placing sound files into Dataa/Music folder following this naming convention

musicmode_runningNumber.fileformat, so for example:

Mainmenu_001.mp3
Mainmenu_002.ogg
Laptop_002.ogg
Tactical_003.wav

*****************************************************************
Different musicmodes are

Mainmenu_ 		<-- Mainmenu music
Laptop_ 		<-- Laptop music
Tactical_		<-- Tactical with nothing special going on
Enemy_			<-- Tactical, enemy present
Battle_			<-- Tactical, enemy present and visible
Victory_		<-- Tactical, battle victory
Death_			<-- Tactical, battle defeat
Creepy_			<-- Tactical, creatures present
CreepyBattle_	<-- Tactical, creatures present and visible

Music files can be .mp3, .ogg or .wav formats and 100 songs in each category is supported.
The running numbering starts from 000

*****************************************************************
A few filenames are treated in a special way to facilitate easy replacement of original music.
To replace original music, insert the following named files into this folder

"menumix1"			<-- Mainmenu music
"marimbad 2"		<-- Laptop music
"nothing A"			<-- Tactical with nothing special going on
"nothing B"
"nothing C"
"nothing D"
"tensor A"			<-- Tactical, enemy present
"tensor B"
"tensor C"
"triumph"
"death"
"battle A"			<-- Tactical, enemy present and visible
"tensor B"			<-- This file is also used as battle music
"creepy"			<-- Tactical, creatures present
"creature battle"	<-- Tactical, creatures present and visible
This commit is contained in:
Asdow
2024-01-27 14:29:51 +02:00
parent c7bd75b60d
commit 7546a23d0d
5 changed files with 194 additions and 480 deletions
+19 -9
View File
@@ -79,8 +79,6 @@
class OBJECTTYPE;
class SOLDIERTYPE;
extern CHAR8 *szMusicList[NUM_MUSIC];
BOOLEAN gfCorruptMap = FALSE;
BOOLEAN gfCorruptSchedules = FALSE;
BOOLEAN gfProfileDataLoaded = FALSE;
@@ -169,6 +167,7 @@ LEVELNODE *gCursorNode = NULL;
INT32 gsCursorGridNo;
INT32 giMusicID = 0;
NewMusicList gMusicMode = MUSICLIST_MAIN_MENU;
void EraseWorldData( );
@@ -1616,16 +1615,27 @@ void HandleKeyboardShortcuts( )
break;
case F4:
#ifdef NEWMUSIC
MusicPlay( giMusicID, MUSIC_OLD_TYPE, FALSE );
#else
MusicPlay( giMusicID );
#endif
MusicPlay(gMusicMode, giMusicID);
ScreenMsg( FONT_YELLOW, MSG_INTERFACE, L"%S", MusicLists[gMusicMode][giMusicID] );
ScreenMsg( FONT_YELLOW, MSG_DEBUG, L"%S", szMusicList[giMusicID] );
// Select next track
giMusicID++;
if( giMusicID >= NUM_MUSIC )
if (giMusicID >= MusicLists[gMusicMode].size())
{
giMusicID = 0;
for (size_t i = 0; i < MAX_MUSIC; i++)
{
if (gMusicMode == i)
{
gMusicMode = static_cast<NewMusicList>(i + 1);
if (gMusicMode == MAX_MUSIC)
{
gMusicMode = MUSICLIST_MAIN_MENU;
}
break;
}
}
}
break;
case F5:
+4 -25
View File
@@ -570,9 +570,6 @@ static int l_AnimMercPtsrusStrategicInsertionData (lua_State *L);
static int l_SetMusicMode (lua_State *L);
static int l_MusicPlay (lua_State *L);
#ifdef NEWMUSIC
static int l_MusicPlayId (lua_State *L);
#endif
static int l_MusicSetVolume (lua_State *L);
static int l_MusicGetVolume (lua_State *L);
#ifdef NEWMUSIC
@@ -1398,7 +1395,6 @@ void IniFunction(lua_State *L, BOOLEAN bQuests )
lua_register(L, "SetMusicMode", l_SetMusicMode );
lua_register(L, "MusicPlay", l_MusicPlay );
#ifdef NEWMUSIC
lua_register(L, "MusicIdPlay", l_MusicPlayId );
lua_register(L, "AddMusic", l_gAddMusic );
lua_register(L, "SetMusicID", l_SetMusicID );
@@ -5715,33 +5711,16 @@ static int l_gAddMusic(lua_State *L)
}
#endif
static int l_MusicPlay (lua_State *L)
{
if ( lua_gettop(L) >= 1 )
{
UINT32 uiNum = lua_tointeger(L,1);
#ifdef NEWMUSIC
MusicPlay( uiNum, MUSIC_OLD_TYPE, FALSE);
#else
MusicPlay( uiNum );
#endif
}
return 0;
}
#ifdef NEWMUSIC
static int l_MusicPlayId (lua_State *L)
{
if ( lua_gettop(L) >= 2 )
{
UINT32 uiNum = lua_tointeger(L,1);
UINT32 uiType = lua_tointeger(L,2);
if (uiType>=1 || uiType<=5 )
MusicPlay( uiNum, uiType, TRUE);
UINT32 musicMode = lua_tointeger(L, 1);
UINT32 song = lua_tointeger(L,2);
MusicPlay( static_cast<NewMusicList>(musicMode), song );
}
return 0;
}
#endif
static int l_SetMusicMode (lua_State *L)
{
if ( lua_gettop(L) >= 1 )
+151 -397
View File
@@ -8,7 +8,6 @@
#include "strategicmap.h"
#include "Overhead Types.h"
//extern int iScreenMode;
static UINT32 uiMusicHandle = NO_SAMPLE;
static BOOLEAN fMusicPlaying = FALSE;
@@ -26,31 +25,36 @@ static UINT8 gubOldMusicMode = 0;
static INT8 gbVictorySongCount = 0;
static INT8 gbDeathSongCount = 0;
#ifdef NEWMUSIC
static INT32 bNothingModeSong = NOTHING_A_MUSIC;
static INT32 bEnemyModeSong = TENSOR_A_MUSIC;
static INT32 bBattleModeSong = BATTLE_A_MUSIC;
static INT32 NewSoundID = -1;
static BOOLEAN SetSoundID = FALSE;
static INT32 gubOldMusicMode2 = 0;
#else
static INT8 bNothingModeSong;
static INT8 bEnemyModeSong;
static INT8 bBattleModeSong;
#endif
static BOOLEAN gfUseCreatureMusic = FALSE;
static INT8 gbFadeSpeed = 1;
static BOOLEAN gfDontRestartSong = FALSE;
// unused
//BOOLEAN gfForceMusicToTense = FALSE;
CHAR8 *szMusicList[NUM_MUSIC]=
// Original music and their hardcoded paths
enum MusicList
{
MARIMBAD2_MUSIC,
MENUMIX_MUSIC,
NOTHING_A_MUSIC,
NOTHING_B_MUSIC,
NOTHING_C_MUSIC,
NOTHING_D_MUSIC,
TENSOR_A_MUSIC,
TENSOR_B_MUSIC,
TENSOR_C_MUSIC,
TRIUMPH_MUSIC,
DEATH_MUSIC,
BATTLE_A_MUSIC,
BATTLE_B_MUSIC, //same as tensor B
CREEPY_MUSIC,
CREATURE_BATTLE_MUSIC,
MUSIC_DIR,
NUM_MUSIC
};
CHAR8* szMusicList[NUM_MUSIC] =
{
"MUSIC\\marimbad 2",
"MUSIC\\menumix1",
@@ -70,6 +74,110 @@ CHAR8 *szMusicList[NUM_MUSIC]=
"MUSIC",
};
std::vector<STR> MusicLists[MAX_MUSIC];
static void AddMusicToList(STR fileName, NewMusicList mode)
{
UINT8 constexpr buf = 64;
CHAR8 musicFile[buf];
if (SoundFileExists(fileName, musicFile))
{
STR music = (STR)MemAlloc(buf * sizeof(CHAR8));
Assert(music);
memset(music, 0, sizeof(CHAR8) * buf);
strcpy(music, musicFile);
MusicLists[mode].push_back(music);
}
}
void InitializeMusicLists()
{
// Special casing original music so they can be easily replaced with new files
AddMusicToList(szMusicList[MENUMIX_MUSIC], MUSICLIST_MAIN_MENU);
AddMusicToList(szMusicList[MARIMBAD2_MUSIC], MUSICLIST_LAPTOP);
AddMusicToList(szMusicList[NOTHING_A_MUSIC], MUSICLIST_TACTICAL_NOTHING);
AddMusicToList(szMusicList[NOTHING_B_MUSIC], MUSICLIST_TACTICAL_NOTHING);
AddMusicToList(szMusicList[NOTHING_C_MUSIC], MUSICLIST_TACTICAL_NOTHING);
AddMusicToList(szMusicList[NOTHING_D_MUSIC], MUSICLIST_TACTICAL_NOTHING);
AddMusicToList(szMusicList[TENSOR_A_MUSIC], MUSICLIST_TACTICAL_ENEMYPRESENT);
AddMusicToList(szMusicList[TENSOR_B_MUSIC], MUSICLIST_TACTICAL_ENEMYPRESENT);
AddMusicToList(szMusicList[TENSOR_C_MUSIC], MUSICLIST_TACTICAL_ENEMYPRESENT);
AddMusicToList(szMusicList[BATTLE_A_MUSIC], MUSICLIST_TACTICAL_BATTLE);
AddMusicToList(szMusicList[BATTLE_B_MUSIC], MUSICLIST_TACTICAL_BATTLE);
AddMusicToList(szMusicList[TRIUMPH_MUSIC], MUSICLIST_TACTICAL_VICTORY);
AddMusicToList(szMusicList[DEATH_MUSIC], MUSICLIST_TACTICAL_DEATH);
AddMusicToList(szMusicList[CREEPY_MUSIC], MUSICLIST_TACTICAL_CREEPY);
AddMusicToList(szMusicList[CREATURE_BATTLE_MUSIC], MUSICLIST_TACTICAL_CREEPY_BATTLE);
UINT8 constexpr buf = 64;
CHAR8 fileName[buf];
// Read music files into list
for (size_t j = MUSICLIST_MAIN_MENU; j < MAX_MUSIC; j++)
{
STR baseFilename;
switch (j)
{
case MUSICLIST_MAIN_MENU:
baseFilename = "MUSIC\\Mainmenu_";
break;
case MUSICLIST_LAPTOP:
baseFilename = "MUSIC\\Laptop_";
break;
case MUSICLIST_TACTICAL_NOTHING:
baseFilename = "MUSIC\\Tactical_";
break;
case MUSICLIST_TACTICAL_ENEMYPRESENT:
baseFilename = "MUSIC\\Enemy_";
break;
case MUSICLIST_TACTICAL_BATTLE:
baseFilename = "MUSIC\\Battle_";
break;
case MUSICLIST_TACTICAL_VICTORY:
baseFilename = "MUSIC\\Victory_";
break;
case MUSICLIST_TACTICAL_DEATH:
baseFilename = "MUSIC\\Death_";
break;
case MUSICLIST_TACTICAL_CREEPY:
baseFilename = "MUSIC\\Creepy_";
break;
case MUSICLIST_TACTICAL_CREEPY_BATTLE:
baseFilename = "MUSIC\\CreepyBattle_";
break;
default:
break;
}
for (size_t i = 0; i < 100; i++)
{
if (i < 10)
{
sprintf(fileName, "%s00%d", baseFilename, i);
}
else if (i < 100)
{
sprintf(fileName, "%s0%d", baseFilename, i);
}
AddMusicToList(fileName, static_cast<NewMusicList>(j));
}
}
}
static STR PickRandomSongFromList(NewMusicList mode)
{
return MusicLists[mode][Random(MusicLists[mode].size())];
}
BOOLEAN StartMusicBasedOnMode(void);
void DoneFadeOutDueToEndMusic(void);
void MusicStopCallback(void *pData);
@@ -77,37 +185,6 @@ BOOLEAN MusicStop(void);
BOOLEAN MusicFadeOut(void);
BOOLEAN MusicFadeIn(void);
#ifdef NEWMUSIC
MUSIC_SOUND_VALUES MusicSoundValues[256];
INT32 GlobalSoundID = -1;
#endif
//extern void HandleEndDemoInCreatureLevel( );
//BOOLEAN NoEnemiesInSight( )
//{
// SOLDIERTYPE *pSoldier;
// INT32 cnt;
//
// // Loop through our guys
// // End the turn of player charactors
// cnt = gTacticalStatus.Team[ gbPlayerNum ].bFirstID;
//
// // look for all mercs on the same team,
// for ( pSoldier = MercPtrs[ cnt ]; cnt <= gTacticalStatus.Team[ gbPlayerNum ].bLastID; cnt++, pSoldier++ )
// {
// if ( pSoldier->bActive && pSoldier->stats.bLife >= OKLIFE )
// {
// if ( pSoldier->aiData.bOppCnt != 0 )
// {
// return( FALSE );
// }
// }
// }
//
// return( TRUE );
//}
//********************************************************************************
// MusicPlay
@@ -117,65 +194,22 @@ INT32 GlobalSoundID = -1;
// Returns: TRUE if the music was started, FALSE if an error occurred
//
//********************************************************************************
#ifdef NEWMUSIC
BOOLEAN MusicPlay(UINT32 uiNum, UINT32 MusicMode, BOOLEAN NewSound )
#else
BOOLEAN MusicPlay(UINT32 uiNum)
#endif
static BOOLEAN MusicPlay(STR zFileName)
{
// WANNE: We want music in windowed mode
//if( 1==iScreenMode ) /* on Windowed mode, skip the music? was coded for WINDOWED_MODE that way...*/
//return FALSE;
static CHAR8 zFileName[164];
SOUNDPARMS spParms;
if(fMusicPlaying)
if (fMusicPlaying)
MusicStop();
memset(&spParms, 0xff, sizeof(SOUNDPARMS));
spParms.uiPriority = PRIORITY_MAX;
spParms.uiVolume = 0;
spParms.uiLoop = 1; // Lesh: only 1 line added
spParms.uiLoop = 1;
spParms.EOSCallback = MusicStopCallback;
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, "About to call SoundPlayStreamedFile" );
// Lesh: patch to allow playback ogg files
#ifdef NEWMUSIC
if ( NewSound == FALSE && MusicMode == MUSIC_OLD_TYPE )
{
#endif
SoundFileExists( szMusicList[uiNum], zFileName );
#ifdef NEWMUSIC
}
else if ( NewSound == TRUE )
{
CHAR8 modstr[32] = "";
CHAR8 modstr2[164] = "";
switch ( MusicMode )
{
case MUSIC_TACTICAL_NOTHING: sprintf( modstr, "NOTHING_" ); break;
case MUSIC_TACTICAL_ENEMYPRESENT: sprintf( modstr, "TENSOR_" ); break;
case MUSIC_TACTICAL_BATTLE: sprintf( modstr, "BATTLE_" ); break;
case MUSIC_TACTICAL_VICTORY: sprintf( modstr, "TRIUMPH_" ); break;
case MUSIC_TACTICAL_BATTLE_MUSIC: sprintf( modstr, "CREATURE_BATTLE_" ); break;
case MUSIC_TACTICAL_CREEPY_MUSIC: sprintf( modstr, "CREEPY_" ); break;
default: break;
}
sprintf( modstr2, "%s\\%s%d", szMusicList[15], modstr, uiNum );
SoundFileExists( modstr2, zFileName );
}
#endif
uiMusicHandle = SoundPlayStreamedFile(zFileName, &spParms);
if(uiMusicHandle != SOUND_ERROR)
if (uiMusicHandle != SOUND_ERROR)
{
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music PLay %d %d", uiMusicHandle, gubMusicMode ) );
gfMusicEnded = FALSE;
fMusicPlaying = TRUE;
@@ -183,10 +217,19 @@ BOOLEAN MusicPlay(UINT32 uiNum)
return TRUE;
}
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music PLay %d %d", uiMusicHandle, gubMusicMode ) );
return FALSE;
}
BOOLEAN MusicPlay(NewMusicList mode, UINT8 songIndex)
{
if (mode >= MAX_MUSIC || songIndex >= MusicLists[mode].size())
{
return FALSE;
}
MusicPlay(MusicLists[mode][songIndex]);
}
//********************************************************************************
// MusicSetVolume
//
@@ -410,78 +453,11 @@ BOOLEAN MusicPoll(BOOLEAN /*fForce*/)
//DebugMsg (TOPIC_JA2,DBG_LEVEL_3,"MusicPoll done");
return TRUE;
}
#ifdef NEWMUSIC
static BOOLEAN SetMusicModeID(UINT8 ubMusicMode, INT32 SoundID, BOOLEAN fForce)
{
static INT8 bPreviousMode = 0;
static INT32 bPreviousMusic = 0;
// OK, check if we want to restore
if (ubMusicMode == MUSIC_RESTORE)
{
if (bPreviousMode == MUSIC_TACTICAL_VICTORY || bPreviousMode == MUSIC_TACTICAL_DEATH)
{
bPreviousMode = MUSIC_TACTICAL_NOTHING;
}
ubMusicMode = bPreviousMode;
SoundID = bPreviousMusic;
GlobalSoundID = SoundID;
}
else
{
// Save previous mode...
bPreviousMode = gubOldMusicMode;
bPreviousMusic = SoundID;
GlobalSoundID = SoundID;
}
// if different, start a new music song
//if ( ( fForce || gubOldMusicMode != ubMusicMode ) && SoundID != -1)
if ( fForce || SoundID != -1 )
{
// Set mode....
gubMusicMode = ubMusicMode;
NewSoundID = SoundID;
GlobalSoundID = SoundID;
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "Music New Mode %d %d", uiMusicHandle, gubMusicMode ) );
gbVictorySongCount = 0;
gbDeathSongCount = 0;
if(uiMusicHandle != NO_SAMPLE)
{
// Fade out old music
MusicFadeOut();
}
else
{
// Change music!
StartMusicBasedOnMode();
}
}
gubOldMusicMode = gubMusicMode;
gubOldMusicMode2 = SoundID;
return TRUE;
}
#endif
static BOOLEAN SetMusicMode(UINT8 ubMusicMode, BOOLEAN fForce)
{
static INT8 bPreviousMode = 0;
#ifdef NEWMUSIC
SetSoundID = FALSE;
//GlobalSoundID = -1;
if ( SetSoundID == FALSE )
NewSoundID = -1;
#endif
// OK, check if we want to restore
if (ubMusicMode == MUSIC_RESTORE)
{
@@ -489,24 +465,7 @@ static BOOLEAN SetMusicMode(UINT8 ubMusicMode, BOOLEAN fForce)
{
bPreviousMode = MUSIC_TACTICAL_NOTHING;
}
#ifdef NEWMUSIC
if ( GlobalSoundID == -1 )
{
SetSoundID = FALSE;
GlobalSoundID = -1;
NewSoundID = -1;
}
else if ( GlobalSoundID != -1)
{
SetSoundID = TRUE;
NewSoundID = gubOldMusicMode2;
GlobalSoundID = NewSoundID;
}
#endif
ubMusicMode = bPreviousMode;
}
else
{
@@ -515,11 +474,7 @@ static BOOLEAN SetMusicMode(UINT8 ubMusicMode, BOOLEAN fForce)
}
// if different, start a new music song
#ifdef NEWMUSIC
if (fForce || gubOldMusicMode != ubMusicMode || GlobalSoundID == -1 || SetSoundID == TRUE )
#else
if (fForce || gubOldMusicMode != ubMusicMode)
#endif
{
// Set mode....
gubMusicMode = ubMusicMode;
@@ -546,36 +501,19 @@ static BOOLEAN SetMusicMode(UINT8 ubMusicMode, BOOLEAN fForce)
return TRUE;
}
#ifdef NEWMUSIC
static BOOLEAN StartMusicBasedOnMode(void)
{
static BOOLEAN fFirstTime = TRUE;
if (fFirstTime)
{
fFirstTime = FALSE;
bNothingModeSong = (INT8) (NOTHING_A_MUSIC + Random(4));
bEnemyModeSong = (INT8) (TENSOR_A_MUSIC + Random(3));
bBattleModeSong = (INT8) (BATTLE_A_MUSIC + Random(2));
}
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "StartMusicBasedOnMode() %d %d", uiMusicHandle, gubMusicMode ) );
// Setup a song based on mode we're in!
switch(gubMusicMode)
{
case MUSIC_MAIN_MENU:
// ATE: Don't fade in
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay(MENUMIX_MUSIC,MUSIC_OLD_TYPE,FALSE);
MusicPlay(PickRandomSongFromList(MUSICLIST_MAIN_MENU));
break;
case MUSIC_LAPTOP:
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay(MARIMBAD2_MUSIC,MUSIC_OLD_TYPE,FALSE);
MusicPlay(PickRandomSongFromList(MUSICLIST_LAPTOP));
break;
case MUSIC_TACTICAL_NOTHING:
@@ -583,31 +521,11 @@ static BOOLEAN StartMusicBasedOnMode(void)
gbFadeSpeed = (INT8)uiMusicVolume;
if(gfUseCreatureMusic)
{
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(CREEPY_MUSIC,MUSIC_OLD_TYPE,FALSE);
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_CREEPY));
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_CREEPY_MUSIC,TRUE);
}
}
else
{
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(bNothingModeSong,MUSIC_OLD_TYPE,FALSE);
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_NOTHING,TRUE);
}
bNothingModeSong = (INT8) (NOTHING_A_MUSIC + Random(4));
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_NOTHING));
}
break;
@@ -616,30 +534,11 @@ static BOOLEAN StartMusicBasedOnMode(void)
gbFadeSpeed = (INT8)uiMusicVolume;
if(gfUseCreatureMusic)
{
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(CREEPY_MUSIC,MUSIC_OLD_TYPE,FALSE);
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_CREEPY));
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_ENEMYPRESENT,TRUE);
}
}
else
{
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(bEnemyModeSong,MUSIC_OLD_TYPE,FALSE);
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_ENEMYPRESENT,TRUE);
}
bEnemyModeSong = (INT8) (TENSOR_A_MUSIC + Random(3));
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_ENEMYPRESENT));
}
break;
@@ -648,47 +547,19 @@ static BOOLEAN StartMusicBasedOnMode(void)
gbFadeSpeed = (INT8)uiMusicVolume;
if(gfUseCreatureMusic)
{
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(CREATURE_BATTLE_MUSIC,MUSIC_OLD_TYPE,FALSE);
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_CREEPY_BATTLE));
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_BATTLE_MUSIC,TRUE);
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_BATTLE));
}
}
else
{
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(bBattleModeSong,MUSIC_OLD_TYPE,FALSE);
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_BATTLE,TRUE);
}
}
bBattleModeSong = (INT8) (BATTLE_A_MUSIC + Random(2));
break;
case MUSIC_TACTICAL_VICTORY:
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(TRIUMPH_MUSIC,MUSIC_OLD_TYPE,FALSE);
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_VICTORY,TRUE);
}
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_VICTORY));
gbVictorySongCount++;
if(gfUseCreatureMusic && !gbWorldSectorZ)
@@ -702,16 +573,7 @@ static BOOLEAN StartMusicBasedOnMode(void)
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
if ( NewSoundID == -1)
{
SetSoundID = FALSE;
MusicPlay(DEATH_MUSIC,MUSIC_OLD_TYPE,FALSE);
}
else
{
SetSoundID = TRUE;
MusicPlay(NewSoundID,MUSIC_TACTICAL_DEATH,TRUE);
}
MusicPlay(PickRandomSongFromList(MUSICLIST_TACTICAL_DEATH));
gbDeathSongCount++;
break;
@@ -722,121 +584,13 @@ static BOOLEAN StartMusicBasedOnMode(void)
return TRUE;
}
#else
static BOOLEAN StartMusicBasedOnMode(void)
{
static BOOLEAN fFirstTime = TRUE;
if (fFirstTime)
{
fFirstTime = FALSE;
bNothingModeSong = (INT8) (NOTHING_A_MUSIC + Random(4));
bEnemyModeSong = (INT8) (TENSOR_A_MUSIC + Random(3));
bBattleModeSong = (INT8) (BATTLE_A_MUSIC + Random(2));
}
//DebugMsg( TOPIC_JA2, DBG_LEVEL_3, String( "StartMusicBasedOnMode() %d %d", uiMusicHandle, gubMusicMode ) );
// Setup a song based on mode we're in!
switch(gubMusicMode)
{
case MUSIC_MAIN_MENU:
// ATE: Don't fade in
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay(MENUMIX_MUSIC);
break;
case MUSIC_LAPTOP:
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay(MARIMBAD2_MUSIC);
break;
case MUSIC_TACTICAL_NOTHING:
// ATE: Don't fade in
gbFadeSpeed = (INT8)uiMusicVolume;
if(gfUseCreatureMusic)
{
MusicPlay(CREEPY_MUSIC);
}
else
{
MusicPlay(bNothingModeSong);
bNothingModeSong = (INT8) (NOTHING_A_MUSIC + Random(4));
}
break;
case MUSIC_TACTICAL_ENEMYPRESENT:
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
if(gfUseCreatureMusic)
{
MusicPlay(CREEPY_MUSIC);
}
else
{
MusicPlay(bEnemyModeSong);
bEnemyModeSong = (INT8) (TENSOR_A_MUSIC + Random(3));
}
break;
case MUSIC_TACTICAL_BATTLE:
// ATE: Don't fade in
gbFadeSpeed = (INT8)uiMusicVolume;
if(gfUseCreatureMusic)
{
MusicPlay(CREATURE_BATTLE_MUSIC);
}
else
{
MusicPlay(bBattleModeSong);
}
bBattleModeSong = (INT8) (BATTLE_A_MUSIC + Random(2));
break;
case MUSIC_TACTICAL_VICTORY:
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay(TRIUMPH_MUSIC);
gbVictorySongCount++;
if(gfUseCreatureMusic && !gbWorldSectorZ)
{
//We just killed all the creatures that just attacked the town.
gfUseCreatureMusic = FALSE;
}
break;
case MUSIC_TACTICAL_DEATH:
// ATE: Don't fade in EnemyPresent...
gbFadeSpeed = (INT8)uiMusicVolume;
MusicPlay(DEATH_MUSIC);
gbDeathSongCount++;
break;
default:
MusicFadeOut();
break;
}
return TRUE;
}
#endif
BOOLEAN SetMusicMode(UINT8 ubMusicMode)
{
return SetMusicMode(ubMusicMode, FALSE);
}
#ifdef NEWMUSIC
BOOLEAN SetMusicModeID(UINT8 ubMusicMode, INT32 SoundID)
{
return SetMusicModeID(ubMusicMode, SoundID, FALSE);
}
#endif
static void MusicStopCallback(void *pData)
{
+16 -49
View File
@@ -3,27 +3,6 @@
#include "Overhead Types.h"
enum MusicList
{
MARIMBAD2_MUSIC,
MENUMIX_MUSIC,
NOTHING_A_MUSIC,
NOTHING_B_MUSIC,
NOTHING_C_MUSIC,
NOTHING_D_MUSIC,
TENSOR_A_MUSIC,
TENSOR_B_MUSIC,
TENSOR_C_MUSIC,
TRIUMPH_MUSIC,
DEATH_MUSIC,
BATTLE_A_MUSIC,
BATTLE_B_MUSIC, //same as tensor B
CREEPY_MUSIC,
CREATURE_BATTLE_MUSIC,
MUSIC_DIR,
NUM_MUSIC
};
enum MusicMode
{
MUSIC_NONE,
@@ -42,43 +21,31 @@ enum MusicMode
MUSIC_TACTICAL_CIV_GROUP_BATTLE,
};
#ifdef NEWMUSIC
typedef struct
enum NewMusicList
{
UINT16 uiIndex;
INT32 SoundTacticalVictory[4];
INT32 SoundTacticalBattle[4];
INT32 SoundTacticalNothing[4];
INT32 SoundTacticalTensor[4];
INT32 SoundTacticalDeath[4];
INT32 SoundTacticalBattleCreature[4];
INT32 SoundTacticalBattleCreepy[4];
INT32 SoundTacticalBattleGroup[NUM_CIV_GROUPS];
MUSICLIST_MAIN_MENU,
MUSICLIST_LAPTOP,
MUSICLIST_TACTICAL_NOTHING,
MUSICLIST_TACTICAL_ENEMYPRESENT,
MUSICLIST_TACTICAL_BATTLE,
MUSICLIST_TACTICAL_VICTORY,
MUSICLIST_TACTICAL_DEATH,
MUSICLIST_TACTICAL_CREEPY,
MUSICLIST_TACTICAL_CREEPY_BATTLE,
} MUSIC_SOUND_VALUES;
MAX_MUSIC,
};
extern MUSIC_SOUND_VALUES MusicSoundValues[256];
extern INT32 GlobalSoundID;
#endif
extern std::vector<STR> MusicLists[MAX_MUSIC];
//extern UINT32 uiMusicHandle;
//extern BOOLEAN fMusicPlaying;
//extern UINT8 gubMusicMode;
//extern BOOLEAN gfForceMusicToTense;
void InitializeMusicLists();
UINT8 GetMusicMode(void);
BOOLEAN SetMusicMode(UINT8 ubMusicMode);
// only for editor (editscreen.cpp)
#ifdef NEWMUSIC
BOOLEAN MusicPlay(UINT32 uiNum, UINT32 MusicMode, BOOLEAN NewSound);
#else
BOOLEAN MusicPlay(UINT32 uiNum);
#endif
// Used in lua scripting and editscreen.cpp
BOOLEAN MusicPlay(NewMusicList mode, UINT8 songIndex);
#ifdef NEWMUSIC
BOOLEAN SetMusicModeID(UINT8 ubMusicMode, INT32 SoundID);
#endif
UINT32 MusicGetVolume(void);
BOOLEAN MusicSetVolume(UINT32 uiVolume);
+4
View File
@@ -56,6 +56,7 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN
#endif
#include <Music Control.h>
static void MAGIC(std::string const& aarrrrgggh = "")
@@ -574,6 +575,9 @@ BOOLEAN InitializeStandardGamingPlatform(HINSTANCE hInstance, int sCommandShow)
return FALSE;
}
FastDebugMsg("Initializing Music");
InitializeMusicLists();
FastDebugMsg("Initializing Game Manager");
// Initialize the Game
if (InitializeGame() == FALSE)