[Scummvm-git-logs] scummvm master -> c737686ac015a3d84038647146d7383d086ecc6f

bluegr noreply at scummvm.org
Sun May 3 12:11:12 UTC 2026


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:
c737686ac0 NANCY: Add handling for images with 24/32 bpp, for Nancy13+


Commit: c737686ac015a3d84038647146d7383d086ecc6f
    https://github.com/scummvm/scummvm/commit/c737686ac015a3d84038647146d7383d086ecc6f
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2026-05-03T15:08:09+03:00

Commit Message:
NANCY: Add handling for images with 24/32 bpp, for Nancy13+

These images are converted to 16bpp internally for now, since the rest
of the engine still expects 16bpp images, but this allows Nancy13 to
start, for now

Changed paths:
    engines/nancy/cursor.cpp
    engines/nancy/graphics.cpp
    engines/nancy/graphics.h
    engines/nancy/nancy.cpp
    engines/nancy/resource.cpp


diff --git a/engines/nancy/cursor.cpp b/engines/nancy/cursor.cpp
index 73c4bb41eb6..de77f251875 100644
--- a/engines/nancy/cursor.cpp
+++ b/engines/nancy/cursor.cpp
@@ -278,6 +278,9 @@ void CursorManager::warpCursor(const Common::Point &pos) {
 }
 
 void CursorManager::applyCursor() {
+	if (g_nancy->getGameType() >= kGameTypeNancy13)
+		return;	// TODO: In nancy13, the cursor format has changed
+
 	if (_curCursorID != _lastCursorID) {
 		Graphics::ManagedSurface *surf;
 		Common::Rect bounds = _cursors[_curCursorID].bounds;
diff --git a/engines/nancy/graphics.cpp b/engines/nancy/graphics.cpp
index 3d6c6312e2f..0454b20ab16 100644
--- a/engines/nancy/graphics.cpp
+++ b/engines/nancy/graphics.cpp
@@ -34,7 +34,9 @@ namespace Nancy {
 
 GraphicsManager::GraphicsManager() :
 	_objects(objectComparator),
-	_inputPixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0),
+	_inputPixelFormat16(2, 5, 5, 5, 0, 10, 5, 0, 0),
+	_inputPixelFormat24(Graphics::PixelFormat::createFormatBGR24()),
+	_inputPixelFormat32(Graphics::PixelFormat::createFormatBGRA32()),
 	_screenPixelFormat(2, 5, 6, 5, 0, 11, 5, 0, 0),
 	_clut8Format(Graphics::PixelFormat::createFormatCLUT8()),
 	_transparentPixelFormat(4, 8, 8, 8, 8, 8, 16, 24, 0),
@@ -49,9 +51,9 @@ void GraphicsManager::init() {
 	if (g_nancy->getGameType() == kGameTypeVampire) {
 		_transColor = bsum->paletteTrans;
 	} else {
-		_transColor = 	(bsum->rTrans << _inputPixelFormat.rShift) |
-						(bsum->gTrans << _inputPixelFormat.gShift) |
-						(bsum->bTrans << _inputPixelFormat.bShift);
+		_transColor = 	(bsum->rTrans << _inputPixelFormat16.rShift) |
+						(bsum->gTrans << _inputPixelFormat16.gShift) |
+						(bsum->bTrans << _inputPixelFormat16.bShift);
 	}
 
 	initGraphics(640, 480, &_screenPixelFormat);
@@ -393,11 +395,19 @@ void GraphicsManager::debugDrawToScreen(const Graphics::ManagedSurface &surf) {
 	_screen.update();
 }
 
-const Graphics::PixelFormat &GraphicsManager::getInputPixelFormat() {
-	if (g_nancy->getGameType() == kGameTypeVampire) {
+const Graphics::PixelFormat &GraphicsManager::getInputPixelFormat(uint bpp) {
+	if (g_nancy->getGameType() == kGameTypeVampire)
 		return _clut8Format;
-	} else {
-		return _inputPixelFormat;
+
+	switch (bpp) {
+	case 16:
+		return _inputPixelFormat16;	// RGB555
+	case 24:
+		return _inputPixelFormat24;
+	case 32:
+		return _inputPixelFormat32;
+	default:
+		error("Unsupported input pixel format with bpp %d", bpp);
 	}
 }
 
diff --git a/engines/nancy/graphics.h b/engines/nancy/graphics.h
index a7116528f2e..efd903a273f 100644
--- a/engines/nancy/graphics.h
+++ b/engines/nancy/graphics.h
@@ -52,7 +52,7 @@ public:
 	const Font *getFont(uint id) const { return id < _fonts.size() ? &_fonts[id] : nullptr; }
 	const Graphics::Screen *getScreen() { return &_screen; }
 
-	const Graphics::PixelFormat &getInputPixelFormat();
+	const Graphics::PixelFormat &getInputPixelFormat(uint bpp = 16);
 	const Graphics::PixelFormat &getScreenPixelFormat();
 	const Graphics::PixelFormat &getTransparentPixelFormat();
 	uint32 getTransColor() { return _transColor; }
@@ -85,7 +85,7 @@ private:
 
 	Common::SortedArray<RenderObject *> _objects;
 
-	Graphics::PixelFormat _inputPixelFormat;
+	Graphics::PixelFormat _inputPixelFormat16, _inputPixelFormat24, _inputPixelFormat32;
 	Graphics::PixelFormat _screenPixelFormat;
 	Graphics::PixelFormat _clut8Format;
 	Graphics::PixelFormat _transparentPixelFormat;
diff --git a/engines/nancy/nancy.cpp b/engines/nancy/nancy.cpp
index ebd256af8c5..653791444ee 100644
--- a/engines/nancy/nancy.cpp
+++ b/engines/nancy/nancy.cpp
@@ -431,8 +431,8 @@ void NancyEngine::bootGameEngine() {
 	// Setup mixer
 	syncSoundSettings();
 
-	if (getGameType() >= kGameTypeNancy13) {
-		// Nancy13+ games use 24/32bpp images, which we don't support yet.
+	if (getGameType() >= kGameTypeNancy14) {
+		// Nancy14+ games use a newer font format, which we don't support yet.
 		error("Game not supported; Use console to inspect game data");
 	}
 
diff --git a/engines/nancy/resource.cpp b/engines/nancy/resource.cpp
index 5b63092907c..986f5127404 100644
--- a/engines/nancy/resource.cpp
+++ b/engines/nancy/resource.cpp
@@ -147,7 +147,7 @@ bool ResourceManager::loadImage(const Common::Path &name, Graphics::ManagedSurfa
 		return false;
 	}
 
-	if (info.depth != 16) {
+	if (info.depth != 16 && info.depth != 24 && info.depth != 32) {
 		warning("Image '%s' has unsupported depth %i", name.toString().c_str(), info.depth);
 		delete stream;
 		return false;
@@ -163,7 +163,7 @@ bool ResourceManager::loadImage(const Common::Path &name, Graphics::ManagedSurfa
 	}
 
 	// Finally, copy the data into the surface
-	uint32 bufSize = info.pitch * info.height * (info.depth / 16);
+	uint32 bufSize = info.pitch * info.height;
 	byte *buf = new byte[bufSize];
 	stream->read(buf, bufSize);
 
@@ -174,7 +174,15 @@ bool ResourceManager::loadImage(const Common::Path &name, Graphics::ManagedSurfa
 	}
 	#endif
 
-	GraphicsManager::copyToManaged(buf, surf, info.width, info.height, g_nancy->_graphics->getInputPixelFormat());
+	GraphicsManager::copyToManaged(buf, surf, info.width, info.height, g_nancy->_graphics->getInputPixelFormat(info.depth));
+
+	if (info.depth != 16) {
+		// Convert 24/32 bpp images to 16 bpp on the fly since that's what the
+		// engine uses internally. These images are used since nancy13.
+		// TODO: add support for 24/32 bpp surfaces in the engine and skip this conversion
+		surf.convertToInPlace(g_nancy->_graphics->getInputPixelFormat());
+	}
+
 	delete[] buf;
 	delete stream;
 	return true;




More information about the Scummvm-git-logs mailing list