aboutsummaryrefslogtreecommitdiff
path: root/engines/director
diff options
context:
space:
mode:
authorEugene Sandulenko2016-08-21 11:30:50 +0200
committerEugene Sandulenko2016-08-21 23:36:25 +0200
commit4b51844e52c785d5ec3af2c986de2b28d0cb4d4c (patch)
treeb10352d9de3548b395ea11dd546578f5465203bd /engines/director
parent6d8e7e0feb25a1d964c3d676e796375f3c709c01 (diff)
downloadscummvm-rg350-4b51844e52c785d5ec3af2c986de2b28d0cb4d4c.tar.gz
scummvm-rg350-4b51844e52c785d5ec3af2c986de2b28d0cb4d4c.tar.bz2
scummvm-rg350-4b51844e52c785d5ec3af2c986de2b28d0cb4d4c.zip
DIRECTOR: RLE variant of 1bpp decoder. Better, but still not there
Diffstat (limited to 'engines/director')
-rw-r--r--engines/director/images.cpp47
1 files changed, 30 insertions, 17 deletions
diff --git a/engines/director/images.cpp b/engines/director/images.cpp
index 8c47bbcfd9..0b440e1b1d 100644
--- a/engines/director/images.cpp
+++ b/engines/director/images.cpp
@@ -147,30 +147,43 @@ bool BITDDecoder::loadStream(Common::SeekableReadStream &stream) {
_surface->create(width, height, Graphics::PixelFormat::createFormatCLUT8());
int x = 0, y = 0;
- byte *p = (byte *)_surface->getBasePtr(x, y);
- while (true) {
- byte in = stream.readByte();
+ while (y < height) {
+ int n = stream.readSByte();
+ int count;
+ int b = 0;
+ int state = 0;
if (stream.eos())
break;
- for (int i = 0; i < 8; i++) {
- *p++ = (in & 0x80) ? 0xff : 0;
- in <<= 1;
- x++;
-
- if (x >= width) {
- x = 0;
- y++;
-
- p = (byte *)_surface->getBasePtr(x, y);
- break;
- }
+ if ((n >= 0) && (n <= 127)) { // If n is between 0 and 127 inclusive, copy the next n+1 bytes literally.
+ count = n + 1;
+ state = 1;
+ } else if ((n >= -127) && (n <= -1)) { // Else if n is between -127 and -1 inclusive, copy the next byte -n+1 times.
+ b = stream.readByte();
+ count = -n + 1;
+ state = 2;
+ } else { // Else if n is -128, noop.
+ count = 0;
}
- if (y >= height) {
- break;
+ for (int i = 0; i < count && y < height; i++) {
+ byte color = 0;
+ if (state == 1) {
+ color = stream.readByte();
+ } else if (state == 2)
+ color = b;
+
+ for (int c = 0; c < 8; c++) {
+ *((byte *)_surface->getBasePtr(x, y)) = (color & (1 << (7 - c % 8))) ? 0 : 0xff;
+ x++;
+ if (x == width) {
+ y++;
+ x = 0;
+ break;
+ }
+ }
}
}