aboutsummaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMax Horn2004-05-05 10:58:07 +0000
committerMax Horn2004-05-05 10:58:07 +0000
commit90cced2a5b65da7810694a118a1633dad439fb2a (patch)
treeb21a5429466b4f6febaa55bc8eb0f0948d990f59 /sound
parent0f57499cb1e7e30fdb5c88cfdb430d53ac43d86a (diff)
downloadscummvm-rg350-90cced2a5b65da7810694a118a1633dad439fb2a.tar.gz
scummvm-rg350-90cced2a5b65da7810694a118a1633dad439fb2a.tar.bz2
scummvm-rg350-90cced2a5b65da7810694a118a1633dad439fb2a.zip
Remove odd sample rate hack (for DOTT demo); instead, be slightly less strict about VOC headers, since DOTT demo (and maybe others) use buggy VOC headers
svn-id: r13787
Diffstat (limited to 'sound')
-rw-r--r--sound/voc.cpp27
1 files changed, 16 insertions, 11 deletions
diff --git a/sound/voc.cpp b/sound/voc.cpp
index 9bc0cb297a..8ade0f6dbc 100644
--- a/sound/voc.cpp
+++ b/sound/voc.cpp
@@ -30,19 +30,13 @@
int getSampleRateFromVOCRate(int vocSR) {
- if (vocSR == 0x83) {
- // FIXME: This is a special hack added by Kirben on Fri Nov 7 11:11:06 2003 UTC,
- // with the comment: "Correct voc rate in DOTT demo".
- // It's not clear to me whether this is indeed a proper workaround for a broken
- // data file, or just a random fix... ?
- return 11025;
- } else if (vocSR == 0xa5 || vocSR == 0xa6) {
+ if (vocSR == 0xa5 || vocSR == 0xa6) {
return 11025;
} else if (vocSR == 0xd2 || vocSR == 0xd3) {
return 22050;
} else {
int sr = 1000000L / (256L - vocSR);
- // Inexect% sampling rates occur e.g. in the kitchen in Monkey Island,
+ // inexact sampling rates occur e.g. in the kitchen in Monkey Island,
// very easy to reach right from the start of the game.
//warning("inexact sample rate used: %i (0x%x)", sr, vocSR);
return sr;
@@ -51,7 +45,14 @@ int getSampleRateFromVOCRate(int vocSR) {
byte *readVOCFromMemory(byte *ptr, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) {
- assert(memcmp(ptr, "Creative Voice File\x1A", 20) == 0);
+ // Verify the VOC header. We are a little bit lenient here to work around
+ // some invalid VOC headers used in various SCUMM games (they have 0x0
+ // instead of 0x1A after the "Creative Voice File" string).
+ if (memcmp(ptr, "Creative Voice File", 19) != 0)
+ error("readVOCFromMemory: Invalid header");
+ if (ptr[19] != 0x1A)
+ debug(3, "readVOCFromMemory: Partially invalid header");
+
int32 offset = READ_LE_UINT16(ptr + 20);
int16 version = READ_LE_UINT16(ptr + 22);
int16 code = READ_LE_UINT16(ptr + 24);
@@ -126,11 +127,15 @@ byte *loadVOCFile(File *file, int &size, int &rate) {
goto invalid;
} else {
invalid:;
- warning("loadVOCFile: invalid header");
+ warning("loadVOCFile: Invalid header");
return NULL;
}
- assert(memcmp(&fileHeader, "Creative Voice File\x1A", 20) == 0);
+ if (memcmp(fileHeader.desc, "Creative Voice File", 19) != 0)
+ error("loadVOCFile: Invalid header");
+ if (fileHeader.desc[19] != 0x1A)
+ debug(3, "loadVOCFile: Partially invalid header");
+
//int32 offset = FROM_LE_16(fileHeader.datablock_offset);
int16 version = FROM_LE_16(fileHeader.version);
int16 code = FROM_LE_16(fileHeader.id);