[Scummvm-git-logs] scummvm master -> 8d50d855e6f13d5a308f036f6ad32df85c42afa3
moralrecordings
code at moral.net.au
Wed Jun 3 14:09:19 UTC 2020
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
56069ac9db DIRECTOR: LINGO: Implement kTheMovie
0c97ec1764 DIRECTOR: LINGO: Let scripts finish executing before stopping
8d50d855e6 DIRECTOR: Implement playSoundChannel
Commit: 56069ac9dbf11f6ff4aa01264fbefc39d0709df5
https://github.com/scummvm/scummvm/commit/56069ac9dbf11f6ff4aa01264fbefc39d0709df5
Author: Scott Percival (code at moral.net.au)
Date: 2020-06-03T19:04:12+08:00
Commit Message:
DIRECTOR: LINGO: Implement kTheMovie
Changed paths:
engines/director/lingo/lingo-the.cpp
diff --git a/engines/director/lingo/lingo-the.cpp b/engines/director/lingo/lingo-the.cpp
index db366b6677..93fbd4a66d 100644
--- a/engines/director/lingo/lingo-the.cpp
+++ b/engines/director/lingo/lingo-the.cpp
@@ -434,6 +434,10 @@ Datum Lingo::getTheEntity(int entity, Datum &id, int field) {
d.type = INT;
d.u.i = _vm->_machineType;
break;
+ case kTheMovie:
+ d.type = STRING;
+ d.u.s = new Common::String(_vm->getCurrentScore()->getArchive()->getFileName());
+ break;
case kTheMouseCast:
{
Common::Point pos = g_system->getEventManager()->getMousePos();
Commit: 0c97ec17647f7e544c40d323356823500070b1e3
https://github.com/scummvm/scummvm/commit/0c97ec17647f7e544c40d323356823500070b1e3
Author: Scott Percival (code at moral.net.au)
Date: 2020-06-03T20:16:50+08:00
Commit Message:
DIRECTOR: LINGO: Let scripts finish executing before stopping
Changed paths:
engines/director/lingo/lingo-codegen.cpp
diff --git a/engines/director/lingo/lingo-codegen.cpp b/engines/director/lingo/lingo-codegen.cpp
index d432575405..24ccde1622 100644
--- a/engines/director/lingo/lingo-codegen.cpp
+++ b/engines/director/lingo/lingo-codegen.cpp
@@ -87,9 +87,6 @@ void Lingo::execute(uint pc) {
break;
}
- if (_vm->getCurrentScore() && _vm->getCurrentScore()->_stopPlay)
- break;
-
if (++counter > 1000 && debugChannelSet(-1, kDebugFewFramesOnly)) {
warning("Lingo::execute(): Stopping due to debug few frames only");
break;
Commit: 8d50d855e6f13d5a308f036f6ad32df85c42afa3
https://github.com/scummvm/scummvm/commit/8d50d855e6f13d5a308f036f6ad32df85c42afa3
Author: Scott Percival (code at moral.net.au)
Date: 2020-06-03T22:08:45+08:00
Commit Message:
DIRECTOR: Implement playSoundChannel
Changed paths:
engines/director/director.cpp
engines/director/lingo/lingo-builtins.cpp
engines/director/score.cpp
engines/director/sound.cpp
engines/director/sound.h
diff --git a/engines/director/director.cpp b/engines/director/director.cpp
index d765e4555f..55cf583f93 100644
--- a/engines/director/director.cpp
+++ b/engines/director/director.cpp
@@ -139,7 +139,7 @@ Common::Error DirectorEngine::run() {
_wm->setEngine(this);
_lingo = new Lingo(this);
- _soundManager = new DirectorSound();
+ _soundManager = new DirectorSound(this);
if (getGameGID() == GID_TEST) {
_mainArchive = nullptr;
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 635ae800db..99c6ee71f3 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1679,47 +1679,19 @@ void LB::b_puppetPalette(int nargs) {
}
void LB::b_puppetSound(int nargs) {
- if (nargs != 1) {
- warning("STUB: b_puppetSound: more than 1 argument, got %d", nargs);
- g_lingo->dropStack(nargs);
- return;
- }
- Score *score = g_director->getCurrentScore();
+ ARGNUMCHECK(1);
DirectorSound *sound = g_director->getSoundManager();
Datum castMember = g_lingo->pop();
+ Score *score = g_director->getCurrentScore();
if (!score) {
warning("b_puppetSound(): no score");
-
return;
}
int castId = g_lingo->castIdFetch(castMember);
-
- if (castId == 0) {
- sound->stopSound(1);
- } else {
- Cast *cast = g_director->getCastMember(castId);
- if (!cast) {
- warning("b_puppetSound: attempted to play a NULL cast member");
- return;
- } else if (cast->_type != kCastSound) {
- error("b_puppetSound: attempted to play a non-SoundCast cast member");
- return;
- }
- bool looping = ((SoundCast *)cast)->_looping;
- SNDDecoder *sd = ((SoundCast *)cast)->_audio;
- if (!sd) {
- warning("b_puppetSound: no audio data attached to cast");
- return;
- }
- if (looping)
- sound->playStream(*sd->getLoopingAudioStream(), 1);
- else
- sound->playStream(*sd->getAudioStream(), 1);
- }
-
+ sound->playCastMember(castId, 1);
}
void LB::b_puppetSprite(int nargs) {
diff --git a/engines/director/score.cpp b/engines/director/score.cpp
index ceaf7289df..b12b944bcb 100644
--- a/engines/director/score.cpp
+++ b/engines/director/score.cpp
@@ -2212,7 +2212,11 @@ Sprite *Score::getSpriteById(uint16 id) {
void Score::playSoundChannel(uint16 frameId) {
Frame *frame = _frames[frameId];
- debug(0, "STUB: playSoundChannel(), Sound1 %d Sound2 %d", frame->_sound1, frame->_sound2);
+
+ debugC(5, kDebugLoading, "playSoundChannel(), Sound1 %d Sound2 %d", frame->_sound1, frame->_sound2);
+ DirectorSound *sound = _vm->getSoundManager();
+ sound->playCastMember(frame->_sound1, 1, false);
+ sound->playCastMember(frame->_sound2, 2, false);
}
void Score::addZoomBox(ZoomBox *box) {
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 6d8e0d8f2e..933b0a2723 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -30,11 +30,12 @@
#include "audio/decoders/aiff.h"
#include "director/director.h"
+#include "director/cast.h"
#include "director/sound.h"
namespace Director {
-DirectorSound::DirectorSound() {
+DirectorSound::DirectorSound(DirectorEngine *vm) : _vm(vm) {
uint numChannels = 2;
if (g_director->getVersion() >= 4) {
numChannels = 4;
@@ -42,6 +43,7 @@ DirectorSound::DirectorSound() {
for (uint i = 0; i < numChannels; i++) {
_channels.push_back(new Audio::SoundHandle());
+ _lastPlayingCasts.push_back(0);
}
_scriptSound = new Audio::SoundHandle();
@@ -96,6 +98,7 @@ void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) {
return;
}
+ _lastPlayingCasts[soundChannel - 1] = 0;
Common::File *file = new Common::File();
@@ -118,6 +121,7 @@ void DirectorSound::playAIFF(Common::String filename, uint8 soundChannel) {
warning("Invalid sound channel %d", soundChannel);
return;
}
+ _lastPlayingCasts[soundChannel - 1] = 0;
Common::File *file = new Common::File();
@@ -151,6 +155,35 @@ void DirectorSound::playStream(Audio::AudioStream &stream, uint8 soundChannel) {
_mixer->playStream(Audio::Mixer::kSFXSoundType, _channels[soundChannel - 1], &stream);
}
+void DirectorSound::playCastMember(int castId, uint8 soundChannel, bool allowRepeat) {
+ if (castId == 0) {
+ stopSound(soundChannel);
+ } else {
+ Cast *soundCast = _vm->getCastMember(castId);
+ if (soundCast) {
+ if (soundCast->_type != kCastSound) {
+ warning("DirectorSound::playCastMember: attempted to play a non-SoundCast cast member %d", castId);
+ } else {
+ if (!allowRepeat && lastPlayingCast(soundChannel) == castId)
+ return;
+ bool looping = ((SoundCast *)soundCast)->_looping;
+ SNDDecoder *sd = ((SoundCast *)soundCast)->_audio;
+ if (!sd) {
+ warning("DirectorSound::playCastMember: no audio data attached to cast member %d", castId);
+ return;
+ }
+ if (looping)
+ playStream(*sd->getLoopingAudioStream(), soundChannel);
+ else
+ playStream(*sd->getAudioStream(), soundChannel);
+ _lastPlayingCasts[soundChannel - 1] = castId;
+ }
+ } else {
+ warning("DirectorSound::playCastMember: couldn't find cast member %d", castId);
+ }
+ }
+}
+
bool DirectorSound::isChannelActive(uint8 soundChannel) {
if (soundChannel == 0 || soundChannel > _channels.size()) {
warning("Invalid sound channel %d", soundChannel);
@@ -160,6 +193,15 @@ bool DirectorSound::isChannelActive(uint8 soundChannel) {
return _mixer->isSoundHandleActive(*_channels[soundChannel - 1]);
}
+int DirectorSound::lastPlayingCast(uint8 soundChannel) {
+ if (soundChannel == 0 || soundChannel > _channels.size()) {
+ warning("Invalid sound channel %d", soundChannel);
+ return false;
+ }
+
+ return _lastPlayingCasts[soundChannel - 1];
+}
+
void DirectorSound::stopSound(uint8 soundChannel) {
if (soundChannel == 0 || soundChannel > _channels.size()) {
warning("Invalid sound channel %d", soundChannel);
@@ -167,12 +209,14 @@ void DirectorSound::stopSound(uint8 soundChannel) {
}
_mixer->stopHandle(*_channels[soundChannel - 1]);
+ _lastPlayingCasts[soundChannel - 1] = 0;
return;
}
void DirectorSound::stopSound() {
for (uint i = 0; i < _channels.size(); i++) {
_mixer->stopHandle(*_channels[i]);
+ _lastPlayingCasts[i] = 0;
}
_mixer->stopHandle(*_scriptSound);
_mixer->stopHandle(*_pcSpeakerHandle);
diff --git a/engines/director/sound.h b/engines/director/sound.h
index 21f6d8e6e1..88c3514dcb 100644
--- a/engines/director/sound.h
+++ b/engines/director/sound.h
@@ -35,14 +35,16 @@ namespace Director {
class DirectorSound {
private:
+ DirectorEngine *_vm;
Common::Array<Audio::SoundHandle *> _channels;
+ Common::Array<int> _lastPlayingCasts;
Audio::SoundHandle *_scriptSound;
Audio::Mixer *_mixer;
Audio::PCSpeaker *_speaker;
Audio::SoundHandle *_pcSpeakerHandle;
public:
- DirectorSound();
+ DirectorSound(DirectorEngine *vm);
~DirectorSound();
void playWAV(Common::String filename, uint8 soundChannel);
@@ -50,8 +52,10 @@ public:
void playFile(Common::String filename, uint8 soundChannel);
void playMCI(Audio::AudioStream &stream, uint32 from, uint32 to);
void playStream(Audio::AudioStream &stream, uint8 soundChannel);
+ void playCastMember(int castId, uint8 soundChannel, bool allowRepeat = true);
void systemBeep();
bool isChannelActive(uint8 soundChannel);
+ int lastPlayingCast(uint8 soundChannel);
void stopSound(uint8 soundChannel);
void stopSound();
};
More information about the Scummvm-git-logs
mailing list