[Scummvm-git-logs] scummvm branch-2-8 -> 10bafbe1627cb527f1e583108296d5d3645d8909

mikrosk noreply at scummvm.org
Sun Jan 28 21:01:24 UTC 2024


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

Summary:
10bafbe162 BACKENDS: ATARI: Fix a crash


Commit: 10bafbe1627cb527f1e583108296d5d3645d8909
    https://github.com/scummvm/scummvm/commit/10bafbe1627cb527f1e583108296d5d3645d8909
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2024-01-28T22:00:58+01:00

Commit Message:
BACKENDS: ATARI: Fix a crash

_offsettedSurf must have the original screen dimensions, similar as done in
AtariGraphicsManager::Screen::reset().

Strangely, this bug was reproducible only in MagiC and not in FreeMiNT+MP.

Changed paths:
    backends/graphics/atari/atari-graphics.cpp


diff --git a/backends/graphics/atari/atari-graphics.cpp b/backends/graphics/atari/atari-graphics.cpp
index c77dbaabbca..cf8722740ae 100644
--- a/backends/graphics/atari/atari-graphics.cpp
+++ b/backends/graphics/atari/atari-graphics.cpp
@@ -1132,17 +1132,16 @@ bool AtariGraphicsManager::isOverlayDirectRendering() const {
 }
 
 AtariGraphicsManager::Screen::Screen(AtariGraphicsManager *manager, int width, int height, const Graphics::PixelFormat &format, const Palette *palette_)
-	: _manager(manager) {
+	: _manager(manager)
+	, palette(palette_) {
 	const AtariMemAlloc &allocFunc = _manager->getStRamAllocFunc();
 
-	palette = palette_;
-
-	width += (_manager->_tt ? 0 : 2 * MAX_HZ_SHAKE);
-	height += 2 * MAX_V_SHAKE;
-
-	const int bitsPerPixel = _manager->getBitsPerPixel(format);
-
-	surf.init(width, height, width * bitsPerPixel / 8, nullptr, format);
+	surf.init(
+		width + (_manager->_tt ? 0 : 2 * MAX_HZ_SHAKE),
+		height + 2 * MAX_V_SHAKE,
+		(width + (_manager->_tt ? 0 : 2 * MAX_HZ_SHAKE)) * _manager->getBitsPerPixel(format) / 8,
+		nullptr,
+		format);
 
 	void *pixelsUnaligned = allocFunc(sizeof(uintptr) + (surf.h * surf.pitch) + ALIGN - 1);
 	if (!pixelsUnaligned) {
@@ -1156,7 +1155,10 @@ AtariGraphicsManager::Screen::Screen(AtariGraphicsManager *manager, int width, i
 
 	memset(surf.getPixels(), 0, surf.h * surf.pitch);
 
-	_offsettedSurf.init(surf.w, surf.h, surf.pitch, surf.getBasePtr(_manager->_tt ? 0 : MAX_HZ_SHAKE, MAX_V_SHAKE), surf.format);
+	_offsettedSurf.init(
+		width, height, surf.pitch,
+		surf.getBasePtr((surf.w - width) / 2, (surf.h - height) / 2),
+		surf.format);
 }
 
 AtariGraphicsManager::Screen::~Screen() {




More information about the Scummvm-git-logs mailing list