[Scummvm-git-logs] scummvm master -> 98c3d0e77917199dd7e4868e878aaee578396779

dreammaster noreply at scummvm.org
Sun Nov 2 04:23:47 UTC 2025


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

Summary:
4b4b2cebf9 BAGEL: MFC: Palette mapping for when bForceBackground is true
e6a84a6ba7 BAGEL: Added dumpres console command for dumping embedded resources
98c3d0e779 BAGEL: MINIGAMES: Finally fix the rendering of the Art Parts scroll button


Commit: 4b4b2cebf953d693cb9be55b20d693fd026eea32
    https://github.com/scummvm/scummvm/commit/4b4b2cebf953d693cb9be55b20d693fd026eea32
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-11-01T21:23:03-07:00

Commit Message:
BAGEL: MFC: Palette mapping for when bForceBackground is true

When a destination DC is called with SelectedPalette with
bForceBackground=true, then not only does it ensure that the
system palette will not be updated, all blitting operations to
it must map from the newly set palette to the system palette

Changed paths:
    engines/bagel/mfc/dc.cpp


diff --git a/engines/bagel/mfc/dc.cpp b/engines/bagel/mfc/dc.cpp
index 9c3d348ad27..3fc0a00e316 100644
--- a/engines/bagel/mfc/dc.cpp
+++ b/engines/bagel/mfc/dc.cpp
@@ -756,12 +756,22 @@ void CDC::Impl::setScreenRect(const Common::Rect &r) {
 }
 
 HPALETTE CDC::Impl::selectPalette(HPALETTE pal, bool bForceBackground) {
+	CWinApp *app = AfxGetApp();
 	HPALETTE oldPal = _palette;
+	//CWnd *pTopLevel = m_pWnd->GetTopLevelFrame();
+
+	_paletteRealized = false;
 	m_bForceBackground = bForceBackground;
+	if (!m_bForceBackground) {
+		m_bForceBackground = app->GetActiveWindow() != m_pWnd;
+		//CDC *dc = wnd->GetDC();
+		//m_bForceBackground = dc->m_hDC == this;
+		//wnd->ReleaseDC(dc);
+	}
 
 	if (pal) {
 		_palette = pal;
-		_hasLogicalPalette = true;
+		_hasLogicalPalette = app->getSystemPalette() != pal;
 		CBitmap::Impl *bitmap = (CBitmap::Impl *)_bitmap;
 
 		auto *newPal = static_cast<CPalette::Impl *>(pal);
@@ -785,9 +795,7 @@ unsigned int CDC::Impl::realizePalette() {
 	if (m_pWnd == nullptr || !pal)
 		return 0;
 
-	CWinApp *app = AfxGetApp();
-	CWnd *pTopLevel = m_pWnd->GetTopLevelFrame();
-	if (!m_bForceBackground && pTopLevel == app->GetActiveWindow()) {
+	if (!m_bForceBackground) {
 		// This window is active - update the system palette
 		AfxGetApp()->setPalette(*pal);
 		_paletteRealized = true;
@@ -1051,18 +1059,28 @@ void CDC::Impl::stretchBlt(int x, int y, int nWidth, int nHeight, CDC *pSrcDC,
 }
 
 uint32 *CDC::Impl::getPaletteMap(const CDC::Impl *srcImpl) {
+	Graphics::Palette *srcPal, *destPal;
+
+	// If we have a logical palette, but are in the background (i.e. not the active one),
+	// then source pixels map from the local logical palette to the system one
+	if (_paletteRealized && m_bForceBackground) {
+		srcPal = dynamic_cast<Graphics::Palette *>(_palette);
+		destPal = dynamic_cast<Graphics::Palette *>(AfxGetApp()->getSystemPalette());
+	}
 	// If we haven't realized our palette locally, or the source bitmap hasn't had any
 	// palette at all set, then return null indicating no palette mapping will occur
-	if (!_paletteRealized || !srcImpl->_hasLogicalPalette)
+	else if (!_paletteRealized || !srcImpl->_hasLogicalPalette)
 		return nullptr;
+	else {
+		srcPal = dynamic_cast<Graphics::Palette *>(srcImpl->_palette);
+		destPal = dynamic_cast<Graphics::Palette *>(_palette);
+	}
 
-	const Graphics::Palette *srcPal = dynamic_cast<Graphics::Palette *>(srcImpl->_palette);
-	const Graphics::Palette *destPal = dynamic_cast<Graphics::Palette *>(_palette);
 	assert(srcPal && destPal && srcPal->size() == destPal->size());
 
 	// Create the map
-	Graphics::PaletteLookup palLookup(srcPal->data(), srcPal->size());
-	return palLookup.createMap(destPal->data(), destPal->size());
+	Graphics::PaletteLookup palLookup(destPal->data(), destPal->size());
+	return palLookup.createMap(srcPal->data(), srcPal->size());
 }
 
 void CDC::Impl::moveTo(int x, int y) {


Commit: e6a84a6ba76af3471d7c1c0c8e9b8b4d81c4eead
    https://github.com/scummvm/scummvm/commit/e6a84a6ba76af3471d7c1c0c8e9b8b4d81c4eead
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-11-01T21:23:03-07:00

Commit Message:
BAGEL: Added dumpres console command for dumping embedded resources

Changed paths:
    engines/bagel/hodjnpodj/console.cpp
    engines/bagel/hodjnpodj/console.h


diff --git a/engines/bagel/hodjnpodj/console.cpp b/engines/bagel/hodjnpodj/console.cpp
index 33389f296cc..16ab7865d2f 100644
--- a/engines/bagel/hodjnpodj/console.cpp
+++ b/engines/bagel/hodjnpodj/console.cpp
@@ -21,15 +21,58 @@
 
 #include "bagel/hodjnpodj/console.h"
 #include "bagel/hodjnpodj/hodjnpodj.h"
+#include "bagel/afxwin.h"
 
 namespace Bagel {
 namespace HodjNPodj {
 
 Console::Console() : GUI::Debugger() {
+	registerCmd("dumpres", WRAP_METHOD(Console, cmdDumpRes));
 }
 
 Console::~Console() {
 }
 
+bool Console::cmdDumpRes(int argc, const char **argv) {
+	if (argc == 2) {
+		int num = atoi(argv[1]);
+		Common::String name = Common::String::format("#%d", num);
+		HINSTANCE hInst = nullptr;
+		uint dwBytes;
+		HRSRC hRsc;
+		HGLOBAL hGbl;
+		byte *pData;
+
+		hRsc = FindResource(hInst, name.c_str(), RT_BITMAP);
+		if (hRsc != nullptr) {
+			dwBytes = (size_t)SizeofResource(hInst, hRsc);
+			hGbl = LoadResource(hInst, hRsc);
+			if ((dwBytes != 0) && (hGbl != nullptr)) {
+				pData = (byte *)LockResource(hGbl);
+				Common::MemoryReadStream rs(pData, dwBytes);
+				Common::DumpFile df;
+				if (df.open("dump.bin"))
+					df.writeStream(&rs);
+
+				UnlockResource(hGbl);
+				FreeResource(hGbl);
+
+				if (df.isOpen())
+					debugPrintf("Created dump.bin\n");
+				else
+					debugPrintf("Could not create dump.bin\n");
+			} else {
+				debugPrintf("Could not find resource\n");
+			}
+		} else {
+			debugPrintf("Could not find resource\n");
+		}
+	} else {
+		debugPrintf("dumpres [num]\n");
+	}
+
+	return true;
+}
+
 } // namespace HodjNPodj
 } // namespace Bagel
diff --git a/engines/bagel/hodjnpodj/console.h b/engines/bagel/hodjnpodj/console.h
index a5d3cf6fc94..a23a9fa0a68 100644
--- a/engines/bagel/hodjnpodj/console.h
+++ b/engines/bagel/hodjnpodj/console.h
@@ -30,6 +30,7 @@ namespace HodjNPodj {
 
 class Console : public GUI::Debugger {
 private:
+	bool cmdDumpRes(int argc, const char **argv);
 
 public:
 	Console();


Commit: 98c3d0e77917199dd7e4868e878aaee578396779
    https://github.com/scummvm/scummvm/commit/98c3d0e77917199dd7e4868e878aaee578396779
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2025-11-01T21:23:03-07:00

Commit Message:
BAGEL: MINIGAMES: Finally fix the rendering of the Art Parts scroll button

Changed paths:
    engines/bagel/mfc/afxwin.h
    engines/bagel/mfc/dc.cpp
    engines/bagel/mfc/wnd.cpp


diff --git a/engines/bagel/mfc/afxwin.h b/engines/bagel/mfc/afxwin.h
index f4b46902d0c..ab08bd289fb 100644
--- a/engines/bagel/mfc/afxwin.h
+++ b/engines/bagel/mfc/afxwin.h
@@ -2095,7 +2095,11 @@ public:
 		assert(_defaultBrush.m_hObject);
 		return (HBRUSH)_defaultBrush.m_hObject;
 	}
-	HPALETTE getSystemPalette() {
+	HPALETTE getCurrentPalette() const {
+		assert(_currentPalette.m_hObject);
+		return (HPALETTE)_currentPalette.m_hObject;
+	}
+	HPALETTE getSystemDefaultPalette() const {
 		assert(_systemPalette.m_hObject);
 		return (HPALETTE)_systemPalette.m_hObject;
 	}
diff --git a/engines/bagel/mfc/dc.cpp b/engines/bagel/mfc/dc.cpp
index 3fc0a00e316..102853863d0 100644
--- a/engines/bagel/mfc/dc.cpp
+++ b/engines/bagel/mfc/dc.cpp
@@ -664,7 +664,7 @@ CDC::Impl::Impl(CWnd *wndOwner) : m_pWnd(wndOwner), _drawMode(R2_COPYPEN) {
 	_font = app->getDefaultFont();
 	_pen = app->getDefaultPen();
 	_brush = app->getDefaultBrush();
-	_palette = app->getSystemPalette();
+	_palette = app->getSystemDefaultPalette();
 }
 
 CDC::Impl::Impl(HDC srcDc) {
@@ -686,7 +686,7 @@ CDC::Impl::Impl(HDC srcDc) {
 		_font = app->getDefaultFont();
 		_pen = app->getDefaultPen();
 		_brush = app->getDefaultBrush();
-		_palette = app->getSystemPalette();
+		_palette = app->getSystemDefaultPalette();
 	}
 }
 
@@ -771,7 +771,7 @@ HPALETTE CDC::Impl::selectPalette(HPALETTE pal, bool bForceBackground) {
 
 	if (pal) {
 		_palette = pal;
-		_hasLogicalPalette = app->getSystemPalette() != pal;
+		_hasLogicalPalette = app->getSystemDefaultPalette() != pal;
 		CBitmap::Impl *bitmap = (CBitmap::Impl *)_bitmap;
 
 		auto *newPal = static_cast<CPalette::Impl *>(pal);
@@ -1065,7 +1065,7 @@ uint32 *CDC::Impl::getPaletteMap(const CDC::Impl *srcImpl) {
 	// then source pixels map from the local logical palette to the system one
 	if (_paletteRealized && m_bForceBackground) {
 		srcPal = dynamic_cast<Graphics::Palette *>(_palette);
-		destPal = dynamic_cast<Graphics::Palette *>(AfxGetApp()->getSystemPalette());
+		destPal = dynamic_cast<Graphics::Palette *>(AfxGetApp()->getCurrentPalette());
 	}
 	// If we haven't realized our palette locally, or the source bitmap hasn't had any
 	// palette at all set, then return null indicating no palette mapping will occur
diff --git a/engines/bagel/mfc/wnd.cpp b/engines/bagel/mfc/wnd.cpp
index 545b77b3298..e6871efb1b4 100644
--- a/engines/bagel/mfc/wnd.cpp
+++ b/engines/bagel/mfc/wnd.cpp
@@ -64,7 +64,7 @@ CWnd::CWnd() : m_hWnd(this) {
 	_hFont = app->getDefaultFont();
 	_hPen = app->getDefaultPen();
 	_hBrush = app->getDefaultBrush();
-	_hPalette = app->getSystemPalette();
+	_hPalette = app->getSystemDefaultPalette();
 }
 
 CWnd::~CWnd() {




More information about the Scummvm-git-logs mailing list