Skip to content

Commit

Permalink
JADE: Play main menu music from XACT SoundBank
Browse files Browse the repository at this point in the history
  • Loading branch information
DrMcCoy committed Dec 28, 2018
1 parent 1013b19 commit 186c080
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 15 deletions.
19 changes: 6 additions & 13 deletions src/engines/jade/game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,14 @@
#include <cassert>

#include "src/aurora/resman.h"
#include "src/aurora/2dafile.h"
#include "src/aurora/2dareg.h"

#include "src/events/events.h"

#include "src/sound/sound.h"
#include "src/sound/audiostream.h"
#include "src/sound/xactwavebank.h"
#include "src/sound/xactsoundbank.h"

#include "src/engines/aurora/util.h"

Expand Down Expand Up @@ -66,7 +68,7 @@ Module &Game::getModule() {

void Game::run() {
try {
_musicBank.reset(Sound::XACTWaveBank::load("musicbank"));
_musicBank.reset(Sound::XACTSoundBank::load("musicbank"));
} catch (...) {
Common::exceptionDispatcherWarning();
}
Expand Down Expand Up @@ -114,19 +116,10 @@ void Game::playMenuMusic() {
stopMenuMusic();

if (_musicBank) {
/* TODO: music.2da contains an entry for "mus_thm_MAINTHEME1", but this
* gives us a state number. We will probably need to throw that state
* number at the XACT SoundBank (xsb) somehow.
*
* Until that works, we'll get the main menu music by its index in the
* XACT WaveBank (xwb) instead.
*/
static const size_t mainMenuMusic = 46;

try {
Sound::AudioStream *stream = Sound::makeLoopingAudioStream(_musicBank->getWave(mainMenuMusic), 0);
const size_t mainTheme = TwoDAReg.get2DA("music").getRow("label", "mus_thm_MAINTHEME1").getInt("state");

_menuMusic = SoundMan.playAudioStream(stream, Sound::kSoundTypeMusic);
_menuMusic = _musicBank->playCue(0, mainTheme, Sound::kSoundTypeMusic);
SoundMan.startChannel(_menuMusic);

} catch (...) {
Expand Down
4 changes: 2 additions & 2 deletions src/engines/jade/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include "src/aurora/nwscript/variablecontainer.h"

namespace Sound {
class XACTWaveBank;
class XACTSoundBank;
}

namespace Engines {
Expand Down Expand Up @@ -74,7 +74,7 @@ class Game : public Aurora::NWScript::VariableContainer {

::Engines::Console *_console;

Common::ScopedPtr<Sound::XACTWaveBank> _musicBank;
Common::ScopedPtr<Sound::XACTSoundBank> _musicBank;
Sound::ChannelHandle _menuMusic;

void playMenuMusic();
Expand Down

0 comments on commit 186c080

Please sign in to comment.