aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/sci/resource.cpp14
-rw-r--r--engines/sci/resource.h14
-rw-r--r--engines/sci/sound/iterator/core.cpp2
-rw-r--r--engines/sci/sound/iterator/iterator.cpp24
-rw-r--r--engines/sci/sound/music.cpp29
-rw-r--r--engines/sci/sound/softseq/adlib.cpp13
-rw-r--r--engines/sci/sound/softseq/amiga.cpp8
-rw-r--r--engines/sci/sound/softseq/mididriver.h2
-rw-r--r--engines/sci/sound/softseq/pcjr.cpp28
-rw-r--r--engines/sci/sound/softseq/pcjr.h4
10 files changed, 59 insertions, 79 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index 526a71bf62..feff560c04 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -1898,7 +1898,7 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
_trackCount = 1;
_tracks = new Track[_trackCount];
_tracks->digitalChannelNr = -1;
- _tracks->type = TRACKTYPE_NONE;
+ _tracks->type = 0; // Not used for SCI0
_tracks->channelCount = 1;
// Digital sample data included? -> Add an additional channel
if (resource->data[0] == 2)
@@ -1957,7 +1957,7 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
// 0xFF:BYTE as terminator to end that track and begin with another track type
// Track type 0xFF is the marker signifying the end of the tracks
- _tracks[trackNr].type = (TrackType) *data++;
+ _tracks[trackNr].type = *data++;
// Counting # of channels used
data2 = data;
_tracks[trackNr].channelCount = 0;
@@ -2028,7 +2028,7 @@ SoundResource::Track* SoundResource::getTrackByNumber(uint16 number) {
}
#endif
-SoundResource::Track* SoundResource::getTrackByType(TrackType type) {
+SoundResource::Track *SoundResource::getTrackByType(byte type) {
if (_soundVersion <= SCI_VERSION_0_LATE)
return &_tracks[0];
@@ -2039,6 +2039,14 @@ SoundResource::Track* SoundResource::getTrackByType(TrackType type) {
return NULL;
}
+SoundResource::Track *SoundResource::getDigitalTrack() {
+ for (int trackNr = 0; trackNr < _trackCount; trackNr++) {
+ if (_tracks[trackNr].digitalChannelNr != -1)
+ return &_tracks[trackNr];
+ }
+ return NULL;
+}
+
// Gets the filter mask for SCI0 sound resources
int SoundResource::getChannelFilterMask(int hardwareMask) {
byte *data = _innerResource->data;
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index cc4b6104fa..e3ef848c87 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -439,15 +439,6 @@ protected:
class SoundResource {
public:
- enum TrackType {
- TRACKTYPE_ADLIB = 0,
- TRACKTYPE_GAMEBLASTER = 9,
- TRACKTYPE_MT32 = 12,
- TRACKTYPE_SPEAKER = 18,
- TRACKTYPE_TANDY = 19,
- TRACKTYPE_NONE = 255
- };
-
struct Channel {
byte number;
byte poly;
@@ -459,7 +450,7 @@ public:
};
struct Track {
- TrackType type;
+ byte type;
byte channelCount;
Channel *channels;
int16 digitalChannelNr;
@@ -472,7 +463,8 @@ public:
#if 0
Track *getTrackByNumber(uint16 number);
#endif
- Track *getTrackByType(TrackType type);
+ Track *getTrackByType(byte type);
+ Track *getDigitalTrack();
int getChannelFilterMask(int hardwareMask);
private:
diff --git a/engines/sci/sound/iterator/core.cpp b/engines/sci/sound/iterator/core.cpp
index 89e4c7b14f..5ea7f1d0f7 100644
--- a/engines/sci/sound/iterator/core.cpp
+++ b/engines/sci/sound/iterator/core.cpp
@@ -263,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(_soundVersion)));
+ SIMSG_SEND(it, SIMSG_SET_PLAYMASK(_mididrv->getPlayId(_soundVersion)));
SIMSG_SEND(it, SIMSG_SET_RHYTHM(_mididrv->hasRhythmChannel()));
if (_iterator == NULL) {
diff --git a/engines/sci/sound/iterator/iterator.cpp b/engines/sci/sound/iterator/iterator.cpp
index 3359d0155b..9c340b5604 100644
--- a/engines/sci/sound/iterator/iterator.cpp
+++ b/engines/sci/sound/iterator/iterator.cpp
@@ -666,20 +666,6 @@ SongIterator *Sci0SongIterator::clone(int delta) {
/*-- SCI1 song iterators --*/
/***************************/
-#define SCI01_INVALID_DEVICE 0xff
-
-/* Second index determines whether PCM output is supported */
-static const int sci0_to_sci1_device_map[][2] = {
- {0x06, 0x0c}, /* MT-32 */
- {0xff, 0xff}, /* YM FB-01 */
- {0x00, 0x00}, /* CMS/Game Blaster-- we assume OPL/2 here... */
- {0xff, 0xff}, /* Casio MT540/CT460 */
- {0x13, 0x13}, /* Tandy 3-voice */
- {0x12, 0x12}, /* PC speaker */
- {0xff, 0xff},
- {0xff, 0xff},
-}; /* Maps bit number to device ID */
-
int Sci1SongIterator::initSample(const int offset) {
Sci1Sample sample;
int rate;
@@ -1008,16 +994,8 @@ SongIterator *Sci1SongIterator::handleMessage(Message msg) {
if (msg.ID == ID) {
channel_mask = 0;
- _deviceId
- = sci0_to_sci1_device_map
- [sci_ffs(msg._arg.i & 0xff) - 1]
- [g_system->getMixer()->isReady()]
- ;
+ _deviceId = msg._arg.i;
- if (_deviceId == 0xff) {
- warning("[iterator] Device %d(%d) not supported",
- msg._arg.i & 0xff, g_system->getMixer()->isReady());
- }
if (_initialised) {
int i;
int toffset = -1;
diff --git a/engines/sci/sound/music.cpp b/engines/sci/sound/music.cpp
index e1ac79f4c9..1b18b8f434 100644
--- a/engines/sci/sound/music.cpp
+++ b/engines/sci/sound/music.cpp
@@ -303,30 +303,17 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
SoundResource::Track *track = NULL;
int channelFilterMask = 0;
- switch (_midiType) {
- case MD_PCSPK:
- track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_SPEAKER);
- break;
- case MD_PCJR:
- track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_TANDY);
- break;
- case MD_ADLIB:
- track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB);
- break;
- case MD_MT32:
- track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_MT32);
- break;
- default:
- // Should never occur
- error("soundInitSnd: Unknown MIDI type");
- break;
- }
+ track = pSnd->soundRes->getTrackByType(_pMidiDrv->getPlayId(_soundVersion));
if (track) {
// If MIDI device is selected but there is no digital track in sound resource
// try to use adlib's digital sample if possible
- if (_bMultiMidi && pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB)->digitalChannelNr != -1)
- track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB);
+ if (_bMultiMidi && (track->digitalChannelNr == -1)) {
+ SoundResource::Track *digital = pSnd->soundRes->getDigitalTrack();
+ if (digital)
+ track = digital;
+ }
+
// Play digital sample
if (track->digitalChannelNr != -1) {
byte *channelData = track->channels[track->digitalChannelNr].data;
@@ -351,7 +338,7 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
pSnd->pauseCounter = 0;
// Find out what channels to filter for SCI0
- channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayMask(_soundVersion));
+ channelFilterMask = pSnd->soundRes->getChannelFilterMask(_pMidiDrv->getPlayId(_soundVersion));
pSnd->pMidiParser->loadMusic(track, pSnd, channelFilterMask, _soundVersion);
// Fast forward to the last position and perform associated events when loading
diff --git a/engines/sci/sound/softseq/adlib.cpp b/engines/sci/sound/softseq/adlib.cpp
index 7cfcf0cbaf..5cca3561bf 100644
--- a/engines/sci/sound/softseq/adlib.cpp
+++ b/engines/sci/sound/softseq/adlib.cpp
@@ -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(SciVersion soundVersion);
+ byte getPlayId(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); }
@@ -812,8 +812,15 @@ int MidiPlayer_Adlib::open(ResourceManager *resMan) {
return static_cast<MidiDriver_Adlib *>(_driver)->open(getSciVersion() <= SCI_VERSION_0_LATE);
}
-int MidiPlayer_Adlib::getPlayMask(SciVersion soundVersion) {
- return (soundVersion == SCI_VERSION_0_EARLY) ? 0x01 : 0x04;
+byte MidiPlayer_Adlib::getPlayId(SciVersion soundVersion) {
+ switch (soundVersion) {
+ case SCI_VERSION_0_EARLY:
+ return 0x01;
+ case SCI_VERSION_0_LATE:
+ return 0x04;
+ default:
+ return 0x00;
+ }
}
MidiPlayer *MidiPlayer_Adlib_create() {
diff --git a/engines/sci/sound/softseq/amiga.cpp b/engines/sci/sound/softseq/amiga.cpp
index 1042d98422..8324fc9dd2 100644
--- a/engines/sci/sound/softseq/amiga.cpp
+++ b/engines/sci/sound/softseq/amiga.cpp
@@ -654,7 +654,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(SciVersion soundVersion);
+ byte getPlayId(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); }
@@ -666,9 +666,9 @@ MidiPlayer *MidiPlayer_Amiga_create() {
return new MidiPlayer_Amiga();
}
-int MidiPlayer_Amiga::getPlayMask(SciVersion soundVersion) {
- if (soundVersion == SCI_VERSION_0_EARLY)
- error("No amiga support for sci0early");
+byte MidiPlayer_Amiga::getPlayId(SciVersion soundVersion) {
+ if (soundVersion != SCI_VERSION_0_LATE)
+ error("Amiga sound support not available for this SCI version");
return 0x40;
}
diff --git a/engines/sci/sound/softseq/mididriver.h b/engines/sci/sound/softseq/mididriver.h
index df0532d732..0569374a10 100644
--- a/engines/sci/sound/softseq/mididriver.h
+++ b/engines/sci/sound/softseq/mididriver.h
@@ -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(SciVersion soundVersion) = 0;
+ virtual byte getPlayId(SciVersion soundVersion) = 0;
virtual int getPolyphony() const = 0;
virtual void setVolume(byte volume) {
diff --git a/engines/sci/sound/softseq/pcjr.cpp b/engines/sci/sound/softseq/pcjr.cpp
index c7dd2f6528..569548c33a 100644
--- a/engines/sci/sound/softseq/pcjr.cpp
+++ b/engines/sci/sound/softseq/pcjr.cpp
@@ -192,18 +192,26 @@ void MidiDriver_PCJr::close() {
_mixer->stopHandle(_mixerSoundHandle);
}
-int MidiPlayer_PCJr::getPlayMask(SciVersion soundVersion) {
- if (soundVersion == SCI_VERSION_0_EARLY)
- return 0x10; // FIXME: Not correct
-
- return 0x10;
-}
-
-int MidiPlayer_PCSpeaker::getPlayMask(SciVersion soundVersion) {
- if (soundVersion == SCI_VERSION_0_EARLY)
+byte MidiPlayer_PCJr::getPlayId(SciVersion soundVersion) {
+ switch (soundVersion) {
+ case SCI_VERSION_0_EARLY:
return 0x02;
+ case SCI_VERSION_0_LATE:
+ return 0x10;
+ default:
+ return 0x13;
+ }
+}
- return 0x20;
+byte MidiPlayer_PCSpeaker::getPlayId(SciVersion soundVersion) {
+ switch (soundVersion) {
+ case SCI_VERSION_0_EARLY:
+ return 0x04;
+ case SCI_VERSION_0_LATE:
+ return 0x20;
+ default:
+ return 0x12;
+ }
}
} // End of namespace Sci
diff --git a/engines/sci/sound/softseq/pcjr.h b/engines/sci/sound/softseq/pcjr.h
index e8b0b9f553..2693706956 100644
--- a/engines/sci/sound/softseq/pcjr.h
+++ b/engines/sci/sound/softseq/pcjr.h
@@ -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(SciVersion soundVersion);
+ byte getPlayId(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(SciVersion soundVersion);
+ byte getPlayId(SciVersion soundVersion);
int getPolyphony() const { return 1; }
};