[Scummvm-git-logs] scummvm master -> 399154408d57d72c7fb88e598a00dfdb62828286

neuromancer noreply at scummvm.org
Mon Jul 24 10:11:12 UTC 2023


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

Summary:
9984e72a24 FREESCAPE: correctly handle screen resize event while demo
19592e8ca1 FREESCAPE: correct computation of mouse position when moving pointer in shooting mode
9cd2572404 FREESCAPE: refactor color remapping code
5efd95f101 FREESCAPE: convert condition bytecode to uint16 to better parse Amiga/Atari conditions
399154408d FREESCAPE: more precise implementation of the SPFX opcode for Amiga/Atari


Commit: 9984e72a248c336afca30b58b96d814cb3b77152
    https://github.com/scummvm/scummvm/commit/9984e72a248c336afca30b58b96d814cb3b77152
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-24T11:43:00+02:00

Commit Message:
FREESCAPE: correctly handle screen resize event while demo

Changed paths:
    engines/freescape/freescape.cpp


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 2ae013a8882..b06af4285bc 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -341,7 +341,9 @@ void FreescapeEngine::processInput() {
 
 	while (g_system->getEventManager()->pollEvent(event)) {
 		if (_demoMode) {
-			if (event.customType != 0xde00)
+			if (event.type == Common::EVENT_SCREEN_CHANGED)
+				; // Allow event
+			else if (event.customType != 0xde00)
 				continue;
 		}
 


Commit: 19592e8ca1850048457d204ddba30657f29e01ff
    https://github.com/scummvm/scummvm/commit/19592e8ca1850048457d204ddba30657f29e01ff
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-24T11:43:00+02:00

Commit Message:
FREESCAPE: correct computation of mouse position when moving pointer in shooting mode

Changed paths:
    engines/freescape/freescape.cpp


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index b06af4285bc..1b55c7a8b1f 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -470,7 +470,7 @@ void FreescapeEngine::processInput() {
 				g_system->warpMouse(mousePos.x, mousePos.y);
 
 			if (_shootMode) {
-				Common::Point resolution = _gfx->nativeResolution();
+				Common::Point resolution(g_system->getWidth(), g_system->getHeight());
 				_crossairPosition.x = _screenW * mousePos.x / resolution.x;
 				_crossairPosition.y = _screenH * mousePos.y / resolution.y;
 				break;


Commit: 9cd25724046dc05854e0d7378dbd79dec4be9e74
    https://github.com/scummvm/scummvm/commit/9cd25724046dc05854e0d7378dbd79dec4be9e74
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-24T11:43:00+02:00

Commit Message:
FREESCAPE: refactor color remapping code

Changed paths:
    engines/freescape/freescape.cpp
    engines/freescape/gfx.cpp
    engines/freescape/language/instruction.cpp


diff --git a/engines/freescape/freescape.cpp b/engines/freescape/freescape.cpp
index 1b55c7a8b1f..9a00d706e69 100644
--- a/engines/freescape/freescape.cpp
+++ b/engines/freescape/freescape.cpp
@@ -297,6 +297,10 @@ void FreescapeEngine::drawFrame() {
 				drawSensorShoot(sensor);
 		}
 		_underFireFrames--;
+		if (_underFireFrames == 0) {
+			_currentArea->unremapColor(_currentArea->_usualBackgroundColor);
+			_currentArea->unremapColor(_currentArea->_skyColor);
+		}
 	}
 
 	if (_shootingFrames > 0) {
@@ -308,9 +312,6 @@ void FreescapeEngine::drawFrame() {
 
 	drawBorder();
 	drawUI();
-
-	_currentArea->unremapColor(_currentArea->_usualBackgroundColor);
-	_currentArea->unremapColor(_currentArea->_skyColor);
 }
 
 void FreescapeEngine::pressedKey(const int keycode) {}
diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index 530f79588d5..73caa384836 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -215,6 +215,15 @@ uint8 Renderer::indexFromColor(uint8 r, uint8 g, uint8 b) {
 
 void Renderer::setColorRemaps(ColorReMap *colorRemaps) {
 	_colorRemaps = colorRemaps;
+
+	if (_renderMode == Common::kRenderZX) {
+		for (auto &it : *_colorRemaps) {
+			if (it._key == 1)
+				_paperColor = it._value;
+			else if (it._key == 3)
+				_inkColor = it._value;
+		}
+	}
 }
 
 bool Renderer::getRGBAtCGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple) {
@@ -330,6 +339,10 @@ bool Renderer::getRGBAtZX(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r
 }
 
 void Renderer::selectColorFromFourColorPalette(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1) {
+	if (_colorRemaps && _colorRemaps->contains(index)) {
+		index = (*_colorRemaps)[index];
+	}
+
 	if (index == 0) {
 		r1 = 0;
 		g1 = 0;
@@ -392,6 +405,11 @@ bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &
 		readFromPalette(color, r2, g2, b2);
 	} else {
 		color = mapEGAColor(index);
+
+		if (_colorRemaps && _colorRemaps->contains(color)) {
+			color = (*_colorRemaps)[color];
+		}
+
 		readFromPalette(color, r1, g1, b1);
 		r2 = r1;
 		g2 = g1;
@@ -401,16 +419,6 @@ bool Renderer::getRGBAtEGA(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &
 }
 
 bool Renderer::getRGBAt(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2, uint8 &g2, uint8 &b2, byte *&stipple) {
-
-	if (_colorRemaps && _colorRemaps->contains(index)) {
-		index = (*_colorRemaps)[index];
-		readFromPalette(index, r1, g1, b1);
-		r2 = r1;
-		g2 = g1;
-		b2 = b1;
-		return true;
-	}
-
 	if (index == _keyColor)
 		return false;
 
@@ -423,6 +431,9 @@ bool Renderer::getRGBAt(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2,
 	}
 
 	if (_renderMode == Common::kRenderAmiga || _renderMode == Common::kRenderAtariST) {
+		if (_colorRemaps && _colorRemaps->contains(index))
+			index = (*_colorRemaps)[index];
+
 		readFromPalette(index, r1, g1, b1);
 		r2 = r1;
 		g2 = g1;
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 17ebb83f044..18ee4a33f44 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -295,7 +295,7 @@ void FreescapeEngine::executeSPFX(FCLInstruction &instruction) {
 	uint16 src = instruction._source;
 	uint16 dst = instruction._destination;
 	if (isAmiga() || isAtariST()) {
-		int color;
+		/*int color;
 		if (src == 0 && dst >= 2 && dst <= 5) {
 			_currentArea->remapColor(dst, 1);
 			return;
@@ -315,11 +315,29 @@ void FreescapeEngine::executeSPFX(FCLInstruction &instruction) {
 			default:
 				color = 0;
 			}
-		}
+		}*/
 
-		debugC(1, kFreescapeDebugCode, "Switching complete palette to color %d", dst);
-		for (int i = 1; i < 16; i++)
-			_currentArea->remapColor(i, color);
+		/*if (dst == 0) {
+			debugC(1, kFreescapeDebugCode, "Switching complete palette to color %d", dst);
+			for (int i = 1; i < 16; i++)
+				_currentArea->remapColor(i, src);
+		} else {
+			if (src == 1) {
+				_currentArea->remapColor(dst, 2);
+			} else if (src == 2)
+				_currentArea->remapColor(dst, 15 - src);
+		}*/
+		if (src == 0) {
+			_currentArea->remapColor(dst, 8);
+		} else if (src == 1) {
+			for (int i = 1; i < 16; i++)
+				_currentArea->remapColor(i, dst + 1);
+		} else if (src == 2) {
+			for (int i = 1; i < 16; i++)
+				_currentArea->remapColor(i, 0);
+
+			_currentArea->remapColor(dst, 15 - 2);
+		}
 	} else {
 		debugC(1, kFreescapeDebugCode, "Switching palette from position %d to %d", src, dst);
 		if (src == 0 && dst == 1)
@@ -329,6 +347,7 @@ void FreescapeEngine::executeSPFX(FCLInstruction &instruction) {
 		else
 			_currentArea->remapColor(src, dst);
 	}
+	_gfx->setColorRemaps(&_currentArea->_colorRemaps);
 	executeRedraw(instruction);
 }
 


Commit: 5efd95f1019b9ba5e23c610dcb3bd5e3898fcc8b
    https://github.com/scummvm/scummvm/commit/5efd95f1019b9ba5e23c610dcb3bd5e3898fcc8b
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-24T11:43:00+02:00

Commit Message:
FREESCAPE: convert condition bytecode to uint16 to better parse Amiga/Atari conditions

Changed paths:
    engines/freescape/freescape.h
    engines/freescape/games/driller/driller.cpp
    engines/freescape/language/8bitDetokeniser.cpp
    engines/freescape/language/8bitDetokeniser.h
    engines/freescape/language/instruction.cpp
    engines/freescape/loaders/8bitBinaryLoader.cpp


diff --git a/engines/freescape/freescape.h b/engines/freescape/freescape.h
index 90bbdf1f1b3..cc141fb4bda 100644
--- a/engines/freescape/freescape.h
+++ b/engines/freescape/freescape.h
@@ -189,7 +189,7 @@ public:
 	Common::Event decodeDOSMouseEvent(int code, int repetition);
 
 	uint16 readField(Common::SeekableReadStream *file, int nbits);
-	Common::Array<uint8> readArray(Common::SeekableReadStream *file, int size);
+	Common::Array<uint16> readArray(Common::SeekableReadStream *file, int size);
 
 	// 8-bit
 	void load8bitBinary(Common::SeekableReadStream *file, int offset, int ncolors);
diff --git a/engines/freescape/games/driller/driller.cpp b/engines/freescape/games/driller/driller.cpp
index e61483762c0..63af0163125 100644
--- a/engines/freescape/games/driller/driller.cpp
+++ b/engines/freescape/games/driller/driller.cpp
@@ -204,7 +204,7 @@ void DrillerEngine::loadAssetsFullGame() {
 	*/
 
 	FCLInstructionVector instructions;
-	Common::Array<uint8> conditionArray;
+	Common::Array<uint16> conditionArray;
 
 	conditionArray.push_back(0xb);
 	conditionArray.push_back(0x20);
diff --git a/engines/freescape/language/8bitDetokeniser.cpp b/engines/freescape/language/8bitDetokeniser.cpp
index 2fc96f03c9c..9b14205e1a1 100644
--- a/engines/freescape/language/8bitDetokeniser.cpp
+++ b/engines/freescape/language/8bitDetokeniser.cpp
@@ -33,7 +33,7 @@ uint8 k8bitMaxVariable = 64;
 uint8 k8bitMaxShield = 64;
 uint8 k8bitMaxEnergy = 64;
 
-Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition, FCLInstructionVector &instructions, bool multipleConditionals) {
+Common::String detokenise8bitCondition(Common::Array<uint16> &tokenisedCondition, FCLInstructionVector &instructions, bool isAmigaAtari) {
 	Common::String detokenisedStream;
 	Common::Array<uint8>::size_type bytePointer = 0;
 	Common::Array<uint8>::size_type sizeOfTokenisedContent = tokenisedCondition.size();
@@ -365,8 +365,13 @@ Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition,
 			// this should toggle border colour or the room palette
 			detokenisedStream += "SPFX (";
 			currentInstruction = FCLInstruction(Token::SPFX);
-			currentInstruction.setSource(tokenisedCondition[bytePointer] >> 4);
-			currentInstruction.setDestination(tokenisedCondition[bytePointer] & 0xf);
+			if (isAmigaAtari) {
+				currentInstruction.setSource(tokenisedCondition[bytePointer] >> 8);
+				currentInstruction.setDestination(tokenisedCondition[bytePointer] & 0xff);
+			} else {
+				currentInstruction.setSource(tokenisedCondition[bytePointer] >> 4);
+				currentInstruction.setDestination(tokenisedCondition[bytePointer] & 0xf);
+			}
 			detokenisedStream += Common::String::format("%d, %d)", currentInstruction._source, currentInstruction._destination);
 			conditionalInstructions->push_back(currentInstruction);
 			currentInstruction = FCLInstruction(Token::UNKNOWN);
diff --git a/engines/freescape/language/8bitDetokeniser.h b/engines/freescape/language/8bitDetokeniser.h
index 8ba7c11a3f0..09df12a11e3 100644
--- a/engines/freescape/language/8bitDetokeniser.h
+++ b/engines/freescape/language/8bitDetokeniser.h
@@ -47,7 +47,7 @@ extern uint8 k8bitMaxVariable;
 extern uint8 k8bitMaxShield;
 extern uint8 k8bitMaxEnergy;
 
-Common::String detokenise8bitCondition(Common::Array<uint8> &tokenisedCondition, FCLInstructionVector &instructions, bool enableActivated);
+Common::String detokenise8bitCondition(Common::Array<uint16> &tokenisedCondition, FCLInstructionVector &instructions, bool enableActivated);
 
 } // End of namespace Freescape
 
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 18ee4a33f44..9cfba5f16e5 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -295,49 +295,17 @@ void FreescapeEngine::executeSPFX(FCLInstruction &instruction) {
 	uint16 src = instruction._source;
 	uint16 dst = instruction._destination;
 	if (isAmiga() || isAtariST()) {
-		/*int color;
-		if (src == 0 && dst >= 2 && dst <= 5) {
-			_currentArea->remapColor(dst, 1);
-			return;
-		}
-
-		if (src == 0) {
-			color = dst;
-		} else {
-
-			switch (src) {
-			case 1:
-				color = 15;
-			break;
-			case 2:
-				color = 14;
-			break;
-			default:
-				color = 0;
-			}
-		}*/
-
-		/*if (dst == 0) {
-			debugC(1, kFreescapeDebugCode, "Switching complete palette to color %d", dst);
-			for (int i = 1; i < 16; i++)
-				_currentArea->remapColor(i, src);
-		} else {
-			if (src == 1) {
-				_currentArea->remapColor(dst, 2);
-			} else if (src == 2)
-				_currentArea->remapColor(dst, 15 - src);
-		}*/
-		if (src == 0) {
-			_currentArea->remapColor(dst, 8);
+		if (src & (1 << 7)) {
+			_currentArea->remapColor(dst & 0x0f, src & 0x70); // src & 0x77, dst & 0x0f
 		} else if (src == 1) {
 			for (int i = 1; i < 16; i++)
-				_currentArea->remapColor(i, dst + 1);
-		} else if (src == 2) {
+				_currentArea->remapColor(i, dst);
+		} /*else if (src == 2) {
 			for (int i = 1; i < 16; i++)
 				_currentArea->remapColor(i, 0);
 
 			_currentArea->remapColor(dst, 15 - 2);
-		}
+		}*/
 	} else {
 		debugC(1, kFreescapeDebugCode, "Switching palette from position %d to %d", src, dst);
 		if (src == 0 && dst == 1)
diff --git a/engines/freescape/loaders/8bitBinaryLoader.cpp b/engines/freescape/loaders/8bitBinaryLoader.cpp
index df7a726535e..f0ea401ebe0 100644
--- a/engines/freescape/loaders/8bitBinaryLoader.cpp
+++ b/engines/freescape/loaders/8bitBinaryLoader.cpp
@@ -62,13 +62,16 @@ uint16 FreescapeEngine::readField(Common::SeekableReadStream *file, int bits) {
 	return value;
 }
 
-Common::Array<uint8> FreescapeEngine::readArray(Common::SeekableReadStream *file, int size) {
-	byte *data = (byte *)malloc(size);
+Common::Array<uint16> FreescapeEngine::readArray(Common::SeekableReadStream *file, int size) {
+	Common::Array<uint16> array;
+
 	for (int i = 0; i < size; i++) {
-		data[i] = readField(file, 8);
+		if (isAmiga() || isAtariST()) {
+			uint16 value = file->readUint16BE();
+			array.push_back(value);
+		} else
+			array.push_back(readField(file, 8));
 	}
-	Common::Array<uint8> array(data, size);
-	free(data);
 	return array;
 }
 
@@ -193,8 +196,8 @@ Object *FreescapeEngine::load8bitObject(Common::SeekableReadStream *file) {
 		FCLInstructionVector instructions;
 		Common::String conditionSource;
 		if (byteSizeOfObject) {
-			Common::Array<uint8> conditionArray = readArray(file, byteSizeOfObject);
-			conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
+			Common::Array<uint16> conditionArray = readArray(file, byteSizeOfObject);
+			conditionSource = detokenise8bitCondition(conditionArray, instructions, isAmiga() || isAtariST());
 			// instructions = getInstructions(conditionSource);
 			debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
 		}
@@ -263,8 +266,8 @@ Object *FreescapeEngine::load8bitObject(Common::SeekableReadStream *file) {
 		byteSizeOfObject = byteSizeOfObject - 5;
 		// grab the object condition, if there is one
 		if (byteSizeOfObject) {
-			Common::Array<uint8> conditionArray = readArray(file, byteSizeOfObject);
-			conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
+			Common::Array<uint16> conditionArray = readArray(file, byteSizeOfObject);
+			conditionSource = detokenise8bitCondition(conditionArray, instructions, isAmiga() || isAtariST());
 			debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
 		}
 		debugC(1, kFreescapeDebugParser, "End of object at %lx", long(file->pos()));
@@ -563,8 +566,8 @@ Area *FreescapeEngine::load8bitArea(Common::SeekableReadStream *file, uint16 nco
 		debugC(1, kFreescapeDebugParser, "length of condition: %d", lengthOfCondition);
 		// get the condition
 		if (lengthOfCondition > 0) {
-			Common::Array<uint8> conditionArray = readArray(file, lengthOfCondition);
-			Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
+			Common::Array<uint16> conditionArray = readArray(file, lengthOfCondition);
+			Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, isAmiga() || isAtariST());
 			area->_conditions.push_back(instructions);
 			area->_conditionSources.push_back(conditionSource);
 			debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());
@@ -661,8 +664,8 @@ void FreescapeEngine::load8bitBinary(Common::SeekableReadStream *file, int offse
 		debugC(1, kFreescapeDebugParser, "length of condition: %d at %lx", lengthOfCondition, long(file->pos()));
 		// get the condition
 		if (lengthOfCondition > 0) {
-			Common::Array<uint8> conditionArray = readArray(file, lengthOfCondition);
-			Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, isCastle());
+			Common::Array<uint16> conditionArray = readArray(file, lengthOfCondition);
+			Common::String conditionSource = detokenise8bitCondition(conditionArray, instructions, isAmiga() || isAtariST());
 			_conditions.push_back(instructions);
 			_conditionSources.push_back(conditionSource);
 			debugC(1, kFreescapeDebugParser, "%s", conditionSource.c_str());


Commit: 399154408d57d72c7fb88e598a00dfdb62828286
    https://github.com/scummvm/scummvm/commit/399154408d57d72c7fb88e598a00dfdb62828286
Author: neuromancer (gustavo.grieco at gmail.com)
Date: 2023-07-24T11:43:00+02:00

Commit Message:
FREESCAPE: more precise implementation of the SPFX opcode for Amiga/Atari

Changed paths:
    engines/freescape/gfx.cpp
    engines/freescape/gfx.h
    engines/freescape/language/instruction.cpp


diff --git a/engines/freescape/gfx.cpp b/engines/freescape/gfx.cpp
index 73caa384836..10ff7bf9b3b 100644
--- a/engines/freescape/gfx.cpp
+++ b/engines/freescape/gfx.cpp
@@ -431,10 +431,14 @@ bool Renderer::getRGBAt(uint8 index, uint8 &r1, uint8 &g1, uint8 &b1, uint8 &r2,
 	}
 
 	if (_renderMode == Common::kRenderAmiga || _renderMode == Common::kRenderAtariST) {
-		if (_colorRemaps && _colorRemaps->contains(index))
-			index = (*_colorRemaps)[index];
+		if (_colorRemaps && _colorRemaps->contains(index)) {
+			int color = (*_colorRemaps)[index];
+			r1 = (color >> 16) & 0xff;
+			g1 = (color >> 8) & 0xff;
+			b1 = color & 0xff;
+		} else
+			readFromPalette(index, r1, g1, b1);
 
-		readFromPalette(index, r1, g1, b1);
 		r2 = r1;
 		g2 = g1;
 		b2 = b1;
diff --git a/engines/freescape/gfx.h b/engines/freescape/gfx.h
index 287fb0ef38a..746e0e3f64f 100644
--- a/engines/freescape/gfx.h
+++ b/engines/freescape/gfx.h
@@ -100,6 +100,7 @@ public:
 
 	// palette
 	void readFromPalette(uint8 index, uint8 &r, uint8 &g, uint8 &b);
+	void setPaletteValue(uint8 index, uint8 r, uint8 g, uint8 b);
 	uint8 indexFromColor(uint8 r, uint8 g, uint8 b);
 	uint8 mapEGAColor(uint8 index);
 
diff --git a/engines/freescape/language/instruction.cpp b/engines/freescape/language/instruction.cpp
index 9cfba5f16e5..0d20ebe765c 100644
--- a/engines/freescape/language/instruction.cpp
+++ b/engines/freescape/language/instruction.cpp
@@ -295,17 +295,45 @@ void FreescapeEngine::executeSPFX(FCLInstruction &instruction) {
 	uint16 src = instruction._source;
 	uint16 dst = instruction._destination;
 	if (isAmiga() || isAtariST()) {
+		uint8 r = 0;
+		uint8 g = 0;
+		uint8 b = 0;
+		uint32 color = 0;
+
 		if (src & (1 << 7)) {
-			_currentArea->remapColor(dst & 0x0f, src & 0x70); // src & 0x77, dst & 0x0f
-		} else if (src == 1) {
+			uint16 v = 0;
+			color = 0;
+			// Extract the color to replace from the src/dst values
+			v = (src & 0x77) << 8;
+			v = v | (dst & 0x70);
+			v = v >> 4;
+
+			// Convert the color to RGB
+			r = (v & 0xf00) >> 8;
+			r = r << 4 | r;
+			r = r & 0xff;
+
+			g = (v & 0xf0) >> 4;
+			g = g << 4 | g;
+			g = g & 0xff;
+
+			b = v & 0xf;
+			b = b << 4 | b;
+			b = b & 0xff;
+
+			color = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
+			_currentArea->remapColor(dst & 0x0f, color); // src & 0x77, dst & 0x0f
+		} else if ((src & 0xf0) >> 4 == 1) {
+			_gfx->readFromPalette(src & 0x0f, r, g, b);
+			color = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
 			for (int i = 1; i < 16; i++)
-				_currentArea->remapColor(i, dst);
-		} /*else if (src == 2) {
+				_currentArea->remapColor(i, color);
+		} else if ((src & 0x0f) == 1) {
+			_gfx->readFromPalette(dst & 0x0f, r, g, b);
+			color = _gfx->_texturePixelFormat.ARGBToColor(0xFF, r, g, b);
 			for (int i = 1; i < 16; i++)
-				_currentArea->remapColor(i, 0);
-
-			_currentArea->remapColor(dst, 15 - 2);
-		}*/
+				_currentArea->remapColor(i, color);
+		}
 	} else {
 		debugC(1, kFreescapeDebugCode, "Switching palette from position %d to %d", src, dst);
 		if (src == 0 && dst == 1)




More information about the Scummvm-git-logs mailing list