[Scummvm-cvs-logs] SF.net SVN: scummvm:[41941] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Jun 29 18:05:50 CEST 2009


Revision: 41941
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41941&view=rev
Author:   lordhoto
Date:     2009-06-29 16:05:50 +0000 (Mon, 29 Jun 2009)

Log Message:
-----------
Modified Palette::load*Palette definition.

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/screen.h

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2009-06-29 12:33:47 UTC (rev 41940)
+++ scummvm/trunk/engines/kyra/screen.cpp	2009-06-29 16:05:50 UTC (rev 41941)
@@ -2838,11 +2838,11 @@
 	debugC(3, kDebugLevelScreen, "Screen::loadPalette('%s', %p)", filename, (const void *)&pal);
 
 	if (_vm->gameFlags().platform == Common::kPlatformAmiga)
-		pal.loadAmigaPalette(*stream, stream->size() / Palette::kAmigaBytesPerColor);
+		pal.loadAmigaPalette(*stream, 0, stream->size() / Palette::kAmigaBytesPerColor);
 	else if (_vm->gameFlags().platform == Common::kPlatformPC98 && _use16ColorMode)
-		pal.loadPC98Palette(*stream, stream->size() / Palette::kPC98BytesPerColor);
+		pal.loadPC98Palette(*stream, 0, stream->size() / Palette::kPC98BytesPerColor);
 	else
-		pal.loadVGAPalette(*stream, stream->size() / Palette::kVGABytesPerColor);
+		pal.loadVGAPalette(*stream, 0, stream->size() / Palette::kVGABytesPerColor);
 
 	delete stream;
 	return true;
@@ -2862,14 +2862,14 @@
 		const int numPals = stream->size() / palSize;
 
 		for (int i = 0; i < numPals; ++i)
-			getPalette(i + firstPalette).loadAmigaPalette(*stream, numColors);
+			getPalette(i + firstPalette).loadAmigaPalette(*stream, 0, numColors);
 	} else {
 		const int numColors = getPalette(firstPalette).getNumColors();
 		const int palSize = getPalette(firstPalette).getNumColors() * Palette::kVGABytesPerColor;
 		const int numPals = stream->size() / palSize;
 
 		for (int i = 0; i < numPals; ++i)
-			getPalette(i + firstPalette).loadVGAPalette(*stream, numColors);
+			getPalette(i + firstPalette).loadVGAPalette(*stream, 0, numColors);
 	}
 
 	delete stream;
@@ -2880,11 +2880,11 @@
 	Common::MemoryReadStream stream(data, bytes, false);
 
 	if (_vm->gameFlags().platform == Common::kPlatformAmiga)
-		pal.loadAmigaPalette(stream, stream.size() / Palette::kAmigaBytesPerColor);
+		pal.loadAmigaPalette(stream, 0, stream.size() / Palette::kAmigaBytesPerColor);
 	else if (_vm->gameFlags().platform == Common::kPlatformPC98 && _use16ColorMode)
-		pal.loadPC98Palette(stream, stream.size() / Palette::kPC98BytesPerColor);
+		pal.loadPC98Palette(stream, 0, stream.size() / Palette::kPC98BytesPerColor);
 	else
-		pal.loadVGAPalette(stream, stream.size() / Palette::kVGABytesPerColor);
+		pal.loadVGAPalette(stream, 0, stream.size() / Palette::kVGABytesPerColor);
 }
 
 // dirty rect handling
@@ -3275,47 +3275,33 @@
 	_palData = 0;
 }
 
