[Scummvm-git-logs] scummvm master -> a379602443ec985d79f4e23c3f04f8bfe40ee19d
sev-
noreply at scummvm.org
Wed May 10 20:32:28 UTC 2023
This automated email contains information about 8 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
093fbae86c DIRECTOR: Add detection entry for "The Cute machine"
401a17d35a DIRECTOR: Add dynamic sound channel allocation
2065a7d39c DIRECTOR: Fix D5 looping sound support
343a177016 DIRECTOR: Add new lookup table for D5 palette fade times
e0c7bec488 DIRECTOR: Fade sounds if the channel handle exists
3b5500227a DIRECTOR: Update the current sound fade during a palette transition
e49e64345b DIRECTOR: Make BitmapCastMember::_bitsPerPixel a uint8
a379602443 DIRECTOR: Hide null calls to Movie::getScriptContext()
Commit: 093fbae86ca4f6fa41f5a6391b8f23af7bb16c47
https://github.com/scummvm/scummvm/commit/093fbae86ca4f6fa41f5a6391b8f23af7bb16c47
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Add detection entry for "The Cute machine"
Changed paths:
engines/director/detection_tables.h
diff --git a/engines/director/detection_tables.h b/engines/director/detection_tables.h
index 2a0a2ded351..a91cecf6eeb 100644
--- a/engines/director/detection_tables.h
+++ b/engines/director/detection_tables.h
@@ -117,6 +117,7 @@ static const PlainGameDescriptor directorGames[] = {
{ "csi", "CSI: Crime Scene Investigation" },
{ "csidarkmotives", "CSI: Crime Scene Investigation - Dark Motives" },
{ "csimiami", "CSI: Miami" },
+ { "cutemachine", "The Cute machine" },
{ "daedalus", "The Daedalus Encounter" },
{ "darkeye", "The Dark Eye" },
{ "dazzeloids", "Dazzeloids" },
@@ -5825,6 +5826,9 @@ static const DirectorGameDescription gameDescriptions[] = {
MACGAME1("crystalskull", "", "Crystal Skull", "c148f66ae3511fb88733102aa27efe7e", 719459, 501),
WINGAME1t("crystalskull", "", "CRYS32.EXE", "3f5fd025e808943e1fa9b91ce63ef9b7", 1410495, 501),
+ WINGAME1("cutemachine", "Windows 3.1", "CUTE.EXE", "2e62abdad839e42068afdcd0644d7dcf", 920035, 500),
+ WINGAME1("cutemachine", "Windows 95", "clickhere.exe", "3460ad87d2ba57104e2810a77b53c220", 1396405, 500),
+
WINGAME2("davidsonps", "v1.0", "DPS32.EXE", "3460ad87d2ba57104e2810a77b53c220", 1401517,
"DPSHOT.DXR", "d980c9272bc723c57238a31790b71f11", 1354686, 500),
// Developed by Wag the Dog Productions
Commit: 401a17d35a538ea899a661a7fe8f3e51c99379dc
https://github.com/scummvm/scummvm/commit/401a17d35a538ea899a661a7fe8f3e51c99379dc
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Add dynamic sound channel allocation
By D5, titles are allowed to play back sounds on an arbitrary channel
and the mixer deals with it. This apparently works to an extent on Mac
for D4 and below, whereas Windows D4 has a hard limit of 4 channels.
As the clear intent is to play something, we should do that for all
versions, unless a counterexample shows up.
Used by Smarty.
Changed paths:
engines/director/sound.cpp
engines/director/sound.h
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index bc0aeb5dddb..8202db42d4a 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -48,8 +48,8 @@ DirectorSound::DirectorSound(Window *window) : _window(window) {
numChannels = 4;
}
- for (uint i = 0; i < numChannels; i++) {
- _channels.push_back(SoundChannel());
+ for (uint i = 1; i <= numChannels; i++) {
+ _channels[i] = new SoundChannel();
}
_mixer = g_system->getMixer();
@@ -65,16 +65,18 @@ DirectorSound::~DirectorSound() {
this->stopSound();
unloadSampleSounds();
delete _speaker;
+ for (auto it : _channels)
+ delete it._value;
}
SoundChannel *DirectorSound::getChannel(uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return nullptr;
- return &_channels[soundChannel - 1];
+ return _channels[soundChannel];
}
void DirectorSound::playFile(Common::String filename, uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
if (debugChannelSet(-1, kDebugFast))
@@ -85,7 +87,7 @@ void DirectorSound::playFile(Common::String filename, uint8 soundChannel) {
cancelFade(soundChannel);
stopSound(soundChannel);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel - 1].handle, sound, -1, getChannelVolume(soundChannel));
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel]->handle, sound, -1, getChannelVolume(soundChannel));
// Set the last played sound so that cast member 0 in the sound channel doesn't stop this file.
setLastPlayedSound(soundChannel, SoundID(), false);
@@ -101,17 +103,20 @@ void DirectorSound::playMCI(Audio::AudioStream &stream, uint32 from, uint32 to)
}
uint8 DirectorSound::getChannelVolume(uint8 soundChannel) {
- return _enable ? _channels[soundChannel - 1].volume : 0;
+ if (!assertChannel(soundChannel))
+ return 0;
+
+ return _enable ? _channels[soundChannel]->volume : 0;
}
void DirectorSound::playStream(Audio::AudioStream &stream, uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
cancelFade(soundChannel);
- _mixer->stopHandle(_channels[soundChannel - 1].handle);
- _mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel - 1].handle, &stream, -1, getChannelVolume(soundChannel));
+ _mixer->stopHandle(_channels[soundChannel]->handle);
+ _mixer->playStream(Audio::Mixer::kSFXSoundType, &_channels[soundChannel]->handle, &stream, -1, getChannelVolume(soundChannel));
}
void DirectorSound::playSound(SoundID soundID, uint8 soundChannel, bool forPuppet) {
@@ -126,7 +131,7 @@ void DirectorSound::playSound(SoundID soundID, uint8 soundChannel, bool forPuppe
}
void DirectorSound::playCastMember(CastMemberID memberID, uint8 soundChannel, bool forPuppet) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
if (memberID.member == 0) {
@@ -142,10 +147,10 @@ void DirectorSound::playCastMember(CastMemberID memberID, uint8 soundChannel, bo
// Director 3 will continue looping until the sound is replaced.
} else if (g_director->getVersion() >= 400) {
// If there is a loopable stream specified, set the loop to expire by itself
- if (_channels[soundChannel - 1].loopPtr) {
+ if (_channels[soundChannel]->loopPtr) {
debugC(5, kDebugSound, "DirectorSound::playCastMember(): telling loop in channel %d to stop", soundChannel);
- _channels[soundChannel - 1].loopPtr->setRemainingIterations(1);
- _channels[soundChannel - 1].loopPtr = nullptr;
+ _channels[soundChannel]->loopPtr->setRemainingIterations(1);
+ _channels[soundChannel]->loopPtr = nullptr;
}
// Don't stop the currently playing sound, just set the last played sound to 0.
@@ -188,9 +193,9 @@ void DirectorSound::playCastMember(CastMemberID memberID, uint8 soundChannel, bo
// For looping sounds, keep a copy of the AudioStream so it is
// possible to gracefully stop the playback
if (looping)
- _channels[soundChannel - 1].loopPtr = dynamic_cast<Audio::LoopableAudioStream *>(as);
+ _channels[soundChannel]->loopPtr = dynamic_cast<Audio::LoopableAudioStream *>(as);
else
- _channels[soundChannel - 1].loopPtr = nullptr;
+ _channels[soundChannel]->loopPtr = nullptr;
playStream(*as, soundChannel);
setLastPlayedSound(soundChannel, memberID, stopOnZero);
}
@@ -243,7 +248,7 @@ void SNDDecoder::loadExternalSoundStream(Common::SeekableReadStreamEndian &strea
}
void DirectorSound::registerFade(uint8 soundChannel, bool fadeIn, int ticks) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
// sound enable is not working on fade sounds, so we just return directly when sounds are not enabling
@@ -252,18 +257,18 @@ void DirectorSound::registerFade(uint8 soundChannel, bool fadeIn, int ticks) {
cancelFade(soundChannel);
- int startVol = fadeIn ? 0 : _channels[soundChannel - 1].volume;
- int targetVol = fadeIn ? _channels[soundChannel - 1].volume : 0;
+ int startVol = fadeIn ? 0 : _channels[soundChannel]->volume;
+ int targetVol = fadeIn ? _channels[soundChannel]->volume : 0;
- _channels[soundChannel - 1].fade = new FadeParams(startVol, targetVol, ticks, _window->getVM()->getMacTicks(), fadeIn);
- _mixer->setChannelVolume(_channels[soundChannel - 1].handle, startVol);
+ _channels[soundChannel]->fade = new FadeParams(startVol, targetVol, ticks, _window->getVM()->getMacTicks(), fadeIn);
+ _mixer->setChannelVolume(_channels[soundChannel]->handle, startVol);
}
bool DirectorSound::fadeChannel(uint8 soundChannel) {
- if (!isChannelValid(soundChannel) || !isChannelActive(soundChannel))
+ if (!assertChannel(soundChannel) || !isChannelActive(soundChannel))
return false;
- FadeParams *fade = _channels[soundChannel - 1].fade;
+ FadeParams *fade = _channels[soundChannel]->fade;
if (!fade)
return false;
@@ -280,44 +285,48 @@ bool DirectorSound::fadeChannel(uint8 soundChannel) {
fadeVol = MAX((fade->totalTicks - fade->lapsedTicks) * ((float)fade->startVol / fade->totalTicks), (float)0);
}
- _mixer->setChannelVolume(_channels[soundChannel - 1].handle, fadeVol);
+ _mixer->setChannelVolume(_channels[soundChannel]->handle, fadeVol);
return true;
}
void DirectorSound::cancelFade(uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
// NOTE: It is assumed that soundChannel has already been validated, which is
// why this method is private.
- if (_channels[soundChannel - 1].fade) {
- _mixer->setChannelVolume(_channels[soundChannel - 1].handle, _channels[soundChannel - 1].fade->targetVol);
+ if (_channels[soundChannel]->fade) {
+ _mixer->setChannelVolume(_channels[soundChannel]->handle, _channels[soundChannel]->fade->targetVol);
- delete _channels[soundChannel - 1].fade;
- _channels[soundChannel - 1].fade = nullptr;
+ delete _channels[soundChannel]->fade;
+ _channels[soundChannel]->fade = nullptr;
}
}
bool DirectorSound::isChannelActive(uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return false;
- if (!_mixer->isSoundHandleActive(_channels[soundChannel - 1].handle))
+ if (!_mixer->isSoundHandleActive(_channels[soundChannel]->handle))
return false;
// Looped sounds are considered to be inactive after the first play
// WORKAROUND HACK
- if (_channels[soundChannel - 1].loopPtr != nullptr)
- return _channels[soundChannel - 1].loopPtr->getCompleteIterations() < 1;
+ if (_channels[soundChannel]->loopPtr != nullptr)
+ return _channels[soundChannel]->loopPtr->getCompleteIterations() < 1;
return true;
}
-bool DirectorSound::isChannelValid(uint8 soundChannel) {
- if (soundChannel == 0 || soundChannel > _channels.size()) {
- warning("Invalid sound channel %d", soundChannel);
+bool DirectorSound::assertChannel(int soundChannel) {
+ if (soundChannel <= 0) {
+ warning("DirectorSound::assertChannel(): Invalid sound channel %d", soundChannel);
return false;
}
+ if (!_channels.contains(soundChannel)) {
+ debugC(5, kDebugSound, "DirectorSound::assertChannel(): allocating sound channel %d", soundChannel);
+ _channels[soundChannel] = new SoundChannel();
+ }
return true;
}
@@ -388,7 +397,7 @@ void DirectorSound::unloadSampleSounds() {
}
void DirectorSound::playExternalSound(uint16 menu, uint16 submenu, uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
SoundID soundId(kSoundExternal, menu, submenu);
@@ -414,23 +423,23 @@ void DirectorSound::playExternalSound(uint16 menu, uint16 submenu, uint8 soundCh
}
void DirectorSound::changingMovie() {
- for (uint i = 1; i < _channels.size(); i++) {
- _channels[i - 1].movieChanged = true;
- if (isChannelActive(i)) {
- if (isChannelPuppet(i)) {
- setPuppetSound(SoundID(), i); // disable puppet sound
+ for (auto it : _channels) {
+ it._value->movieChanged = true;
+ if (isChannelActive(it._key)) {
+ if (isChannelPuppet(it._key)) {
+ setPuppetSound(SoundID(), it._key); // disable puppet sound
}
// Don't stop this sound until there's a new, non-zero sound in this channel.
- _channels[i - 1].stopOnZero = false;
+ it._value->stopOnZero = false;
// If this is a looping sound, make it loop automatically until that happens.
- const SoundID &lastPlayedSound = _channels[i - 1].lastPlayedSound;
+ const SoundID &lastPlayedSound = it._value->lastPlayedSound;
if (lastPlayedSound.type == kSoundCast) {
CastMemberID memberID(lastPlayedSound.u.cast.member, lastPlayedSound.u.cast.castLib);
CastMember *soundCast = _window->getCurrentMovie()->getCastMember(memberID);
if (soundCast && soundCast->_type == kCastSound && static_cast<SoundCastMember *>(soundCast)->_looping) {
- _mixer->loopChannel(_channels[i - 1].handle);
+ _mixer->loopChannel(it._value->handle);
}
}
}
@@ -439,41 +448,41 @@ void DirectorSound::changingMovie() {
}
void DirectorSound::setLastPlayedSound(uint8 soundChannel, SoundID soundId, bool stopOnZero) {
- _channels[soundChannel - 1].lastPlayedSound = soundId;
- _channels[soundChannel - 1].stopOnZero = stopOnZero;
- _channels[soundChannel - 1].movieChanged = false;
+ _channels[soundChannel]->lastPlayedSound = soundId;
+ _channels[soundChannel]->stopOnZero = stopOnZero;
+ _channels[soundChannel]->movieChanged = false;
}
bool DirectorSound::isLastPlayedSound(uint8 soundChannel, const SoundID &soundId) {
- return !_channels[soundChannel - 1].movieChanged && _channels[soundChannel - 1].lastPlayedSound == soundId;
+ return !_channels[soundChannel]->movieChanged && _channels[soundChannel]->lastPlayedSound == soundId;
}
bool DirectorSound::shouldStopOnZero(uint8 soundChannel) {
- return _channels[soundChannel - 1].stopOnZero;
+ return _channels[soundChannel]->stopOnZero;
}
void DirectorSound::stopSound(uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
debugC(5, kDebugSound, "DirectorSound::stopSound(): stopping channel %d", soundChannel);
- if (_channels[soundChannel - 1].loopPtr)
- _channels[soundChannel - 1].loopPtr = nullptr;
+ if (_channels[soundChannel]->loopPtr)
+ _channels[soundChannel]->loopPtr = nullptr;
cancelFade(soundChannel);
- _mixer->stopHandle(_channels[soundChannel - 1].handle);
+ _mixer->stopHandle(_channels[soundChannel]->handle);
setLastPlayedSound(soundChannel, SoundID());
return;
}
void DirectorSound::stopSound() {
debugC(5, kDebugSound, "DirectorSound::stopSound(): stopping all channels");
- for (uint i = 0; i < _channels.size(); i++) {
- if (_channels[i].loopPtr)
- _channels[i].loopPtr = nullptr;
- cancelFade(i + 1);
+ for (auto it : _channels) {
+ if (it._value->loopPtr)
+ it._value->loopPtr = nullptr;
+ cancelFade(it._key);
- _mixer->stopHandle(_channels[i].handle);
- setLastPlayedSound(i + 1, SoundID());
+ _mixer->stopHandle(it._value->handle);
+ setLastPlayedSound(it._key, SoundID());
}
_mixer->stopHandle(_scriptSound);
@@ -486,37 +495,37 @@ void DirectorSound::systemBeep() {
}
bool DirectorSound::isChannelPuppet(uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return false;
// cast member ID 0 means "not a puppet"
- if (_channels[soundChannel - 1].puppet.type == kSoundCast && _channels[soundChannel - 1].puppet.u.cast.member == 0)
+ if (_channels[soundChannel]->puppet.type == kSoundCast && _channels[soundChannel]->puppet.u.cast.member == 0)
return false;
return true;
}
void DirectorSound::setPuppetSound(SoundID soundId, uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
- _channels[soundChannel - 1].newPuppet = true;
- _channels[soundChannel - 1].puppet = soundId;
- _channels[soundChannel - 1].stopOnZero = true;
+ _channels[soundChannel]->newPuppet = true;
+ _channels[soundChannel]->puppet = soundId;
+ _channels[soundChannel]->stopOnZero = true;
}
void DirectorSound::playPuppetSound(uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return;
// only play if the puppet was just set
- if (!_channels[soundChannel - 1].newPuppet)
+ if (!_channels[soundChannel]->newPuppet)
return;
debugC(5, kDebugSound, "DirectorSound::playPuppetSound(): playing on channel %d", soundChannel);
- _channels[soundChannel - 1].newPuppet = false;
- playSound(_channels[soundChannel - 1].puppet, soundChannel, true);
+ _channels[soundChannel]->newPuppet = false;
+ playSound(_channels[soundChannel]->puppet, soundChannel, true);
}
void DirectorSound::playFPlaySound() {
@@ -602,9 +611,9 @@ void DirectorSound::playFPlaySound(const Common::Array<Common::String> &fplayLis
void DirectorSound::setSoundLevelInternal(uint8 soundChannel, uint8 soundLevel) {
// we have 8 level of sounds, and in ScummVM, we have range 0 to 255, thus 1 level represent 32
- _channels[soundChannel - 1].volume = soundLevel * 32;
+ _channels[soundChannel]->volume = soundLevel * 32;
if (_enable && isChannelActive(soundChannel))
- _mixer->setChannelVolume(_channels[soundChannel - 1].handle, _channels[soundChannel - 1].volume);
+ _mixer->setChannelVolume(_channels[soundChannel]->handle, _channels[soundChannel]->volume);
}
// -1 represent all the sound channel
@@ -615,7 +624,7 @@ void DirectorSound::setSoundLevel(int channel, uint8 soundLevel) {
}
if (channel != -1) {
- if (!isChannelValid(channel))
+ if (!assertChannel(channel))
return;
debugC(5, kDebugSound, "DirectorSound::setSoundLevel: setting channel %d to level %d", channel, soundLevel);
setSoundLevelInternal(channel, soundLevel);
@@ -627,9 +636,9 @@ void DirectorSound::setSoundLevel(int channel, uint8 soundLevel) {
}
uint8 DirectorSound::getSoundLevel(uint8 soundChannel) {
- if (!isChannelValid(soundChannel))
+ if (!assertChannel(soundChannel))
return 0;
- return _channels[soundChannel - 1].volume / 32;
+ return _channels[soundChannel]->volume / 32;
}
SNDDecoder::SNDDecoder()
diff --git a/engines/director/sound.h b/engines/director/sound.h
index 5e323319aba..af41b0357f2 100644
--- a/engines/director/sound.h
+++ b/engines/director/sound.h
@@ -157,7 +157,7 @@ class DirectorSound {
private:
Window *_window;
- Common::Array<SoundChannel> _channels;
+ Common::HashMap<int, SoundChannel *> _channels;
Audio::SoundHandle _scriptSound;
Audio::Mixer *_mixer;
Audio::PCSpeaker *_speaker;
@@ -193,10 +193,6 @@ public:
void loadSampleSounds(uint type);
void unloadSampleSounds();
- void setLastPlayedSound(uint8 soundChannel, SoundID soundId, bool stopOnZero = true);
- bool isLastPlayedSound(uint8 soundChannel, const SoundID &soundId);
- bool shouldStopOnZero(uint8 soundChannel);
-
bool isChannelPuppet(uint8 soundChannel);
void setPuppetSound(SoundID soundId, uint8 soundChannel);
void playPuppetSound(uint8 soundChannel);
@@ -213,9 +209,13 @@ public:
void stopSound();
private:
+ void setLastPlayedSound(uint8 soundChannel, SoundID soundId, bool stopOnZero = true);
+ bool isLastPlayedSound(uint8 soundChannel, const SoundID &soundId);
+ bool shouldStopOnZero(uint8 soundChannel);
+
uint8 getChannelVolume(uint8 soundChannel);
void setSoundLevelInternal(uint8 soundChannel, uint8 soundLevel);
- bool isChannelValid(uint8 soundChannel);
+ bool assertChannel(int soundChannel);
void cancelFade(uint8 soundChannel);
};
Commit: 2065a7d39cc4c89def6db7d0924b3445878666c0
https://github.com/scummvm/scummvm/commit/2065a7d39cc4c89def6db7d0924b3445878666c0
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Fix D5 looping sound support
Fixes the intro fadeout of The Cute machine.
Changed paths:
engines/director/cast.cpp
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 7f2ec709d9f..0e9d9b75ca8 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -1251,7 +1251,7 @@ void Cast::loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id) {
}
// For SoundCastMember, read the flags in the CastInfo
- if (_version >= kFileVer400 && _version < kFileVer500 && member->_type == kCastSound) {
+ if (_version >= kFileVer400 && _version < kFileVer600 && member->_type == kCastSound) {
((SoundCastMember *)member)->_looping = castInfo.flags & 16 ? 0 : 1;
}
Commit: 343a17701676b8906462cbf182ef766e8f1752ea
https://github.com/scummvm/scummvm/commit/343a17701676b8906462cbf182ef766e8f1752ea
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Add new lookup table for D5 palette fade times
When fading a palette, Director lets you pick a "frame rate" between 1
and 30. These each correspond to a fixed transition time, with the
higher framerates converging to zero.
In D4 and under the slowest of these frame rates is half a second.
After some user feedback they changed this in D5 to be a range
of times, ranging from a leisurely 16.5 seconds all the way to
instantaneous.
Fixes the intro fade in The Cute machine.
Changed paths:
engines/director/cast.cpp
engines/director/palette-fade.h
engines/director/score.cpp
diff --git a/engines/director/cast.cpp b/engines/director/cast.cpp
index 0e9d9b75ca8..b209a7c52c4 100644
--- a/engines/director/cast.cpp
+++ b/engines/director/cast.cpp
@@ -1253,6 +1253,8 @@ void Cast::loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id) {
// For SoundCastMember, read the flags in the CastInfo
if (_version >= kFileVer400 && _version < kFileVer600 && member->_type == kCastSound) {
((SoundCastMember *)member)->_looping = castInfo.flags & 16 ? 0 : 1;
+ } else if (_version >= kFileVer600 && member->_type == kCastSound) {
+ warning("STUB: Cast::loadCastInfo(): Sound cast member info not yet supported for version %d", _version);
}
// For FilmLoopCastMember, read the flags in the CastInfo
@@ -1261,6 +1263,8 @@ void Cast::loadCastInfo(Common::SeekableReadStreamEndian &stream, uint16 id) {
((FilmLoopCastMember *)member)->_enableSound = castInfo.flags & 8 ? 1 : 0;
((FilmLoopCastMember *)member)->_crop = castInfo.flags & 2 ? 0 : 1;
((FilmLoopCastMember *)member)->_center = castInfo.flags & 1 ? 1 : 0;
+ } else if (_version >= kFileVer500 && member->_type == kCastFilmLoop) {
+ warning("STUB: Cast::loadCastInfo(): Film loop cast member info not yet supported for version %d", _version);
}
ci->autoHilite = castInfo.flags & 2;
diff --git a/engines/director/palette-fade.h b/engines/director/palette-fade.h
index c6ab6ed41e3..f2fd60545cc 100644
--- a/engines/director/palette-fade.h
+++ b/engines/director/palette-fade.h
@@ -163,4 +163,10 @@ static int kFadeColorFrames[30] = {
5, 4, 3, 3, 2, 2, 2, 1, 1, 1
};
-static int fadeColorWait = 30;
+static int kFadeColorFramesD5[30] = {
+ 989, 955, 921, 887, 852, 818, 783, 750, 715, 680,
+ 646, 612, 578, 543, 509, 475, 440, 406, 372, 337,
+ 303, 269, 234, 200, 166, 131, 97, 63, 28, 1
+};
+
+static int kFadeColorWait = 30;
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 74076ebab04..4a9e2b257b4 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -687,6 +687,8 @@ bool Score::renderPrePaletteCycle(uint16 frameId, RenderMode mode) {
int frameDelay = 1000/60;
int fadeFrames = kFadeColorFrames[frameRate - 1];
+ if (_vm->getVersion() >= 500)
+ fadeFrames = kFadeColorFramesD5[frameRate - 1];
byte calcPal[768];
// Copy the current palette into the snapshot buffer
@@ -971,11 +973,13 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
int frameDelay = 1000/60;
int fadeFrames = kFadeColorFrames[frameRate - 1];
+ if (_vm->getVersion() >= 500)
+ fadeFrames = kFadeColorFramesD5[frameRate - 1];
// Wait for a fixed time
g_director->setPalette(fadePal, 256);
g_director->draw();
- for (int i = 0; i < fadeColorWait; i++) {
+ for (int i = 0; i < kFadeColorWait; i++) {
// On click, stop loop and reset palette
if (_vm->processEvents(true)) {
debugC(2, kDebugImages, "Score::renderPaletteCycle(): interrupted, setting palette to %s", currentPalette.asString().c_str());
Commit: e0c7bec4886559c431ac04dc068a9a7684ae8ca1
https://github.com/scummvm/scummvm/commit/e0c7bec4886559c431ac04dc068a9a7684ae8ca1
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Fade sounds if the channel handle exists
isChannelActive() excludes looping sounds, which are allowed to
be faded in or out.
Fixes the intro music fading in The Cute machine.
Changed paths:
engines/director/sound.cpp
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 8202db42d4a..ae0d033bc93 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -251,6 +251,8 @@ void DirectorSound::registerFade(uint8 soundChannel, bool fadeIn, int ticks) {
if (!assertChannel(soundChannel))
return;
+ debugC(5, kDebugSound, "DirectorSound::registerFade(): registered fading channel %d %s over %d ticks", soundChannel, fadeIn ? "in" : "out", ticks);
+
// sound enable is not working on fade sounds, so we just return directly when sounds are not enabling
if (!_enable)
return;
@@ -265,7 +267,10 @@ void DirectorSound::registerFade(uint8 soundChannel, bool fadeIn, int ticks) {
}
bool DirectorSound::fadeChannel(uint8 soundChannel) {
- if (!assertChannel(soundChannel) || !isChannelActive(soundChannel))
+ if (!assertChannel(soundChannel))
+ return false;
+
+ if (!_mixer->isSoundHandleActive(_channels[soundChannel]->handle))
return false;
FadeParams *fade = _channels[soundChannel]->fade;
@@ -285,6 +290,7 @@ bool DirectorSound::fadeChannel(uint8 soundChannel) {
fadeVol = MAX((fade->totalTicks - fade->lapsedTicks) * ((float)fade->startVol / fade->totalTicks), (float)0);
}
+ debugC(5, kDebugSound, "DirectorSound::fadeChannel(): fading channel %d volume to %d", soundChannel, fadeVol);
_mixer->setChannelVolume(_channels[soundChannel]->handle, fadeVol);
return true;
}
Commit: 3b5500227ab713b76298c263eed67cd5c27c24ca
https://github.com/scummvm/scummvm/commit/3b5500227ab713b76298c263eed67cd5c27c24ca
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Update the current sound fade during a palette transition
Fixes the intro music fading in The Cute machine.
Changed paths:
engines/director/score.cpp
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index 4a9e2b257b4..1ca5c0e2a6c 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -705,6 +705,7 @@ bool Score::renderPrePaletteCycle(uint16 frameId, RenderMode mode) {
// the previous frame's layout.
debugC(2, kDebugImages, "Score::renderPrePaletteCycle(): fading palette to %s over %d frames", currentPalette.asString().c_str(), fadeFrames);
for (int i = 0; i < fadeFrames; i++) {
+ uint32 startTime = g_system->getMillis();
lerpPalette(
calcPal,
_paletteSnapshotBuffer, 256,
@@ -714,13 +715,19 @@ bool Score::renderPrePaletteCycle(uint16 frameId, RenderMode mode) {
);
g_director->setPalette(calcPal, 256);
g_director->draw();
+ if (_activeFade) {
+ if (!_soundManager->fadeChannel(_activeFade))
+ _activeFade = 0;
+ }
// On click, stop loop and reset palette
if (_vm->processEvents(true)) {
debugC(2, kDebugImages, "Score::renderPrePaletteCycle(): interrupted, setting palette to %s", currentPalette.asString().c_str());
g_director->setPalette(currentPalette);
return true;
}
- g_director->delayMillis(frameDelay);
+ uint32 endTime = g_system->getMillis();
+ int diff = (int)frameDelay - (int)(endTime - startTime);
+ g_director->delayMillis(MAX(0, diff));
}
} else {
@@ -742,6 +749,7 @@ bool Score::renderPrePaletteCycle(uint16 frameId, RenderMode mode) {
}
for (int i = 0; i < fadeFrames; i++) {
+ uint32 startTime = g_system->getMillis();
lerpPalette(
calcPal,
_paletteSnapshotBuffer, 256,
@@ -751,13 +759,19 @@ bool Score::renderPrePaletteCycle(uint16 frameId, RenderMode mode) {
);
g_director->setPalette(calcPal, 256);
g_director->draw();
+ if (_activeFade) {
+ if (!_soundManager->fadeChannel(_activeFade))
+ _activeFade = 0;
+ }
// On click, stop loop and reset palette
if (_vm->processEvents(true)) {
debugC(2, kDebugImages, "Score::renderPrePaletteCycle(): interrupted, setting palette to %s", currentPalette.asString().c_str());
g_director->setPalette(currentPalette);
return true;
}
- g_director->delayMillis(frameDelay);
+ uint32 endTime = g_system->getMillis();
+ int diff = (int)frameDelay - (int)(endTime - startTime);
+ g_director->delayMillis(MAX(0, diff));
}
}
}
@@ -855,25 +869,39 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
debugC(2, kDebugImages, "Score::renderPaletteCycle(): color cycle palette %s, from colors %d to %d, over %d steps %d times", currentPalette.asString().c_str(), firstColor, lastColor, steps, _frames[frameId]->_palette.cycleCount);
for (int i = 0; i < _frames[frameId]->_palette.cycleCount; i++) {
for (int j = 0; j < steps; j++) {
+ uint32 startTime = g_system->getMillis();
g_director->shiftPalette(firstColor, lastColor, false);
g_director->draw();
+ if (_activeFade) {
+ if (!_soundManager->fadeChannel(_activeFade))
+ _activeFade = 0;
+ }
// On click, stop loop and reset palette
if (_vm->processEvents(true)) {
g_director->setPalette(currentPalette);
return;
}
- g_director->delayMillis(delay);
+ uint32 endTime = g_system->getMillis();
+ int diff = (int)delay - (int)(endTime - startTime);
+ g_director->delayMillis(MAX(0, diff));
}
if (_frames[frameId]->_palette.autoReverse) {
for (int j = 0; j < steps; j++) {
+ uint32 startTime = g_system->getMillis();
g_director->shiftPalette(firstColor, lastColor, true);
g_director->draw();
+ if (_activeFade) {
+ if (!_soundManager->fadeChannel(_activeFade))
+ _activeFade = 0;
+ }
// On click, stop loop and reset palette
if (_vm->processEvents(true)) {
g_director->setPalette(currentPalette);
return;
}
- g_director->delayMillis(delay);
+ uint32 endTime = g_system->getMillis();
+ int diff = (int)delay - (int)(endTime - startTime);
+ g_director->delayMillis(MAX(0, diff));
}
}
}
@@ -980,18 +1008,26 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
g_director->setPalette(fadePal, 256);
g_director->draw();
for (int i = 0; i < kFadeColorWait; i++) {
+ uint32 startTime = g_system->getMillis();
+ if (_activeFade) {
+ if (!_soundManager->fadeChannel(_activeFade))
+ _activeFade = 0;
+ }
// On click, stop loop and reset palette
if (_vm->processEvents(true)) {
debugC(2, kDebugImages, "Score::renderPaletteCycle(): interrupted, setting palette to %s", currentPalette.asString().c_str());
g_director->setPalette(currentPalette);
return;
}
- g_director->delayMillis(frameDelay);
+ uint32 endTime = g_system->getMillis();
+ int diff = (int)frameDelay - (int)(endTime - startTime);
+ g_director->delayMillis(MAX(0, diff));
}
debugC(2, kDebugImages, "Score::renderPaletteCycle(): fading palette to %s over %d frames", currentPalette.asString().c_str(), fadeFrames);
for (int i = 0; i < fadeFrames; i++) {
+ uint32 startTime = g_system->getMillis();
lerpPalette(
calcPal,
fadePal, 256,
@@ -1001,13 +1037,19 @@ void Score::renderPaletteCycle(uint16 frameId, RenderMode mode) {
);
g_director->setPalette(calcPal, 256);
g_director->draw();
+ if (_activeFade) {
+ if (!_soundManager->fadeChannel(_activeFade))
+ _activeFade = 0;
+ }
// On click, stop loop and reset palette
if (_vm->processEvents(true)) {
debugC(2, kDebugImages, "Score::renderPaletteCycle(): interrupted, setting palette to %s", currentPalette.asString().c_str());
g_director->setPalette(currentPalette);
return;
}
- g_director->delayMillis(frameDelay);
+ uint32 endTime = g_system->getMillis();
+ int diff = (int)frameDelay - (int)(endTime - startTime);
+ g_director->delayMillis(MAX(0, diff));
}
}
Commit: e49e64345b2c704ef9549e1120b6bd652e4ec764
https://github.com/scummvm/scummvm/commit/e49e64345b2c704ef9549e1120b6bd652e4ec764
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Make BitmapCastMember::_bitsPerPixel a uint8
Fixes several bitmaps in The Cute machine.
Changed paths:
engines/director/castmember/bitmap.cpp
engines/director/castmember/bitmap.h
diff --git a/engines/director/castmember/bitmap.cpp b/engines/director/castmember/bitmap.cpp
index 331757737b0..899e5eb8636 100644
--- a/engines/director/castmember/bitmap.cpp
+++ b/engines/director/castmember/bitmap.cpp
@@ -56,6 +56,10 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
_bitsPerPixel = 0;
_external = false;
+ if (debugChannelSet(5, kDebugLoading)) {
+ stream.hexdump(stream.size());
+ }
+
if (version < kFileVer400) {
_flags1 = flags1; // region: 0 - auto, 1 - matte, 2 - disabled
@@ -95,7 +99,8 @@ BitmapCastMember::BitmapCastMember(Cast *cast, uint16 castId, Common::SeekableRe
_regY = stream.readUint16();
_regX = stream.readUint16();
- _bitsPerPixel = stream.readUint16();
+ stream.readByte();
+ _bitsPerPixel = stream.readByte();
if (stream.eos()) {
_bitsPerPixel = 0;
diff --git a/engines/director/castmember/bitmap.h b/engines/director/castmember/bitmap.h
index 8ba47cac4bc..ee1efae3f97 100644
--- a/engines/director/castmember/bitmap.h
+++ b/engines/director/castmember/bitmap.h
@@ -67,7 +67,7 @@ public:
CastMemberID _clut;
CastMemberID _ditheredTargetClut;
- uint16 _bitsPerPixel;
+ uint8 _bitsPerPixel;
uint32 _tag;
bool _noMatte;
Commit: a379602443ec985d79f4e23c3f04f8bfe40ee19d
https://github.com/scummvm/scummvm/commit/a379602443ec985d79f4e23c3f04f8bfe40ee19d
Author: Scott Percival (code at moral.net.au)
Date: 2023-05-10T22:32:21+02:00
Commit Message:
DIRECTOR: Hide null calls to Movie::getScriptContext()
Changed paths:
engines/director/movie.cpp
diff --git a/engines/director/movie.cpp b/engines/director/movie.cpp
index 13012e95151..f3bbaa44339 100644
--- a/engines/director/movie.cpp
+++ b/engines/director/movie.cpp
@@ -488,7 +488,7 @@ ScriptContext *Movie::getScriptContext(ScriptType type, CastMemberID id) {
if (result == nullptr && _sharedCast) {
result = _sharedCast->_lingoArchive->getScriptContext(type, id.member);
}
- } else {
+ } else if (!id.isNull()) {
warning("Movie::getScriptContext: Unknown castLib %d", id.castLib);
}
return result;
More information about the Scummvm-git-logs
mailing list