From 0719a4e6c27a10af41303aa961812b3dde333045 Mon Sep 17 00:00:00 2001 From: Torbjörn Andersson Date: Tue, 4 Oct 2005 18:19:14 +0000 Subject: I misunderstood sev on how sf75() should work. Perhaps this is better? svn-id: r18932 --- saga/gfx.cpp | 28 +++++++++++++++++++++++----- 1 file changed, 23 insertions(+), 5 deletions(-) (limited to 'saga/gfx.cpp') diff --git a/saga/gfx.cpp b/saga/gfx.cpp index 121bd7cb19..c18115e7e9 100644 --- a/saga/gfx.cpp +++ b/saga/gfx.cpp @@ -182,12 +182,30 @@ void Gfx::setPalette(const PalEntry *pal) { } void Gfx::setPaletteColor(int n, int r, int g, int b) { - _currentPal[4 * n + 0] = r; - _currentPal[4 * n + 1] = g; - _currentPal[4 * n + 2] = b; - _currentPal[4 * n + 3] = 0; + bool update = false; - _system->setPalette(_currentPal, n, 1); + // This function may get called a lot. To avoid forcing full-screen + // updates, only update the palette if the color actually changes. + + if (_currentPal[4 * n + 0] != r) { + _currentPal[4 * n + 0] = r; + update = true; + } + if (_currentPal[4 * n + 1] != g) { + _currentPal[4 * n + 1] = g; + update = true; + } + if (_currentPal[4 * n + 2] != b) { + _currentPal[4 * n + 2] = b; + update = true; + } + if (_currentPal[4 * n + 3] != 0) { + _currentPal[4 * n + 3] = 0; + update = true; + } + + if (update) + _system->setPalette(_currentPal, n, 1); } void Gfx::getCurrentPal(PalEntry *src_pal) { -- cgit v1.2.3