[Scummvm-cvs-logs] SF.net SVN: scummvm:[40082] scummvm/trunk/engines/sci/gfx/res_pal.cpp

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Wed Apr 22 22:08:59 CEST 2009


Revision: 40082
          http://scummvm.svn.sourceforge.net/scummvm/?rev=40082&view=rev
Author:   thebluegr
Date:     2009-04-22 20:08:59 +0000 (Wed, 22 Apr 2009)

Log Message:
-----------
Cleanup

Modified Paths:
--------------
    scummvm/trunk/engines/sci/gfx/res_pal.cpp

Modified: scummvm/trunk/engines/sci/gfx/res_pal.cpp
===================================================================
--- scummvm/trunk/engines/sci/gfx/res_pal.cpp	2009-04-22 17:54:30 UTC (rev 40081)
+++ scummvm/trunk/engines/sci/gfx/res_pal.cpp	2009-04-22 20:08:59 UTC (rev 40082)
@@ -42,22 +42,13 @@
 Palette *gfxr_read_pal11(int id, byte *resource, int size) {
 	int start_color = resource[25];
 	int format = resource[32];
-	int entry_size = 0;
-	Palette *retval;
+	int offset = (format == SCI_PAL_FORMAT_VARIABLE_FLAGS) ? 1 : 0;
+	int entry_size = 3 + offset;
 	byte *pal_data = resource + 37;
 	int _colors_nr = READ_LE_UINT16(resource + 29);
+	Palette *retval = new Palette(_colors_nr + start_color);
 	int i;
 
-	switch (format) {
-	case SCI_PAL_FORMAT_VARIABLE_FLAGS :
-		entry_size = 4;
-		break;
-	case SCI_PAL_FORMAT_CONSTANT_FLAGS :
-		entry_size = 3;
-		break;
-	}
-
-	retval = new Palette(_colors_nr + start_color);
 	char buf[100];
 	sprintf(buf, "read_pal11 (id %d)", id);
 	retval->name = buf;
@@ -66,14 +57,7 @@
 		retval->setColor(i, 0, 0, 0);
 	}
 	for (i = start_color; i < start_color + _colors_nr; i ++) {
-		switch (format) {
-		case SCI_PAL_FORMAT_CONSTANT_FLAGS:
-			retval->setColor(i, pal_data[0], pal_data[1], pal_data[2]);
-			break;
-		case SCI_PAL_FORMAT_VARIABLE_FLAGS:
-			retval->setColor(i, pal_data[1], pal_data[2], pal_data[3]);
-			break;
-		}
+		retval->setColor(i, pal_data[0 + offset], pal_data[1 + offset], pal_data[2 + offset]);
 		pal_data += entry_size;
 	}
 
@@ -93,18 +77,10 @@
 	pos = PALETTE_START;
 
 	while (pos < size/* && resource[pos] == COLOR_OK && counter < MAX_COLORS*/) {
-		int color = resource[pos] | (resource[pos + 1] << 8) | (resource[pos + 2] << 16) | (resource[pos + 3] << 24);
-
+		colors[counter++] = resource[pos] | (resource[pos + 1] << 8) | (resource[pos + 2] << 16) | (resource[pos + 3] << 24);
 		pos += 4;
-
-		colors[counter++] = color;
 	}
 
-	if (counter < MAX_COLORS && resource[pos] != COLOR_OK) {
-		GFXERROR("Palette %04x uses unknown palette color prefix 0x%02x at offset 0x%04x\n", id, resource[pos], pos);
-		return NULL;
-	}
-
 	if (counter < MAX_COLORS) {
 		GFXERROR("Palette %04x ends prematurely\n", id);
 		return NULL;


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