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

mikrosk noreply at scummvm.org
Fri Apr 7 13:53:53 UTC 2023


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:
b2103898a7 GRAPHICS: ATARI: Optionally avoid surface pitch align


Commit: b2103898a77418dea96e7d1f14696dbe4ce72064
    https://github.com/scummvm/scummvm/commit/b2103898a77418dea96e7d1f14696dbe4ce72064
Author: Miro Kropacek (miro.kropacek at gmail.com)
Date: 2023-04-07T15:54:28+02:00

Commit Message:
GRAPHICS: ATARI: Optionally avoid surface pitch align

Some engines are too bound to linear surfaces in 8bpp that it is very
hard to repair them. So instead of polluting the engine with
Surface::init() & delete[] Surface::getPixels() just use this
workaround.

It is also useful as an early fix for newly found engines which may be
fixable later.

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


diff --git a/backends/graphics/atari/atari-graphics.cpp b/backends/graphics/atari/atari-graphics.cpp
index 6d81878bb81..05803492fa4 100644
--- a/backends/graphics/atari/atari-graphics.cpp
+++ b/backends/graphics/atari/atari-graphics.cpp
@@ -39,6 +39,8 @@
 #include "graphics/blit.h"
 #include "gui/ThemeEngine.h"
 
+bool g_unalignedPitch = false;
+
 #define SCREEN_ACTIVE
 
 AtariGraphicsManager::AtariGraphicsManager() {
@@ -293,6 +295,21 @@ void AtariGraphicsManager::fillScreen(uint32 col) {
 void AtariGraphicsManager::updateScreen() {
 	//debug("updateScreen");
 
+	if (_checkUnalignedPitch) {
+		const Common::ConfigManager::Domain *activeDomain = ConfMan.getActiveDomain();
+		if (activeDomain) {
+			// FIXME: Some engines are too bound to linear surfaces that it is very
+			// hard to repair them. So instead of polluting the engine with
+			// Surface::init() & delete[] Surface::getPixels() just use this hack.
+			Common::String engineId = activeDomain->getValOrDefault("engineid");
+			if (engineId == "parallaction") {
+				g_unalignedPitch = true;
+			}
+		}
+
+		_checkUnalignedPitch = false;
+	}
+
 	// updates outOfScreen OR srcRect/dstRect (only if visible/needed)
 	_cursor.update(isOverlayVisible() ? _screenOverlaySurface : _screenSurface,
 				   _workScreen->cursorPositionChanged || _workScreen->cursorSurfaceChanged);
@@ -448,6 +465,9 @@ void AtariGraphicsManager::hideOverlay() {
 	_oldWorkScreen = nullptr;
 	_cursor.swap();
 
+	// FIXME: perhaps there's a better way but this will do for now
+	_checkUnalignedPitch = true;
+
 	_overlayVisible = false;
 }
 
diff --git a/backends/graphics/atari/atari-graphics.h b/backends/graphics/atari/atari-graphics.h
index 00bbaebe7a7..bcfc3284303 100644
--- a/backends/graphics/atari/atari-graphics.h
+++ b/backends/graphics/atari/atari-graphics.h
@@ -241,6 +241,8 @@ private:
 	bool _overlayVisible = false;
 	Graphics::Surface _overlaySurface;
 
+	bool _checkUnalignedPitch = false;
+
 	struct Cursor {
 		void update(const Graphics::Surface &screen, bool isModified);
 
diff --git a/graphics/blit-atari.cpp b/graphics/blit-atari.cpp
index 796f3746808..48c72932b9c 100644
--- a/graphics/blit-atari.cpp
+++ b/graphics/blit-atari.cpp
@@ -89,6 +89,9 @@ void unlockSuperBlitter() {
 		syncSuperBlitter();
 }
 
+// see atari-graphics.cpp
+extern bool g_unalignedPitch;
+
 namespace Graphics {
 
 constexpr size_t ALIGN = 16;	// 16 bytes
@@ -103,7 +106,9 @@ void Surface::create(int16 width, int16 height, const PixelFormat &f) {
 	h = height;
 	format = f;
 	// align pitch to a 16-byte boundary for a possible C2P conversion
-	pitch = (w * format.bytesPerPixel + ALIGN - 1) & (-ALIGN);
+	pitch = g_unalignedPitch
+		? w * format.bytesPerPixel
+		: (w * format.bytesPerPixel + ALIGN - 1) & (-ALIGN);
 
 	if (width && height) {
 		if (hasSuperVidel()) {




More information about the Scummvm-git-logs mailing list