aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm/he
diff options
context:
space:
mode:
authorEugene Sandulenko2016-05-03 19:52:18 +0200
committerEugene Sandulenko2016-05-03 19:52:18 +0200
commitebeeb467c429e5ea3a03a903f530c8252cc57d0c (patch)
tree88a8e39ed592ffabf016ecd99cd330fb7b79477e /engines/scumm/he
parentacfcbd591965ddd1bd63621fab9840036582068d (diff)
downloadscummvm-rg350-ebeeb467c429e5ea3a03a903f530c8252cc57d0c.tar.gz
scummvm-rg350-ebeeb467c429e5ea3a03a903f530c8252cc57d0c.tar.bz2
scummvm-rg350-ebeeb467c429e5ea3a03a903f530c8252cc57d0c.zip
SCUMM HE: Fixes to T14 image clipping
Diffstat (limited to 'engines/scumm/he')
-rw-r--r--engines/scumm/he/moonbase/moonbase.cpp42
1 files changed, 24 insertions, 18 deletions
diff --git a/engines/scumm/he/moonbase/moonbase.cpp b/engines/scumm/he/moonbase/moonbase.cpp
index 77b9808176..b6bfd4515e 100644
--- a/engines/scumm/he/moonbase/moonbase.cpp
+++ b/engines/scumm/he/moonbase/moonbase.cpp
@@ -59,6 +59,9 @@ void Moonbase::blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, con
return;
Common::Rect clippedRect = clippedDstRect.findIntersectingRect(dstOperation);
+ int cx = clippedRect.right - clippedRect.left;
+ int cy = clippedRect.bottom - clippedRect.top;
+
int sx = ((clippedRect.left - x) + srcLimitsRect.left);
int sy = ((clippedRect.top - y) + srcLimitsRect.top);
@@ -67,19 +70,18 @@ void Moonbase::blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, con
int headerSize = READ_LE_UINT32(wizd + 0x4);
uint8 *dataPointer = wizd + 0x8 + headerSize;
- for (int i = 0; i < height; i++) {
+ for (int i = 0; i < sy; i++) {
+ uint16 lineSize = READ_LE_UINT16(dataPointer + 0);
+
+ dataPointer += lineSize;
+ }
+
+ for (int i = 0; i < cy; i++) {
uint16 lineSize = READ_LE_UINT16(dataPointer + 0);
uint8 *singlesOffset = READ_LE_UINT16(dataPointer + 2) + dataPointer;
uint8 *quadsOffset = READ_LE_UINT16(dataPointer + 4) + dataPointer;
- if (i < sy) {
- dataPointer += lineSize;
- dst += dstPitch;
-
- continue;
- }
-
- int pixels = width;
+ int pixels = 0;
byte *dst1 = dst;
byte *codes = dataPointer + 6;
@@ -89,27 +91,31 @@ void Moonbase::blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, con
if (code == 0) { // quad
for (int c = 0; c < 4; c++) {
- if (width - pixels >= sx) {
+ if (pixels >= sx) {
WRITE_LE_UINT16(dst1, READ_LE_UINT16(quadsOffset));
dst1 += 2;
}
quadsOffset += 2;
- pixels--;
+ pixels++;
}
} else if (code < 0) { // single
- if (width - pixels >= sx) {
+ if (pixels >= sx) {
WRITE_LE_UINT16(dst1, READ_LE_UINT16(singlesOffset));
dst1 += 2;
}
singlesOffset += 2;
- pixels--;
+ pixels++;
} else { // skip
if ((code & 1) == 0) {
code >>= 1;
- dst1 += code * 2;
- pixels -= code;
+
+ for (int j = 0; j < code; j++) {
+ if (pixels >= sx)
+ dst1 += 2;
+ pixels++;
+ }
} else { // special case
- if (width - pixels >= sx) {
+ if (pixels >= sx) {
int alpha = code >> 1;
uint16 color = READ_LE_UINT16(singlesOffset);
@@ -137,11 +143,11 @@ void Moonbase::blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, con
dst1 += 2;
}
singlesOffset += 2;
- pixels--;
+ pixels++;
}
}
- if (pixels <= 0)
+ if (pixels >= cx + sx)
break;
}