[Scummvm-git-logs] scummvm master -> cacc668cec7f226a4c38d81b717efbcd96ffc0bc
moralrecordings
code at moral.net.au
Sat Mar 28 04:55:50 UTC 2020
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
3c654b1dad DIRECTOR: LINGO: Implement b_sound features
cacc668cec DIRECTOR: LINGO: Add b_sound wrapper for bytecode engine
Commit: 3c654b1dad304655c491d610241319b7c82de7b7
https://github.com/scummvm/scummvm/commit/3c654b1dad304655c491d610241319b7c82de7b7
Author: Scott Percival (code at moral.net.au)
Date: 2020-03-28T12:55:20+08:00
Commit Message:
DIRECTOR: LINGO: Implement b_sound features
Changed paths:
engines/director/lingo/lingo-builtins.cpp
engines/director/sound.cpp
engines/director/sound.h
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index 3960bb9906..d345fb5709 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -1696,15 +1696,27 @@ void LB::b_mciwait(int nargs) {
}
void LB::b_soundBusy(int nargs) {
- g_lingo->printSTUBWithArglist("b_soundBusy", nargs);
+ if (nargs != 1) {
+ error("b_soundBusy: expected 1 argument, got %d", nargs);
+ g_lingo->dropStack(nargs);
+ return;
+ }
- g_lingo->dropStack(nargs);
+ DirectorSound *sound = g_director->getSoundManager();
+ Datum whichChannel = g_lingo->pop();
+ if (whichChannel.type != INT) {
+ warning("b_soundBusy(): whichChannel arg should be of type INT, not %s", whichChannel.type2str());
+ return;
+ }
+ bool isBusy = sound->isChannelActive(whichChannel.u.i);
+ Datum result;
+ result.type = INT;
+ result.u.i = isBusy ? 1 : 0;
+ g_lingo->push(result);
}
void LB::b_soundClose(int nargs) {
- g_lingo->printSTUBWithArglist("b_soundClose", nargs);
-
- g_lingo->dropStack(nargs);
+ b_soundStop(nargs);
}
void LB::b_soundFadeIn(int nargs) {
@@ -1720,15 +1732,42 @@ void LB::b_soundFadeOut(int nargs) {
}
void LB::b_soundPlayFile(int nargs) {
- g_lingo->printSTUBWithArglist("b_soundPlayFile", nargs);
+ if (nargs != 2) {
+ error("b_soundPlayFile: expected 2 arguments, got %d", nargs);
+ g_lingo->dropStack(nargs);
+ return;
+ }
- g_lingo->dropStack(nargs);
+ Datum whichFile = g_lingo->pop();
+ if (whichFile.type != STRING) {
+ warning("b_soundPlayFile(): whichFile arg should be of type STRING, not %s", whichFile.type2str());
+ return;
+ }
+
+ DirectorSound *sound = g_director->getSoundManager();
+ Datum whichChannel = g_lingo->pop();
+ if (whichChannel.type != INT) {
+ warning("b_soundPlayFile(): whichChannel arg should be of type INT, not %s", whichChannel.type2str());
+ return;
+ }
+
+ sound->playFile(*whichFile.u.s, whichChannel.u.i);
}
void LB::b_soundStop(int nargs) {
- g_lingo->printSTUBWithArglist("b_soundStop", nargs);
+ if (nargs != 1) {
+ error("b_soundStop: expected 1 argument, got %d", nargs);
+ g_lingo->dropStack(nargs);
+ return;
+ }
- g_lingo->dropStack(nargs);
+ DirectorSound *sound = g_director->getSoundManager();
+ Datum whichChannel = g_lingo->pop();
+ if (whichChannel.type != INT) {
+ warning("b_soundStop(): whichChannel arg should be of type INT, not %s", whichChannel.type2str());
+ return;
+ }
+ sound->stopSound(whichChannel.u.i);
}
///////////////////
diff --git a/engines/director/sound.cpp b/engines/director/sound.cpp
index 931fc3a805..a612bfb291 100644
--- a/engines/director/sound.cpp
+++ b/engines/director/sound.cpp
@@ -52,6 +52,33 @@ DirectorSound::~DirectorSound() {
delete _scriptSound;
}
+void DirectorSound::playFile(Common::String filename, uint8 soundChannel) {
+ Common::File *file = new Common::File();
+
+ if (!file->open(filename)) {
+ warning("Failed to open %s", filename.c_str());
+
+ delete file;
+
+ return;
+ }
+
+ uint32 magic1 = file->readUint32BE();
+ file->readUint32BE();
+ uint32 magic2 = file->readUint32BE();
+ delete file;
+
+ if (magic1 == MKTAG('R', 'I', 'F', 'F') &&
+ magic2 == MKTAG('W', 'A', 'V', 'E')) {
+ playWAV(filename, soundChannel);
+ } else if (magic1 == MKTAG('F', 'O', 'R', 'M') &&
+ magic2 == MKTAG('A', 'I', 'F', 'F')) {
+ playAIFF(filename, soundChannel);
+ } else {
+ warning("Unknown file type for %s", filename.c_str());
+ }
+}
+
void DirectorSound::playWAV(Common::String filename, uint8 soundChannel) {
Common::File *file = new Common::File();
diff --git a/engines/director/sound.h b/engines/director/sound.h
index 38677a4a53..107d76d9e1 100644
--- a/engines/director/sound.h
+++ b/engines/director/sound.h
@@ -48,6 +48,7 @@ public:
void playWAV(Common::String filename, uint8 channelID);
void playAIFF(Common::String filename, uint8 channelID);
+ void playFile(Common::String filename, uint8 channelID);
void playMCI(Audio::AudioStream &stream, uint32 from, uint32 to);
void playStream(Audio::AudioStream &stream, uint8 soundChannel);
void playStream(Audio::SeekableAudioStream &stream, uint8 soundChannel);
Commit: cacc668cec7f226a4c38d81b717efbcd96ffc0bc
https://github.com/scummvm/scummvm/commit/cacc668cec7f226a4c38d81b717efbcd96ffc0bc
Author: Scott Percival (code at moral.net.au)
Date: 2020-03-28T12:55:26+08:00
Commit Message:
DIRECTOR: LINGO: Add b_sound wrapper for bytecode engine
Changed paths:
engines/director/lingo/lingo-builtins.cpp
engines/director/lingo/lingo-builtins.h
diff --git a/engines/director/lingo/lingo-builtins.cpp b/engines/director/lingo/lingo-builtins.cpp
index d345fb5709..a048b6df53 100644
--- a/engines/director/lingo/lingo-builtins.cpp
+++ b/engines/director/lingo/lingo-builtins.cpp
@@ -197,6 +197,7 @@ static struct BuiltinProto {
{ "beep", LB::b_beep, 0, 1, false, 2, BLTIN }, // D2
{ "mci", LB::b_mci, 1, 1, false, 3, BLTIN }, // D3.1 c
{ "mciwait", LB::b_mciwait, 1, 1, false, 4, BLTIN }, // D4 c
+ { "sound", LB::b_sound, 2, 3, false, 3, BLTIN }, // D3 c
{ "sound-close", LB::b_soundClose, 1, 1, false, 4, BLTIN }, // D4 c
{ "sound-fadeIn", LB::b_soundFadeIn, 1, 2, false, 3, BLTIN }, // D3 c
{ "sound-fadeOut", LB::b_soundFadeOut, 1, 2, false, 3, BLTIN }, // D3 c
@@ -1695,6 +1696,54 @@ void LB::b_mciwait(int nargs) {
g_lingo->func_mciwait(*d.u.s);
}
+void LB::b_sound(int nargs) {
+ // Builtin function for sound as used by the Director bytecode engine.
+ //
+ // Accepted arguments:
+ // "close", INT soundChannel
+ // "fadeIn", INT soundChannel(, INT ticks)
+ // "fadeOut", INT soundChannel(, INT ticks)
+ // "playFile", INT soundChannel, STRING fileName
+ // "stop", INT soundChannel
+
+ if (nargs >= 2 && nargs <= 3) {
+ Datum verb;
+ Datum firstArg = g_lingo->pop();
+ Datum secondArg = g_lingo->pop();
+ if (nargs > 2) {
+ verb = g_lingo->pop();
+ g_lingo->push(secondArg);
+ g_lingo->push(firstArg);
+ } else {
+ verb = secondArg;
+ g_lingo->push(firstArg);
+ }
+
+ if (verb.type != STRING) {
+ warning("b_sound: verb arg should be of type STRING, not %s", verb.type2str());
+ return;
+ }
+
+ if (*verb.u.s == "close") {
+ b_soundClose(nargs - 1);
+ } else if (*verb.u.s == "fadeIn") {
+ b_soundFadeIn(nargs - 1);
+ } else if (*verb.u.s == "fadeOut") {
+ b_soundFadeOut(nargs - 1);
+ } else if (*verb.u.s == "playFile") {
+ b_soundPlayFile(nargs - 1);
+ } else if (*verb.u.s == "stop") {
+ b_soundStop(nargs - 1);
+ } else {
+ warning("b_sound: unknown verb %s", verb.u.s->c_str());
+ }
+
+ } else {
+ warning("b_sound: expected 2 or 3 args, not %d", nargs);
+ g_lingo->dropStack(nargs);
+ }
+}
+
void LB::b_soundBusy(int nargs) {
if (nargs != 1) {
error("b_soundBusy: expected 1 argument, got %d", nargs);
diff --git a/engines/director/lingo/lingo-builtins.h b/engines/director/lingo/lingo-builtins.h
index b07a36955d..f70cc13d4a 100644
--- a/engines/director/lingo/lingo-builtins.h
+++ b/engines/director/lingo/lingo-builtins.h
@@ -174,6 +174,7 @@ namespace LB {
void b_beep(int nargs);
void b_mci(int nargs);
void b_mciwait(int nargs);
+ void b_sound(int nargs);
void b_soundBusy(int nargs);
void b_soundClose(int nargs);
void b_soundFadeIn(int nargs);
More information about the Scummvm-git-logs
mailing list