aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2006-03-12 14:22:27 +0000
committerJohannes Schickel2006-03-12 14:22:27 +0000
commitcd28f28d3248d1186a797fcb77a512efaaf31ad3 (patch)
tree767fab920dc413ee1e5a59c4f02e273d95a34b34
parentc8347b23b1552328bf1c986e2c394acb81242738 (diff)
downloadscummvm-rg350-cd28f28d3248d1186a797fcb77a512efaaf31ad3.tar.gz
scummvm-rg350-cd28f28d3248d1186a797fcb77a512efaaf31ad3.tar.bz2
scummvm-rg350-cd28f28d3248d1186a797fcb77a512efaaf31ad3.zip
Music in the last two intro scenes plays now again with adlib.
Cleaned up the sound code a bit (removed some unneeded functions). svn-id: r21234
-rw-r--r--engines/kyra/kyra.cpp2
-rw-r--r--engines/kyra/kyra.h2
-rw-r--r--engines/kyra/seqplayer.cpp5
-rw-r--r--engines/kyra/sequences_v1.cpp5
-rw-r--r--engines/kyra/sound.cpp34
-rw-r--r--engines/kyra/sound.h52
-rw-r--r--engines/kyra/sound_adlib.cpp31
7 files changed, 38 insertions, 93 deletions
diff --git a/engines/kyra/kyra.cpp b/engines/kyra/kyra.cpp
index 9d1c880b7d..74505b4adf 100644
--- a/engines/kyra/kyra.cpp
+++ b/engines/kyra/kyra.cpp
@@ -646,8 +646,6 @@ void KyraEngine::startup() {
error("Could not load \"_NPC.EMC\" script");
}
- snd_playTheme(1);
- snd_setSoundEffectFile(1);
enterNewScene(_currentCharacter->sceneId, _currentCharacter->facing, 0, 0, 1);
if (_abortIntroFlag && _skipFlag) {
diff --git a/engines/kyra/kyra.h b/engines/kyra/kyra.h
index b90c58dda9..d89dbc8c97 100644
--- a/engines/kyra/kyra.h
+++ b/engines/kyra/kyra.h
@@ -587,8 +587,6 @@ protected:
void seq_playCredits();
void updateKyragemFading();
- void snd_setSoundEffectFile(int file);
-
static OpcodeProc _opcodeTable[];
static const int _opcodeTableSize;
diff --git a/engines/kyra/seqplayer.cpp b/engines/kyra/seqplayer.cpp
index 0075ec314f..51fa53a518 100644
--- a/engines/kyra/seqplayer.cpp
+++ b/engines/kyra/seqplayer.cpp
@@ -404,11 +404,10 @@ void SeqPlayer::s1_playTrack() {
break;
}
} else {*/
- if (msg == 0) {
- // nothing to do here...
- } else if (msg == 1) {
+ if (msg == 1) {
_sound->beginFadeOut();
} else {
+ _sound->haltTrack();
_sound->playTrack(msg);
}
// }
diff --git a/engines/kyra/sequences_v1.cpp b/engines/kyra/sequences_v1.cpp
index 72841d1aa3..ac86e46e94 100644
--- a/engines/kyra/sequences_v1.cpp
+++ b/engines/kyra/sequences_v1.cpp
@@ -82,7 +82,7 @@ void KyraEngine::seq_demo() {
_screen->fadeFromBlack();
delay(60 * _tickLength);
_screen->fadeToBlack();
- _sound->stopMusic();
+ _sound->haltTrack();
}
void KyraEngine::seq_intro() {
@@ -110,7 +110,6 @@ void KyraEngine::seq_intro() {
_seq->setCopyViewOffs(true);
_screen->setFont(Screen::FID_8_FNT);
snd_playTheme(MUSIC_INTRO, 2);
- snd_setSoundEffectFile(MUSIC_INTRO);
_text->setTalkCoords(144);
for (int i = 0; i < ARRAYSIZE(introProcTable) && !seq_skipSequence(); ++i) {
(this->*introProcTable[i])();
@@ -118,7 +117,7 @@ void KyraEngine::seq_intro() {
_text->setTalkCoords(136);
delay(30 * _tickLength);
_seq->setCopyViewOffs(false);
- _sound->stopMusic();
+ _sound->haltTrack();
if (_features & GF_TALKIE) {
_res->unloadPakFile("INTRO.VRM");
}
diff --git a/engines/kyra/sound.cpp b/engines/kyra/sound.cpp
index b1f685231d..9e0434da8f 100644
--- a/engines/kyra/sound.cpp
+++ b/engines/kyra/sound.cpp
@@ -92,7 +92,7 @@ SoundMidiPC::SoundMidiPC(MidiDriver *driver, Audio::Mixer *mixer, KyraEngine *en
_eventFromMusic = false;
_fadeMusicOut = _sfxIsPlaying = false;
_fadeStartTime = 0;
- _isPlaying = _isLooping = _nativeMT32 = false;
+ _isPlaying = _nativeMT32 = false;
_soundEffect = _parser = 0;
_soundEffectSource = _parserSource = 0;
@@ -203,9 +203,6 @@ void SoundMidiPC::metaEvent(byte type, byte *data, uint16 length) {
switch (type) {
case 0x2F: // End of Track
if (_eventFromMusic) {
- if (!_isLooping) {
- _isPlaying = false;
- }
// remap all channels
for (int i = 0; i < 16; ++i) {
_virChannel[i] = i;
@@ -220,7 +217,7 @@ void SoundMidiPC::metaEvent(byte type, byte *data, uint16 length) {
}
}
-void SoundMidiPC::playMusic(const char *file) {
+void SoundMidiPC::loadMusicFile(const char *file) {
char filename[25];
sprintf(filename, "%s.XMI", file);
@@ -233,6 +230,7 @@ void SoundMidiPC::playMusic(const char *file) {
}
playMusic(data, size);
+ loadSoundEffectFile(file);
}
void SoundMidiPC::playMusic(uint8 *data, uint32 size) {
@@ -291,7 +289,6 @@ void SoundMidiPC::loadSoundEffectFile(uint8 *data, uint32 size) {
}
void SoundMidiPC::stopMusic() {
- _isLooping = false;
_isPlaying = false;
if (_parser) {
_parser->unloadMusic();
@@ -330,7 +327,6 @@ void SoundMidiPC::onTimer(void *refCon) {
music->setVolume(255);
music->_fadeStartTime = 0;
music->_fadeMusicOut = false;
- music->_isLooping = false;
music->_isPlaying = false;
music->_eventFromMusic = true;
@@ -360,14 +356,12 @@ void SoundMidiPC::onTimer(void *refCon) {
}
}
-void SoundMidiPC::playTrack(uint8 track, bool loop) {
+void SoundMidiPC::playTrack(uint8 track) {
if (_parser) {
_isPlaying = true;
- _isLooping = loop;
_parser->setTrack(track);
_parser->jumpToTick(0);
_parser->setTempo(1);
- _parser->property(MidiParser::mpAutoLoop, loop);
}
}
@@ -392,14 +386,8 @@ void KyraEngine::snd_playTheme(int file, int track) {
debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_playTheme(%d)", file);
assert(file < _musicFilesCount);
_curMusicTheme = _newMusicTheme = file;
- _sound->playMusic(_musicFiles[file]);
- _sound->playTrack(track, false);
-}
-
-void KyraEngine::snd_setSoundEffectFile(int file) {
- debugC(9, kDebugLevelMain | kDebugLevelSound, "KyraEngine::snd_setSoundEffectFile(%d)", file);
- assert(file < _musicFilesCount);
- _sound->loadSoundEffectFile(_musicFiles[file]);
+ _sound->loadMusicFile(_musicFiles[file]);
+ _sound->playTrack(track);
}
void KyraEngine::snd_playSoundEffect(int track) {
@@ -416,18 +404,18 @@ void KyraEngine::snd_playWanderScoreViaMap(int command, int restart) {
static const int8 soundTable[] = {
-1, 0, -1, 1, 0, 3, 0, 2,
0, 4, 1, 2, 1, 3, 1, 4,
- 1, 0x5C, 1, 6, 1, 7, 2, 2,
+ 1, 92, 1, 6, 1, 7, 2, 2,
2, 3, 2, 4, 2, 5, 2, 6,
2, 7, 3, 3, 3, 4, 1, 8,
1, 9, 4, 2, 4, 3, 4, 4,
4, 5, 4, 6, 4, 7, 4, 8,
- 1, 0x0B, 1, 0x0C, 1, 0x0E, 1, 0x0D,
- 4, 9, 5, 0x0C, 6, 2, 6, 6,
+ 1, 11, 1, 12, 1, 14, 1, 13,
+ 4, 9, 5, 12, 6, 2, 6, 6,
6, 7, 6, 8, 6, 9, 6, 3,
6, 4, 6, 5, 7, 2, 7, 3,
7, 4, 7, 5, 7, 6, 7, 7,
7, 8, 7, 9, 8, 2, 8, 3,
- 8, 4, 8, 5, 6, 0x0B, 5, 0x0B
+ 8, 4, 8, 5, 6, 11, 5, 11
};
//if (!_disableSound) {
// XXX
@@ -446,7 +434,7 @@ void KyraEngine::snd_playWanderScoreViaMap(int command, int restart) {
if (_lastMusicCommand != command) {
_lastMusicCommand = command;
_sound->haltTrack();
- _sound->playTrack(soundTable[command*2+1], true);
+ _sound->playTrack(soundTable[command*2+1]);
}
} else {
_lastMusicCommand = 1;
diff --git a/engines/kyra/sound.h b/engines/kyra/sound.h
index 2baccc0d9a..1d90d24335 100644
--- a/engines/kyra/sound.h
+++ b/engines/kyra/sound.h
@@ -49,20 +49,14 @@ public:
virtual void setVolume(int volume) = 0;
virtual int getVolume() = 0;
- virtual void playMusic(const char *file) = 0;
- virtual void stopMusic() = 0;
+ virtual void loadMusicFile(const char *file) = 0;
- virtual void playTrack(uint8 track, bool looping = true) = 0;
+ virtual void playTrack(uint8 track) = 0;
virtual void haltTrack() = 0;
- virtual void startTrack() = 0;
-
- virtual void loadSoundEffectFile(const char *file) = 0;
- virtual void stopSoundEffect() = 0;
virtual void playSoundEffect(uint8 track) = 0;
virtual void beginFadeOut() = 0;
- virtual bool fadeOut() = 0;
void voicePlay(const char *file);
void voiceUnload() {}
@@ -97,20 +91,14 @@ public:
void setVolume(int volume);
int getVolume();
- void playMusic(const char *file);
- void stopMusic();
+ void loadMusicFile(const char *file);
- void playTrack(uint8 track, bool looping);
+ void playTrack(uint8 track);
void haltTrack();
- void startTrack();
-
- void loadSoundEffectFile(const char *file);
- void stopSoundEffect();
void playSoundEffect(uint8 track);
void beginFadeOut();
- bool fadeOut();
private:
void loadSoundFile(const char *file);
@@ -139,26 +127,14 @@ public:
void setVolume(int volume);
int getVolume() { return _volume; }
- void hasNativeMT32(bool nativeMT32) { _nativeMT32 = nativeMT32; }
- bool isMT32() { return _nativeMT32; }
-
- void playMusic(const char *file);
- void playMusic(uint8 *data, uint32 size);
- void stopMusic();
-
- void playTrack(uint8 track, bool looping);
+ void loadMusicFile(const char *file);
+
+ void playTrack(uint8 track);
void haltTrack() { _isPlaying = false; }
- void startTrack() { _isPlaying = true; }
- void setPassThrough(bool b) { _passThrough = b; }
-
- void loadSoundEffectFile(const char *file);
- void loadSoundEffectFile(uint8 *data, uint32 size);
- void stopSoundEffect();
-
+
void playSoundEffect(uint8 track);
void beginFadeOut();
- bool fadeOut() { return _fadeMusicOut; }
//MidiDriver interface implementation
int open();
@@ -172,8 +148,19 @@ public:
//Channel allocation functions
MidiChannel *allocateChannel() { return 0; }
MidiChannel *getPercussionChannel() { return 0; }
+
+ void setPassThrough(bool b) { _passThrough = b; }
+
+ void hasNativeMT32(bool nativeMT32) { _nativeMT32 = nativeMT32; }
+ bool isMT32() { return _nativeMT32; }
private:
+ void playMusic(uint8 *data, uint32 size);
+ void stopMusic();
+ void loadSoundEffectFile(const char *file);
+ void loadSoundEffectFile(uint8 *data, uint32 size);
+
+ void stopSoundEffect();
static void onTimer(void *data);
@@ -188,7 +175,6 @@ private:
bool _sfxIsPlaying;
uint32 _fadeStartTime;
bool _fadeMusicOut;
- bool _isLooping;
bool _eventFromMusic;
MidiParser *_parser;
byte *_parserSource;
diff --git a/engines/kyra/sound_adlib.cpp b/engines/kyra/sound_adlib.cpp
index 6dcedc4b8a..0c8f53957b 100644
--- a/engines/kyra/sound_adlib.cpp
+++ b/engines/kyra/sound_adlib.cpp
@@ -31,11 +31,6 @@
#include "sound/fmopl.h"
#include "sound/audiostream.h"
-// TODO:
-// - check how the sounds are stopped (doesn't work atm whyever)
-// - implement music pausing + stop and fadeing
-// - check why the sfx sounds strange sometimes
-
// Basic Adlib Programming:
// http://www.gamedev.net/reference/articles/article446.asp
@@ -175,7 +170,7 @@ private:
void primaryEffect1(OutputState &state);
void primaryEffect2(OutputState &state);
- void secondaryEffect1(OutputState& state);
+ void secondaryEffect1(OutputState &state);
void resetAdlibState();
void writeOPL(byte reg, byte val);
@@ -2187,32 +2182,18 @@ int SoundAdlibPC::getVolume() {
return 0;
}
-void SoundAdlibPC::playMusic(const char *file) {
+void SoundAdlibPC::loadMusicFile(const char *file) {
loadSoundFile(file);
}
-void SoundAdlibPC::stopMusic() {
- //playSoundEffect(0);
-}
-
-void SoundAdlibPC::playTrack(uint8 track, bool looping) {
+void SoundAdlibPC::playTrack(uint8 track) {
playSoundEffect(track);
}
void SoundAdlibPC::haltTrack() {
unk1();
unk2();
- _engine->_system->delayMillis(3 * 60);
-}
-
-void SoundAdlibPC::startTrack() {
-}
-
-void SoundAdlibPC::loadSoundEffectFile(const char *file) {
- loadSoundFile(file);
-}
-
-void SoundAdlibPC::stopSoundEffect() {
+ //_engine->_system->delayMillis(3 * 60);
}
void SoundAdlibPC::playSoundEffect(uint8 track) {
@@ -2251,10 +2232,6 @@ void SoundAdlibPC::beginFadeOut() {
playSoundEffect(1);
}
-bool SoundAdlibPC::fadeOut() {
- return false;
-}
-
void SoundAdlibPC::loadSoundFile(const char *file) {
if (_soundFileLoaded == file)
return;