diff options
author | johndoe123 | 2014-04-15 13:21:00 +0200 |
---|---|---|
committer | Eugene Sandulenko | 2018-07-20 06:43:33 +0000 |
commit | 1f74de6a4679cecba4fd77e9c79cfaee9c3dd0f6 (patch) | |
tree | d8a58e89f20839b2853551bf41b28a9623a0e2af /engines/illusions/screen.cpp | |
parent | b1927ca30458226ad7ed52cc85d37416261d444d (diff) | |
download | scummvm-rg350-1f74de6a4679cecba4fd77e9c79cfaee9c3dd0f6.tar.gz scummvm-rg350-1f74de6a4679cecba4fd77e9c79cfaee9c3dd0f6.tar.bz2 scummvm-rg350-1f74de6a4679cecba4fd77e9c79cfaee9c3dd0f6.zip |
ILLUSIONS: More work on Duckman
- Implement palette fader
- Add more inventory functions
- Add more script opcodes
Diffstat (limited to 'engines/illusions/screen.cpp')
-rw-r--r-- | engines/illusions/screen.cpp | 46 |
1 files changed, 44 insertions, 2 deletions
diff --git a/engines/illusions/screen.cpp b/engines/illusions/screen.cpp index 35e8b59271..2ac1a44eaf 100644 --- a/engines/illusions/screen.cpp +++ b/engines/illusions/screen.cpp @@ -237,6 +237,8 @@ Screen::Screen(IllusionsEngine *vm, int16 width, int16 height, int bpp) _needRefreshPalette = false; memset(_mainPalette, 0, sizeof(_mainPalette)); + _isFaderActive = false; + } Screen::~Screen() { @@ -372,12 +374,52 @@ void Screen::shiftPalette(int16 fromIndex, int16 toIndex) { void Screen::updatePalette() { if (_needRefreshPalette) { - // TODO Update fader palette - setSystemPalette(_mainPalette); + if (_isFaderActive) { + updateFaderPalette(); + setSystemPalette(_faderPalette); + } else { + setSystemPalette(_mainPalette); + } _needRefreshPalette = false; } } +void Screen::updateFaderPalette() { + if (_newFaderValue >= 255) { + _newFaderValue -= 256; + for (int i = _firstFaderIndex; i <= _lastFaderIndex; ++i) { + byte r = _mainPalette[i * 3 + 0]; + byte g = _mainPalette[i * 3 + 1]; + byte b = _mainPalette[i * 3 + 2]; + _faderPalette[i * 3 + 0] = r - (((_newFaderValue * (255 - r)) >> 8) & 0xFF); + _faderPalette[i * 3 + 1] = g - (((_newFaderValue * (255 - g)) >> 8) & 0xFF); + _faderPalette[i * 3 + 2] = b - (((_newFaderValue * (255 - b)) >> 8) & 0xFF); + } + } else { + for (int i = _firstFaderIndex; i <= _lastFaderIndex; ++i) { + byte r = _mainPalette[i * 3 + 0]; + byte g = _mainPalette[i * 3 + 1]; + byte b = _mainPalette[i * 3 + 2]; + _faderPalette[i * 3 + 0] = _newFaderValue * r / 255; + _faderPalette[i * 3 + 1] = _newFaderValue * g / 255; + _faderPalette[i * 3 + 2] = _newFaderValue * b / 255; + } + } +} + +void Screen::setFader(int newValue, int firstIndex, int lastIndex) { + if (newValue == 255) { + _isFaderActive = false; + _needRefreshPalette = true; + } else { + _isFaderActive = true; + _needRefreshPalette = true; + _newFaderValue = newValue; + _firstFaderIndex = firstIndex - 1; + _lastFaderIndex = lastIndex; + } +} + void Screen::buildColorTransTbl() { const int cr = _mainPalette[3 * 1 + 0]; const int cg = _mainPalette[3 * 1 + 1]; |