diff options
author | athrxx | 2019-12-10 22:05:18 +0100 |
---|---|---|
committer | athrxx | 2019-12-18 20:50:47 +0100 |
commit | 04e85a0f3d71c8740ecaf8ff2e66143e95ec055a (patch) | |
tree | a167f194b0c90c63d4dfe2887e57f9848ee0778c /engines/kyra/graphics/screen.cpp | |
parent | e2d4f1e6f141f398dc08e0b8f777332ff2c48b98 (diff) | |
download | scummvm-rg350-04e85a0f3d71c8740ecaf8ff2e66143e95ec055a.tar.gz scummvm-rg350-04e85a0f3d71c8740ecaf8ff2e66143e95ec055a.tar.bz2 scummvm-rg350-04e85a0f3d71c8740ecaf8ff2e66143e95ec055a.zip |
KYRA: (Amiga) - minor code reduction
(eliminate some duplicate code for dirty rect handling)
Diffstat (limited to 'engines/kyra/graphics/screen.cpp')
-rw-r--r-- | engines/kyra/graphics/screen.cpp | 105 |
1 files changed, 22 insertions, 83 deletions
diff --git a/engines/kyra/graphics/screen.cpp b/engines/kyra/graphics/screen.cpp index d9ebb4ff88..c7d16ff1e6 100644 --- a/engines/kyra/graphics/screen.cpp +++ b/engines/kyra/graphics/screen.cpp @@ -202,7 +202,7 @@ bool Screen::init() { const int numColorsInternal = _useAmigaExtraColors ? 64 : numColors; _use256ColorMode = (_bytesPerPixel != 2 && !_isAmiga && !_use16ColorMode && _renderMode != Common::kRenderCGA && _renderMode != Common::kRenderEGA); - _interfacePaletteEnabled = false; + _dualPaletteModeSplitY = 0; _screenPalette = new Palette(numColorsInternal); assert(_screenPalette); @@ -351,7 +351,7 @@ void Screen::updateScreen() { if (_useOverlays) updateDirtyRectsOvl(); - else if (_isAmiga && _interfacePaletteEnabled) + else if (_isAmiga && _dualPaletteModeSplitY) updateDirtyRectsAmiga(); else updateDirtyRects(); @@ -385,68 +385,26 @@ void Screen::updateDirtyRects() { void Screen::updateDirtyRectsAmiga() { if (_forceFullUpdate) { - _system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, 136); - - // Page 8 is not used by Kyra 1 AMIGA, thus we can use it to adjust the colors - copyRegion(0, 136, 0, 0, 320, 64, 0, 8, CR_NO_P_CHECK); - - uint8 *dst = getPagePtr(8); - for (int y = 0; y < 64; ++y) - for (int x = 0; x < 320; ++x) - *dst++ += 32; - - _system->copyRectToScreen(getCPagePtr(8), SCREEN_W, 0, 136, SCREEN_W, 64); + uint32 *pos = (uint32*)(_pagePtrs[0] + _dualPaletteModeSplitY * SCREEN_W); + uint16 h = (SCREEN_H - _dualPaletteModeSplitY) * (SCREEN_W >> 2); + while (h--) + *pos++ |= 0x20202020; + _system->copyRectToScreen(getCPagePtr(0), SCREEN_W, 0, 0, SCREEN_W, SCREEN_H); } else { - const byte *page0 = getCPagePtr(0); Common::List<Common::Rect>::iterator it; - for (it = _dirtyRects.begin(); it != _dirtyRects.end(); ++it) { - if (it->bottom <= 136) { - _system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height()); - } else { - // Check whether the rectangle is part of both the screen and the interface - if (it->top < 136) { - // The rectangle covers both screen part and interface part - - const int screenHeight = 136 - it->top; - const int interfaceHeight = it->bottom - 136; - - const int width = it->width(); - const int lineAdd = SCREEN_W - width; - - // Copy the screen part verbatim - _system->copyRectToScreen(page0 + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, width, screenHeight); - - // Adjust the interface part - copyRegion(it->left, 136, 0, 0, width, interfaceHeight, 0, 8, Screen::CR_NO_P_CHECK); - - uint8 *dst = getPagePtr(8); - for (int y = 0; y < interfaceHeight; ++y) { - for (int x = 0; x < width; ++x) - *dst++ += 32; - dst += lineAdd; - } - - _system->copyRectToScreen(getCPagePtr(8), SCREEN_W, it->left, 136, width, interfaceHeight); - } else { - // The rectangle only covers the interface part - - const int width = it->width(); - const int height = it->height(); - const int lineAdd = SCREEN_W - width; - - copyRegion(it->left, it->top, 0, 0, width, height, 0, 8, Screen::CR_NO_P_CHECK); - - uint8 *dst = getPagePtr(8); - for (int y = 0; y < height; ++y) { - for (int x = 0; x < width; ++x) - *dst++ += 32; - dst += lineAdd; - } - - _system->copyRectToScreen(getCPagePtr(8), SCREEN_W, it->left, it->top, width, height); + if (it->bottom >= _dualPaletteModeSplitY) { + int16 startY = MAX<int16>(_dualPaletteModeSplitY, it->top); + int16 h = it->bottom - startY + 1; + int16 w = it->width(); + uint8 *pos = _pagePtrs[0] + startY * SCREEN_W + it->left; + while (h--) { + for (int x = 0; x < w; ++x) + *pos++ |= 0x20; + pos += (SCREEN_W - w); } } + _system->copyRectToScreen(_pagePtrs[0] + it->top * SCREEN_W + it->left, SCREEN_W, it->left, it->top, it->width(), it->height()); } } @@ -969,8 +927,8 @@ void Screen::setScreenPalette(const Palette &pal) { _system->getPaletteManager()->setPalette(screenPal, 0, pal.getNumColors()); } -void Screen::enableInterfacePalette(bool e) { - _interfacePaletteEnabled = e; +void Screen::enableDualPaletteMode(int splitY) { + _dualPaletteModeSplitY = splitY; _forceFullUpdate = true; _dirtyRects.clear(); @@ -980,28 +938,9 @@ void Screen::enableInterfacePalette(bool e) { updateScreen(); } -void Screen::setInterfacePalette(const Palette &pal, uint8 r, uint8 g, uint8 b) { - if (!_isAmiga) - return; - - uint8 screenPal[32 * 3]; - - assert(32 <= pal.getNumColors()); - - for (int i = 0; i < pal.getNumColors(); ++i) { - if (i != 0x10) { - screenPal[3 * i + 0] = (pal[i * 3 + 0] * 0xFF) / 0x3F; - screenPal[3 * i + 1] = (pal[i * 3 + 1] * 0xFF) / 0x3F; - screenPal[3 * i + 2] = (pal[i * 3 + 2] * 0xFF) / 0x3F; - } else { - screenPal[3 * i + 0] = (r * 0xFF) / 0x3F; - screenPal[3 * i + 1] = (g * 0xFF) / 0x3F; - screenPal[3 * i + 2] = (b * 0xFF) / 0x3F; - } - } - - _paletteChanged = true; - _system->getPaletteManager()->setPalette(screenPal, 32, pal.getNumColors()); +void Screen::disableDualPaletteMode() { + _dualPaletteModeSplitY = 0; + _forceFullUpdate = true; } void Screen::copyToPage0(int y, int h, uint8 page, uint8 *seqBuf) { |