mirror of
https://github.com/ZDoom/Raze.git
synced 2025-02-27 13:50:49 +00:00
- music code.
This commit is contained in:
parent
a4ce1688d5
commit
7f7a576961
5 changed files with 93 additions and 10 deletions
|
@ -40,6 +40,7 @@ set( PCH_SOURCES
|
||||||
src/whtag.cpp
|
src/whtag.cpp
|
||||||
src/wh.cpp
|
src/wh.cpp
|
||||||
src/main.cpp
|
src/main.cpp
|
||||||
|
src/music.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
add_game_library2( whaven )
|
add_game_library2( whaven )
|
||||||
|
|
|
@ -228,6 +228,7 @@ void GameInterface::app_init()
|
||||||
}
|
}
|
||||||
|
|
||||||
FadeInit();
|
FadeInit();
|
||||||
|
setupmidi();
|
||||||
//sndInit();
|
//sndInit();
|
||||||
//initpaletteshifts();
|
//initpaletteshifts();
|
||||||
InitOriginalEpisodes();
|
InitOriginalEpisodes();
|
||||||
|
@ -243,8 +244,6 @@ void GameInterface::Startup()
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
::GameInterface* CreateInterface()
|
::GameInterface* CreateInterface()
|
||||||
{
|
{
|
||||||
return new GameInterface;
|
return new GameInterface;
|
||||||
|
|
85
source/games/whaven/src/music.cpp
Normal file
85
source/games/whaven/src/music.cpp
Normal file
|
@ -0,0 +1,85 @@
|
||||||
|
#include "ns.h"
|
||||||
|
#include "wh.h"
|
||||||
|
#include "raze_music.h"
|
||||||
|
#include "mapinfo.h"
|
||||||
|
|
||||||
|
BEGIN_WH_NS
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
NUMLEVELS = 17,
|
||||||
|
SONGSPERLEVEL = 4,
|
||||||
|
|
||||||
|
BASE_SONG = 0,
|
||||||
|
songelements = 3,
|
||||||
|
totallevels = 6,
|
||||||
|
arrangements = 3,
|
||||||
|
|
||||||
|
};
|
||||||
|
static int songsperlevel;
|
||||||
|
static int oldsong;
|
||||||
|
|
||||||
|
static bool playthesong(int which, bool looped)
|
||||||
|
{
|
||||||
|
char buffer[40];
|
||||||
|
mysnprintf(buffer, 40, "%s/%04", isWh2()? "F_SONGS" : "SONGS", which);
|
||||||
|
return Mus_Play(currentLevel->labelName, buffer, looped);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool loadlevelsongs(int which)
|
||||||
|
{
|
||||||
|
oldsong = which;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void startsong(int which) // 0, 1, 2 or 3
|
||||||
|
{
|
||||||
|
int index = (oldsong * SONGSPERLEVEL) + which;
|
||||||
|
bool result = playthesong(index, !attacktheme);
|
||||||
|
if (result && which < 2) attacktheme = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
void startmusic(int level)
|
||||||
|
{
|
||||||
|
if (!isWh2())
|
||||||
|
{
|
||||||
|
level %= 6;
|
||||||
|
int index = (songsperlevel * level) + (songelements * 2) + BASE_SONG;
|
||||||
|
playthesong(index, true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (level < 0 || level > NUMLEVELS - 1)
|
||||||
|
level = 0;
|
||||||
|
|
||||||
|
loadlevelsongs(level);
|
||||||
|
startsong(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void SND_MenuMusic()
|
||||||
|
{
|
||||||
|
if (isWh2())
|
||||||
|
{
|
||||||
|
startmusic(NUMLEVELS - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int which = (totallevels * songsperlevel) + BASE_SONG + 2;
|
||||||
|
playthesong(which, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void setupmidi()
|
||||||
|
{
|
||||||
|
if (isWh2())
|
||||||
|
songsperlevel = 4;
|
||||||
|
else
|
||||||
|
songsperlevel = songelements * arrangements;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
END_WH_NS
|
|
@ -447,13 +447,11 @@ inline void SND_StopLoop(int)
|
||||||
inline void SND_CheckLoops()
|
inline void SND_CheckLoops()
|
||||||
{}
|
{}
|
||||||
|
|
||||||
|
void startmusic(int);
|
||||||
|
void startsong(int);
|
||||||
|
void setupmidi();
|
||||||
|
|
||||||
extern int attacktheme;
|
extern int attacktheme;
|
||||||
inline void startsong(int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
inline void startmusic(int)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -662,13 +662,13 @@ grpinfo
|
||||||
|
|
||||||
grpinfo
|
grpinfo
|
||||||
{
|
{
|
||||||
// The file identification info here is for joesnd which is one of two containers in the game data.
|
// The file identification info here is for joesnd which is one of three containers in the game data.
|
||||||
name "Witchaven 2"
|
name "Witchaven 2"
|
||||||
flags GAMEFLAG_WITCHAVEN2
|
flags GAMEFLAG_WITCHAVEN2
|
||||||
crc 0x2F673425
|
crc 0x2F673425
|
||||||
size 3051520
|
size 3051520
|
||||||
defname "witchaven2.def"
|
defname "witchaven2.def"
|
||||||
loadgrp "SONGS"
|
loadgrp "F_SONGS", "W_SONGS"
|
||||||
gamefilter "Witchaven.Witchaven2"
|
gamefilter "Witchaven.Witchaven2"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue