mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-14 16:07:39 +00:00
SCI/newmusic: added filter support for kq4early and adlib
svn-id: r46563
This commit is contained in:
parent
f9754ca68b
commit
2f5f625b98
@ -291,13 +291,13 @@ static void _free_graphics_input(EngineState *s) {
|
||||
}
|
||||
#endif
|
||||
|
||||
int game_init_sound(EngineState *s, int sound_flags) {
|
||||
int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion) {
|
||||
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
||||
if (getSciVersion() > SCI_VERSION_0_LATE)
|
||||
sound_flags |= SFX_STATE_FLAG_MULTIPLAY;
|
||||
|
||||
s->sfx_init_flags = sound_flags;
|
||||
s->_sound.sfx_init(s->resMan, sound_flags);
|
||||
s->_sound.sfx_init(s->resMan, sound_flags, soundVersion);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
@ -421,7 +421,7 @@ int game_init(EngineState *s) {
|
||||
|
||||
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
||||
if (s->sfx_init_flags & SFX_STATE_FLAG_NOSOUND)
|
||||
game_init_sound(s, 0);
|
||||
game_init_sound(s, 0, s->detectDoSoundType());
|
||||
#endif
|
||||
|
||||
// Load game language into printLang property of game object
|
||||
@ -437,7 +437,7 @@ int game_exit(EngineState *s) {
|
||||
if (!s->successor) {
|
||||
s->_sound.sfx_exit();
|
||||
// Reinit because some other code depends on having a valid state
|
||||
game_init_sound(s, SFX_STATE_FLAG_NOSOUND);
|
||||
game_init_sound(s, SFX_STATE_FLAG_NOSOUND, s->detectDoSoundType());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -903,7 +903,7 @@ EngineState *gamestate_restore(EngineState *s, Common::SeekableReadStream *fh) {
|
||||
|
||||
#ifdef USE_OLD_MUSIC_FUNCTIONS
|
||||
temp = retval->_sound._songlib;
|
||||
retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags);
|
||||
retval->_sound.sfx_init(retval->resMan, s->sfx_init_flags, s->detectDoSoundType());
|
||||
retval->sfx_init_flags = s->sfx_init_flags;
|
||||
retval->_sound._songlib.freeSounds();
|
||||
retval->_sound._songlib = temp;
|
||||
|
@ -492,9 +492,10 @@ int game_init_graphics(EngineState *s);
|
||||
* the sound data.
|
||||
* @param[in] s The state to initialize the sound in
|
||||
* @param[in] sound_flags Flags to pass to the sound subsystem
|
||||
* @param[in] soundVersion sound-version that got detected during game init
|
||||
* @return 0 on success, 1 if an error occured
|
||||
*/
|
||||
int game_init_sound(EngineState *s, int sound_flags);
|
||||
int game_init_sound(EngineState *s, int sound_flags, SciVersion soundVersion);
|
||||
|
||||
/**
|
||||
* Runs an SCI game
|
||||
|
@ -1942,7 +1942,15 @@ int SoundResource::getChannelFilterMask(int hardwareMask) {
|
||||
|
||||
switch (_soundVersion) {
|
||||
case SCI_VERSION_0_EARLY:
|
||||
channelMask = 0xFFFF;
|
||||
data++; // Skip over digital sample flag
|
||||
for (int channelNr = 0; channelNr < 16; channelNr++) {
|
||||
channelMask = channelMask >> 1;
|
||||
if (*data & hardwareMask) {
|
||||
// this Channel is supposed to get played for hardware
|
||||
channelMask |= 0x8000;
|
||||
}
|
||||
data++;
|
||||
}
|
||||
break;
|
||||
|
||||
case SCI_VERSION_0_LATE:
|
||||
|
@ -180,7 +180,9 @@ Common::Error SciEngine::run() {
|
||||
// since we cannot let the game control where saves are stored)
|
||||
strcpy(_gamestate->sys_strings->_strings[SYS_STRING_SAVEDIR]._value, "");
|
||||
|
||||
_gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _audio, _gamestate->detectDoSoundType());
|
||||
SciVersion soundVersion = _gamestate->detectDoSoundType();
|
||||
|
||||
_gamestate->_soundCmd = new SoundCommandParser(_resMan, segMan, _audio, soundVersion);
|
||||
|
||||
GfxState gfx_state;
|
||||
_gamestate->gfx_state = &gfx_state;
|
||||
@ -198,7 +200,7 @@ Common::Error SciEngine::run() {
|
||||
}
|
||||
#endif
|
||||
|
||||
if (game_init_sound(_gamestate, 0)) {
|
||||
if (game_init_sound(_gamestate, 0, soundVersion)) {
|
||||
warning("Game initialization failed: Error in sound subsystem. Aborting...");
|
||||
return Common::kUnknownError;
|
||||
}
|
||||
|
@ -59,6 +59,7 @@ public:
|
||||
int _polyphony;
|
||||
|
||||
protected:
|
||||
SciVersion _soundVersion;
|
||||
MidiPlayer *_mididrv;
|
||||
|
||||
SongIterator *_iterator;
|
||||
@ -77,7 +78,7 @@ protected:
|
||||
static void player_timer_callback(void *refCon);
|
||||
|
||||
public:
|
||||
SfxPlayer();
|
||||
SfxPlayer(SciVersion soundVersion);
|
||||
~SfxPlayer();
|
||||
|
||||
/**
|
||||
@ -138,7 +139,8 @@ public:
|
||||
int getVolume();
|
||||
};
|
||||
|
||||
SfxPlayer::SfxPlayer() {
|
||||
SfxPlayer::SfxPlayer(SciVersion soundVersion)
|
||||
: _soundVersion(soundVersion) {
|
||||
_polyphony = 0;
|
||||
|
||||
_mididrv = 0;
|
||||
@ -261,7 +263,7 @@ Common::Error SfxPlayer::init(ResourceManager *resMan, int expected_latency) {
|
||||
|
||||
Common::Error SfxPlayer::add_iterator(SongIterator *it, uint32 start_time) {
|
||||
Common::StackLock lock(_mutex);
|
||||
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(_mididrv->getPlayMask()));
|
||||
SIMSG_SEND(it, SIMSG_SET_PLAYMASK(_mididrv->getPlayMask(_soundVersion)));
|
||||
SIMSG_SEND(it, SIMSG_SET_RHYTHM(_mididrv->hasRhythmChannel()));
|
||||
|
||||
if (_iterator == NULL) {
|
||||
@ -648,7 +650,7 @@ static int sfx_play_iterator_pcm(SongIterator *it, SongHandle handle) {
|
||||
|
||||
#define DELAY (1000000 / SFX_TICKS_PER_SEC)
|
||||
|
||||
void SfxState::sfx_init(ResourceManager *resMan, int flags) {
|
||||
void SfxState::sfx_init(ResourceManager *resMan, int flags, SciVersion soundVersion) {
|
||||
_songlib._lib = 0;
|
||||
_song = NULL;
|
||||
_flags = flags;
|
||||
@ -673,7 +675,7 @@ void SfxState::sfx_init(ResourceManager *resMan, int flags) {
|
||||
return;
|
||||
}
|
||||
|
||||
_player = new SfxPlayer();
|
||||
_player = new SfxPlayer(soundVersion);
|
||||
|
||||
if (!_player) {
|
||||
warning("[SFX] No song player found");
|
||||
|
@ -72,7 +72,7 @@ public:
|
||||
** Parameters: (ResourceManager *) resMan: Resource manager for initialization
|
||||
** (int) flags: SFX_STATE_FLAG_*
|
||||
*/
|
||||
void sfx_init(ResourceManager *resMan, int flags);
|
||||
void sfx_init(ResourceManager *resMan, int flags, SciVersion soundVersion);
|
||||
|
||||
/** Deinitializes the sound subsystem. */
|
||||
void sfx_exit();
|
||||
|
@ -335,7 +335,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
|
||||
pSnd->pMidiParser->setTimerRate(_dwTempo);
|
||||
}
|
||||
// Find out what channels to filter for SCI0
|
||||
channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayMask());
|
||||
channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayMask(_soundVersion));
|
||||
pSnd->pMidiParser->loadMusic(track, pSnd, channelFilterMask, _soundVersion);
|
||||
}
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ class MidiPlayer_Adlib : public MidiPlayer {
|
||||
public:
|
||||
MidiPlayer_Adlib() { _driver = new MidiDriver_Adlib(g_system->getMixer()); }
|
||||
int open(ResourceManager *resMan);
|
||||
int getPlayMask() const { return 0x04; }
|
||||
int getPlayMask(SciVersion soundVersion);
|
||||
int getPolyphony() const { return MidiDriver_Adlib::kVoices; }
|
||||
bool hasRhythmChannel() const { return false; }
|
||||
void setVolume(byte volume) { static_cast<MidiDriver_Adlib *>(_driver)->setVolume(volume); }
|
||||
@ -811,6 +811,14 @@ int MidiPlayer_Adlib::open(ResourceManager *resMan) {
|
||||
return static_cast<MidiDriver_Adlib *>(_driver)->open(getSciVersion() <= SCI_VERSION_0_LATE);
|
||||
}
|
||||
|
||||
int MidiPlayer_Adlib::getPlayMask(SciVersion soundVersion) {
|
||||
switch (soundVersion) {
|
||||
case SCI_VERSION_0_EARLY:
|
||||
return 0x10; // FIXME: Not correct
|
||||
}
|
||||
return 0x04;
|
||||
}
|
||||
|
||||
MidiPlayer *MidiPlayer_Adlib_create() {
|
||||
return new MidiPlayer_Adlib();
|
||||
}
|
||||
|
@ -651,7 +651,7 @@ void MidiDriver_Amiga::generateSamples(int16 *data, int len) {
|
||||
class MidiPlayer_Amiga : public MidiPlayer {
|
||||
public:
|
||||
MidiPlayer_Amiga() { _driver = new MidiDriver_Amiga(g_system->getMixer()); }
|
||||
int getPlayMask() const { return 0x40; }
|
||||
int getPlayMask(SciVersion soundVersion);
|
||||
int getPolyphony() const { return MidiDriver_Amiga::kVoices; }
|
||||
bool hasRhythmChannel() const { return false; }
|
||||
void setVolume(byte volume) { static_cast<MidiDriver_Amiga *>(_driver)->setVolume(volume); }
|
||||
@ -663,4 +663,12 @@ MidiPlayer *MidiPlayer_Amiga_create() {
|
||||
return new MidiPlayer_Amiga();
|
||||
}
|
||||
|
||||
int MidiPlayer_Amiga::getPlayMask(SciVersion soundVersion) {
|
||||
switch (soundVersion) {
|
||||
case SCI_VERSION_0_EARLY:
|
||||
return 0x40; // FIXME: Not correct
|
||||
}
|
||||
return 0x40;
|
||||
}
|
||||
|
||||
} // End of namespace Sci
|
||||
|
@ -81,7 +81,7 @@ public:
|
||||
MidiChannel *getPercussionChannel() { return _driver->getPercussionChannel(); }
|
||||
void setTimerCallback(void *timer_param, Common::TimerManager::TimerProc timer_proc) { _driver->setTimerCallback(timer_param, timer_proc); }
|
||||
|
||||
virtual int getPlayMask() const = 0;
|
||||
virtual int getPlayMask(SciVersion soundVersion) = 0;
|
||||
virtual int getPolyphony() const = 0;
|
||||
|
||||
virtual void setVolume(byte volume) {
|
||||
|
@ -192,4 +192,20 @@ void MidiDriver_PCJr::close() {
|
||||
_mixer->stopHandle(_mixerSoundHandle);
|
||||
}
|
||||
|
||||
int MidiPlayer_PCJr::getPlayMask(SciVersion soundVersion) {
|
||||
switch (soundVersion) {
|
||||
case SCI_VERSION_0_EARLY:
|
||||
return 0x10; // FIXME: Not correct
|
||||
}
|
||||
return 0x10;
|
||||
}
|
||||
|
||||
int MidiPlayer_PCSpeaker::getPlayMask(SciVersion soundVersion) {
|
||||
switch (soundVersion) {
|
||||
case SCI_VERSION_0_EARLY:
|
||||
return 0x20; // FIXME: Not correct
|
||||
}
|
||||
return 0x20;
|
||||
}
|
||||
|
||||
} // End of namespace Sci
|
||||
|
@ -68,7 +68,7 @@ class MidiPlayer_PCJr : public MidiPlayer {
|
||||
public:
|
||||
MidiPlayer_PCJr() { _driver = new MidiDriver_PCJr(g_system->getMixer()); }
|
||||
int open(ResourceManager *resMan) { return static_cast<MidiDriver_PCJr *>(_driver)->open(getPolyphony()); }
|
||||
int getPlayMask() const { return 0x10; }
|
||||
int getPlayMask(SciVersion soundVersion);
|
||||
int getPolyphony() const { return 3; }
|
||||
bool hasRhythmChannel() const { return false; }
|
||||
void setVolume(byte volume) { static_cast<MidiDriver_PCJr *>(_driver)->_global_volume = volume; }
|
||||
@ -76,7 +76,7 @@ public:
|
||||
|
||||
class MidiPlayer_PCSpeaker : public MidiPlayer_PCJr {
|
||||
public:
|
||||
int getPlayMask() const { return 0x20; }
|
||||
int getPlayMask(SciVersion soundVersion);
|
||||
int getPolyphony() const { return 1; }
|
||||
};
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user