[Scummvm-git-logs] scummvm master -> fd45d6cca7c35b1b53517d78aa12d2e2074b4af9

antoniou79 a.antoniou79 at gmail.com
Sat Jul 3 16:39:35 UTC 2021


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:
fd45d6cca7 BLADERUNNER: Fix map from 5bit color to 8bit


Commit: fd45d6cca7c35b1b53517d78aa12d2e2074b4af9
    https://github.com/scummvm/scummvm/commit/fd45d6cca7c35b1b53517d78aa12d2e2074b4af9
Author: antoniou79 (a.antoniou79 at gmail.com)
Date: 2021-07-03T19:31:48+03:00

Commit Message:
BLADERUNNER: Fix map from 5bit color to 8bit

This fixes a bug with Izo's flash not entirely hiding McCoy, Izo and NPCs

White value was previously calculated as r,g,b (248,248,248) instead of (255,255,255)

Changed paths:
  A engines/bladerunner/color.cpp
    engines/bladerunner/color.h
    engines/bladerunner/debugger.cpp
    engines/bladerunner/module.mk
    engines/bladerunner/script/scene/hc01.cpp
    engines/bladerunner/slice_animations.cpp
    engines/bladerunner/slice_renderer.cpp


diff --git a/engines/bladerunner/color.cpp b/engines/bladerunner/color.cpp
new file mode 100644
index 0000000000..62d8615d91
--- /dev/null
+++ b/engines/bladerunner/color.cpp
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "bladerunner/color.h"
+
+namespace BladeRunner {
+
+// This array essentially stores the conversion from unsigned 5bit values to 8bit
+// ie. ((int)i * 255) / 31 (integer division), for i values 0 to 31	
+// Note that just using a multiplier 256/16 (= 8) will not properly
+// map the color, since eg. value 31 would be mapped to 248 instead of 255.
+const uint8 Color::map5BitsTo8Bits[] = {0, 8, 16, 24, 32, 41, 49, 57, 65, 74, 82, 90, 98, 106, 115, 123, 131, 139, 148, 156, 164, 172, 180, 189, 197, 205, 213, 222, 230, 238, 246, 255};
+
+uint8 Color::get8BitColorFrom5Bit(uint8 col5b) {
+	if (col5b > 31) {
+		// A value larger than 31 is invalid (never going to happen for 5bits)
+		// but still catch the case, since the parameter is 8bits
+		return 255;
+	}
+	return map5BitsTo8Bits[col5b];
+}
+	
+} // End of namespace BladeRunner
\ No newline at end of file
diff --git a/engines/bladerunner/color.h b/engines/bladerunner/color.h
index 8123f775d1..aa27816cc3 100644
--- a/engines/bladerunner/color.h
+++ b/engines/bladerunner/color.h
@@ -27,7 +27,11 @@
 
 namespace BladeRunner {
 
-struct Color {
+class Color {
+
+	static const uint8 map5BitsTo8Bits[32];
+
+public:
 	float r;
 	float g;
 	float b;
@@ -35,6 +39,8 @@ struct Color {
 	Color() : r(0.0f), g(0.0f), b(0.0f) {}
 
 	Color(float r_, float g_, float b_) : r(r_), g(g_), b(b_) {}
+
+	static uint8 get8BitColorFrom5Bit(uint8 col5b);
 };
 
 #include "common/pack-start.h"
diff --git a/engines/bladerunner/debugger.cpp b/engines/bladerunner/debugger.cpp
index d65188eb1f..780e2ebf93 100644
--- a/engines/bladerunner/debugger.cpp
+++ b/engines/bladerunner/debugger.cpp
@@ -2617,12 +2617,11 @@ void Debugger::drawScreenEffects() {
 					Common::Rect r((entry.x + x) * 2, (entry.y + y) * 2, (entry.x + x) * 2 + 2, (entry.y + y) * 2 + 2);
 
 					int ec = entry.data[j++];
-					const int bladeToScummVmConstant = 256 / 16;
-
+					// We need to convert from 5 bits per channel (r,g,b) to 8 bits
 					int color = _vm->_surfaceFront.format.RGBToColor(
-						CLIP(entry.palette[ec].r * bladeToScummVmConstant, 0, 255),
-						CLIP(entry.palette[ec].g * bladeToScummVmConstant, 0, 255),
-						CLIP(entry.palette[ec].b * bladeToScummVmConstant, 0, 255));
+						Color::get8BitColorFrom5Bit(entry.palette[ec].r),
+						Color::get8BitColorFrom5Bit(entry.palette[ec].g),
+						Color::get8BitColorFrom5Bit(entry.palette[ec].b));
 					_vm->_surfaceFront.fillRect(r, color);
 				}
 			}
diff --git a/engines/bladerunner/module.mk b/engines/bladerunner/module.mk
index aae2394a9b..202c00443e 100644
--- a/engines/bladerunner/module.mk
+++ b/engines/bladerunner/module.mk
@@ -17,6 +17,7 @@ MODULE_OBJS = \
 	bladerunner.o \
 	boundingbox.o \
 	chapters.o \
+	color.o \
 	combat.o \
 	crimes_database.o \
 	debugger.o \
diff --git a/engines/bladerunner/script/scene/hc01.cpp b/engines/bladerunner/script/scene/hc01.cpp
index b82ec95d76..b86beb724a 100644
--- a/engines/bladerunner/script/scene/hc01.cpp
+++ b/engines/bladerunner/script/scene/hc01.cpp
@@ -113,10 +113,13 @@ bool SceneScriptHC01::ClickedOnActor(int actorId) {
 			if (!Game_Flag_Query(kFlagHC01IzoTalk1)) {
 				Actor_Face_Actor(kActorIzo, kActorMcCoy, true);
 				if (_vm->_cutContent) {
-					Actor_Says_With_Pause(kActorIzo,  0, 0.2f, 13);
+					Actor_Says_With_Pause(kActorIzo, 0, 0.2f, 13);
+					Actor_Face_Actor(kActorMcCoy, kActorIzo, true);
+					Actor_Says_With_Pause(kActorIzo, 10, 0.2f, 13);
+				} else {
+					Actor_Says_With_Pause(kActorIzo, 10, 0.2f, 13);
+					Actor_Face_Actor(kActorMcCoy, kActorIzo, true);
 				}
-				Actor_Says_With_Pause(kActorIzo, 10, 0.2f, 13);
-				Actor_Face_Actor(kActorMcCoy, kActorIzo, true);
 				Actor_Says(kActorIzo, 20, 17);
 				Actor_Says(kActorMcCoy, 1035, 18);
 				Actor_Says_With_Pause(kActorIzo, 30, 0.2f, 17);
@@ -216,6 +219,7 @@ bool SceneScriptHC01::ClickedOn2DRegion(int region) {
 
 void SceneScriptHC01::SceneFrameAdvanced(int frame) {
 	Set_Fade_Color(1.0f, 1.0f, 1.0f);
+
 	if (frame >= 61
 	 && frame < 65
 	) {
diff --git a/engines/bladerunner/slice_animations.cpp b/engines/bladerunner/slice_animations.cpp
index b501c63205..32e39eeccc 100644
--- a/engines/bladerunner/slice_animations.cpp
+++ b/engines/bladerunner/slice_animations.cpp
@@ -58,8 +58,8 @@ bool SliceAnimations::open(const Common::String &name) {
 			_palettes[i].color[j].g = color_g;
 			_palettes[i].color[j].b = color_b;
 
-			const int bladeToScummVmConstant = 256 / 32; // 5 bits to 8 bits
-			_palettes[i].value[j] = screenFormat.RGBToColor(color_r * bladeToScummVmConstant, color_g * bladeToScummVmConstant, color_b * bladeToScummVmConstant);
+			// We need to convert from 5 bits per channel (r,g,b) to 8 bits
+			_palettes[i].value[j] = screenFormat.RGBToColor(Color::get8BitColorFrom5Bit(color_r), Color::get8BitColorFrom5Bit(color_g), Color::get8BitColorFrom5Bit(color_b));
 		}
 	}
 
diff --git a/engines/bladerunner/slice_renderer.cpp b/engines/bladerunner/slice_renderer.cpp
index 6997305d7b..c40f7da372 100644
--- a/engines/bladerunner/slice_renderer.cpp
+++ b/engines/bladerunner/slice_renderer.cpp
@@ -582,9 +582,8 @@ void SliceRenderer::drawSlice(int slice, bool advanced, int y, Graphics::Surface
 						color.r = ((int)(_setEffectColor.r + _lightsColor.r * color.r) / 65536) + aescColor.r;
 						color.g = ((int)(_setEffectColor.g + _lightsColor.g * color.g) / 65536) + aescColor.g;
 						color.b = ((int)(_setEffectColor.b + _lightsColor.b * color.b) / 65536) + aescColor.b;
-
-						int bladeToScummVmConstant = 256 / 32;
-						outColor = _pixelFormat.RGBToColor(CLIP(color.r * bladeToScummVmConstant, 0, 255), CLIP(color.g * bladeToScummVmConstant, 0, 255), CLIP(color.b * bladeToScummVmConstant, 0, 255));
+						// We need to convert from 5 bits per channel (r,g,b) to 8 bits
+						outColor = _pixelFormat.RGBToColor(Color::get8BitColorFrom5Bit(color.r), Color::get8BitColorFrom5Bit(color.g), Color::get8BitColorFrom5Bit(color.b));
 					}
 
 					for (int x = previousVertexX; x != vertexX; ++x) {




More information about the Scummvm-git-logs mailing list