- music code.

This commit is contained in:
Christoph Oelckers 2020-10-18 00:36:21 +02:00
parent a4ce1688d5
commit 7f7a576961
5 changed files with 93 additions and 10 deletions

View file

@ -40,6 +40,7 @@ set( PCH_SOURCES
src/whtag.cpp
src/wh.cpp
src/main.cpp
src/music.cpp
)
add_game_library2( whaven )

View file

@ -228,6 +228,7 @@ void GameInterface::app_init()
}
FadeInit();
setupmidi();
//sndInit();
//initpaletteshifts();
InitOriginalEpisodes();
@ -243,8 +244,6 @@ void GameInterface::Startup()
*/
}
::GameInterface* CreateInterface()
{
return new GameInterface;

View 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

View file

@ -447,13 +447,11 @@ inline void SND_StopLoop(int)
inline void SND_CheckLoops()
{}
void startmusic(int);
void startsong(int);
void setupmidi();
extern int attacktheme;
inline void startsong(int)
{
}
inline void startmusic(int)
{
}

View file

@ -662,13 +662,13 @@ 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"
flags GAMEFLAG_WITCHAVEN2
crc 0x2F673425
size 3051520
defname "witchaven2.def"
loadgrp "SONGS"
loadgrp "F_SONGS", "W_SONGS"
gamefilter "Witchaven.Witchaven2"
}