SCI/newmusic: now adding digital sample data as separate channel for sci0 games (not yet playing)
svn-id: r46629
This commit is contained in:
parent
19cb4ad6e0
commit
e6ad7523c8
3 changed files with 41 additions and 24 deletions
|
@ -198,7 +198,7 @@ bool ResourceManager::loadPatch(Resource *res, Common::File &file) {
|
||||||
res->data = new byte[res->size];
|
res->data = new byte[res->size];
|
||||||
|
|
||||||
if (res->headerSize > 0)
|
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))) {
|
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());
|
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
|
#endif
|
||||||
else
|
else
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
||||||
Common::ArchiveMemberList files;
|
Common::ArchiveMemberList files;
|
||||||
SearchMan.listMatchingMembers(files, "RESOURCE.0??");
|
SearchMan.listMatchingMembers(files, "RESOURCE.0??");
|
||||||
|
|
||||||
#ifdef ENABLE_SCI32
|
#ifdef ENABLE_SCI32
|
||||||
SearchMan.listMatchingMembers(files, "RESSCI.0??");
|
SearchMan.listMatchingMembers(files, "RESSCI.0??");
|
||||||
#endif
|
#endif
|
||||||
|
@ -757,7 +757,7 @@ ResourceManager::ResVersion ResourceManager::detectMapVersion() {
|
||||||
mapDetected = kResVersionSci32;
|
mapDetected = kResVersionSci32;
|
||||||
else if (directoryType < 0x80 || ((directoryType & 0x7f) > 0x20 && directoryType != 0xFF))
|
else if (directoryType < 0x80 || ((directoryType & 0x7f) > 0x20 && directoryType != 0xFF))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Offset is above file size? -> definitely not SCI1/SCI1.1
|
// Offset is above file size? -> definitely not SCI1/SCI1.1
|
||||||
if (directoryOffset > fileStream->size())
|
if (directoryOffset > fileStream->size())
|
||||||
break;
|
break;
|
||||||
|
@ -769,7 +769,7 @@ ResourceManager::ResVersion ResourceManager::detectMapVersion() {
|
||||||
if ((directorySize % 5 == 0) && (directorySize % 6))
|
if ((directorySize % 5 == 0) && (directorySize % 6))
|
||||||
mapDetected = kResVersionSci11;
|
mapDetected = kResVersionSci11;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (directoryType == 0xFF) {
|
if (directoryType == 0xFF) {
|
||||||
// FFh entry needs to point to EOF
|
// FFh entry needs to point to EOF
|
||||||
if (directoryOffset != fileStream->size())
|
if (directoryOffset != fileStream->size())
|
||||||
|
@ -1601,7 +1601,7 @@ void ResourceManager::detectSciVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set view type
|
// Set view type
|
||||||
if (viewCompression == kCompDCL
|
if (viewCompression == kCompDCL
|
||||||
#ifdef ENABLE_SCI32
|
#ifdef ENABLE_SCI32
|
||||||
|| viewCompression == kCompSTACpack
|
|| viewCompression == kCompSTACpack
|
||||||
#endif
|
#endif
|
||||||
|
@ -1612,7 +1612,7 @@ void ResourceManager::detectSciVersion() {
|
||||||
// Otherwise we detect it from a view
|
// Otherwise we detect it from a view
|
||||||
_viewType = detectViewType();
|
_viewType = detectViewType();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle SCI32 versions here
|
// Handle SCI32 versions here
|
||||||
if (_volVersion == kResVersionSci32) {
|
if (_volVersion == kResVersionSci32) {
|
||||||
// SCI2.1/3 and SCI1 Late resource maps are the same, except that
|
// 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;
|
_innerResource = resource;
|
||||||
|
|
||||||
byte *data = resource->data, *data2;
|
byte *data, *data2;
|
||||||
Channel *channel;
|
byte *dataEnd;
|
||||||
|
Channel *channel, *sampleChannel;
|
||||||
|
|
||||||
switch (_soundVersion) {
|
switch (_soundVersion) {
|
||||||
case SCI_VERSION_0_EARLY:
|
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
|
// SCI0 only has a header of 0x11/0x21 byte length and the actual midi track follows afterwards
|
||||||
_trackCount = 1;
|
_trackCount = 1;
|
||||||
_tracks = new Track[_trackCount];
|
_tracks = new Track[_trackCount];
|
||||||
_tracks->nDigital = 0xFF;
|
_tracks->digitalChannelNr = -1;
|
||||||
_tracks->type = TRACKTYPE_NONE;
|
_tracks->type = TRACKTYPE_NONE;
|
||||||
_tracks->channelCount = 1;
|
_tracks->channelCount = 1;
|
||||||
|
// Digital sample data included? -> Add an additional channel
|
||||||
|
if (resource->data[0] == 2)
|
||||||
|
_tracks->channelCount++;
|
||||||
_tracks->channels = new Channel[_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) {
|
if (_soundVersion == SCI_VERSION_0_EARLY) {
|
||||||
channel->data = resource->data + 0x11;
|
channel->data = resource->data + 0x11;
|
||||||
channel->size = resource->size - 0x11;
|
channel->size = resource->size - 0x11;
|
||||||
|
@ -1838,15 +1842,28 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
|
||||||
channel->data = resource->data + 0x21;
|
channel->data = resource->data + 0x21;
|
||||||
channel->size = resource->size - 0x21;
|
channel->size = resource->size - 0x21;
|
||||||
}
|
}
|
||||||
|
if (_tracks->channelCount == 2) {
|
||||||
channel->number = 0;
|
// Digital sample data included
|
||||||
channel->poly = 0;
|
_tracks->digitalChannelNr = 1;
|
||||||
channel->time = channel->prev = 0;
|
sampleChannel = &_tracks->channels[1];
|
||||||
channel->unk = 0;
|
// 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;
|
break;
|
||||||
|
|
||||||
case SCI_VERSION_1_EARLY:
|
case SCI_VERSION_1_EARLY:
|
||||||
case SCI_VERSION_1_LATE:
|
case SCI_VERSION_1_LATE:
|
||||||
|
data = resource->data;
|
||||||
// Count # of tracks
|
// Count # of tracks
|
||||||
_trackCount = 0;
|
_trackCount = 0;
|
||||||
while ((*data++) != 0xFF) {
|
while ((*data++) != 0xFF) {
|
||||||
|
@ -1873,7 +1890,7 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
|
||||||
}
|
}
|
||||||
_tracks[trackNr].channels = new Channel[_tracks[trackNr].channelCount];
|
_tracks[trackNr].channels = new Channel[_tracks[trackNr].channelCount];
|
||||||
if (_tracks[trackNr].type != 0xF0) { // Digital track marker - not supported currently
|
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++) {
|
for (channelNr = 0; channelNr < _tracks[trackNr].channelCount; channelNr++) {
|
||||||
channel = &_tracks[trackNr].channels[channelNr];
|
channel = &_tracks[trackNr].channels[channelNr];
|
||||||
channel->unk = READ_LE_UINT16(data);
|
channel->unk = READ_LE_UINT16(data);
|
||||||
|
@ -1883,7 +1900,7 @@ SoundResource::SoundResource(uint32 resNumber, ResourceManager *resMan, SciVersi
|
||||||
channel->poly = *(channel->data - 1);
|
channel->poly = *(channel->data - 1);
|
||||||
channel->time = channel->prev = 0;
|
channel->time = channel->prev = 0;
|
||||||
if (channel->number == 0xFE) // Digital channel
|
if (channel->number == 0xFE) // Digital channel
|
||||||
_tracks[trackNr].nDigital = channelNr;
|
_tracks[trackNr].digitalChannelNr = channelNr;
|
||||||
data += 6;
|
data += 6;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -450,7 +450,7 @@ public:
|
||||||
|
|
||||||
struct Track {
|
struct Track {
|
||||||
TrackType type;
|
TrackType type;
|
||||||
byte nDigital;
|
int16 digitalChannelNr;
|
||||||
byte channelCount;
|
byte channelCount;
|
||||||
Channel *channels;
|
Channel *channels;
|
||||||
};
|
};
|
||||||
|
|
|
@ -304,13 +304,13 @@ void SciMusic::soundInitSnd(MusicEntry *pSnd) {
|
||||||
if (track) {
|
if (track) {
|
||||||
// if MIDI device is selected but there is no digital track in sound resource
|
// if MIDI device is selected but there is no digital track in sound resource
|
||||||
// try to use adlib's digital sample if possible
|
// try to use adlib's digital sample if possible
|
||||||
if (_midiType <= MD_MT32 && track->nDigital == 0xFF && _bMultiMidi) {
|
if (_midiType <= MD_MT32 && track->digitalChannelNr == -1 && _bMultiMidi) {
|
||||||
if (pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB)->nDigital != 0xFF)
|
if (pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB)->digitalChannelNr != -1)
|
||||||
track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB);
|
track = pSnd->soundRes->getTrackByType(SoundResource::TRACKTYPE_ADLIB);
|
||||||
}
|
}
|
||||||
// play digital sample
|
// play digital sample
|
||||||
if (track->nDigital != 0xFF) {
|
if (track->digitalChannelNr != -1) {
|
||||||
byte *channelData = track->channels[track->nDigital].data;
|
byte *channelData = track->channels[track->digitalChannelNr].data;
|
||||||
int rate = READ_LE_UINT16(channelData);
|
int rate = READ_LE_UINT16(channelData);
|
||||||
uint32 size = READ_LE_UINT16(channelData + 2);
|
uint32 size = READ_LE_UINT16(channelData + 2);
|
||||||
assert(READ_LE_UINT16(channelData + 4) == 0); // Possibly a compression flag
|
assert(READ_LE_UINT16(channelData + 4) == 0); // Possibly a compression flag
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue