[Scummvm-git-logs] scummvm master -> 9c2332854fc15e37243040696c855cbfee972428
dreammaster
paulfgilbert at gmail.com
Tue Feb 25 02:11:05 UTC 2020
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
9c2332854f ULTIMA8: Avoid left shifts of -ve numbers (undefined in c spec)
Commit: 9c2332854fc15e37243040696c855cbfee972428
https://github.com/scummvm/scummvm/commit/9c2332854fc15e37243040696c855cbfee972428
Author: Matthew Duggan (mgithub at guarana.org)
Date: 2020-02-24T18:11:01-08:00
Commit Message:
ULTIMA8: Avoid left shifts of -ve numbers (undefined in c spec)
In practice it probably does the expected thing on every platform, but
it's an easy fix and better to be safe.
Changed paths:
engines/ultima/ultima8/audio/sonarc_audio_sample.cpp
diff --git a/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp b/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp
index ef1f5a5165..192f58e73b 100644
--- a/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp
+++ b/engines/ultima/ultima8/audio/sonarc_audio_sample.cpp
@@ -117,8 +117,8 @@ void SonarcAudioSample::decode_EC(int mode, int samplecount,
if (ones == 0) {
data >>= 1; // strip zero
// low byte contains (mode+1) _bits of the sample
- int8 sample = data & 0xFF;
- sample <<= (7 - mode);
+ const uint8 usample = data & 0xFF;
+ int8 sample = usample << (7 - mode);
sample >>= (7 - mode); // sign extend
*dest++ = (uint8)(sample + 0x80);
data >>= mode + 1;
@@ -126,8 +126,8 @@ void SonarcAudioSample::decode_EC(int mode, int samplecount,
} else if (ones < 7 - mode) {
data >>= ones + 1; // strip ones and zero
// low byte contains (mode+ones) _bits of the sample
- int8 sample = data & 0xFF;
- sample <<= (7 - mode - ones);
+ const uint8 usample = data & 0xFF;
+ int8 sample = usample << (7 - mode - ones);
sample &= 0x7F;
if (!(sample & 0x40))
sample |= 0x80; // reconstruct sign bit
More information about the Scummvm-git-logs
mailing list