ADL: Fix flood fill palette setting

This commit is contained in:
Walter van Niftrik 2016-03-16 15:08:47 +01:00 committed by Walter van Niftrik
parent 7ff7e0def4
commit 46528f2c04
3 changed files with 38 additions and 20 deletions

View File

@ -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] = { };

View File

@ -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);

View File

@ -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);
}
}