diff options
| author | Filippos Karapetis | 2016-01-08 15:19:04 +0200 | 
|---|---|---|
| committer | Filippos Karapetis | 2016-01-08 15:19:04 +0200 | 
| commit | c6e083bcf4e566dc93a9b588519fcfb4088be0c2 (patch) | |
| tree | 5467b5b76d2cf9bf0fc931d9953183afd86ca2ec | |
| parent | 04346170185d2a22ec714807df0d29ef9f92b6e9 (diff) | |
| download | scummvm-rg350-c6e083bcf4e566dc93a9b588519fcfb4088be0c2.tar.gz scummvm-rg350-c6e083bcf4e566dc93a9b588519fcfb4088be0c2.tar.bz2 scummvm-rg350-c6e083bcf4e566dc93a9b588519fcfb4088be0c2.zip  | |
SCI: Simplify the SCI32 palette cycling code
| -rw-r--r-- | engines/sci/graphics/palette32.cpp | 29 | 
1 files changed, 10 insertions, 19 deletions
diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp index 0b53eb1b01..2b70f9c0d7 100644 --- a/engines/sci/graphics/palette32.cpp +++ b/engines/sci/graphics/palette32.cpp @@ -130,23 +130,6 @@ inline void _doCycle(PalCycler *cycler, const int16 speed) {  	cycler->currentCycle = (uint8) (currentCycle % numColorsToCycle);  } -inline void _applyCycleToPalette(PalCycler *cycler, Palette *palette) { -	const int16 currentCycle = cycler->currentCycle; -	const uint16 numColorsToCycle = cycler->numColorsToCycle; - -	Color *tempPalette = new Color[numColorsToCycle]; -	Color *sourceColor = palette->colors + cycler->fromColor; -	memcpy(tempPalette, sourceColor, sizeof(tempPalette)); - -	Color *targetColor = sourceColor; -	for (int numColorsCycled = 0; numColorsCycled < numColorsToCycle; ++numColorsCycled) { -		Color sourceColor = *(tempPalette + ((currentCycle + numColorsCycled) % numColorsToCycle)); -		*(targetColor + numColorsCycled) = sourceColor; -	} - -	delete[] tempPalette; -} -  void GfxPalette32::applyAllCycles() {  	for (int cyclerIndex = 0, numCyclers = ARRAYSIZE(_cyclers); cyclerIndex < numCyclers; ++cyclerIndex) {  		PalCycler *cycler = _cyclers[cyclerIndex]; @@ -154,7 +137,11 @@ void GfxPalette32::applyAllCycles() {  			cycler->currentCycle = (uint8) ((((int) cycler->currentCycle) + 1) % cycler->numColorsToCycle);  			// Disassembly was not fully evaluated to verify this is exactly the same  			// as the code from applyCycles, but it appeared to be at a glance -			_applyCycleToPalette(cycler, &_sysPalette); +			Color paletteCopy[256]; +			memcpy(paletteCopy, _sysPalette.colors, sizeof(Color) * 256); +			for (int i = 0; i < cycler->numColorsToCycle; i++) { +				_sysPalette.colors[cycler->fromColor + i] = paletteCopy[cycler->fromColor + (cycler->currentCycle + i) % cycler->numColorsToCycle]; +			}  		}  	}  } @@ -173,7 +160,11 @@ void GfxPalette32::applyCycles() {  			}  		} -		_applyCycleToPalette(cycler, &_sysPalette); +		Color paletteCopy[256]; +		memcpy(paletteCopy, _sysPalette.colors, sizeof(Color) * 256); +		for (int j = 0; j < cycler->numColorsToCycle; j++) { +			_sysPalette.colors[cycler->fromColor + j] = paletteCopy[cycler->fromColor + (cycler->currentCycle + j) % cycler->numColorsToCycle]; +		}  	}  }  | 
