aboutsummaryrefslogtreecommitdiff
path: root/engines/scumm
diff options
context:
space:
mode:
authorEugene Sandulenko2016-05-04 22:53:46 +0200
committerEugene Sandulenko2016-05-04 22:53:46 +0200
commitb8f288873bbcd54e7a984ccd9ae56e82e78aa631 (patch)
tree9aac40f1f54fa0244a539d52c138f31ba4ef4f33 /engines/scumm
parent5cfbb176e793797d1345429f88d7efe4b733f98e (diff)
downloadscummvm-rg350-b8f288873bbcd54e7a984ccd9ae56e82e78aa631.tar.gz
scummvm-rg350-b8f288873bbcd54e7a984ccd9ae56e82e78aa631.tar.bz2
scummvm-rg350-b8f288873bbcd54e7a984ccd9ae56e82e78aa631.zip
SCUMM HE: Fix premultiplied T14 calculation
We were hitting integer overflow which lead to shadow artifacts.
Diffstat (limited to 'engines/scumm')
-rw-r--r--engines/scumm/he/moonbase/moonbase.cpp11
1 files changed, 6 insertions, 5 deletions
diff --git a/engines/scumm/he/moonbase/moonbase.cpp b/engines/scumm/he/moonbase/moonbase.cpp
index b6bfd4515e..1f9d843bb9 100644
--- a/engines/scumm/he/moonbase/moonbase.cpp
+++ b/engines/scumm/he/moonbase/moonbase.cpp
@@ -118,13 +118,13 @@ void Moonbase::blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, con
if (pixels >= sx) {
int alpha = code >> 1;
uint16 color = READ_LE_UINT16(singlesOffset);
+ uint32 orig = READ_LE_UINT16(dst1);
//WRITE_LE_UINT16(dst1, color); // ENABLE_PREMUL_ALPHA = 0
// ENABLE_PREMUL_ALPHA = 2
if (alpha > 32) {
alpha -= 32;
- uint32 orig = READ_LE_UINT16(dst1);
uint32 oR = orig & 0x7c00;
uint32 oG = orig & 0x03e0;
uint32 oB = orig & 0x1f;
@@ -134,10 +134,11 @@ void Moonbase::blitT14WizImage(uint8 *dst, int dstw, int dsth, int dstPitch, con
WRITE_LE_UINT16(dst1, (dR & 0x7c00) | (dG & 0x3e0) | (dB & 0x1f));
} else {
- uint32 orig = READ_LE_UINT16(dst1);
- uint32 pass1 = ((((orig << 16) | orig) & 0x3e07c1f * alpha) >> 5) & 0x3e07c1f;
- uint32 pass2 = (((pass1 << 16) | pass1) + color) & 0xffff;
- WRITE_LE_UINT16(dst1, pass2);
+ uint32 pix = ((orig << 16) | orig) & 0x3e07c1f;
+ pix = (((pix * alpha) & 0xffffffff) >> 5) & 0x3e07c1f;
+ pix = ((pix << 16) + pix + color) & 0xffff;
+
+ WRITE_LE_UINT16(dst1, pix);
}
dst1 += 2;