aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrichiesams2013-08-29 02:01:57 -0500
committerWillem Jan Palenstijn2013-09-24 13:59:38 +0200
commitcdc484218186daa9a4f60792a2070ad089b7853e (patch)
tree4ee5655b59018a47903b912770e9d59065278998
parentf146a0209fdc3bf0dd5e26dbca8b5257b6ee7c0e (diff)
downloadscummvm-rg350-cdc484218186daa9a4f60792a2070ad089b7853e.tar.gz
scummvm-rg350-cdc484218186daa9a4f60792a2070ad089b7853e.tar.bz2
scummvm-rg350-cdc484218186daa9a4f60792a2070ad089b7853e.zip
ZVISION: Convert RLF animations to RBG 565
This is part of a series of commits converting all game assets to RBG 565 from RBG 555. The argument is that certain backends do not support RGB 555.
-rw-r--r--engines/zvision/rlf_animation.cpp35
-rw-r--r--engines/zvision/rlf_animation.h4
2 files changed, 25 insertions, 14 deletions
diff --git a/engines/zvision/rlf_animation.cpp b/engines/zvision/rlf_animation.cpp
index 90b39dc757..df1fe118da 100644
--- a/engines/zvision/rlf_animation.cpp
+++ b/engines/zvision/rlf_animation.cpp
@@ -33,6 +33,9 @@
namespace ZVision {
+const Graphics::PixelFormat RlfAnimation::_pixelFormat555 = Graphics::PixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+const Graphics::PixelFormat RlfAnimation::_pixelFormat565 = Graphics::PixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0);
+
RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
: _stream(stream),
_lastFrameRead(0),
@@ -41,8 +44,8 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
_height(0),
_frameTime(0),
_frames(0),
- _currentFrameBuffer(0),
_currentFrame(-1),
+ _currentFrameBuffer(0),
_frameBufferByteSize(0) {
if (!_file.open(fileName)) {
warning("RLF animation file %s could not be opened", fileName.c_str());
@@ -68,12 +71,8 @@ RlfAnimation::RlfAnimation(const Common::String &fileName, bool stream)
}
RlfAnimation::~RlfAnimation() {
- if (_frames != 0) {
- delete[] _frames;
- }
- if (_currentFrameBuffer != 0) {
- delete[] _currentFrameBuffer;
- }
+ delete[] _currentFrameBuffer;
+ delete[] _frames;
}
bool RlfAnimation::readHeader() {
@@ -230,11 +229,14 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
} else if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
- WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+ byte r, g, b;
+ _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = _pixelFormat565.RGBToColor(r, g, b);
+ WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
destOffset += 2;
@@ -248,7 +250,7 @@ void RlfAnimation::decodeMaskedRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
} else if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
@@ -275,11 +277,14 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
} else if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
- WRITE_UINT16(dest + destOffset, READ_LE_UINT16(source + sourceOffset));
+ byte r, g, b;
+ _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 destColor = _pixelFormat565.RGBToColor(r, g, b);
+ WRITE_UINT16(dest + destOffset, destColor);
sourceOffset += 2;
destOffset += 2;
@@ -293,14 +298,16 @@ void RlfAnimation::decodeSimpleRunLengthEncoding(int8 *source, int8 *dest, uint3
return;
}
- uint16 sampleColor = READ_LE_UINT16(source + sourceOffset);
+ byte r, g, b;
+ _pixelFormat555.colorToRGB(READ_LE_UINT16(source + sourceOffset), r, g, b);
+ uint16 sampleColor = _pixelFormat565.RGBToColor(r, g, b);
sourceOffset += 2;
numberOfSamples += 2;
while (numberOfSamples > 0) {
if (destOffset + 1 >= destSize) {
// TODO: Make this warning silent or in a high debug level. It happens for almost all frames.
- warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
+ //warning("Frame decoding overflow\n\tsourceOffset=%u\tsourceSize=%u\n\tdestOffset=%u\tdestSize=%u", sourceOffset, sourceSize, destOffset, destSize);
return;
}
diff --git a/engines/zvision/rlf_animation.h b/engines/zvision/rlf_animation.h
index 5091185a36..6f93934f1f 100644
--- a/engines/zvision/rlf_animation.h
+++ b/engines/zvision/rlf_animation.h
@@ -26,6 +26,7 @@
#include "common/types.h"
#include "common/file.h"
+#include "graphics/surface.h"
namespace Common {
@@ -51,6 +52,9 @@ private:
uint32 encodedSize;
};
+ const static Graphics::PixelFormat _pixelFormat555;
+ const static Graphics::PixelFormat _pixelFormat565;
+
private:
Common::File _file;
bool _stream;