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.
This commit is contained in:
Miro Kropacek 2023-04-07 15:49:38 +02:00
parent c0eaf1227d
commit b2103898a7
3 changed files with 28 additions and 1 deletions

View file

@ -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()) {