aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2009-12-27 12:17:43 +0000
committerMartin Kiewitz2009-12-27 12:17:43 +0000
commite6ad7523c8acdd1bf0fc37e841da627f568d6fcd (patch)
tree5eaae52fd2aacf594d6a6b0097ab211c15f7d258 /engines/sci
parent19cb4ad6e02927607af851d08d1b176cbb1f8bea (diff)
downloadscummvm-rg350-e6ad7523c8acdd1bf0fc37e841da627f568d6fcd.tar.gz
scummvm-rg350-e6ad7523c8acdd1bf0fc37e841da627f568d6fcd.tar.bz2
scummvm-rg350-e6ad7523c8acdd1bf0fc37e841da627f568d6fcd.zip
SCI/newmusic: now adding digital sample data as separate channel for sci0 games (not yet playing)
svn-id: r46629
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/resource.cpp55
-rw-r--r--engines/sci/resource.h2
-rw-r--r--engines/sci/sfx/music.cpp8
3 files changed, 41 insertions, 24 deletions
diff --git a/engines/sci/resource.cpp b/engines/sci/resource.cpp
index ac3f1a85e5..896947dc35 100644
--- a/engines/sci/resource.cpp
+++ b/engines/sci/resource.cpp
@@ -198,7 +198,7 @@ bool ResourceManager::loadPatch(Resource *res, Common::File &file) {
res->data = new byte[res->size];
if (res->headerSize > 0)
- res->header = new byte[res->headerSize];
+ res->header = new byte[res->headerSize];
if ((res->data == NULL) || ((res->headerSize > 0) && (res->header == NULL))) {
error("Can't allocate %d bytes needed for loading %s", res->size + res->headerSize, res->id.toString().c_str());
@@ -367,11 +367,11 @@ int ResourceManager::addAppropriateSources() {
#endif
else
return 0;
-
+
Common::ArchiveMemberList files;
SearchMan.listMatchingMembers(files, "RESOURCE.0??");
-
+
#ifdef ENABLE_SCI32
SearchMan.listMatchingMembers(files, "RESSCI.0??");
#endif
@@ -757,7 +757,7 @@ ResourceManager::ResVersion ResourceManager::detectMapVersion() {
mapDetected = kResVersionSci32;
else if (directoryType < 0x80 || ((directoryType & 0x7f) > 0x20 && directoryType != 0xFF))
break;
-
+
// Offset is above file size? -> definitely not SCI1/SCI1.1
if (directoryOffset > fileStream->size())
break;
@@ -769,7 +769,7 @@ ResourceManager::ResVersion ResourceManager::detectMapVersion() {
if ((directorySize % 5 == 0) && (directorySize % 6))
mapDetected = kResVersionSci11;
}
-
+
if (directoryType == 0xFF) {
// FFh entry needs to point to EOF
if (directoryOffset != fileStream->size())
@@ -1601,7 +1601,7 @@ void ResourceManager::detectSciVersion() {
}
// Set view type
- if (viewCompression == kCompDCL
+ if (viewCompression == kCompDCL
#ifdef ENABLE_SCI32
|| viewCompression == kCompSTACpack
#endif
@@ -1612,7 +1612,7 @@ void ResourceManager::detectSciVersion() {
// Otherwise we detect it from a view
_viewType = detectViewType();
}
-
+
// Handle SCI32 versions here
if (_volVersion == kResVersionSci32) {
// SCI2.1/3 and SCI1 Late resource maps are the same, except that
@@ -1816,8 +1816,9 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
_innerResource = resource;
- byte *data = resource->data, *data2;
- Channel *channel;
+ byte *data, *data2;
+ byte *dataEnd;
+ Channel *channel, *sampleChannel;
switch (_soundVersion) {
case SCI_VERSION_0_EARLY:
@@ -1825,12 +1826,15 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
// SCI0 only has a header of 0x11/0x21 byte length and the actual midi track follows afterwards
_trackCount = 1;
_tracks = new Track[_trackCount];
- _tracks->nDigital = 0xFF;
+ _tracks->digitalChannelNr = -1;
_tracks->type = TRACKTYPE_NONE;
_tracks->channelCount = 1;
+ // Digital sample data included? -> Add an additional channel
+ if (resource->data[0] == 2)
+ _tracks->channelCount++;
_tracks->channels = new Channel[_tracks->channelCount];
- channel = _tracks->channels;
-
+ memset(_tracks->channels, 0, sizeof(Channel) * _tracks->channelCount);
+ channel = &_tracks->channels[0];
if (_soundVersion == SCI_VERSION_0_EARLY) {
channel->data = resource->data + 0x11;
channel->size = resource->size - 0x11;
@@ -1838,15 +1842,28 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
channel->data = resource->data + 0x21;
channel->size = resource->size - 0x21;
}
-
- channel->number = 0;
- channel->poly = 0;
- channel->time = channel->prev = 0;
- channel->unk = 0;
+ if (_tracks->channelCount == 2) {
+ // Digital sample data included
+ _tracks->digitalChannelNr = 1;
+ sampleChannel = &_tracks->channels[1];
+ // we need to find 0xFC (channel terminator) within the data
+ data = channel->data;
+ dataEnd = channel->data + channel->size;
+ while ((data < dataEnd) && (*data != 0xfc))
+ data++;
+ // Skip any following 0xFCs as well
+ while ((data < dataEnd) && (*data == 0xfc))
+ data++;
+ // Now adjust channels accordingly
+ sampleChannel->data = data;
+ sampleChannel->size = channel->size - (data - channel->data);
+ channel->size = data - channel->data;
+ }
break;
case SCI_VERSION_1_EARLY:
case SCI_VERSION_1_LATE:
+ data = resource->data;
// Count # of tracks
_trackCount = 0;
while ((*data++) != 0xFF) {
@@ -1873,7 +1890,7 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
}
_tracks[trackNr].channels = new Channel[_tracks[trackNr].channelCount];
if (_tracks[trackNr].type != 0xF0) { // Digital track marker - not supported currently
- _tracks[trackNr].nDigital = 0xFF; // No digital channel associated
+ _tracks[trackNr].digitalChannelNr = -1; // No digital sound associated
for (channelNr = 0; channelNr < _tracks[trackNr].channelCount; channelNr++) {
channel = &_tracks[trackNr].channels[channelNr];
channel->unk = READ_LE_UINT16(data);
@@ -1883,7 +1900,7 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
channel->poly = *(channel->data - 1);
channel->time = channel->prev = 0;
if (channel->number == 0xFE) // Digital channel
- _tracks[trackNr].nDigital = channelNr;
+ _tracks[trackNr].digitalChannelNr = channelNr;
data += 6;
}
} else {
diff --git a/engines/sci/resource.h b/engines/sci/resource.h
index ab66fa4ac6..a3f6c35213 100644
--- a/engines/sci/resource.h
+++ b/engines/sci/resource.h
@@ -450,7 +450,7 @@ public:
struct Track {
TrackType type;
- byte nDigital;
+ int16 digitalChannelNr;
byte channelCount;
Channel *channels;
};
diff --git a/engines/sci/sfx/music.cpp b/engines/sci/sfx/music.cpp
index d6f00478bc..eb64cdee1f 100644
--- a/engines/sci/sfx/music.cpp
+++ b/engines/sci/sfx/music.cpp
@@ -304,13 +304,13 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
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 (_midiType <= MD_MT32 && track->nDigital == 0xFF && _bMultiMidi) {
- if (pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB)->nDigital != 0xFF)
+ if (_midiType <= MD_MT32 && track->digitalChannelNr == -1 && _bMultiMidi) {
+ if (pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB)->digitalChannelNr != -1)
track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB);
}
// play digital sample
- if (track->nDigital != 0xFF) {
- byte *channelData = track->channels[track->nDigital].data;
+ if (track->digitalChannelNr != -1) {
+ byte *channelData = track->channels[track->digitalChannelNr].data;
int rate = READ_LE_UINT16(channelData);
uint32 size = READ_LE_UINT16(channelData + 2);
assert(READ_LE_UINT16(channelData + 4) == 0); // Possibly a compression flag