aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2016-03-16 15:08:47 +0100
committerWalter van Niftrik2016-06-06 20:35:49 +0200
commit46528f2c04d593f50e8c1a04d25c6cd663c3d209 (patch)
tree927195225e7e3fe817775c918738f8e0f561102f
parent7ff7e0def4670fee3346c4b75aa1e79d2f684bb0 (diff)
downloadscummvm-rg350-46528f2c04d593f50e8c1a04d25c6cd663c3d209.tar.gz
scummvm-rg350-46528f2c04d593f50e8c1a04d25c6cd663c3d209.tar.bz2
scummvm-rg350-46528f2c04d593f50e8c1a04d25c6cd663c3d209.zip
ADL: Fix flood fill palette setting
-rw-r--r--engines/adl/display.cpp29
-rw-r--r--engines/adl/display.h4
-rw-r--r--engines/adl/graphics_v2.cpp25
3 files changed, 38 insertions, 20 deletions
diff --git a/engines/adl/display.cpp b/engines/adl/display.cpp
index 2ecfbebfd7..b7f6eb9923 100644
--- a/engines/adl/display.cpp
+++ b/engines/adl/display.cpp
@@ -217,13 +217,6 @@ void Display::loadFrameBuffer(Common::ReadStream &stream) {
error("Failed to read frame buffer");
}
-void Display::putPixelRaw(const Common::Point &p, byte color) {
- byte *b = _frameBuf + p.y * DISPLAY_PITCH + (p.x / 7);
- color ^= *b;
- color &= 0x80 | (1 << (p.x % 7));
- *b ^= color;
-}
-
void Display::putPixel(const Common::Point &p, byte color) {
byte offset = p.x / 7;
byte mask = 0x80 | (1 << (p.x % 7));
@@ -241,14 +234,19 @@ void Display::putPixel(const Common::Point &p, byte color) {
color ^= 0x7f;
}
- byte *b = _frameBuf + p.y * DISPLAY_PITCH + offset;
- color ^= *b;
- color &= mask;
- *b ^= color;
+ writeFrameBuffer(p, color, mask);
+}
+
+void Display::setPixelBit(const Common::Point &p, byte color) {
+ writeFrameBuffer(p, color, 1 << (p.x % 7));
+}
+
+void Display::setPixelPalette(const Common::Point &p, byte color) {
+ writeFrameBuffer(p, color, 0x80);
}
bool Display::getPixelBit(const Common::Point &p) const {
- byte *b = _frameBuf + p.y * DISPLAY_PITCH + (p.x / 7);
+ byte *b = _frameBuf + p.y * DISPLAY_PITCH + p.x / 7;
return *b & (1 << (p.x % 7));
}
@@ -328,6 +326,13 @@ void Display::showCursor(bool enable) {
_showCursor = enable;
}
+void Display::writeFrameBuffer(const Common::Point &p, byte color, byte mask) {
+ byte *b = _frameBuf + p.y * DISPLAY_PITCH + p.x / 7;
+ color ^= *b;
+ color &= mask;
+ *b ^= color;
+}
+
void Display::showScanlines(bool enable) {
byte pal[COLOR_PALETTE_ENTRIES * 3] = { };
diff --git a/engines/adl/display.h b/engines/adl/display.h
index 2946a7e94a..bc27b7cb6b 100644
--- a/engines/adl/display.h
+++ b/engines/adl/display.h
@@ -63,8 +63,9 @@ public:
// Graphics
void loadFrameBuffer(Common::ReadStream &stream);
- void putPixelRaw(const Common::Point &p, byte color);
void putPixel(const Common::Point &p, byte color);
+ void setPixelBit(const Common::Point &p, byte color);
+ void setPixelPalette(const Common::Point &p, byte color);
bool getPixelBit(const Common::Point &p) const;
void clear(byte color);
@@ -80,6 +81,7 @@ public:
void showCursor(bool enable);
private:
+ void writeFrameBuffer(const Common::Point &p, byte color, byte mask);
void updateHiResSurface();
void showScanlines(bool enable);
diff --git a/engines/adl/graphics_v2.cpp b/engines/adl/graphics_v2.cpp
index 289f43e8de..d829b9526e 100644
--- a/engines/adl/graphics_v2.cpp
+++ b/engines/adl/graphics_v2.cpp
@@ -26,6 +26,7 @@
#include "adl/display.h"
#include "adl/graphics.h"
+#include "adl/adl.h"
namespace Adl {
@@ -175,23 +176,33 @@ static byte getPatternColor(const Common::Point &p, byte pattern) {
void Graphics_v2::fillRow(const Common::Point &p, bool stopBit, byte pattern) {
const byte color = getPatternColor(p, pattern);
- _display.putPixelRaw(p, color);
+ _display.setPixelPalette(p, color);
+ _display.setPixelBit(p, color);
Common::Point q(p);
byte c = color;
- while (++q.x < DISPLAY_WIDTH && _display.getPixelBit(q) != stopBit) {
- if ((q.x % 7) == 0)
+ while (++q.x < DISPLAY_WIDTH) {
+ if ((q.x % 7) == 0) {
c = getPatternColor(q, pattern);
- _display.putPixelRaw(q, c);
+ // Palette is set before the first bit is tested
+ _display.setPixelPalette(q, c);
+ }
+ if (_display.getPixelBit(q) == stopBit)
+ break;
+ _display.setPixelBit(q, c);
}
q = p;
c = color;
- while (--q.x >= 0 && _display.getPixelBit(q) != stopBit) {
- if ((q.x % 7) == 6)
+ while (--q.x >= 0) {
+ if ((q.x % 7) == 6) {
c = getPatternColor(q, pattern);
- _display.putPixelRaw(q, c);
+ _display.setPixelPalette(q, c);
+ }
+ if (_display.getPixelBit(q) == stopBit)
+ break;
+ _display.setPixelBit(q, c);
}
}