[Scummvm-cvs-logs] scummvm master -> c6e083bcf4e566dc93a9b588519fcfb4088be0c2

bluegr bluegr at gmail.com
Fri Jan 8 14:19:46 CET 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
c6e083bcf4 SCI: Simplify the SCI32 palette cycling code


Commit: c6e083bcf4e566dc93a9b588519fcfb4088be0c2
    https://github.com/scummvm/scummvm/commit/c6e083bcf4e566dc93a9b588519fcfb4088be0c2
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2016-01-08T15:19:04+02:00

Commit Message:
SCI: Simplify the SCI32 palette cycling code

Changed paths:
    engines/sci/graphics/palette32.cpp



diff --git a/engines/sci/graphics/palette32.cpp b/engines/sci/graphics/palette32.cpp
index 0b53eb1..2b70f9c 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];
+		}
 	}
 }
 






More information about the Scummvm-git-logs mailing list