aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
authorMarisa-Chan2014-03-06 15:22:05 +0700
committerMarisa-Chan2014-03-06 15:22:05 +0700
commit7d1c4ec27cb197ea729ab468ecd7f4cbd4594202 (patch)
treef30a5cb1d41ca392dc4e375e5eab76d9a281e2f6 /engines/zvision
parent26d923e354d22a3d8aeb007f4d6f1e5dc669efb4 (diff)
downloadscummvm-rg350-7d1c4ec27cb197ea729ab468ecd7f4cbd4594202.tar.gz
scummvm-rg350-7d1c4ec27cb197ea729ab468ecd7f4cbd4594202.tar.bz2
scummvm-rg350-7d1c4ec27cb197ea729ab468ecd7f4cbd4594202.zip
ZVISION: Fix rlf incorrect ABS -128 issue
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/rlf_animation.cpp20
1 files changed, 11 insertions, 9 deletions
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index f23f569d98..5784df0dac 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -268,6 +268,7 @@ void RlfAnimation::applyFrameToCurrent(const RlfAnimation::Frame &frame) {
void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
uint32 sourceOffset = 0;
uint32 destOffset = 0;
+ int16 numberOfCopy = 0;
while (sourceOffset < sourceSize) {
int8 numberOfSamples = source[sourceOffset];
@@ -276,9 +277,9 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
// If numberOfSamples is negative, the next abs(numberOfSamples) samples should
// be copied directly from source to dest
if (numberOfSamples < 0) {
- numberOfSamples = ABS(numberOfSamples);
+ numberOfCopy = -numberOfSamples;
- while (numberOfSamples > 0) {
+ while (numberOfCopy > 0) {
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
@@ -293,7 +294,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
sourceOffset += 2;
destOffset += 2;
- numberOfSamples--;
+ numberOfCopy--;
}
// If numberOfSamples is >= 0, move destOffset forward ((numberOfSamples * 2) + 2)
@@ -314,6 +315,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint32 sourceSize, uint32 destSize) const {
uint32 sourceOffset = 0;
uint32 destOffset = 0;
+ int16 numberOfCopy = 0;
while (sourceOffset < sourceSize) {
int8 numberOfSamples = source[sourceOffset];
@@ -322,9 +324,9 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
// If numberOfSamples is negative, the next abs(numberOfSamples) samples should
// be copied directly from source to dest
if (numberOfSamples < 0) {
- numberOfSamples = ABS(numberOfSamples);
+ numberOfCopy = -numberOfSamples;
- while (numberOfSamples > 0) {
+ while (numberOfCopy > 0) {
if (sourceOffset + 1 >= sourceSize) {
return;
} else if (destOffset + 1 >= destSize) {
@@ -339,7 +341,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
sourceOffset += 2;
destOffset += 2;
- numberOfSamples--;
+ numberOfCopy--;
}
// If numberOfSamples is >= 0, copy one sample from source to the
@@ -354,8 +356,8 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
uint16 sampleColor = Graphics::RGBToColor<Graphics::ColorMasks<565> >(r, g, b);
sourceOffset += 2;
- numberOfSamples += 2;
- while (numberOfSamples > 0) {
+ numberOfCopy = numberOfSamples + 2;
+ while (numberOfCopy > 0) {
if (destOffset + 1 >= destSize) {
debug(2, "Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
@@ -363,7 +365,7 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
WRITE_UINT16(dest + destOffset, sampleColor);
destOffset += 2;
- numberOfSamples--;
+ numberOfCopy--;
}
}
}