-void Palette::loadVGAPalette(Common::ReadStream &stream, int colors) {
-	if (colors == -1)
-		colors = _numColors;
+void Palette::loadVGAPalette(Common::ReadStream &stream, int startIndex, int colors) {
+	assert(startIndex + colors <= _numColors);
 
-	assert(colors <= _numColors);
-
-	stream.read(_palData, colors * 3);
-	memset(_palData + colors * 3, 0, (_numColors - colors) * 3);
+	stream.read(_palData + startIndex * 3, colors * 3);
 }
 
-void Palette::loadAmigaPalette(Common::ReadStream &stream, int colors) {
-	if (colors == -1)
-		colors = _numColors;
+void Palette::loadAmigaPalette(Common::ReadStream &stream, int startIndex, int colors) {
+	assert(startIndex + colors <= _numColors);
 
-	assert(colors <= _numColors);
-
 	for (int i = 0; i < colors; ++i) {
 		uint16 col = stream.readUint16BE();
-		_palData[i * 3 + 2] = ((col & 0xF) * 0xFF) / 0x3F; col >>= 4;
-		_palData[i * 3 + 1] = ((col & 0xF) * 0xFF) / 0x3F; col >>= 4;
-		_palData[i * 3 + 0] = ((col & 0xF) * 0xFF) / 0x3F; col >>= 4;
+		_palData[(i + startIndex) * 3 + 2] = ((col & 0xF) * 0xFF) / 0x3F; col >>= 4;
+		_palData[(i + startIndex) * 3 + 1] = ((col & 0xF) * 0xFF) / 0x3F; col >>= 4;
+		_palData[(i + startIndex) * 3 + 0] = ((col & 0xF) * 0xFF) / 0x3F; col >>= 4;
 	}
-
-	memset(_palData + colors * 3, 0, (_numColors - colors) * 3);
 }
 
-void Palette::loadPC98Palette(Common::ReadStream &stream, int colors) {
-	if (colors == -1)
-		colors = _numColors;
+void Palette::loadPC98Palette(Common::ReadStream &stream, int startIndex, int colors) {
+	assert(startIndex + colors <= _numColors);
 
-	assert(colors <= _numColors);
-
 	for (int i = 0; i < colors; ++i) {
 		const byte g = stream.readByte(), r = stream.readByte(), b = stream.readByte();
 
-		_palData[i * 3 + 0] = ((r & 0x0F) * 0x3F) / 0x0F;
-		_palData[i * 3 + 1] = ((g & 0x0F) * 0x3F) / 0x0F;
-		_palData[i * 3 + 2] = ((b & 0x0F) * 0x3F) / 0x0F;
+		_palData[(i + startIndex) * 3 + 0] = ((r & 0x0F) * 0x3F) / 0x0F;
+		_palData[(i + startIndex) * 3 + 1] = ((g & 0x0F) * 0x3F) / 0x0F;
+		_palData[(i + startIndex) * 3 + 2] = ((b & 0x0F) * 0x3F) / 0x0F;
 	}
-
-	memset(_palData + colors * 3, 0, (_numColors - colors) * 3);
 }
 
 void Palette::clear() {

Modified: scummvm/trunk/engines/kyra/screen.h
===================================================================
--- scummvm/trunk/engines/kyra/screen.h	2009-06-29 12:33:47 UTC (rev 41940)
+++ scummvm/trunk/engines/kyra/screen.h	2009-06-29 16:05:50 UTC (rev 41941)
@@ -82,17 +82,17 @@
 	/**
 	 * Load a VGA palette from the given stream.
 	 */
-	void loadVGAPalette(Common::ReadStream &stream, int colors = -1);
+	void loadVGAPalette(Common::ReadStream &stream, int startIndex, int colors);
 
 	/**
 	 * Load a AMIGA palette from the given stream.
 	 */
-	void loadAmigaPalette(Common::ReadStream &stream, int colors = -1);
+	void loadAmigaPalette(Common::ReadStream &stream, int startIndex, int colors);
 
 	/**
 	 * Load a PC98 16 color palette from the given stream.
 	 */
-	void loadPC98Palette(Common::ReadStream &stream, int colors = -1);
+	void loadPC98Palette(Common::ReadStream &stream, int startIndex, int colors);
 
 	/**
 	 * Return the number of colors this palette manages.


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list