diff options
author | Johannes Schickel | 2009-06-29 16:08:39 +0000 |
---|---|---|
committer | Johannes Schickel | 2009-06-29 16:08:39 +0000 |
commit | 6f46b6923684626cb1248872a6448078420ad819 (patch) | |
tree | 04126907fd00b6cc366ebef893adc6f60d8515c6 /engines | |
parent | 3b7f11d4cce9f72fc451fec74559dfc44352c76a (diff) | |
download | scummvm-rg350-6f46b6923684626cb1248872a6448078420ad819.tar.gz scummvm-rg350-6f46b6923684626cb1248872a6448078420ad819.tar.bz2 scummvm-rg350-6f46b6923684626cb1248872a6448078420ad819.zip |
Cleanup KyraEngine_MR::updateCharPal.
svn-id: r41949
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/kyra_mr.cpp | 40 |
1 files changed, 15 insertions, 25 deletions
diff --git a/engines/kyra/kyra_mr.cpp b/engines/kyra/kyra_mr.cpp index 4f4d77b509..b7e5608e94 100644 --- a/engines/kyra/kyra_mr.cpp +++ b/engines/kyra/kyra_mr.cpp @@ -898,40 +898,30 @@ void KyraEngine_MR::updateCharAnimFrame(int character, int *table) { void KyraEngine_MR::updateCharPal(int unk1) { int layer = _screen->getLayer(_mainCharacter.x1, _mainCharacter.y1) - 1; const uint8 *src = _costPalBuffer + _characterShapeFile * 72; - uint8 *dst = _screen->getPalette(0).getData() + 432; + Palette &dst = _screen->getPalette(0); const int8 *sceneDatPal = &_sceneDatPalette[layer * 3]; if (layer != _lastCharPalLayer && unk1) { - for (int i = 0, j = 0; i < 72; ++i) { - uint8 col = *dst; - int8 addCol = *src + *sceneDatPal; - addCol = MAX<int8>(0, MIN<int8>(addCol, 63)); - addCol = (col - addCol) >> 1; - *dst -= addCol; - ++dst; - ++src; - ++sceneDatPal; - ++j; - if (j > 3) { - sceneDatPal = &_sceneDatPalette[layer * 3]; - j = 0; + for (int i = 144; i < 168; ++i) { + for (int j = 0; j < 3; ++j) { + uint8 col = dst[i * 3 + j]; + uint8 subCol = src[(i - 144) * 3 + j] + sceneDatPal[j]; + subCol = CLIP<uint8>(subCol, 0, 63); + subCol = (col - subCol) >> 1; + dst[i * 3 + j] -= subCol; } } + _charPalUpdate = true; _screen->setScreenPalette(_screen->getPalette(0)); _lastCharPalLayer = layer; } else if (_charPalUpdate || !unk1) { - memcpy(dst, src, 72); - - for (int i = 0, j = 0; i < 72; ++i) { - uint8 col = *dst + *sceneDatPal; - *dst = MAX<int8>(0, MIN<int8>(col, 63)); - ++dst; - ++sceneDatPal; - ++j; - if (j >= 3) { - sceneDatPal = &_sceneDatPalette[layer * 3]; - j = 0; + dst.copy(_costPalBuffer, _characterShapeFile * 24, 24, 144); + + for (int i = 144; i < 168; ++i) { + for (int j = 0; j < 3; ++j) { + uint8 col = dst[i * 3 + j] + sceneDatPal[j]; + dst[i * 3 + j] = CLIP<uint8>(col, 0, 63); } } |