diff options
author | Torbjörn Andersson | 2003-12-02 07:41:04 +0000 |
---|---|---|
committer | Torbjörn Andersson | 2003-12-02 07:41:04 +0000 |
commit | af02beefd950eeb931fab78b91fe9c518d55c476 (patch) | |
tree | a05ddd57525d48a7add3198c32168ba4d9bdadf4 | |
parent | 13db38223cf2d9eb9292d2bda1fcf6b8df13552a (diff) | |
download | scummvm-rg350-af02beefd950eeb931fab78b91fe9c518d55c476.tar.gz scummvm-rg350-af02beefd950eeb931fab78b91fe9c518d55c476.tar.bz2 scummvm-rg350-af02beefd950eeb931fab78b91fe9c518d55c476.zip |
cleanup
svn-id: r11457
-rw-r--r-- | sword2/driver/d_sound.cpp | 28 |
1 files changed, 11 insertions, 17 deletions
diff --git a/sword2/driver/d_sound.cpp b/sword2/driver/d_sound.cpp index 89b6bece76..7ff29f3507 100644 --- a/sword2/driver/d_sound.cpp +++ b/sword2/driver/d_sound.cpp @@ -292,7 +292,7 @@ int32 Sound::amISpeaking() { /** * This function loads and decompresses a list of speech from a cluster, but - * does not play it. This is primarily used by PlayCompSpeech(), but also to + * does not play it. This is primarily used by playCompSpeech(), but also to * store the voice-overs for the animated cutscenes until they are played. * @param filename the file name of the speech cluster file * @param speechid the text line id used to reference the speech @@ -302,7 +302,7 @@ int32 Sound::amISpeaking() { uint32 Sound::preFetchCompSpeech(const char *filename, uint32 speechid, uint16 **buf) { uint32 i; uint8 *data8; - uint32 speechIndex[2]; + uint32 speechPos, speechLength; File fp; uint32 bufferSize; @@ -315,30 +315,24 @@ uint32 Sound::preFetchCompSpeech(const char *filename, uint32 speechid, uint16 * fp.seek((speechid + 1) * 8, SEEK_SET); - if (fp.read(speechIndex, sizeof(uint32) * 2) != (sizeof(uint32) * 2)) { - fp.close(); - return 0; - } - -#ifdef SCUMM_BIG_ENDIAN - speechIndex[0] = SWAP_BYTES_32(speechIndex[0]); - speechIndex[1] = SWAP_BYTES_32(speechIndex[1]); -#endif + speechPos = fp.readUint32LE(); + speechLength = fp.readUint32LE(); - if (!speechIndex[0] || !speechIndex[1]) { + if (!speechPos || !speechLength) { fp.close(); return 0; } // Create a temporary buffer for compressed speech - if ((data8 = (uint8 *) malloc(speechIndex[1])) == NULL) { + data8 = (uint8 *) malloc(speechLength); + if (!data8) { fp.close(); return 0; } - fp.seek(speechIndex[0], SEEK_SET); + fp.seek(speechPos, SEEK_SET); - if (fp.read(data8, speechIndex[1]) != speechIndex[1]) { + if (fp.read(data8, speechLength) != speechLength) { fp.close(); free(data8); return 0; @@ -348,7 +342,7 @@ uint32 Sound::preFetchCompSpeech(const char *filename, uint32 speechid, uint16 * // Decompress data into speech buffer. - bufferSize = (speechIndex[1] - 1) * 2; + bufferSize = (speechLength - 1) * 2; *buf = (uint16 *) malloc(bufferSize); if (!*buf) { @@ -361,7 +355,7 @@ uint32 Sound::preFetchCompSpeech(const char *filename, uint32 speechid, uint16 * // Starting Value data16[0] = READ_LE_UINT16(data8); - for (i = 1; i < speechIndex[1] - 1; i++) { + for (i = 1; i < speechLength - 1; i++) { if (GetCompressedSign(data8[i + 1])) data16[i] = data16[i - 1] - (GetCompressedAmplitude(data8[i + 1]) << GetCompressedShift(data8[i + 1])); else |