aboutsummaryrefslogtreecommitdiff
path: root/engines/mads
diff options
context:
space:
mode:
authorPaul Gilbert2014-10-22 20:43:22 -0400
committerPaul Gilbert2014-10-22 20:43:22 -0400
commitc021759ad2f0fdb723f98a62739bdf6d5de9c350 (patch)
treedef5ba8229508990024b6bf5e662f6fe5f812fbd /engines/mads
parent1860c2107adb4d08ce6d5a360b47bf5c19392713 (diff)
downloadscummvm-rg350-c021759ad2f0fdb723f98a62739bdf6d5de9c350.tar.gz
scummvm-rg350-c021759ad2f0fdb723f98a62739bdf6d5de9c350.tar.bz2
scummvm-rg350-c021759ad2f0fdb723f98a62739bdf6d5de9c350.zip
MADS: Add md5 checks for the asound.00* sound drivers
The implementation of the sound driver code relies on the data for each sound being at specific locations in the files, so this ensures that if any language version changes the sound files, we'll know about it
Diffstat (limited to 'engines/mads')
-rw-r--r--engines/mads/nebular/sound_nebular.cpp28
-rw-r--r--engines/mads/nebular/sound_nebular.h5
-rw-r--r--engines/mads/sound.cpp9
3 files changed, 42 insertions, 0 deletions
diff --git a/engines/mads/nebular/sound_nebular.cpp b/engines/mads/nebular/sound_nebular.cpp
index c540eb4382..a6dce74bba 100644
--- a/engines/mads/nebular/sound_nebular.cpp
+++ b/engines/mads/nebular/sound_nebular.cpp
@@ -24,6 +24,7 @@
#include "audio/decoders/raw.h"
#include "common/algorithm.h"
#include "common/debug.h"
+#include "common/md5.h"
#include "common/memstream.h"
#include "mads/sound.h"
#include "mads/nebular/sound_nebular.h"
@@ -218,6 +219,33 @@ ASound::~ASound() {
_mixer->stopHandle(_soundHandle);
}
+void ASound::validate() {
+ byte digest[16];
+ Common::File f;
+ static const char *const MD5[] = {
+ "205398468de2c8873b7d4d73d5be8ddc",
+ "f9b2d944a2fb782b1af5c0ad592306d3",
+ "7431f8dad77d6ddfc24e6f3c0c4ac7df",
+ "eb1f3f5a4673d3e73d8ac1818c957cf4",
+ "f936dd853073fa44f3daac512e91c476",
+ "3dc139d3e02437a6d9b732072407c366",
+ "af0edab2934947982e9a405476702e03",
+ "8cbc25570b50ba41c9b5361cad4fbedc",
+ "a31e4783e098f633cbb6689adb41dd4f"
+ };
+
+ for (int i = 1; i <= 9; ++i) {
+ Common::String filename = Common::String::format("ASOUND.00%d", i);
+ if (!f.open(filename))
+ error("Could not process - %s", filename.c_str());
+ Common::String md5str = Common::computeStreamMD5AsString(f, 8192);
+ f.close();
+
+ if (md5str != MD5[i - 1])
+ error("Invalid sound file - %s", filename.c_str());
+ }
+}
+
void ASound::adlibInit() {
write(4, 0x60);
write(4, 0x80);
diff --git a/engines/mads/nebular/sound_nebular.h b/engines/mads/nebular/sound_nebular.h
index abb6516030..ccfd40ad52 100644
--- a/engines/mads/nebular/sound_nebular.h
+++ b/engines/mads/nebular/sound_nebular.h
@@ -318,6 +318,11 @@ public:
virtual ~ASound();
/**
+ * Validates the Adlib sound files
+ */
+ static void validate();
+
+ /**
* Execute a player command. Most commands represent sounds to play, but some
* low number commands also provide control operations.
* @param commandId Player ommand to execute.
diff --git a/engines/mads/sound.cpp b/engines/mads/sound.cpp
index d0aa770a4d..1652550ba3 100644
--- a/engines/mads/sound.cpp
+++ b/engines/mads/sound.cpp
@@ -39,6 +39,15 @@ SoundManager::SoundManager(MADSEngine *vm, Audio::Mixer *mixer) {
_opl = OPL::Config::create();
_opl->init(11025);
+
+ // Validate sound files
+ switch (_vm->getGameID()) {
+ case GType_RexNebular:
+ Nebular::ASound::validate();
+ break;
+ default:
+ break;
+ }
}
SoundManager::~SoundManager() {