[Scummvm-git-logs] scummvm master -> 5ab39c05cda2b7a97cea7de1fbc635ae1b9a7dec

Strangerke noreply at scummvm.org
Sun Jun 8 14:14:37 UTC 2025


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

Summary:
5ab39c05cd M4: Change the macros in krn_pal to handle differently the grey values, fix 2 erroneous values. This also fixes Coverity


Commit: 5ab39c05cda2b7a97cea7de1fbc635ae1b9a7dec
    https://github.com/scummvm/scummvm/commit/5ab39c05cda2b7a97cea7de1fbc635ae1b9a7dec
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-08T15:14:01+01:00

Commit Message:
M4: Change the macros in krn_pal to handle differently the grey values, fix 2 erroneous values. This also fixes Coverity 1532908, 1533010 and 1563743

Changed paths:
    engines/m4/graphics/krn_pal.cpp
    engines/m4/graphics/krn_pal.h


diff --git a/engines/m4/graphics/krn_pal.cpp b/engines/m4/graphics/krn_pal.cpp
index 68fe3198895..037824e63e7 100644
--- a/engines/m4/graphics/krn_pal.cpp
+++ b/engines/m4/graphics/krn_pal.cpp
@@ -41,12 +41,12 @@ namespace M4 {
 
 #define IS_RIDDLE   g_engine->getGameType() == GType_Riddle
 #define GREY_START	(IS_RIDDLE ? 21 : 32)
-#define NUM_GREYS	(IS_RIDDLE ? 64 : 32)
 #define GREY_END	(IS_RIDDLE ? 58 : 63)
+#define NUM_GREYS   (1 + GREY_END - GREY_START)
 
-#define FREE_START	(IS_RIDDLE ? 59 : 64)
+#define FREE_START	(GREY_END + 1)
 #define FREE_END	255
-#define NUM_FREE	(IS_RIDDLE ? 255 - 59 + 1 : 255 - 64 + 1)
+#define NUM_FREE	(255 - FREE_START + 1)
 
 static HotkeyCB remember_esc_key;
 
@@ -162,7 +162,7 @@ void krn_fade_to_grey(RGB8 *pal, int32 steps, int32 delay) {
 
 	// Make translation table to translate colors using entries 59-255 into 21-58 range
 
-	for (int32 i = 0; i < 32; i++) {
+	for (int32 i = 0; i < NUM_GREYS; i++) {
 		int32 bestMatch = 65;
 		int32 minDist = 255;
 
diff --git a/engines/m4/graphics/krn_pal.h b/engines/m4/graphics/krn_pal.h
index 810cf72d205..288336db789 100644
--- a/engines/m4/graphics/krn_pal.h
+++ b/engines/m4/graphics/krn_pal.h
@@ -68,7 +68,7 @@ struct KernelPal_Globals {
 	RGB8 *_picPal = nullptr;
 	int32 _seriesHash = 0;
 	machine *_seriesAnim8 = nullptr;
-	uint8 _translation[32];		// Only 32 greys in ramp
+	uint8 _translation[38];		// Only 32 greys in ramp for Orion, 38 for Riddle
 
 	int32 _colorAreaX1 = -1;
 	int32 _colorAreaY1 = -1;




More information about the Scummvm-git-logs mailing list