diff options
author | Paul Gilbert | 2019-08-30 23:10:26 -0700 |
---|---|---|
committer | Paul Gilbert | 2019-08-30 23:10:26 -0700 |
commit | 4377a0d995cd0486c809020e11625f86aff6259d (patch) | |
tree | 29aa2df4d18803b8ac47b01f7bac4627f53f5100 /engines/xeen | |
parent | 9213920ac12198ab96dd804111b93d6b38e900c8 (diff) | |
download | scummvm-rg350-4377a0d995cd0486c809020e11625f86aff6259d.tar.gz scummvm-rg350-4377a0d995cd0486c809020e11625f86aff6259d.tar.bz2 scummvm-rg350-4377a0d995cd0486c809020e11625f86aff6259d.zip |
XEEN: Workaround black pixels when rendering transparent Shades
Diffstat (limited to 'engines/xeen')
-rw-r--r-- | engines/xeen/sprites.cpp | 30 | ||||
-rw-r--r-- | engines/xeen/sprites.h | 2 |
2 files changed, 24 insertions, 8 deletions
diff --git a/engines/xeen/sprites.cpp b/engines/xeen/sprites.cpp index 76bd74285b..4ac53835d5 100644 --- a/engines/xeen/sprites.cpp +++ b/engines/xeen/sprites.cpp @@ -446,17 +446,31 @@ const uint16 DRAWER3_OFFSET[4] = { 1, 2, 4, 8 }; SpriteDrawer3::SpriteDrawer3(byte *data, size_t filesize, int index) : SpriteDrawer(data, filesize) { _offset = DRAWER3_OFFSET[index]; _mask = DRAWER3_MASK[index]; + + g_system->getPaletteManager()->grabPalette(_palette, 0, PALETTE_COUNT); + _hasPalette = false; + for (byte *pal = _palette; pal < _palette + PALETTE_SIZE && !_hasPalette; ++pal) + _hasPalette = *pal != 0; } void SpriteDrawer3::drawPixel(byte *dest, byte pixel) { - byte level = (pixel & _mask) - _offset + (*dest & 0xf); - - if (level >= 0x80) { - *dest &= 0xf0; - } else if (level <= 0xf) { - *dest = (*dest & 0xf0) | level; - } else { - *dest |= 0xf; + // WORKAROUND: This is slightly different then the original: + // 1) The original has bunches of black pixels appearing. This does index increments to avoid such pixels + // 2) It also prevents any pixels being drawn in the single initial frame until the palette is set + if (_hasPalette) { + byte level = (pixel & _mask) - _offset + (*dest & 0xf); + + if (level >= 0x80) { + *dest &= 0xf0; + } else if (level <= 0xf) { + *dest = (*dest & 0xf0) | level; + } else { + *dest |= 0xf; + } + + // + while (*dest < 0xff && !_palette[*dest * 3] && !_palette[*dest * 3 + 1] && !_palette[*dest * 3 + 2]) + ++*dest; } } diff --git a/engines/xeen/sprites.h b/engines/xeen/sprites.h index f2619c81b6..5a245885c4 100644 --- a/engines/xeen/sprites.h +++ b/engines/xeen/sprites.h @@ -224,6 +224,8 @@ public: class SpriteDrawer3 : public SpriteDrawer { private: uint16 _offset, _mask; + byte _palette[256 * 3]; + bool _hasPalette; private: /** * Output a pixel |