Skip to content

Commit

Permalink
XEEN: Fix setting up music, musPlayInstrument command
Browse files Browse the repository at this point in the history
  • Loading branch information
dreammaster committed Sep 16, 2016
1 parent b873188 commit c72d421
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 24 deletions.
9 changes: 4 additions & 5 deletions engines/xeen/music.cpp
Expand Up @@ -179,7 +179,7 @@ void MusicDriver::playFX(uint effectId, const byte *data) {
}

void MusicDriver::playSong(const byte *data) {
_musDataPtr = data;
_musDataPtr = _musStartPtr = data;
_musSubroutines.clear();
_musCountdownTimer = 0;
_field1E = true;
Expand Down Expand Up @@ -473,8 +473,9 @@ bool AdlibMusicDriver::musInjectMidi(const byte *&srcP, byte param) {
}

bool AdlibMusicDriver::musPlayInstrument(const byte *&srcP, byte param) {
byte instrument = *srcP++;
if (param < 7)
playInstrument(param, _musInstrumentPtrs[param]);
playInstrument(param, _musInstrumentPtrs[instrument]);

return false;
}
Expand Down Expand Up @@ -576,9 +577,7 @@ const uint AdlibMusicDriver::WAVEFORMS[24] = {

/*------------------------------------------------------------------------*/

Music::Music(Audio::Mixer *mixer) : _mixer(mixer), _musicDriver(nullptr),
_songData(nullptr) {
_mixer = mixer;
Music::Music() : _musicDriver(nullptr), _songData(nullptr) {
_musicDriver = new AdlibMusicDriver();
loadEffectsData();
}
Expand Down
11 changes: 8 additions & 3 deletions engines/xeen/music.h
Expand Up @@ -308,11 +308,9 @@ class Music {
* Updates any playing music
*/
void update();

protected:
Audio::Mixer *_mixer;
public:
Music(Audio::Mixer *mixer);
Music();
~Music();

/**
Expand Down Expand Up @@ -344,6 +342,13 @@ class Music {
* Plays a song
*/
void playSong(const Common::String &name);

/**
* Plays a song
*/
void playSong(const byte *data) {
_musicDriver->playSong(data);
}
};

} // End of namespace Xeen
Expand Down
7 changes: 1 addition & 6 deletions engines/xeen/sound.cpp
Expand Up @@ -47,8 +47,7 @@ void Voc::stop() {

/*------------------------------------------------------------------------*/

Sound::Sound(XeenEngine *vm, Audio::Mixer *mixer): Music(mixer) {

Sound::Sound(XeenEngine *vm, Audio::Mixer *mixer): Music(), _mixer(mixer) {
}

void Sound::proc2(Common::SeekableReadStream &f) {
Expand All @@ -69,10 +68,6 @@ void Sound::playSound(Common::SeekableReadStream *s, Audio::SoundHandle &soundHa
_mixer->playStream(soundType, &soundHandle, stream);
}

void Sound::playMusic(Common::SeekableReadStream *s, Audio::SoundHandle &soundHandle) {
// TODO
}

void Sound::stopSound(Audio::SoundHandle &soundHandle) {
_mixer->stopHandle(soundHandle);
}
Expand Down
11 changes: 2 additions & 9 deletions engines/xeen/sound.h
Expand Up @@ -56,6 +56,8 @@ class Voc: public Common::File {
};

class Sound : public Music {
private:
Audio::Mixer *_mixer;
public:
Sound(XeenEngine *vm, Audio::Mixer *mixer);

Expand All @@ -67,19 +69,12 @@ class Sound : public Music {

void stopMusic(int id);

void playSong(Common::SeekableReadStream &f) {}

/**
* Play a given sound
*/
void playSound(Common::SeekableReadStream *s, Audio::SoundHandle &soundHandle,
Audio::Mixer::SoundType soundType = Audio::Mixer::kSFXSoundType);

/**
* Play a given music
*/
void playMusic(Common::SeekableReadStream *s, Audio::SoundHandle &soundHandle);

/**
* Stop playing a sound
*/
Expand All @@ -88,8 +83,6 @@ class Sound : public Music {
void playSample(const Common::SeekableReadStream *stream, int v2 = 1) {}

bool playSample(int v1, int v2) { return false; }

void playFX(int id) {}
};

} // End of namespace Xeen
Expand Down
16 changes: 15 additions & 1 deletion engines/xeen/worldofxeen/darkside_cutscenes.cpp
Expand Up @@ -55,6 +55,19 @@ bool DarkSideCutscenes::showDarkSideTitle() {
screen.draw();
screen.fadeIn(4);

// **DEBUG**: Testing music
File f("bigtheme.m", *_vm->_files->_sideArchives[1]);
byte *data = new byte[f.size()];
f.read(data, f.size());
f.close();

sound.playSong(data);

events.updateGameCounter();
events.wait(1000, true);

delete[] data;
/*
// Initial loop for dragon roaring
int nwcIndex = 0, nwcFrame = 0;
for (int idx = 0; idx < 55 && !_vm->shouldQuit(); ++idx) {
Expand Down Expand Up @@ -128,9 +141,10 @@ bool DarkSideCutscenes::showDarkSideTitle() {
screen.fadeOut(8);
screen.draw();
screen.fadeIn(4);

events.updateGameCounter();
events.wait(60, true);
*/
return true;
}

Expand Down

0 comments on commit c72d421

Please sign in to comment.