[Scummvm-git-logs] scummvm master -> 80e83c1a4b73fdc9b83cb36cd61a4835e9a939e7
dreammaster
noreply at scummvm.org
Sat Jun 1 18:39:10 UTC 2024
This automated email contains information about 3 new commits which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
2027813d67 GRAPHICS: Added Palette::createEGAPalette method
2bc022fb8c MM: MM1: Use Graphics::Palette::createEGAPalette
80e83c1a4b GRAPHICS: Support Graphics::Palette in PaletteManager
Commit: 2027813d6768e973c86b451883dcbafbda3ba68e
https://github.com/scummvm/scummvm/commit/2027813d6768e973c86b451883dcbafbda3ba68e
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-06-01T11:26:17-07:00
Commit Message:
GRAPHICS: Added Palette::createEGAPalette method
Changed paths:
graphics/palette.cpp
graphics/palette.h
diff --git a/graphics/palette.cpp b/graphics/palette.cpp
index 6e6797af05b..09d718e0b7b 100644
--- a/graphics/palette.cpp
+++ b/graphics/palette.cpp
@@ -22,6 +22,16 @@
namespace Graphics {
+static const byte EGA_PALETTE[16][3] = {
+ { 0x00, 0x00, 0x00 }, { 0x00, 0x00, 0xaa }, { 0x00, 0xaa, 0x00 },
+ { 0x00, 0xaa, 0xaa }, { 0xaa, 0x00, 0x00 }, { 0xaa, 0x00, 0xaa },
+ { 0xaa, 0x55, 0x00 }, { 0xaa, 0xaa, 0xaa }, { 0x55, 0x55, 0x55 },
+ { 0x55, 0x55, 0xff }, { 0x55, 0xff, 0x55 }, { 0x55, 0xff, 0xff },
+ { 0xff, 0x55, 0x55 }, { 0xff, 0x55, 0xff }, { 0xff, 0xff, 0x55 },
+ { 0xff, 0xff, 0xff }
+};
+
+
Palette::Palette(uint size) : _data(nullptr), _size(size) {
if (_size > 0) {
_data = new byte[_size * 3]();
@@ -47,6 +57,11 @@ Palette::~Palette() {
delete[] _data;
}
+Palette Palette::createEGAPalette() {
+ return Palette(&EGA_PALETTE[0][0], 16);
+}
+
+
Palette &Palette::operator=(const Palette &rhs) {
delete[] _data;
_data = nullptr;
diff --git a/graphics/palette.h b/graphics/palette.h
index dac9875574a..99326333730 100644
--- a/graphics/palette.h
+++ b/graphics/palette.h
@@ -62,6 +62,11 @@ public:
~Palette();
+ /**
+ * Constructs a new palette containing the standarad EGA palette
+ */
+ static Palette createEGAPalette();
+
Palette &operator=(const Palette &rhs);
bool operator==(const Palette &rhs) const { return equals(rhs); }
bool operator!=(const Palette &rhs) const { return !equals(rhs); }
Commit: 2bc022fb8c81c5dd0dfbc769e02c9752c151ee72
https://github.com/scummvm/scummvm/commit/2bc022fb8c81c5dd0dfbc769e02c9752c151ee72
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-06-01T11:26:17-07:00
Commit Message:
MM: MM1: Use Graphics::Palette::createEGAPalette
Changed paths:
engines/mm/mm1/gfx/gfx.cpp
diff --git a/engines/mm/mm1/gfx/gfx.cpp b/engines/mm/mm1/gfx/gfx.cpp
index 4eec3eb329f..e1d705dcd4b 100644
--- a/engines/mm/mm1/gfx/gfx.cpp
+++ b/engines/mm/mm1/gfx/gfx.cpp
@@ -21,6 +21,7 @@
#include "common/system.h"
#include "common/debug.h"
+#include "graphics/palette.h"
#include "graphics/paletteman.h"
#include "graphics/screen.h"
#include "mm/mm1/gfx/gfx.h"
@@ -31,38 +32,26 @@ namespace Gfx {
byte EGA_INDEXES[EGA_PALETTE_COUNT];
-static const uint32 EGA_PALETTE[16] = {
- 0x000000, 0x0000aa, 0x00aa00, 0x00aaaa,
- 0xaa0000, 0xaa00aa, 0xaa5500, 0xaaaaaa,
- 0x555555, 0x5555ff, 0x55ff55, 0x55ffff,
- 0xff5555, 0xff55ff, 0xffff55, 0xffffff
-};
-
-
void GFX::setEgaPalette() {
- byte pal[16 * 3];
- byte *pDest = pal;
-
- for (int i = 0; i < EGA_PALETTE_COUNT; ++i) {
- *pDest++ = (EGA_PALETTE[i] >> 16) & 0xff;
- *pDest++ = (EGA_PALETTE[i] >> 8) & 0xff;
- *pDest++ = EGA_PALETTE[i] & 0xff;
- EGA_INDEXES[i] = i;
- }
-
- g_system->getPaletteManager()->setPalette(pal, 0, 16);
+ Graphics::Palette ega = Graphics::Palette::createEGAPalette();
+ g_system->getPaletteManager()->setPalette(ega.data(), 0, 16);
uint32 c = 0xffffffff;
g_system->getPaletteManager()->setPalette((const byte *)&c, 255, 1);
// Set the EGA palette indexes to be themselves
+ for (int i = 0; i < EGA_PALETTE_COUNT; ++i)
+ EGA_INDEXES[i] = i;
}
void GFX::findPalette(const byte palette[256 * 3]) {
+ Graphics::Palette ega = Graphics::Palette::createEGAPalette();
+ const byte *data = ega.data();
+
for (int col = 0; col < 16; ++col) {
- byte r = (EGA_PALETTE[col] >> 16) & 0xff;
- byte g = (EGA_PALETTE[col] >> 8) & 0xff;
- byte b = EGA_PALETTE[col] & 0xff;
+ byte r = data[col * 3 + 2];
+ byte g = data[col * 3 + 1];
+ byte b = data[col * 3 + 0];
int closestDiff = 0x7fffffff;
byte closest = 0;
const byte *pal = &palette[0];
Commit: 80e83c1a4b73fdc9b83cb36cd61a4835e9a939e7
https://github.com/scummvm/scummvm/commit/80e83c1a4b73fdc9b83cb36cd61a4835e9a939e7
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2024-06-01T11:38:27-07:00
Commit Message:
GRAPHICS: Support Graphics::Palette in PaletteManager
Changed paths:
engines/mm/mm1/gfx/gfx.cpp
graphics/paletteman.h
diff --git a/engines/mm/mm1/gfx/gfx.cpp b/engines/mm/mm1/gfx/gfx.cpp
index e1d705dcd4b..ce9774cdaec 100644
--- a/engines/mm/mm1/gfx/gfx.cpp
+++ b/engines/mm/mm1/gfx/gfx.cpp
@@ -34,7 +34,7 @@ byte EGA_INDEXES[EGA_PALETTE_COUNT];
void GFX::setEgaPalette() {
Graphics::Palette ega = Graphics::Palette::createEGAPalette();
- g_system->getPaletteManager()->setPalette(ega.data(), 0, 16);
+ g_system->getPaletteManager()->setPalette(ega);
uint32 c = 0xffffffff;
g_system->getPaletteManager()->setPalette((const byte *)&c, 255, 1);
diff --git a/graphics/paletteman.h b/graphics/paletteman.h
index fba234284f4..c688826c0fd 100644
--- a/graphics/paletteman.h
+++ b/graphics/paletteman.h
@@ -24,6 +24,7 @@
#include "common/scummsys.h"
#include "common/noncopyable.h"
+#include "graphics/palette.h"
/**
* @defgroup graphics_palette PaletteManager
@@ -73,6 +74,10 @@ public:
*/
virtual void setPalette(const byte *colors, uint start, uint num) = 0;
+ void setPalette(const Graphics::Palette &pal, uint start = 0) {
+ setPalette(pal.data(), start, pal.size());
+ }
+
/**
* Grabs a specified part of the currently active palette.
* The format is the same as for setPalette.
@@ -105,6 +110,12 @@ public:
* @see getScreenFormat
*/
virtual void grabPalette(byte *colors, uint start, uint num) const = 0;
+
+ Graphics::Palette grabPalette(uint start, uint num) {
+ byte tmp[256 * 3];
+ grabPalette(tmp, start, num);
+ return Graphics::Palette(tmp, num);
+ }
};
/** @} */
More information about the Scummvm-git-logs
mailing list