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

athrxx at users.sourceforge.net athrxx at users.sourceforge.net
Mon Sep 21 01:25:39 CEST 2009


Revision: 44223
          http://scummvm.svn.sourceforge.net/scummvm/?rev=44223&view=rev
Author:   athrxx
Date:     2009-09-20 23:25:39 +0000 (Sun, 20 Sep 2009)

Log Message:
-----------
LOL/PC-98: start fixing color issues (still not working correctly though)

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/lol.cpp
    scummvm/trunk/engines/kyra/lol.h
    scummvm/trunk/engines/kyra/scene_lol.cpp
    scummvm/trunk/engines/kyra/screen_lol.cpp
    scummvm/trunk/engines/kyra/sprites_lol.cpp

Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp	2009-09-20 23:00:08 UTC (rev 44222)
+++ scummvm/trunk/engines/kyra/lol.cpp	2009-09-20 23:25:39 UTC (rev 44223)
@@ -1697,12 +1697,18 @@
 void LoLEngine::generateBrightnessPalette(const Palette &src, Palette &dst, int brightness, int modifier) {
 	dst.copy(src);
 	if (_flags.use16ColorMode) {
-		if (!(brightness && modifier >= 0 && modifier < 8 && (_flagsTable[31] & 0x08)))
+		if (!brightness)
+			modifier = 0;
+		else if (modifier < 0 || modifier > 7 || (_flagsTable[31] & 0x08))
 			modifier = 8;
+		
 		modifier >>= 1;
 		if (modifier)
 			modifier--;
-		_blockBrightness = 16 * modifier;
+		if (modifier > 3)
+			modifier = 3;
+		_blockBrightness = modifier << 4;
+		_sceneUpdateRequired = true;
 
 	} else {
 		_screen->loadSpecialColors(dst);
@@ -1743,7 +1749,6 @@
 		return;
 
 	if (_flags.use16ColorMode) {
-
 		_screen->loadPalette("lol.nol", _screen->getPalette(0));
 	} else {
 		Palette tpal(256);
@@ -3902,7 +3907,8 @@
 	for (int i = 0; i < 109; i++)
 		_automapShapes[i] = _screen->getPtrToShape(shp, i + 11);
 
-	_screen->generateGrayOverlay(_screen->getPalette(3), _mapOverlay, 52, 0, 0, 0, 256, false);
+	if (!_flags.use16ColorMode)
+		_screen->generateGrayOverlay(_screen->getPalette(3), _mapOverlay, 52, 0, 0, 0, 256, false);
 
 	_screen->loadFont(Screen::FID_9_FNT, "FONT9PN.FNT");
 	_screen->loadFont(Screen::FID_6_FNT, "FONT6PN.FNT");

Modified: scummvm/trunk/engines/kyra/lol.h
===================================================================
--- scummvm/trunk/engines/kyra/lol.h	2009-09-20 23:00:08 UTC (rev 44222)
+++ scummvm/trunk/engines/kyra/lol.h	2009-09-20 23:25:39 UTC (rev 44223)
@@ -1095,7 +1095,7 @@
 	uint16 _specialGuiShapeY;
 	uint16 _specialGuiShapeMirrorFlag;
 
-	char _lastSuppFile[12];
+	char _lastBlockDataFile[12];
 	char _lastOverridePalFile[12];
 	char *_lastOverridePalFilePtr;
 	int _lastSpecialColor;

Modified: scummvm/trunk/engines/kyra/scene_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/scene_lol.cpp	2009-09-20 23:00:08 UTC (rev 44222)
+++ scummvm/trunk/engines/kyra/scene_lol.cpp	2009-09-20 23:25:39 UTC (rev 44223)
@@ -348,7 +348,7 @@
 	if (file) {
 		_lastSpecialColor = specialColor;
 		_lastSpecialColorWeight = weight;
-		strcpy(_lastSuppFile, file);
+		strcpy(_lastBlockDataFile, file);
 		if (palFile) {
 			strcpy(_lastOverridePalFile, palFile);
 			_lastOverridePalFilePtr = _lastOverridePalFile;
@@ -359,14 +359,11 @@
 
 	if (_flags.use16ColorMode) {
 		if (_lastSpecialColor == 0x66)
-			//_lastSpecialColor = stricmp(file, "YVEL2") ? 0xcc : 0x44;
-			_lastSpecialColor = scumm_stricmp(file, "YVEL2") ? 0xc : 0x4;
+			_lastSpecialColor = stricmp(file, "YVEL2") ? 0xcc : 0x44;
 		else if (_lastSpecialColor == 0x6b)
-			//_lastSpecialColor = 0xcc;
-			_lastSpecialColor = 0xc;
+			_lastSpecialColor = 0xcc;
 		else
-			//_lastSpecialColor = 0x44;
-			_lastSpecialColor = 0x4;
+			_lastSpecialColor = 0x44;
 	}
 
 	char fname[13];
@@ -374,7 +371,7 @@
 	int tlen = 0;
 
 	if (_flags.use16ColorMode) {
-		snprintf(fname, sizeof(fname), "%s.VCF", _lastSuppFile);
+		snprintf(fname, sizeof(fname), "%s.VCF", _lastBlockDataFile);
 		_screen->loadBitmap(fname, 3, 3, 0);
 		v = _screen->getCPagePtr(2);
 		tlen = READ_LE_UINT16(v) << 5;
@@ -387,7 +384,7 @@
 		memcpy(_vcfBlocks, v, tlen);
 	}
 
-	snprintf(fname, sizeof(fname), "%s.VCN", _lastSuppFile);
+	snprintf(fname, sizeof(fname), "%s.VCN", _lastBlockDataFile);
 	_screen->loadBitmap(fname, 3, 3, 0);
 	v = _screen->getCPagePtr(2);
 	tlen = READ_LE_UINT16(v);
@@ -401,13 +398,12 @@
 	_vcnBlocks = new uint8[vcnLen];
 
 	if (_flags.use16ColorMode) {
-		_screen->getPalette(0).fill(0, 16, 0xff);
 		_screen->loadPalette("LOL.NOL", _screen->getPalette(0));
 
 		/*static const uint8 colTable[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
 		Palette &pl = _screen->getPalette(0);
 		for (int i = 15; i >= 0; i--)			
-			pl.copy(pl, i, 1, colTable[i]);*/
+			pl.copy(pl, i, 1, i);*/
 
 	} else {
 		if (_vcnShift)
@@ -444,7 +440,7 @@
 	memcpy(_vcnBlocks, v, vcnLen);
 	v += vcnLen;
 
-	snprintf(fname, sizeof(fname), "%s.VMP", _lastSuppFile);
+	snprintf(fname, sizeof(fname), "%s.VMP", _lastBlockDataFile);
 	_screen->loadBitmap(fname, 3, 3, 0);
 	v = _screen->getCPagePtr(2);
 
@@ -464,12 +460,13 @@
 		weight = (weight > 0) ? (weight * 255) / 100 : 0;
 		_screen->generateLevelOverlay(_screen->getPalette(0), _screen->getLevelOverlay(i), _lastSpecialColor, weight);
 
-		for (int ii = 0; ii < 128; ii++) {
+		int l = _flags.use16ColorMode ? 256 : 128;
+		for (int ii = 0; ii < l; ii++) {
 			if (_screen->getLevelOverlay(i)[ii] == 255)
 				_screen->getLevelOverlay(i)[ii] = 0;
 		}
 
-		for (int ii = 128; ii < 256; ii++)
+		for (int ii = l; ii < 256; ii++)
 			_screen->getLevelOverlay(i)[ii] = ii & 0xff;
 	}
 
@@ -477,22 +474,21 @@
 		_screen->getLevelOverlay(7)[i] = i & 0xff;
 
 	if (_flags.use16ColorMode) {
-		//_screen->getLevelOverlay(6)[0xee] = 0xee;
-		//if (_lastSpecialColor == 0x44)			
-		//	_screen->getLevelOverlay(5)[0xee] = 0xee;
-		_screen->getLevelOverlay(6)[0xe] = 0xe;
-		if (_lastSpecialColor == 0x4)			
-			_screen->getLevelOverlay(5)[0xe] = 0xe;
+		_screen->getLevelOverlay(6)[0xee] = 0xee;
+		if (_lastSpecialColor == 0x44)			
+			_screen->getLevelOverlay(5)[0xee] = 0xee;
 
 		for (int i = 0; i < 7; i++)
 			memcpy(_screen->getLevelOverlay(i), _screen->getLevelOverlay(i + 1), 256);
 
+		_screen->loadPalette("LOL.NOL", _screen->getPalette(0));
+
 		static const uint8 colTable[] = { 0x00, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, 0x77, 0x88, 0x99, 0xAA, 0xBB, 0xCC, 0xDD, 0xEE, 0xFF };
 		
 		for (int i = 0; i < 8; i++) {
 			uint8 *pl = _screen->getLevelOverlay(7 - i);
-			for (int ii = 15; ii >= 0; ii--)
-				_vcnExpTable[((7 - i) << 4) + ii] = pl[colTable[ii]];
+			for (int ii = 0; ii < 16; ii++)
+				_vcnExpTable[(i << 4) + ii] = pl[colTable[ii]];
 		}
 	}
 
@@ -1496,9 +1492,13 @@
 		gui_disableControls(controlMode);
 
 		if (fadeFlag) {
-			_screen->getPalette(3).copy(_screen->getPalette(0), 128);
-			_screen->loadSpecialColors(_screen->getPalette(3));
-			_screen->fadePalette(_screen->getPalette(3), 10);
+			if (_flags.use16ColorMode) {
+				setPaletteBrightness(_screen->getPalette(0), _brightness, _lampEffect);
+			} else {
+				_screen->getPalette(3).copy(_screen->getPalette(0), 128);
+				_screen->loadSpecialColors(_screen->getPalette(3));
+				_screen->fadePalette(_screen->getPalette(3), 10);
+			}
 			_screen->_fadeFlag = 0;
 		}
 
@@ -2086,10 +2086,26 @@
 				xOffs = _levelShapeProperties[l].shapeX[shpIx];
 				yOffs = _levelShapeProperties[l].shapeY[shpIx];
 				shpIx = _dscOvlMap[shpIx];
-				ovl = _screen->getLevelOverlay(ovlIndex);
+				int ov = ovlIndex;
+				if (_flags.use16ColorMode) {
+					uint8 bb = _blockBrightness >> 4;
+					if (ov > bb)
+						ov -= bb;
+						else
+						ov = 0;
+				}
+				ovl = _screen->getLevelOverlay(ov);
 			} else if (_levelShapeProperties[l].shapeIndex[shpIx] != 0xffff) {
 				scaleW = scaleH = 0x100;
-				ovl = _screen->getLevelOverlay(7);
+				int ov = 7;
+				if (_flags.use16ColorMode) {
+					uint8 bb = _blockBrightness >> 4;
+					if (ov > bb)
+						ov -= bb;
+						else
+						ov = 0;
+				}
+				ovl = _screen->getLevelOverlay(ov);
 			}
 
 			if (_levelShapeProperties[l].shapeIndex[shpIx] != 0xffff) {

Modified: scummvm/trunk/engines/kyra/screen_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen_lol.cpp	2009-09-20 23:00:08 UTC (rev 44222)
+++ scummvm/trunk/engines/kyra/screen_lol.cpp	2009-09-20 23:25:39 UTC (rev 44223)
@@ -165,29 +165,33 @@
 	if (weight > 255)
 		weight = 255;
 
-	uint16 r = srcPal[opColor * 3];
-	uint16 g = srcPal[opColor * 3 + 1];
-	uint16 b = srcPal[opColor * 3 + 2];
+	uint8 *srt = new uint8[768];
+	memset(srt, 0x3f, 768);
+	memcpy(srt, srcPal.getData(), srcPal.getNumColors() * 3);
+	
+	uint16 r = srt[opColor * 3];
+	uint16 g = srt[opColor * 3 + 1];
+	uint16 b = srt[opColor * 3 + 2];
 
 	uint8 *d = ovl;
 	*d++ = 0;
 
-	for (int i = 1; i != srcPal.getNumColors() - 1; i++) {
-		uint16 a = srcPal[i * 3];
+	for (int i = 1; i != 255; i++) {
+		uint16 a = srt[i * 3];
 		uint8 dr = a - ((((a - r) * (weight >> 1)) << 1) >> 8);
-		a = srcPal[i * 3 + 1];
+		a = srt[i * 3 + 1];
 		uint8 dg = a - ((((a - g) * (weight >> 1)) << 1) >> 8);
-		a = srcPal[i * 3 + 2];
+		a = srt[i * 3 + 2];
 		uint8 db = a - ((((a - b) * (weight >> 1)) << 1) >> 8);
 
 		int l = opColor;
-		int m = 0x7fff;
-		int ii = 127;
+		int m = _use16ColorMode ? 0xffff : 0x7fff;
+		int ii = _use16ColorMode ? 255 : 127;
 		int x = 1;
-		const uint8 *s = srcPal.getData() + 3;
+		const uint8 *s = srt + 3;
 
 		do {
-			if (i == x) {
+			if (!_use16ColorMode && i == x) {
 				s += 3;
 			} else {
 				int t = *s++ - dr;
@@ -203,8 +207,10 @@
 				}
 
 				if (c <= m) {
-					m = c;
-					l = x;
+					if (!_use16ColorMode || x != opColor && i != x) {
+						m = c;
+						l = x;
+					}
 				}
 			}
 			x++;
@@ -213,6 +219,7 @@
 		*d++ = l & 0xff;
 	}
 
+	delete []srt;
 	return ovl;
 }
 

Modified: scummvm/trunk/engines/kyra/sprites_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sprites_lol.cpp	2009-09-20 23:00:08 UTC (rev 44222)
+++ scummvm/trunk/engines/kyra/sprites_lol.cpp	2009-09-20 23:25:39 UTC (rev 44223)
@@ -940,6 +940,14 @@
 	if (d > 7)
 		d = 7;
 
+	if (_flags.use16ColorMode) {
+		uint8 bb = _blockBrightness >> 4;
+		if (d > bb)
+			d -= bb;
+		else
+			d = 0;
+	}
+
 	uint8 *ovl = _screen->getLevelOverlay(d);
 	int doorScaledWitdh = _screen->getShapeScaledWidth(shape, _dmScaleW);
 
@@ -992,6 +1000,13 @@
 	if (tblValue == -1) {
 		r = 7 - ((r / 3) - 1);
 		r = CLIP(r, 0, 7);
+		if (_flags.use16ColorMode) {
+			uint8 bb = _blockBrightness >> 4;
+			if (r > bb)
+				r -= bb;
+			else
+				r = 0;
+		}
 		ovl = _screen->getLevelOverlay(r);
 	} else {
 		memset(tmpOvl + 1, tblValue, 15);


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