From a8d7265c5eae16b18bb336b3f3f70f6eb5552374 Mon Sep 17 00:00:00 2001 From: Gregory Montoir Date: Fri, 3 Nov 2006 21:03:12 +0000 Subject: added basic handler for VOC block 9 svn-id: r24590 --- sound/voc.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/sound/voc.cpp b/sound/voc.cpp index 5f6118537f..726b555a79 100644 --- a/sound/voc.cpp +++ b/sound/voc.cpp @@ -47,7 +47,7 @@ int getSampleRateFromVOCRate(int vocSR) { } } -byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) { +static byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate, int &loops, int &begin_loop, int &end_loop) { VocFileHeader fileHeader; if (stream.read(&fileHeader, 8) != 8) @@ -91,11 +91,26 @@ byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate, int &l len |= stream.readByte() << 16; switch (code) { - case 1: { - int time_constant = stream.readByte(); - int packing = stream.readByte(); - len -= 2; - rate = getSampleRateFromVOCRate(time_constant); + case 1: + case 9: { + int packing; + if (code == 1) { + int time_constant = stream.readByte(); + packing = stream.readByte(); + len -= 2; + rate = getSampleRateFromVOCRate(time_constant); + } else { + rate = stream.readUint32LE(); + int bits = stream.readByte(); + int channels = stream.readByte(); + if (bits != 8 || channels != 1) { + warning("Unsupported VOC file format (%d bits per sample, %d channels)", bits, channels); + break; + } + packing = stream.readUint16LE(); + stream.readUint32LE(); + len -= 12; + } debug(9, "VOC Data Block: %d, %d, %d", rate, packing, len); if (packing == 0) { if (size) { @@ -119,7 +134,7 @@ byte *loadVOCFromStream(Common::ReadStream &stream, int &size, int &rate, int &l assert(len == 0); break; default: - warning("Invalid code in VOC file : %d", code); + warning("Unhandled code in VOC file : %d", code); return ret_sound; } } -- cgit v1.2.3