[Scummvm-git-logs] scummvm master -> 49329618cb786f3253c71f9c2f7b99aa0452463b
Strangerke
noreply at scummvm.org
Fri Jun 6 21:46:11 UTC 2025
This automated email contains information about 2 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
7fcdfc21ea M4: RIDDLE: Fix more colors in interface palette
49329618cb M4: Some cleanup in graphics, remove some useless includes
Commit: 7fcdfc21ea5d63eca2e0bbbb905d1a24ba378b16
https://github.com/scummvm/scummvm/commit/7fcdfc21ea5d63eca2e0bbbb905d1a24ba378b16
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-06T22:43:22+01:00
Commit Message:
M4: RIDDLE: Fix more colors in interface palette
Changed paths:
engines/m4/riddle/gui/interface.cpp
diff --git a/engines/m4/riddle/gui/interface.cpp b/engines/m4/riddle/gui/interface.cpp
index f33e6761af4..b357f92ac5f 100644
--- a/engines/m4/riddle/gui/interface.cpp
+++ b/engines/m4/riddle/gui/interface.cpp
@@ -132,11 +132,11 @@ void Interface::freshen_sentence() {
bool Interface::set_interface_palette(RGB8 *myPalette) {
gr_pal_set_RGB8(&myPalette[0], 0, 0, 0);
gr_pal_set_RGB8(&myPalette[1], 0, 0, 0);
- gr_pal_set_RGB8(&myPalette[2], 0, 0, 39);
- gr_pal_set_RGB8(&myPalette[3], 0, 75, 71);
- gr_pal_set_RGB8(&myPalette[4], 0, 107, 103);
- gr_pal_set_RGB8(&myPalette[5], 0, 135, 131);
- gr_pal_set_RGB8(&myPalette[6], 0, 171, 163);
+ gr_pal_set_RGB8(&myPalette[2], 39, 39, 39);
+ gr_pal_set_RGB8(&myPalette[3], 71, 75, 71);
+ gr_pal_set_RGB8(&myPalette[4], 103, 107, 103);
+ gr_pal_set_RGB8(&myPalette[5], 131, 135, 131);
+ gr_pal_set_RGB8(&myPalette[6], 163, 171, 163);
gr_pal_set_RGB8(&myPalette[7], 199, 215, 207);
gr_pal_set_RGB8(&myPalette[8], 235, 247, 231);
gr_pal_set_RGB8(&myPalette[9], 131, 103, 63);
Commit: 49329618cb786f3253c71f9c2f7b99aa0452463b
https://github.com/scummvm/scummvm/commit/49329618cb786f3253c71f9c2f7b99aa0452463b
Author: Strangerke (arnaud.boutonne at gmail.com)
Date: 2025-06-06T22:45:56+01:00
Commit Message:
M4: Some cleanup in graphics, remove some useless includes
Changed paths:
engines/m4/adv_r/adv_inv.h
engines/m4/graphics/gr_buff.cpp
engines/m4/graphics/gr_font.cpp
engines/m4/graphics/gr_line.cpp
engines/m4/graphics/gr_pal.cpp
engines/m4/graphics/gr_series.cpp
engines/m4/graphics/gr_sprite.cpp
engines/m4/graphics/gr_sprite.h
diff --git a/engines/m4/adv_r/adv_inv.h b/engines/m4/adv_r/adv_inv.h
index 246b8a0b63e..26105bbebb8 100644
--- a/engines/m4/adv_r/adv_inv.h
+++ b/engines/m4/adv_r/adv_inv.h
@@ -25,7 +25,6 @@
#include "common/array.h"
#include "common/serializer.h"
-#include "common/stream.h"
namespace M4 {
diff --git a/engines/m4/graphics/gr_buff.cpp b/engines/m4/graphics/gr_buff.cpp
index a507aff4145..a0c2e306dc4 100644
--- a/engines/m4/graphics/gr_buff.cpp
+++ b/engines/m4/graphics/gr_buff.cpp
@@ -112,7 +112,7 @@ int32 gr_buffer_free(Buffer *buf) {
byte *gr_buffer_pointer(Buffer *buf, int32 x, int32 y) {
if (!buf || !buf->data || y < 0 || x < 0) {
error_show(FL, 'BUF!', "buffer_pointer x,y = %d,%d", x, y);
- return 0;
+ return nullptr;
}
return (byte *)(buf->data + x + (y * buf->stride));
@@ -121,7 +121,7 @@ byte *gr_buffer_pointer(Buffer *buf, int32 x, int32 y) {
const byte *gr_buffer_pointer(const Buffer *buf, int32 x, int32 y) {
if (!buf || !buf->data || y < 0 || x < 0) {
error_show(FL, 'BUF!', "buffer_pointer x,y = %d,%d", x, y);
- return 0;
+ return nullptr;
}
return (byte *)(buf->data + x + (y * buf->stride));
@@ -188,9 +188,7 @@ bool gr_buffer_rect_copy(Buffer *from, Buffer *to, int32 x, int32 y, int32 w, in
}
int32 gr_buffer_rect_fill(Buffer *target, int32 x1, int32 y1, int32 w, int32 h) {
- int32 i;
- uint8 *start;
- byte color = gr_color_get_current();
+ const byte color = gr_color_get_current();
// if no data, bad.
if (!target || !target->data)
@@ -209,8 +207,8 @@ int32 gr_buffer_rect_fill(Buffer *target, int32 x1, int32 y1, int32 w, int32 h)
if ((w < 1) || (h < 1))
return true;
- start = target->data + y1 * target->stride + x1;
- for (i = 0; i < h; i++, start += target->stride)
+ uint8 *start = target->data + y1 * target->stride + x1;
+ for (int32 i = 0; i < h; i++, start += target->stride)
memset(start, color, w);
return true;
diff --git a/engines/m4/graphics/gr_font.cpp b/engines/m4/graphics/gr_font.cpp
index b377e7371f7..94d798720e0 100644
--- a/engines/m4/graphics/gr_font.cpp
+++ b/engines/m4/graphics/gr_font.cpp
@@ -21,7 +21,6 @@
#include "m4/graphics/gr_font.h"
#include "m4/graphics/gr_buff.h"
-#include "m4/graphics/gr_pal.h"
#include "m4/mem/mem.h"
#include "m4/core/errors.h"
#include "m4/core/imath.h"
@@ -240,7 +239,7 @@ int32 gr_font_string_width(char *out_string, int32 auto_spacing) {
int32 gr_font_string_width(const Common::String &str, int32 auto_spacing) {
char *tmp = new char[str.size() + 1];
Common::copy(str.c_str(), str.c_str() + str.size() + 1, tmp);
- int32 result = gr_font_string_width(tmp, auto_spacing);
+ const int32 result = gr_font_string_width(tmp, auto_spacing);
delete[] tmp;
return result;
@@ -263,7 +262,6 @@ int32 gr_font_write(Buffer *target, char *out_string, int32 x, int32 y, int32 w,
_G(custom_ascii_converter)(out_string); // call it with the string
}
- int32 i, j;
int32 target_w;
if (w)
target_w = imath_min(target->w, x + w);
@@ -282,7 +280,7 @@ int32 gr_font_write(Buffer *target, char *out_string, int32 x, int32 y, int32 w,
if (!height)
return x;
- int32 bottom = y + height - 1;
+ const int32 bottom = y + height - 1;
if (bottom > (target->h - 1)) {
height -= imath_min((int32)height, (bottom - (target->h - 1)));
}
@@ -299,8 +297,8 @@ int32 gr_font_write(Buffer *target, char *out_string, int32 x, int32 y, int32 w,
short *offsetArray = _G(font)->offset;
while (*out_string) {
- byte c = (*out_string++) & 0x7f;
- int32 wdth = widthArray[c];
+ const byte c = (*out_string++) & 0x7f;
+ const int32 wdth = widthArray[c];
// if width is zero, nothing to draw
@@ -308,16 +306,16 @@ int32 gr_font_write(Buffer *target, char *out_string, int32 x, int32 y, int32 w,
if ((cursX + wdth) >= target_w) // if character doesn't fit in buffer, abort
return cursX;
- int32 offset = offsetArray[c];
+ const int32 offset = offsetArray[c];
Byte *charData = &fontPixData[offset];
- int32 bytesInChar = (_G(font)->width[c] >> 2) + 1; // bytesPer[wdth]; // 2 bits per pixel
+ const int32 bytesInChar = (_G(font)->width[c] >> 2) + 1; // bytesPer[wdth]; // 2 bits per pixel
if (skipTop)
charData += bytesInChar * skipTop;
- for (i = 0; i < height; i++) {
- for (j = 0; j < bytesInChar; j++) {
- Byte workByte = *charData++;
+ for (int32 i = 0; i < height; i++) {
+ for (int32 j = 0; j < bytesInChar; j++) {
+ const Byte workByte = *charData++;
if (workByte & 0xc0)
*target_ptr = font_colors[(workByte & 0xc0) >> 6];
target_ptr++;
@@ -350,25 +348,22 @@ int32 gr_font_write(Buffer *target, char *out_string, int32 x, int32 y, int32 w,
int32 gr_font_write(Buffer *target, const char *out_string, int32 x, int32 y, int32 w, int32 auto_spacing) {
char *tmp = mem_strdup(out_string);
- int32 result = gr_font_write(target, tmp, x, y, w, auto_spacing);
+ const int32 result = gr_font_write(target, tmp, x, y, w, auto_spacing);
free(tmp);
return result;
}
Font *gr_font_load(const char *fontName) {
- uint32 tag;
- Font *newFont;
-
SysFile fontFile(fontName);
if (!fontFile.exists())
return nullptr;
- tag = fontFile.readUint32LE();
+ uint32 tag = fontFile.readUint32LE();
if (tag != 'FONT')
error_show(FL, 'FNTL', "font: %s chkpnt: %d", (const char *)fontName, 0);
- newFont = (Font *)mem_alloc(sizeof(Font), STR_FONTSTRUCT);
+ Font *newFont = (Font *)mem_alloc(sizeof(Font), STR_FONTSTRUCT);
if (!newFont)
error_show(FL, 'OOM!', "_G(font) struct");
diff --git a/engines/m4/graphics/gr_line.cpp b/engines/m4/graphics/gr_line.cpp
index d7f14517be8..e324e7711c0 100644
--- a/engines/m4/graphics/gr_line.cpp
+++ b/engines/m4/graphics/gr_line.cpp
@@ -25,11 +25,8 @@
namespace M4 {
void gr_vline_xor(Buffer *buf, int32 x, int32 y1, int32 y2) {
- byte *start;
- int32 i;
-
if (y1 > y2) {
- i = y1; y1 = y2; y2 = i;
+ SWAP(y1, y2);
}
if ((x > buf->w) || (y1 > buf->h))
@@ -38,35 +35,29 @@ void gr_vline_xor(Buffer *buf, int32 x, int32 y1, int32 y2) {
if (y2 > buf->h)
y2 = buf->h; // Don't draw past bottom
- start = buf->data + x;
+ byte *start = buf->data + x;
- for (i = y1; i < y2; i++, start += buf->stride)
+ for (int32 i = y1; i < y2; i++, start += buf->stride)
*start ^= 0xff;
}
void gr_hline_xor(Buffer *buf, int32 x1, int32 x2, int32 y) {
- byte *start;
- int32 i;
-
if (x1 > x2) {
- i = x1; x1 = x2; x2 = i;
+ SWAP(x1, x2);
}
if ((y > buf->h) || (x1 > buf->w))
return;
- start = gr_buffer_pointer(buf, x1, y);
+ byte *start = gr_buffer_pointer(buf, x1, y);
- for (i = x1; i < x2; i++, start++)
+ for (int32 i = x1; i < x2; i++, start++)
*start ^= 0xff;
}
void gr_vline(Buffer *buf, int32 x, int32 y1, int32 y2) {
- byte *start;
- int32 i;
-
if (y1 > y2) {
- i = y1; y1 = y2; y2 = i;
+ SWAP(y1, y2);
}
if ((x > buf->w) || (y1 > buf->h))
@@ -76,30 +67,27 @@ void gr_vline(Buffer *buf, int32 x, int32 y1, int32 y2) {
if (y2 > buf->h)
y2 = buf->h; // don't draw past bottom
- start = gr_buffer_pointer(buf, x, y1);
+ byte *start = gr_buffer_pointer(buf, x, y1);
- for (i = y1; i < y2; i++, start += buf->stride)
+ for (int32 i = y1; i < y2; i++, start += buf->stride)
*start = _G(color);
}
void gr_hline(Buffer *buf, int32 x1, int32 x2, int32 y) {
- byte *start;
- int32 i;
-
if (x1 > x2) {
- i = x1; x1 = x2; x2 = i;
+ SWAP(x1, x2);
}
if ((y > buf->h) || (x1 > buf->w))
return;
- start = gr_buffer_pointer(buf, x1, y);
+ byte *start = gr_buffer_pointer(buf, x1, y);
x2++;
if (x2 > buf->w)
x2 = buf->w;
- for (i = x1; i < x2; i++, start++)
+ for (int32 i = x1; i < x2; i++, start++)
*start = _G(color);
}
@@ -123,9 +111,8 @@ void gr_line(int32 x1, int32 y1, int32 x2, int32 y2, int32 color, Buffer *screen
int32 error_term = 0; // Initialize error term
if (xdiff > ydiff) { // If difference is bigger in x dimension
- int32 length = xdiff + 1; // ...prepare to count off in x direction
- int32 i;
- for (i = 0; i < length; i++) { // Loop through points in x direction
+ const int32 length = xdiff + 1; // ...prepare to count off in x direction
+ for (int32 i = 0; i < length; i++) { // Loop through points in x direction
myData[offset] = (char)color; // Set the next pixel in the line to COLOR
offset += x_unit; // Move offset to next pixel in x direction
error_term += ydiff; // Check to see if move required in y direction
@@ -135,7 +122,7 @@ void gr_line(int32 x1, int32 y1, int32 x2, int32 y2, int32 color, Buffer *screen
}
}
} else { // If difference is bigger in y dimension
- int32 length = ydiff + 1; // ...prepare to count off in y direction
+ const int32 length = ydiff + 1; // ...prepare to count off in y direction
for (int32 i = 0; i < length; i++) { // Loop through points in y direction
myData[offset] = (char)color; // Set the next pixel in the line to COLOR
offset += y_unit; // Move offset to next pixel in y direction
diff --git a/engines/m4/graphics/gr_pal.cpp b/engines/m4/graphics/gr_pal.cpp
index 830dd0c1a07..c034e5f71bc 100644
--- a/engines/m4/graphics/gr_pal.cpp
+++ b/engines/m4/graphics/gr_pal.cpp
@@ -56,9 +56,7 @@ byte gr_color_get_current() {
}
void gr_pal_clear(RGB8 *palette) {
- int i;
-
- for (i = 0; i < 256; i++) {
+ for (int i = 0; i < 256; i++) {
palette[i].r = 0;
palette[i].g = 0;
palette[i].b = 0;
@@ -101,13 +99,13 @@ void gr_pal_clear_range(RGB8 *palette, int first_color, int last_color) {
}
uint8 gr_pal_find_best_match(RGB8 *pal, uint8 r, uint8 g, uint8 b) {
- int i, index = 0, Rdiff, Gdiff, Bdiff;
+ int index = 0;
uint32 minDist = 0x7fffffff;
- for (i = 0; i < 256; ++i) {
- Rdiff = r - pal[i].r;
- Gdiff = g - pal[i].g;
- Bdiff = b - pal[i].b;
+ for (int i = 0; i < 256; ++i) {
+ const int Rdiff = r - pal[i].r;
+ const int Gdiff = g - pal[i].g;
+ const int Bdiff = b - pal[i].b;
if (Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff < (int)minDist) {
minDist = Rdiff * Rdiff + Gdiff * Gdiff + Bdiff * Bdiff;
index = i;
@@ -121,7 +119,7 @@ void gr_pal_interface(RGB8 *fixpal) {
if (_GI().set_interface_palette(fixpal))
return;
- // Low intesity
+ // Low intensity
gr_pal_set_RGB8(&fixpal[0], 0, 0, 0); // r0 g0 b0 black
gr_pal_set_RGB8(&fixpal[1], 0, 0, 168); // r0 g0 b2 blue
gr_pal_set_RGB8(&fixpal[2], 0, 168, 0); // r0 g2 b0 green
@@ -175,7 +173,7 @@ void pal_mirror_colours(int first_color, int last_color, RGB8 *pal) {
if (first_color < 0 || last_color > 255 || first_color > last_color)
error_show(FL, 'Burg', "pal_mirror_colours index error");
- int num_colors = last_color - first_color + 1;
+ const int num_colors = last_color - first_color + 1;
for (int index = 0; index < num_colors; ++index) {
RGB8 *destP = pal + (last_color + num_colors - index);
RGB8 *srcP = pal + (first_color + index);
diff --git a/engines/m4/graphics/gr_series.cpp b/engines/m4/graphics/gr_series.cpp
index d30ac1af791..80cf70fbb48 100644
--- a/engines/m4/graphics/gr_series.cpp
+++ b/engines/m4/graphics/gr_series.cpp
@@ -35,7 +35,7 @@ void Series::play(const char *seriesName, frac16 layer, uint32 flags,
_series = M4::series_play(seriesName, layer, flags, triggerNum, frameRate,
loopCount, s, x, y, firstFrame, lastFrame);
- Common::String shadow = Common::String::format("%ss", seriesName);
+ const Common::String shadow = Common::String::format("%ss", seriesName);
_seriesS = M4::series_play(shadow.c_str(), layer + 1, flags, -1, frameRate,
loopCount, s, x, y, firstFrame, lastFrame);
}
@@ -45,7 +45,7 @@ void Series::show(const char *seriesName, frac16 layer, uint32 flags,
_series = M4::series_show(seriesName, layer, flags, triggerNum, duration,
index, s, x, y);
- Common::String shadow = Common::String::format("%ss", seriesName);
+ const Common::String shadow = Common::String::format("%ss", seriesName);
_seriesS = M4::series_show(shadow.c_str(), layer + 1, flags, -1, duration,
index, s, x, y);
}
@@ -89,7 +89,7 @@ static void series_trigger_dispatch_callback(frac16 myMessage, machine * /*sende
}
int32 series_load(const char *seriesName, int32 assetIndex, RGB8 *myPal) {
- int32 myAssetIndex = AddWSAssetCELS(seriesName, assetIndex, myPal);
+ const int32 myAssetIndex = AddWSAssetCELS(seriesName, assetIndex, myPal);
if ((myAssetIndex < 0) || (myAssetIndex >= 256))
error_show(FL, 'SPNF', seriesName);
@@ -102,7 +102,7 @@ void series_unload(int32 assetIndex) {
}
bool series_draw_sprite(int32 spriteHash, int32 index, Buffer *destBuff, int32 x, int32 y) {
- M4sprite srcSprite, *srcSpritePtr;
+ M4sprite srcSprite;
M4Rect clipRect, updateRect;
if (!destBuff) {
@@ -110,7 +110,7 @@ bool series_draw_sprite(int32 spriteHash, int32 index, Buffer *destBuff, int32 x
return false;
}
- srcSpritePtr = &srcSprite;
+ M4sprite *srcSpritePtr = &srcSprite;
if ((srcSpritePtr = GetWSAssetSprite(nullptr, (uint32)spriteHash, (uint32)index, srcSpritePtr, nullptr)) == nullptr)
error_show(FL, 'SPNF', "hash: %d, index: %d", spriteHash, index);
@@ -161,7 +161,6 @@ bool series_show_frame(int32 spriteHash, int32 index, Buffer *destBuff, int32 x,
}
machine *series_stream(const char *seriesName, int32 frameRate, int32 layer, int32 trigger) {
- machine *m;
SysFile *sysFile = new SysFile(seriesName);
// Store the frameRate in g_temp1
@@ -177,7 +176,7 @@ machine *series_stream(const char *seriesName, int32 frameRate, int32 layer, int
// Set the layer
_G(globals)[GLB_TEMP_6] = layer << 16;
- m = kernel_spawn_machine(seriesName, HASH_STREAM_MACHINE, series_trigger_dispatch_callback);
+ machine *m = kernel_spawn_machine(seriesName, HASH_STREAM_MACHINE, series_trigger_dispatch_callback);
return m;
}
diff --git a/engines/m4/graphics/gr_sprite.cpp b/engines/m4/graphics/gr_sprite.cpp
index 7be5ee9db21..c39664bf597 100644
--- a/engines/m4/graphics/gr_sprite.cpp
+++ b/engines/m4/graphics/gr_sprite.cpp
@@ -35,7 +35,6 @@ namespace M4 {
* S and D are Raw encoded (unencoded!) buffers.
*/
static uint8 scale_sprite(Buffer *S, Buffer *D, uint32 ScaleX, uint32 ScaleY) {
- uint16 ErrX, ErrY, i, j;
uint8 *pScaled, *pData = S->data;
if (!D)
@@ -60,12 +59,12 @@ static uint8 scale_sprite(Buffer *S, Buffer *D, uint32 ScaleX, uint32 ScaleY) {
if (!(D->data = pScaled = (uint8 *)mem_alloc(D->h * D->stride, "scaled buffer")))
error_show(FL, 'OOM!', "scaled buffer h:%uld w:%uld", D->h, D->stride);
- ErrY = 50;
- for (i = 0; i < S->h; ++i) {
+ uint16 ErrY = 50;
+ for (uint16 i = 0; i < S->h; ++i) {
ErrY += ScaleY;
while (ErrY >= 100) {
- ErrX = 50;
- for (j = 0; j < S->w; ++j) {
+ uint16 ErrX = 50;
+ for (uint16 j = 0; j < S->w; ++j) {
ErrX += ScaleX;
while (ErrX >= 100) {
*pScaled++ = *pData;
@@ -157,7 +156,7 @@ uint8 gr_sprite_draw(DrawRequest *drawReq) {
source = afterScaled;
}
- bool shadow = (drawReq->Src->encoding & SHADOW) != 0;
+ const bool shadow = (drawReq->Src->encoding & SHADOW) != 0;
assert(!shadow || drawReq->ICT);
M4Surface dst(*drawReq->Dest);
@@ -190,10 +189,10 @@ uint8 gr_sprite_draw(DrawRequest *drawReq) {
static uint16 EncodeScan(uint8 *pi, uint8 *po, uint16 scanlen, uint8 EndByte) {
uint8 *ps = pi + 1;
- uint16 outlen = 0, limit, run;
+ uint16 outlen = 0, run;
while (scanlen) {
- limit = (scanlen < 255) ? scanlen : 255;
+ uint16 limit = (scanlen < 255) ? scanlen : 255;
//imath_min(scanlen, 255);
for (run = 1; run < limit && *pi == *ps; ++run, ++ps) {}
diff --git a/engines/m4/graphics/gr_sprite.h b/engines/m4/graphics/gr_sprite.h
index 3e050f79fa6..4335e67e0ba 100644
--- a/engines/m4/graphics/gr_sprite.h
+++ b/engines/m4/graphics/gr_sprite.h
@@ -23,7 +23,6 @@
#define M4_GRAPHICS_GR_SPRITE_H
#include "m4/m4_types.h"
-#include "m4/gui/gui.h"
namespace M4 {
More information about the Scummvm-git-logs
mailing list