From 160b94fdaaa585f0af5a9d6dde3b2a839109d663 Mon Sep 17 00:00:00 2001 From: Paweł Kołodziejski Date: Fri, 26 Dec 2003 22:53:30 +0000 Subject: added handing voc loops svn-id: r11951 --- sound/voc.cpp | 15 ++++++++++----- sound/voc.h | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) (limited to 'sound') diff --git a/sound/voc.cpp b/sound/voc.cpp index 2fc77e6781..b0429ce2ac 100644 --- a/sound/voc.cpp +++ b/sound/voc.cpp @@ -26,23 +26,27 @@ #include "sound/voc.h" -byte *readCreativeVoc(byte *ptr, int32 &size, int &rate) { +byte *readCreativeVoc(byte *ptr, int32 &size, int &rate, int32 &loops) { + assert(strncmp((char *)ptr, "Creative Voice File\x1A", 20) == 0); int32 offset = READ_LE_UINT16(ptr + 20); int16 version = READ_LE_UINT16(ptr + 22); int16 code = READ_LE_UINT16(ptr + 24); assert(version == 0x010A || version == 0x0114); assert(code == ~version + 0x1234); + bool quit = 0; - byte *ret_sound = 0; size = 0; - int loops = 0; + byte *ret_sound = 0; + size = 0; + while (!quit) { int len = READ_LE_UINT32(ptr + offset); offset += 4; code = len & 0xFF; len >>= 8; switch(code) { - case 0: quit = 1; break; + case 0: quit = 1; + break; case 1: { int time_constant = ptr[offset++]; int packing = ptr[offset++]; @@ -62,7 +66,8 @@ byte *readCreativeVoc(byte *ptr, int32 &size, int &rate) { } } break; case 6: // begin of loop - loops = len + 1; + loops = (uint16)READ_LE_UINT16(ptr + offset); + warning("voc loops: %d", loops); break; case 7: // end of loop break; diff --git a/sound/voc.h b/sound/voc.h index f29e804b4e..0dbbba524b 100644 --- a/sound/voc.h +++ b/sound/voc.h @@ -55,7 +55,7 @@ struct VocBlockHeader { * return the corresponding sample frequency. */ extern int getSampleRateFromVOCRate(int vocSR); -extern byte *readCreativeVoc(byte *ptr, int32 &size, int &rate); +extern byte *readCreativeVoc(byte *ptr, int32 &size, int &rate, int32 &loops); extern byte *loadVocSample(File *file, int32 &size, int &rate); #endif -- cgit v1.2.3