[Scummvm-git-logs] scummvm master -> 42e2fee1cd8802b17b98597bde00469c5a7b2ef9
OMGPizzaGuy
noreply at scummvm.org
Sun Jun 1 15:45:36 UTC 2025
This automated email contains information about 5 new commits which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
1ef18b565d ULTIMA8: Move palette map generation out of the manager
9489afbf60 ULTIMA8: Remove palette manager dependency on SKF movie player
b5d4246656 ULTIMA8: Improve error messages on render surface
078f447263 ULTIMA8: Support CLUT8 source for faded and masked blit on render surface
42e2fee1cd ULTIMA8: Support CLUT8 format on palette maps
Commit: 1ef18b565d964d300c6c6b181f7afad39c886078
https://github.com/scummvm/scummvm/commit/1ef18b565d964d300c6c6b181f7afad39c886078
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2025-06-01T10:16:21-05:00
Commit Message:
ULTIMA8: Move palette map generation out of the manager
Changed paths:
engines/ultima/ultima8/gfx/palette.cpp
engines/ultima/ultima8/gfx/palette.h
engines/ultima/ultima8/gfx/palette_manager.cpp
engines/ultima/ultima8/gfx/palette_manager.h
diff --git a/engines/ultima/ultima8/gfx/palette.cpp b/engines/ultima/ultima8/gfx/palette.cpp
index ddd9bf6f16d..94bb0d15e12 100644
--- a/engines/ultima/ultima8/gfx/palette.cpp
+++ b/engines/ultima/ultima8/gfx/palette.cpp
@@ -19,8 +19,9 @@
*
*/
-#include "ultima/ultima8/misc/debugger.h"
#include "ultima/ultima8/gfx/palette.h"
+#include "ultima/ultima8/gfx/texture.h"
+#include "ultima/ultima8/misc/debugger.h"
namespace Ultima {
namespace Ultima8 {
@@ -79,5 +80,87 @@ void Palette::transformRGB(int &r_, int &g_, int &b_) const {
if (b_ > 0xFF) b_ = 0xFF;
}
+void Palette::updateNativeMap(const Graphics::PixelFormat &format, int maxindex) {
+ if (maxindex == 0)
+ maxindex = size();
+
+ for (int i = 0; i < maxindex; i++) {
+ int32 r, g, b;
+ byte sr, sg, sb;
+
+ // Normal palette
+ get(i, sr, sg, sb);
+ _native_untransformed[i] = format.RGBToColor(sr, sg, sb);
+
+ r = _matrix[0] * sr +
+ _matrix[1] * sg +
+ _matrix[2] * sb +
+ _matrix[3] * 255;
+ if (r < 0)
+ r = 0;
+ if (r > 0x7F800)
+ r = 0x7F800;
+
+ g = _matrix[4] * sr +
+ _matrix[5] * sg +
+ _matrix[6] * sb +
+ _matrix[7] * 255;
+ if (g < 0)
+ g = 0;
+ if (g > 0x7F800)
+ g = 0x7F800;
+
+ b = _matrix[8] * sr +
+ _matrix[9] * sg +
+ _matrix[10] * sb +
+ _matrix[11] * 255;
+ if (b < 0)
+ b = 0;
+ if (b > 0x7F800)
+ b = 0x7F800;
+
+ // Transformed normal palette
+ _native[i] = format.RGBToColor(static_cast<uint8>(r >> 11),
+ static_cast<uint8>(g >> 11),
+ static_cast<uint8>(b >> 11));
+
+ // Transformed XFORM palette (Uses the TEX32 format)
+ if (TEX32_A(_xform_untransformed[i])) {
+ r = _matrix[0] * TEX32_R(_xform_untransformed[i]) +
+ _matrix[1] * TEX32_G(_xform_untransformed[i]) +
+ _matrix[2] * TEX32_B(_xform_untransformed[i]) +
+ _matrix[3] * 255;
+ if (r < 0)
+ r = 0;
+ if (r > 0x7F800)
+ r = 0x7F800;
+
+ g = _matrix[4] * TEX32_R(_xform_untransformed[i]) +
+ _matrix[5] * TEX32_G(_xform_untransformed[i]) +
+ _matrix[6] * TEX32_B(_xform_untransformed[i]) +
+ _matrix[7] * 255;
+ if (g < 0)
+ g = 0;
+ if (g > 0x7F800)
+ g = 0x7F800;
+
+ b = _matrix[8] * TEX32_R(_xform_untransformed[i]) +
+ _matrix[9] * TEX32_G(_xform_untransformed[i]) +
+ _matrix[10] * TEX32_B(_xform_untransformed[i]) +
+ _matrix[11] * 255;
+ if (b < 0)
+ b = 0;
+ if (b > 0x7F800)
+ b = 0x7F800;
+
+ _xform[i] = TEX32_PACK_RGBA(static_cast<uint8>(r >> 11),
+ static_cast<uint8>(g >> 11),
+ static_cast<uint8>(b >> 11),
+ TEX32_A(_xform_untransformed[i]));
+ } else
+ _xform[i] = 0;
+ }
+}
+
} // End of namespace Ultima8
} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/gfx/palette.h b/engines/ultima/ultima8/gfx/palette.h
index fea64f3f928..4d889d7b5e0 100644
--- a/engines/ultima/ultima8/gfx/palette.h
+++ b/engines/ultima/ultima8/gfx/palette.h
@@ -23,6 +23,7 @@
#define ULTIMA8_GFX_PALETTE_H
#include "graphics/palette.h"
+#include "graphics/pixelformat.h"
#include "ultima/ultima8/gfx/pal_transforms.h"
namespace Common {
@@ -43,6 +44,9 @@ public:
// Not designed for speed - just useful for one-offs.
void transformRGB(int &r, int &g, int &b) const;
+ // Update the palette maps based on the pixel format and the current transformation matrix
+ void updateNativeMap(const Graphics::PixelFormat &format, int maxindex = 0);
+
// Untransformed pixel format palette map
uint32 _native_untransformed[256];
diff --git a/engines/ultima/ultima8/gfx/palette_manager.cpp b/engines/ultima/ultima8/gfx/palette_manager.cpp
index ba526eb1fd1..05d43a74b4f 100644
--- a/engines/ultima/ultima8/gfx/palette_manager.cpp
+++ b/engines/ultima/ultima8/gfx/palette_manager.cpp
@@ -54,7 +54,7 @@ void PaletteManager::reset() {
void PaletteManager::updatedPalette(PalIndex index, int maxindex) {
Palette *pal = getPalette(index);
if (pal)
- createNativePalette(pal, maxindex, _format);
+ pal->updateNativeMap(_format, maxindex);
}
// Reset all the transforms back to default
@@ -70,7 +70,7 @@ void PaletteManager::resetTransforms() {
pal->_transform = Transform_None;
for (int j = 0; j < 12; j++)
pal->_matrix[j] = matrix[j];
- createNativePalette(pal, 0, _format); // convert to native format
+ pal->updateNativeMap(_format);
}
}
@@ -103,7 +103,7 @@ void PaletteManager::PixelFormatChanged(const Graphics::PixelFormat &format) {
// Create native _palettes for all currently loaded _palettes
for (unsigned int i = 0; i < _palettes.size(); ++i)
if (_palettes[i])
- createNativePalette(_palettes[i], 0, _format);
+ _palettes[i]->updateNativeMap(_format);
}
void PaletteManager::load(PalIndex index, Common::ReadStream &rs, Common::ReadStream &xformrs) {
@@ -115,7 +115,7 @@ void PaletteManager::load(PalIndex index, Common::ReadStream &rs, Common::ReadSt
Palette *pal = new Palette;
pal->load(rs, xformrs);
- createNativePalette(pal, 0, _format); // convert to native format
+ pal->updateNativeMap(_format);
_palettes[index] = pal;
}
@@ -129,7 +129,7 @@ void PaletteManager::load(PalIndex index, Common::ReadStream &rs) {
Palette *pal = new Palette;
pal->load(rs);
- createNativePalette(pal, 0, _format); // convert to native format
+ pal->updateNativeMap(_format);
_palettes[index] = pal;
}
@@ -142,7 +142,7 @@ void PaletteManager::duplicate(PalIndex src, PalIndex dest) {
if (srcpal)
*newpal = *srcpal;
- createNativePalette(newpal, 0, _format); // convert to native format
+ newpal->updateNativeMap(_format);
if (_palettes.size() <= static_cast<unsigned int>(dest))
_palettes.resize(dest + 1);
_palettes[dest] = newpal;
@@ -157,12 +157,11 @@ Palette *PaletteManager::getPalette(PalIndex index) {
void PaletteManager::transformPalette(PalIndex index, const int16 matrix[12]) {
Palette *pal = getPalette(index);
-
- if (!pal) return;
-
- for (int i = 0; i < 12; i++)
- pal->_matrix[i] = matrix[i];
- createNativePalette(pal, 0, _format); // convert to native format
+ if (pal) {
+ for (int i = 0; i < 12; i++)
+ pal->_matrix[i] = matrix[i];
+ pal->updateNativeMap(_format);
+ }
}
void PaletteManager::untransformPalette(PalIndex index) {
@@ -355,86 +354,5 @@ void PaletteManager::getTransformMatrix(int16 matrix[12], uint32 col32) {
matrix[11] = (static_cast<int32>(TEX32_B(col32)) * 0x800) / 255;
}
-void PaletteManager::createNativePalette(Palette *palette, int maxindex, const Graphics::PixelFormat &format) {
- if (maxindex == 0)
- maxindex = 256;
- for (int i = 0; i < maxindex; i++) {
- int32 r, g, b;
- byte sr, sg, sb;
-
- // Normal palette
- palette->get(i, sr, sg, sb);
- palette->_native_untransformed[i] = format.RGBToColor(sr, sg, sb);
-
- r = palette->_matrix[0] * sr +
- palette->_matrix[1] * sg +
- palette->_matrix[2] * sb +
- palette->_matrix[3] * 255;
- if (r < 0)
- r = 0;
- if (r > 0x7F800)
- r = 0x7F800;
-
- g = palette->_matrix[4] * sr +
- palette->_matrix[5] * sg +
- palette->_matrix[6] * sb +
- palette->_matrix[7] * 255;
- if (g < 0)
- g = 0;
- if (g > 0x7F800)
- g = 0x7F800;
-
- b = palette->_matrix[8] * sr +
- palette->_matrix[9] * sg +
- palette->_matrix[10] * sb +
- palette->_matrix[11] * 255;
- if (b < 0)
- b = 0;
- if (b > 0x7F800)
- b = 0x7F800;
-
- // Transformed normal palette
- palette->_native[i] = format.RGBToColor(static_cast<uint8>(r >> 11),
- static_cast<uint8>(g >> 11),
- static_cast<uint8>(b >> 11));
-
- // Transformed XFORM palette (Uses the TEX32 format)
- if (TEX32_A(palette->_xform_untransformed[i])) {
- r = palette->_matrix[0] * TEX32_R(palette->_xform_untransformed[i]) +
- palette->_matrix[1] * TEX32_G(palette->_xform_untransformed[i]) +
- palette->_matrix[2] * TEX32_B(palette->_xform_untransformed[i]) +
- palette->_matrix[3] * 255;
- if (r < 0)
- r = 0;
- if (r > 0x7F800)
- r = 0x7F800;
-
- g = palette->_matrix[4] * TEX32_R(palette->_xform_untransformed[i]) +
- palette->_matrix[5] * TEX32_G(palette->_xform_untransformed[i]) +
- palette->_matrix[6] * TEX32_B(palette->_xform_untransformed[i]) +
- palette->_matrix[7] * 255;
- if (g < 0)
- g = 0;
- if (g > 0x7F800)
- g = 0x7F800;
-
- b = palette->_matrix[8] * TEX32_R(palette->_xform_untransformed[i]) +
- palette->_matrix[9] * TEX32_G(palette->_xform_untransformed[i]) +
- palette->_matrix[10] * TEX32_B(palette->_xform_untransformed[i]) +
- palette->_matrix[11] * 255;
- if (b < 0)
- b = 0;
- if (b > 0x7F800)
- b = 0x7F800;
-
- palette->_xform[i] = TEX32_PACK_RGBA(static_cast<uint8>(r >> 11),
- static_cast<uint8>(g >> 11),
- static_cast<uint8>(b >> 11),
- TEX32_A(palette->_xform_untransformed[i]));
- } else
- palette->_xform[i] = 0;
- }
-}
-
} // End of namespace Ultima8
} // End of namespace Ultima
diff --git a/engines/ultima/ultima8/gfx/palette_manager.h b/engines/ultima/ultima8/gfx/palette_manager.h
index c749f1d1a05..785d4cbf10d 100644
--- a/engines/ultima/ultima8/gfx/palette_manager.h
+++ b/engines/ultima/ultima8/gfx/palette_manager.h
@@ -89,8 +89,6 @@ public:
bool loadTransforms(Common::ReadStream &rs);
void saveTransforms(Common::WriteStream &ws);
- void createNativePalette(Palette *palette, int maxindex, const Graphics::PixelFormat &format);
-
private:
Std::vector<Palette *> _palettes;
Graphics::PixelFormat _format;
Commit: 9489afbf60881ddb30755b404e648f5342958619
https://github.com/scummvm/scummvm/commit/9489afbf60881ddb30755b404e648f5342958619
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2025-06-01T10:16:21-05:00
Commit Message:
ULTIMA8: Remove palette manager dependency on SKF movie player
Changed paths:
engines/ultima/ultima8/gfx/skf_player.cpp
engines/ultima/ultima8/gfx/skf_player.h
diff --git a/engines/ultima/ultima8/gfx/skf_player.cpp b/engines/ultima/ultima8/gfx/skf_player.cpp
index 42e8fe68968..8a0d8e58713 100644
--- a/engines/ultima/ultima8/gfx/skf_player.cpp
+++ b/engines/ultima/ultima8/gfx/skf_player.cpp
@@ -27,7 +27,6 @@
#include "ultima/ultima8/filesys/raw_archive.h"
#include "ultima/ultima8/gfx/shape.h"
#include "ultima/ultima8/gfx/texture.h"
-#include "ultima/ultima8/gfx/palette_manager.h"
#include "ultima/ultima8/audio/music_process.h"
#include "ultima/ultima8/audio/audio_process.h"
#include "ultima/ultima8/audio/raw_audio_sample.h"
@@ -280,8 +279,6 @@ void SKFPlayer::run() {
_curFrame++;
- PaletteManager *palman = PaletteManager::get_instance();
-
uint16 objecttype = 0;
do {
_curObject++;
@@ -301,13 +298,13 @@ void SKFPlayer::run() {
switch (objecttype) {
case 1:
- palman->load(PaletteManager::Pal_Movie, *object);
+ _palette.load(*object);
+ _palette.updateNativeMap(_buffer->getRawSurface()->format);
break;
case 2: {
object->seek(0);
Shape *shape = new Shape(object, &U8SKFShapeFormat);
- Palette *pal = palman->getPalette(PaletteManager::Pal_Movie);
- shape->setPalette(pal);
+ shape->setPalette(&_palette);
_buffer->BeginPainting();
_buffer->Paint(shape, 0, 0, 0);
_buffer->EndPainting();
diff --git a/engines/ultima/ultima8/gfx/skf_player.h b/engines/ultima/ultima8/gfx/skf_player.h
index eb3f5c4c369..be9cbace9b6 100644
--- a/engines/ultima/ultima8/gfx/skf_player.h
+++ b/engines/ultima/ultima8/gfx/skf_player.h
@@ -25,6 +25,7 @@
#include "ultima/shared/std/containers.h"
#include "ultima/ultima8/gfx/movie_player.h"
#include "ultima/ultima8/gfx/render_surface.h"
+#include "ultima/ultima8/gfx/palette.h"
namespace Ultima {
namespace Ultima8 {
@@ -64,6 +65,7 @@ private:
unsigned int _frameRate;
uint8 _fadeColour, _fadeLevel;
RenderSurface *_buffer;
+ Palette _palette;
RenderedText *_subs;
int _subtitleY;
bool _introMusicHack;
Commit: b5d4246656e0c3b4f3a6df1541c9df9426b41b89
https://github.com/scummvm/scummvm/commit/b5d4246656e0c3b4f3a6df1541c9df9426b41b89
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2025-06-01T10:16:21-05:00
Commit Message:
ULTIMA8: Improve error messages on render surface
Changed paths:
engines/ultima/ultima8/gfx/render_surface.cpp
diff --git a/engines/ultima/ultima8/gfx/render_surface.cpp b/engines/ultima/ultima8/gfx/render_surface.cpp
index 523feaa2504..950bf10864e 100644
--- a/engines/ultima/ultima8/gfx/render_surface.cpp
+++ b/engines/ultima/ultima8/gfx/render_surface.cpp
@@ -426,7 +426,7 @@ void RenderSurface::FadedBlit(const Graphics::ManagedSurface &src, const Common:
fadedBlitLogic<uint32, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
}
else {
- error("FadedBlit not supported from %d bpp to %d bpp", src.format.bpp(), _surface->format.bpp());
+ error("FadedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
} else if (_surface->format.bytesPerPixel == 2) {
if (src.format.bytesPerPixel == 4) {
@@ -436,11 +436,11 @@ void RenderSurface::FadedBlit(const Graphics::ManagedSurface &src, const Common:
fadedBlitLogic<uint16, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
}
else {
- error("FadedBlit not supported from %d bpp to %d bpp", src.format.bpp(), _surface->format.bpp());
+ error("FadedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
}
else {
- error("FadedBlit not supported from %d bpp to %d bpp", src.format.bpp(), _surface->format.bpp());
+ error("FadedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
}
@@ -552,7 +552,7 @@ void RenderSurface::MaskedBlit(const Graphics::ManagedSurface &src, const Common
} else if (src.format.bytesPerPixel == 2) {
maskedBlitLogic<uint32, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
} else {
- error("MaskedBlit not supported from %d bpp to %d bpp", src.format.bpp(), _surface->format.bpp());
+ error("MaskedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
} else if (_surface->format.bytesPerPixel == 2) {
if (src.format.bytesPerPixel == 4) {
@@ -560,10 +560,10 @@ void RenderSurface::MaskedBlit(const Graphics::ManagedSurface &src, const Common
} else if (src.format.bytesPerPixel == 2) {
maskedBlitLogic<uint16, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
} else {
- error("MaskedBlit not supported from %d bpp to %d bpp", src.format.bpp(), _surface->format.bpp());
+ error("MaskedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
} else {
- error("MaskedBlit not supported from %d bpp to %d bpp", src.format.bpp(), _surface->format.bpp());
+ error("MaskedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
}
@@ -867,6 +867,8 @@ void RenderSurface::Paint(const Shape *s, uint32 framenum, int32 x, int32 y, boo
paintLogic<uint32>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, map);
else if (_surface->format.bytesPerPixel == 2)
paintLogic<uint16>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, map);
+ else
+ error("Paint not supported for surface format: %s", _surface->format.toString().c_str());
}
//
@@ -886,6 +888,8 @@ void RenderSurface::PaintTranslucent(const Shape *s, uint32 framenum, int32 x, i
paintBlendedLogic<uint32>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, false, 0, map, xform_map);
else if (_surface->format.bytesPerPixel == 2)
paintBlendedLogic<uint16>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, false, 0, map, xform_map);
+ else
+ error("PaintTranslucent not supported for surface format: %s", _surface->format.toString().c_str());
}
//
@@ -905,6 +909,8 @@ void RenderSurface::PaintInvisible(const Shape *s, uint32 framenum, int32 x, int
paintBlendedLogic<uint32>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, true, 0, map, xform_map);
else if (_surface->format.bytesPerPixel == 2)
paintBlendedLogic<uint16>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, true, 0, map, xform_map);
+ else
+ error("PaintInvisible not supported for surface format: %s", _surface->format.toString().c_str());
}
//
@@ -924,6 +930,8 @@ void RenderSurface::PaintHighlight(const Shape *s, uint32 framenum, int32 x, int
paintBlendedLogic<uint32>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, false, col32, map, xform_map);
else if (_surface->format.bytesPerPixel == 2)
paintBlendedLogic<uint16>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, false, col32, map, xform_map);
+ else
+ error("PaintHighlight not supported for surface format: %s", _surface->format.toString().c_str());
}
//
@@ -943,6 +951,8 @@ void RenderSurface::PaintHighlightInvis(const Shape *s, uint32 framenum, int32 x
paintBlendedLogic<uint32>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, true, col32, map, xform_map);
else if (_surface->format.bytesPerPixel == 2)
paintBlendedLogic<uint16>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, true, col32, map, xform_map);
+ else
+ error("PaintHighlightInvis not supported for surface format: %s", _surface->format.toString().c_str());
}
} // End of namespace Ultima8
Commit: 078f447263a15e2d21a4bf3cbf3ebced193ccfa3
https://github.com/scummvm/scummvm/commit/078f447263a15e2d21a4bf3cbf3ebced193ccfa3
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2025-06-01T10:16:21-05:00
Commit Message:
ULTIMA8: Support CLUT8 source for faded and masked blit on render surface
Changed paths:
engines/ultima/ultima8/gfx/render_surface.cpp
diff --git a/engines/ultima/ultima8/gfx/render_surface.cpp b/engines/ultima/ultima8/gfx/render_surface.cpp
index 950bf10864e..d8376a40e5f 100644
--- a/engines/ultima/ultima8/gfx/render_surface.cpp
+++ b/engines/ultima/ultima8/gfx/render_surface.cpp
@@ -374,11 +374,21 @@ void inline fadedBlitLogic(uint8 *pixels, int32 pitch,
int srcStep = sizeof(uintSrc);
int srcDelta = src.pitch - w * sizeof(uintSrc);
+ byte palette[768];
+ src.grabPalette(palette, 0, 256);
+
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
uint8 sa, sr, sg, sb;
const uint32 color = *(reinterpret_cast<const uintSrc *>(srcPixels));
- src.format.colorToARGB(color, sa, sr, sg, sb);
+ if (src.format.isCLUT8()) {
+ sa = 0xff;
+ sr = palette[color * 3 + 0];
+ sg = palette[color * 3 + 1];
+ sb = palette[color * 3 + 2];
+ } else {
+ src.format.colorToARGB(color, sa, sr, sg, sb);
+ }
if (sa == 0xFF || (sa && !alpha_blend)) {
uintDst *dest = reinterpret_cast<uintDst *>(dstPixels);
@@ -425,6 +435,9 @@ void RenderSurface::FadedBlit(const Graphics::ManagedSurface &src, const Common:
else if (src.format.bytesPerPixel == 2) {
fadedBlitLogic<uint32, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
}
+ else if (src.format.isCLUT8()) {
+ fadedBlitLogic<uint32, uint8>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
+ }
else {
error("FadedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
@@ -435,6 +448,9 @@ void RenderSurface::FadedBlit(const Graphics::ManagedSurface &src, const Common:
else if (src.format.bytesPerPixel == 2) {
fadedBlitLogic<uint16, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
}
+ else if (src.format.isCLUT8()) {
+ fadedBlitLogic<uint16, uint8>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
+ }
else {
error("FadedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
@@ -501,13 +517,23 @@ void inline maskedBlitLogic(uint8 *pixels, int32 pitch,
int srcStep = sizeof(uintSrc);
int srcDelta = src.pitch - w * sizeof(uintSrc);
+ byte palette[768];
+ src.grabPalette(palette, 0, 256);
+
for (int y = 0; y < h; ++y) {
for (int x = 0; x < w; ++x) {
uintDst *dest = reinterpret_cast<uintDst *>(dstPixels);
if (!aMask || (*dest & aMask)) {
uint8 sa, sr, sg, sb;
const uint32 color = *(reinterpret_cast<const uintSrc *>(srcPixels));
- src.format.colorToARGB(color, sa, sr, sg, sb);
+ if (src.format.isCLUT8()) {
+ sa = 0xff;
+ sr = palette[color * 3 + 0];
+ sg = palette[color * 3 + 1];
+ sb = palette[color * 3 + 2];
+ } else {
+ src.format.colorToARGB(color, sa, sr, sg, sb);
+ }
if (sa == 0xFF || (sa && !alpha_blend)) {
*dest = format.RGBToColor((sr * ia + r) >> 8,
@@ -551,6 +577,8 @@ void RenderSurface::MaskedBlit(const Graphics::ManagedSurface &src, const Common
maskedBlitLogic<uint32, uint32>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
} else if (src.format.bytesPerPixel == 2) {
maskedBlitLogic<uint32, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
+ } else if (src.format.isCLUT8()) {
+ maskedBlitLogic<uint32, uint8>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
} else {
error("MaskedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
@@ -559,6 +587,8 @@ void RenderSurface::MaskedBlit(const Graphics::ManagedSurface &src, const Common
maskedBlitLogic<uint16, uint32>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
} else if (src.format.bytesPerPixel == 2) {
maskedBlitLogic<uint16, uint16>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
+ } else if (src.format.isCLUT8()) {
+ maskedBlitLogic<uint16, uint8>(_pixels, _pitch, _clipWindow, _surface->format, src, srcRect, dx, dy, col32, alpha_blend);
} else {
error("MaskedBlit not supported from %s to %s", src.format.toString().c_str(), _surface->format.toString().c_str());
}
@@ -637,7 +667,7 @@ void inline paintLogic(uint8 *pixels, int32 pitch,
const int srcDelta = src.pitch - (w * srcStep);
const int dstDelta = pitch - (w * dstStep);
- const uint8 keycolor = frame->_keycolor;
+ const uint8 keycolor = frame->_keycolor;
const uint8 *srcPixels = reinterpret_cast<const uint8 *>(src.getBasePtr(srcRect.left, srcRect.top));
uint8 *dstPixels = reinterpret_cast<uint8 *>(pixels + x * sizeof(uintX) + pitch * y);
Commit: 42e2fee1cd8802b17b98597bde00469c5a7b2ef9
https://github.com/scummvm/scummvm/commit/42e2fee1cd8802b17b98597bde00469c5a7b2ef9
Author: Matthew Jimenez (matthew.jimenez at outlook.com)
Date: 2025-06-01T10:16:21-05:00
Commit Message:
ULTIMA8: Support CLUT8 format on palette maps
This allows non-blended shape paint operations on to CLUT8 surfaces.
Changed paths:
engines/ultima/ultima8/gfx/palette.cpp
engines/ultima/ultima8/gfx/render_surface.cpp
diff --git a/engines/ultima/ultima8/gfx/palette.cpp b/engines/ultima/ultima8/gfx/palette.cpp
index 94bb0d15e12..d32f93e8ce9 100644
--- a/engines/ultima/ultima8/gfx/palette.cpp
+++ b/engines/ultima/ultima8/gfx/palette.cpp
@@ -90,7 +90,11 @@ void Palette::updateNativeMap(const Graphics::PixelFormat &format, int maxindex)
// Normal palette
get(i, sr, sg, sb);
- _native_untransformed[i] = format.RGBToColor(sr, sg, sb);
+ if (format.isCLUT8()) {
+ _native_untransformed[i] = i;
+ } else {
+ _native_untransformed[i] = format.RGBToColor(sr, sg, sb);
+ }
r = _matrix[0] * sr +
_matrix[1] * sg +
@@ -100,6 +104,7 @@ void Palette::updateNativeMap(const Graphics::PixelFormat &format, int maxindex)
r = 0;
if (r > 0x7F800)
r = 0x7F800;
+ r = r >> 11;
g = _matrix[4] * sr +
_matrix[5] * sg +
@@ -109,6 +114,7 @@ void Palette::updateNativeMap(const Graphics::PixelFormat &format, int maxindex)
g = 0;
if (g > 0x7F800)
g = 0x7F800;
+ g = g >> 11;
b = _matrix[8] * sr +
_matrix[9] * sg +
@@ -118,11 +124,18 @@ void Palette::updateNativeMap(const Graphics::PixelFormat &format, int maxindex)
b = 0;
if (b > 0x7F800)
b = 0x7F800;
+ b = b >> 11;
// Transformed normal palette
- _native[i] = format.RGBToColor(static_cast<uint8>(r >> 11),
- static_cast<uint8>(g >> 11),
- static_cast<uint8>(b >> 11));
+ if (format.isCLUT8()) {
+ _native[i] = findBestColor(static_cast<uint8>(r),
+ static_cast<uint8>(g),
+ static_cast<uint8>(b));
+ } else {
+ _native[i] = format.RGBToColor(static_cast<uint8>(r),
+ static_cast<uint8>(g),
+ static_cast<uint8>(b));
+ }
// Transformed XFORM palette (Uses the TEX32 format)
if (TEX32_A(_xform_untransformed[i])) {
diff --git a/engines/ultima/ultima8/gfx/render_surface.cpp b/engines/ultima/ultima8/gfx/render_surface.cpp
index d8376a40e5f..9b1bdb8b08e 100644
--- a/engines/ultima/ultima8/gfx/render_surface.cpp
+++ b/engines/ultima/ultima8/gfx/render_surface.cpp
@@ -897,6 +897,8 @@ void RenderSurface::Paint(const Shape *s, uint32 framenum, int32 x, int32 y, boo
paintLogic<uint32>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, map);
else if (_surface->format.bytesPerPixel == 2)
paintLogic<uint16>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, map);
+ else if (_surface->format.isCLUT8())
+ paintLogic<uint8>(_pixels, _pitch, _clipWindow, _surface->format, frame, x, y, mirrored, map);
else
error("Paint not supported for surface format: %s", _surface->format.toString().c_str());
}
More information about the Scummvm-git-logs
mailing list