[Scummvm-git-logs] scummvm master -> f20c9ab9586108072bb4db129d0e0748a8ae21c5
sluicebox
22204938+sluicebox at users.noreply.github.com
Fri Aug 13 20:36:27 UTC 2021
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
ee43d777c4 SCI: Fix crash in pathfinding debug code
f20c9ab958 SCI: Fix pathfinding debug colors in SCI 1.1 games
Commit: ee43d777c455cdba5eccfc18d3e5a923af9bd35f
https://github.com/scummvm/scummvm/commit/ee43d777c455cdba5eccfc18d3e5a923af9bd35f
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2021-08-13T15:36:15-05:00
Commit Message:
SCI: Fix crash in pathfinding debug code
Fixes crash when kDebugLevelAvoidPath is enabled and kMergePoly merges
room obstacles, such in QFG1VGA after defeating a monster.
The debugging code that draws obstacles uses the polygon type as an
index to a color array and asserts that this value is between 0 and 3,
but that didn't take into account the 0x10 flag that kMergePoly sets.
Changed paths:
engines/sci/engine/kpathing.cpp
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index f148d3e579..d232f78750 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -401,7 +401,7 @@ static void draw_polygon(EngineState *s, reg_t polygon, int width, int height) {
#endif
int size = readSelectorValue(segMan, polygon, SELECTOR(size));
- int type = readSelectorValue(segMan, polygon, SELECTOR(type));
+ int type = readSelectorValue(segMan, polygon, SELECTOR(type)) & ~0x10; // ignore kMergePoly flag
Common::Point first, prev;
int i;
Commit: f20c9ab9586108072bb4db129d0e0748a8ae21c5
https://github.com/scummvm/scummvm/commit/f20c9ab9586108072bb4db129d0e0748a8ae21c5
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2021-08-13T15:36:15-05:00
Commit Message:
SCI: Fix pathfinding debug colors in SCI 1.1 games
The pathfinding debugging code is using Sierra's buggy 8-bit matching
algorithm to find colors for drawing obstacles and path points in most
of the SCI 1.1 games. This usually results all colors being black.
Now we select the good 16-bit algorithm for internal use.
Changed paths:
engines/sci/engine/kpathing.cpp
engines/sci/graphics/palette.cpp
engines/sci/graphics/palette.h
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index d232f78750..b9782ce6f6 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -321,10 +321,10 @@ static void draw_line(EngineState *s, Common::Point p1, Common::Point p2, int ty
int poly_colors[4] = { 0, 0, 0, 0 };
if (getSciVersion() <= SCI_VERSION_1_1) {
- poly_colors[0] = g_sci->_gfxPalette16->kernelFindColor(0, 255, 0); // green
- poly_colors[1] = g_sci->_gfxPalette16->kernelFindColor(0, 0, 255); // blue
- poly_colors[2] = g_sci->_gfxPalette16->kernelFindColor(255, 0, 0); // red
- poly_colors[3] = g_sci->_gfxPalette16->kernelFindColor(255, 255, 0); // yellow
+ poly_colors[0] = g_sci->_gfxPalette16->kernelFindColor(0, 255, 0, true); // green
+ poly_colors[1] = g_sci->_gfxPalette16->kernelFindColor(0, 0, 255, true); // blue
+ poly_colors[2] = g_sci->_gfxPalette16->kernelFindColor(255, 0, 0, true); // red
+ poly_colors[3] = g_sci->_gfxPalette16->kernelFindColor(255, 255, 0, true); // yellow
#ifdef ENABLE_SCI32
} else {
poly_colors[0] = g_sci->_gfxPalette32->matchColor(0, 255, 0); // green
@@ -360,8 +360,8 @@ static void draw_point(EngineState *s, Common::Point p, int start, int width, in
int point_colors[2] = { 0, 0 };
if (getSciVersion() <= SCI_VERSION_1_1) {
- point_colors[0] = g_sci->_gfxPalette16->kernelFindColor(0, 255, 0); // green
- point_colors[1] = g_sci->_gfxPalette16->kernelFindColor(0, 0, 255); // blue
+ point_colors[0] = g_sci->_gfxPalette16->kernelFindColor(0, 255, 0, true); // green
+ point_colors[1] = g_sci->_gfxPalette16->kernelFindColor(0, 0, 255, true); // blue
#ifdef ENABLE_SCI32
} else {
point_colors[0] = g_sci->_gfxPalette32->matchColor(0, 255, 0); // green
diff --git a/engines/sci/graphics/palette.cpp b/engines/sci/graphics/palette.cpp
index f82f99838c..21772b8a6f 100644
--- a/engines/sci/graphics/palette.cpp
+++ b/engines/sci/graphics/palette.cpp
@@ -443,14 +443,14 @@ void GfxPalette::drewPicture(GuiResourceId pictureId) {
}
}
-uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue) {
+uint16 GfxPalette::matchColor(byte matchRed, byte matchGreen, byte matchBlue, bool force16BitColorMatch) {
int16 colorNr;
int16 differenceRed, differenceGreen, differenceBlue;
int16 differenceTotal = 0;
int16 bestDifference = 0x7FFF;
uint16 bestColorNr = 255;
- if (_use16bitColorMatch) {
+ if (_use16bitColorMatch || force16BitColorMatch) {
// used by SCI0 to SCI1, also by the first few SCI1.1 games
for (colorNr = 0; colorNr < 256; colorNr++) {
if ((!_sysPalette.colors[colorNr].used))
@@ -560,8 +560,8 @@ void GfxPalette::kernelSetIntensity(uint16 fromColor, uint16 toColor, uint16 int
}
}
-int16 GfxPalette::kernelFindColor(uint16 r, uint16 g, uint16 b) {
- return matchColor(r, g, b) & SCI_PALETTE_MATCH_COLORMASK;
+int16 GfxPalette::kernelFindColor(uint16 r, uint16 g, uint16 b, bool force16BitColorMatch) {
+ return matchColor(r, g, b, force16BitColorMatch) & SCI_PALETTE_MATCH_COLORMASK;
}
// Returns true, if palette got changed
diff --git a/engines/sci/graphics/palette.h b/engines/sci/graphics/palette.h
index c3e163f52b..abfb0d773a 100644
--- a/engines/sci/graphics/palette.h
+++ b/engines/sci/graphics/palette.h
@@ -55,7 +55,7 @@ public:
void set(Palette *sciPal, bool force, bool forceRealMerge = false, bool includeFirstColor = true);
bool insert(Palette *newPalette, Palette *destPalette, bool includeFirstColor = false);
bool merge(Palette *pFrom, bool force, bool forceRealMerge);
- uint16 matchColor(byte r, byte g, byte b);
+ uint16 matchColor(byte r, byte g, byte b, bool force16BitColorMatch = false);
void getSys(Palette *pal);
uint16 getTotalColorCount() const { return _totalScreenColors; }
@@ -70,7 +70,7 @@ public:
void kernelSetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
void kernelUnsetFlag(uint16 fromColor, uint16 toColor, uint16 flag);
void kernelSetIntensity(uint16 fromColor, uint16 toColor, uint16 intensity, bool setPalette);
- int16 kernelFindColor(uint16 r, uint16 g, uint16 b);
+ int16 kernelFindColor(uint16 r, uint16 g, uint16 b, bool force16BitColorMatch = false);
bool kernelAnimate(byte fromColor, byte toColor, int speed);
void kernelAnimateSet();
reg_t kernelSave();
More information about the Scummvm-git-logs
mailing list