aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorMartin Kiewitz2010-01-09 21:12:08 +0000
committerMartin Kiewitz2010-01-09 21:12:08 +0000
commit6619d95f48e2b3f5a67c58c4e951d2f371f21a62 (patch)
tree7c5e7cbf81a8ba7013742572528bf88206f76db3 /engines/sci
parentc73927ee4cb070a026a05624086e4e3e95ef54c7 (diff)
downloadscummvm-rg350-6619d95f48e2b3f5a67c58c4e951d2f371f21a62.tar.gz
scummvm-rg350-6619d95f48e2b3f5a67c58c4e951d2f371f21a62.tar.bz2
scummvm-rg350-6619d95f48e2b3f5a67c58c4e951d2f371f21a62.zip
kPortrait: found the coordinate offsets, corrected actual bitmap size (sometimes extra bytes are appended per line) animation bitmaps now valid
svn-id: r47210
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/graphics/portrait.cpp28
-rw-r--r--engines/sci/graphics/portrait.h2
2 files changed, 26 insertions, 4 deletions
diff --git a/engines/sci/graphics/portrait.cpp b/engines/sci/graphics/portrait.cpp
index d8ff2d005c..d2fbe60b1d 100644
--- a/engines/sci/graphics/portrait.cpp
+++ b/engines/sci/graphics/portrait.cpp
@@ -103,12 +103,27 @@ void Portrait::init() {
// Read all bitmaps
PortraitBitmap *curBitmap = _bitmaps;
uint16 bitmapNr;
+ uint16 bytesPerLine;
for (bitmapNr = 0; bitmapNr < _bitmapCount; bitmapNr++) {
+ curBitmap->width = READ_LE_UINT16(data + 2);
curBitmap->height = READ_LE_UINT16(data + 4);
- curBitmap->width = READ_LE_UINT16(data + 6);
+ bytesPerLine = READ_LE_UINT16(data + 6);
+ if (bytesPerLine < curBitmap->width)
+ error("kPortrait: bytesPerLine larger than actual width");
+ curBitmap->extraBytesPerLine = bytesPerLine - curBitmap->width;
curBitmap->rawBitmap = data + 14;
- data += 14 + (curBitmap->height * curBitmap->width);
+ data += 14 + (curBitmap->height * bytesPerLine);
+ curBitmap++;
+ }
+
+ // Offset table follows
+ curBitmap = _bitmaps;
+ data += 18;
+ for (bitmapNr = 0; bitmapNr < _bitmapCount; bitmapNr++) {
+ curBitmap->displaceX = READ_LE_UINT16(data);
+ curBitmap->displaceY = READ_LE_UINT16(data + 2);
+ data += 14;
curBitmap++;
}
}
@@ -169,15 +184,20 @@ void Portrait::drawBitmap(uint16 bitmapNr) {
byte *data = _bitmaps[bitmapNr].rawBitmap;
uint16 bitmapHeight = _bitmaps[bitmapNr].height;
uint16 bitmapWidth = _bitmaps[bitmapNr].width;
+ Common::Point bitmapPosition = _position;
+
+ bitmapPosition.x += _bitmaps[bitmapNr].displaceX;
+ bitmapPosition.y += _bitmaps[bitmapNr].displaceY;
for (int y = 0; y < bitmapHeight; y++) {
for (int x = 0; x < bitmapWidth; x++) {
- _screen->putPixelOnDisplay(_position.x + x, _position.y + y, _portraitPalette.mapping[*data++]);
+ _screen->putPixelOnDisplay(bitmapPosition.x + x, bitmapPosition.y + y, _portraitPalette.mapping[*data++]);
}
+ data += _bitmaps[bitmapNr].extraBytesPerLine;
}
Common::Rect bitmapRect = Common::Rect(bitmapWidth, bitmapHeight);
- bitmapRect.moveTo(_position.x, _position.y);
+ bitmapRect.moveTo(bitmapPosition.x, bitmapPosition.y);
_screen->copyDisplayRectToScreen(bitmapRect);
g_system->updateScreen();
}
diff --git a/engines/sci/graphics/portrait.h b/engines/sci/graphics/portrait.h
index 71218bdd90..15540627e9 100644
--- a/engines/sci/graphics/portrait.h
+++ b/engines/sci/graphics/portrait.h
@@ -30,6 +30,8 @@ namespace Sci {
struct PortraitBitmap {
int16 width, height;
+ int16 extraBytesPerLine;
+ uint16 displaceX, displaceY;
byte *rawBitmap;
};