2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2004-11-25 23:33:21 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2014-02-18 01:34:20 +00:00
|
|
|
*
|
2004-11-25 23:33:21 +00:00
|
|
|
*/
|
|
|
|
|
2007-11-06 23:03:19 +00:00
|
|
|
#include "common/algorithm.h"
|
2012-03-08 03:00:22 +00:00
|
|
|
#include "common/endian.h"
|
2004-11-25 23:33:21 +00:00
|
|
|
#include "common/util.h"
|
2011-04-24 08:34:27 +00:00
|
|
|
#include "common/rect.h"
|
|
|
|
#include "common/textconsole.h"
|
2005-05-08 12:33:55 +00:00
|
|
|
#include "graphics/primitives.h"
|
2004-11-25 23:33:21 +00:00
|
|
|
#include "graphics/surface.h"
|
2012-07-14 04:03:04 +00:00
|
|
|
#include "graphics/conversion.h"
|
2004-11-25 23:33:21 +00:00
|
|
|
|
|
|
|
namespace Graphics {
|
|
|
|
|
2007-11-06 22:40:29 +00:00
|
|
|
template<typename T>
|
|
|
|
static void plotPoint(int x, int y, int color, void *data) {
|
2005-05-08 12:33:55 +00:00
|
|
|
Surface *s = (Surface *)data;
|
2005-05-17 12:17:30 +00:00
|
|
|
if (x >= 0 && x < s->w && y >= 0 && y < s->h) {
|
2007-11-06 22:40:29 +00:00
|
|
|
T *ptr = (T *)s->getBasePtr(x, y);
|
|
|
|
*ptr = (T)color;
|
2005-05-17 12:17:30 +00:00
|
|
|
}
|
2005-05-08 12:33:55 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void Surface::drawLine(int x0, int y0, int x1, int y1, uint32 color) {
|
2011-04-17 15:30:44 +00:00
|
|
|
if (format.bytesPerPixel == 1)
|
2007-11-06 22:40:29 +00:00
|
|
|
Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<byte>, this);
|
2011-04-17 15:30:44 +00:00
|
|
|
else if (format.bytesPerPixel == 2)
|
2007-11-06 22:40:29 +00:00
|
|
|
Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<uint16>, this);
|
2011-05-19 22:33:00 +00:00
|
|
|
else if (format.bytesPerPixel == 4)
|
|
|
|
Graphics::drawLine(x0, y0, x1, y1, color, plotPoint<uint32>, this);
|
2005-05-08 12:33:55 +00:00
|
|
|
else
|
2011-05-19 22:33:00 +00:00
|
|
|
error("Surface::drawLine: bytesPerPixel must be 1, 2, or 4");
|
2005-05-08 12:33:55 +00:00
|
|
|
}
|
|
|
|
|
2011-10-27 23:20:28 +00:00
|
|
|
void Surface::drawThickLine(int x0, int y0, int x1, int y1, int penX, int penY, uint32 color) {
|
|
|
|
if (format.bytesPerPixel == 1)
|
|
|
|
Graphics::drawThickLine(x0, y0, x1, y1, penX, penY, color, plotPoint<byte>, this);
|
|
|
|
else if (format.bytesPerPixel == 2)
|
|
|
|
Graphics::drawThickLine(x0, y0, x1, y1, penX, penY, color, plotPoint<uint16>, this);
|
|
|
|
else if (format.bytesPerPixel == 4)
|
|
|
|
Graphics::drawThickLine(x0, y0, x1, y1, penX, penY, color, plotPoint<uint32>, this);
|
|
|
|
else
|
|
|
|
error("Surface::drawThickLine: bytesPerPixel must be 1, 2, or 4");
|
|
|
|
}
|
|
|
|
|
2011-04-17 13:17:42 +00:00
|
|
|
void Surface::create(uint16 width, uint16 height, const PixelFormat &f) {
|
2005-05-08 21:24:33 +00:00
|
|
|
free();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-08 21:24:33 +00:00
|
|
|
w = width;
|
|
|
|
h = height;
|
2011-04-17 13:17:42 +00:00
|
|
|
format = f;
|
2011-04-17 15:30:44 +00:00
|
|
|
pitch = w * format.bytesPerPixel;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2011-08-12 21:30:38 +00:00
|
|
|
if (width && height) {
|
|
|
|
pixels = calloc(width * height, format.bytesPerPixel);
|
|
|
|
assert(pixels);
|
|
|
|
}
|
2005-05-08 21:24:33 +00:00
|
|
|
}
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2005-05-08 21:24:33 +00:00
|
|
|
void Surface::free() {
|
2008-01-28 00:14:17 +00:00
|
|
|
::free(pixels);
|
|
|
|
pixels = 0;
|
|
|
|
w = h = pitch = 0;
|
2011-04-17 15:30:44 +00:00
|
|
|
format = PixelFormat();
|
2005-05-08 21:24:33 +00:00
|
|
|
}
|
|
|
|
|
2013-08-03 01:42:37 +00:00
|
|
|
void Surface::init(uint16 width, uint16 height, uint16 newPitch, void *newPixels, const PixelFormat &f) {
|
|
|
|
w = width;
|
|
|
|
h = height;
|
|
|
|
pitch = newPitch;
|
|
|
|
pixels = newPixels;
|
|
|
|
format = f;
|
|
|
|
}
|
|
|
|
|
2008-09-16 14:10:55 +00:00
|
|
|
void Surface::copyFrom(const Surface &surf) {
|
2011-04-17 19:27:34 +00:00
|
|
|
create(surf.w, surf.h, surf.format);
|
2013-08-01 21:53:18 +00:00
|
|
|
if (surf.pitch == pitch) {
|
|
|
|
memcpy(pixels, surf.pixels, h * pitch);
|
|
|
|
} else {
|
|
|
|
const byte *src = (const byte *)surf.pixels;
|
|
|
|
byte *dst = (byte *)pixels;
|
|
|
|
for (int y = h; y > 0; --y) {
|
|
|
|
memcpy(dst, src, w * format.bytesPerPixel);
|
|
|
|
src += surf.pitch;
|
|
|
|
dst += pitch;
|
|
|
|
}
|
|
|
|
}
|
2008-09-16 14:10:55 +00:00
|
|
|
}
|
|
|
|
|
2013-08-02 16:37:12 +00:00
|
|
|
Surface Surface::getSubArea(const Common::Rect &area) {
|
|
|
|
Common::Rect effectiveArea(area);
|
|
|
|
effectiveArea.clip(w, h);
|
|
|
|
|
|
|
|
Surface subSurface;
|
|
|
|
subSurface.w = effectiveArea.width();
|
|
|
|
subSurface.h = effectiveArea.height();
|
|
|
|
subSurface.pitch = pitch;
|
|
|
|
subSurface.pixels = getBasePtr(area.left, area.top);
|
|
|
|
subSurface.format = format;
|
|
|
|
return subSurface;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Surface Surface::getSubArea(const Common::Rect &area) const {
|
|
|
|
Common::Rect effectiveArea(area);
|
|
|
|
effectiveArea.clip(w, h);
|
|
|
|
|
|
|
|
Surface subSurface;
|
|
|
|
subSurface.w = effectiveArea.width();
|
|
|
|
subSurface.h = effectiveArea.height();
|
|
|
|
subSurface.pitch = pitch;
|
|
|
|
// We need to cast the const away here because a Surface always has a
|
|
|
|
// pointer to modifiable pixel data.
|
|
|
|
subSurface.pixels = const_cast<void *>(getBasePtr(area.left, area.top));
|
|
|
|
subSurface.format = format;
|
|
|
|
return subSurface;
|
|
|
|
}
|
|
|
|
|
2013-09-22 20:53:15 +00:00
|
|
|
void Surface::copyRectToSurface(const void *buffer, int srcPitch, int destX, int destY, int width, int height) {
|
2013-08-15 00:42:56 +00:00
|
|
|
assert(buffer);
|
|
|
|
|
2013-09-12 14:30:28 +00:00
|
|
|
assert(destX >= 0 && destX < w);
|
|
|
|
assert(destY >= 0 && destY < h);
|
|
|
|
assert(height > 0 && destY + height <= h);
|
|
|
|
assert(width > 0 && destX + width <= w);
|
2013-08-15 00:42:56 +00:00
|
|
|
|
|
|
|
// Copy buffer data to internal buffer
|
|
|
|
const byte *src = (const byte *)buffer;
|
2013-09-12 14:30:28 +00:00
|
|
|
byte *dst = (byte *)getBasePtr(destX, destY);
|
2013-08-15 00:42:56 +00:00
|
|
|
for (int i = 0; i < height; i++) {
|
|
|
|
memcpy(dst, src, width * format.bytesPerPixel);
|
2013-09-22 20:53:15 +00:00
|
|
|
src += srcPitch;
|
|
|
|
dst += pitch;
|
2013-08-15 00:42:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-09-12 14:30:28 +00:00
|
|
|
void Surface::copyRectToSurface(const Graphics::Surface &srcSurface, int destX, int destY, const Common::Rect subRect) {
|
|
|
|
assert(srcSurface.format == format);
|
|
|
|
|
|
|
|
copyRectToSurface(srcSurface.getBasePtr(subRect.left, subRect.top), srcSurface.pitch, destX, destY, subRect.width(), subRect.height());
|
|
|
|
}
|
|
|
|
|
2005-05-02 18:00:05 +00:00
|
|
|
void Surface::hLine(int x, int y, int x2, uint32 color) {
|
2004-11-25 23:33:21 +00:00
|
|
|
// Clipping
|
|
|
|
if (y < 0 || y >= h)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (x2 < x)
|
|
|
|
SWAP(x2, x);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-11-25 23:33:21 +00:00
|
|
|
if (x < 0)
|
|
|
|
x = 0;
|
|
|
|
if (x2 >= w)
|
|
|
|
x2 = w - 1;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2007-11-06 23:03:19 +00:00
|
|
|
if (x2 < x)
|
|
|
|
return;
|
|
|
|
|
2011-04-17 15:30:44 +00:00
|
|
|
if (format.bytesPerPixel == 1) {
|
2004-11-25 23:33:21 +00:00
|
|
|
byte *ptr = (byte *)getBasePtr(x, y);
|
2011-05-19 22:37:24 +00:00
|
|
|
memset(ptr, (byte)color, x2 - x + 1);
|
2011-04-17 15:30:44 +00:00
|
|
|
} else if (format.bytesPerPixel == 2) {
|
2004-11-25 23:33:21 +00:00
|
|
|
uint16 *ptr = (uint16 *)getBasePtr(x, y);
|
2011-11-16 17:06:30 +00:00
|
|
|
Common::fill(ptr, ptr + (x2 - x + 1), (uint16)color);
|
2011-05-19 22:33:00 +00:00
|
|
|
} else if (format.bytesPerPixel == 4) {
|
|
|
|
uint32 *ptr = (uint32 *)getBasePtr(x, y);
|
2011-11-16 17:06:30 +00:00
|
|
|
Common::fill(ptr, ptr + (x2 - x + 1), color);
|
2004-11-25 23:33:21 +00:00
|
|
|
} else {
|
2011-05-19 22:33:00 +00:00
|
|
|
error("Surface::hLine: bytesPerPixel must be 1, 2, or 4");
|
2004-11-25 23:33:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-02 18:00:05 +00:00
|
|
|
void Surface::vLine(int x, int y, int y2, uint32 color) {
|
2004-11-25 23:33:21 +00:00
|
|
|
// Clipping
|
|
|
|
if (x < 0 || x >= w)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (y2 < y)
|
|
|
|
SWAP(y2, y);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-11-25 23:33:21 +00:00
|
|
|
if (y < 0)
|
|
|
|
y = 0;
|
|
|
|
if (y2 >= h)
|
|
|
|
y2 = h - 1;
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2011-04-17 15:30:44 +00:00
|
|
|
if (format.bytesPerPixel == 1) {
|
2004-11-25 23:33:21 +00:00
|
|
|
byte *ptr = (byte *)getBasePtr(x, y);
|
|
|
|
while (y++ <= y2) {
|
|
|
|
*ptr = (byte)color;
|
|
|
|
ptr += pitch;
|
|
|
|
}
|
2011-04-17 15:30:44 +00:00
|
|
|
} else if (format.bytesPerPixel == 2) {
|
2004-11-25 23:33:21 +00:00
|
|
|
uint16 *ptr = (uint16 *)getBasePtr(x, y);
|
|
|
|
while (y++ <= y2) {
|
|
|
|
*ptr = (uint16)color;
|
2011-05-19 22:37:24 +00:00
|
|
|
ptr += pitch / 2;
|
2004-11-25 23:33:21 +00:00
|
|
|
}
|
2011-06-19 22:59:48 +00:00
|
|
|
|
2011-05-19 22:33:00 +00:00
|
|
|
} else if (format.bytesPerPixel == 4) {
|
|
|
|
uint32 *ptr = (uint32 *)getBasePtr(x, y);
|
|
|
|
while (y++ <= y2) {
|
|
|
|
*ptr = color;
|
|
|
|
ptr += pitch / 4;
|
|
|
|
}
|
2004-11-25 23:33:21 +00:00
|
|
|
} else {
|
2011-05-19 22:33:00 +00:00
|
|
|
error("Surface::vLine: bytesPerPixel must be 1, 2, or 4");
|
2004-11-25 23:33:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-11-06 23:03:19 +00:00
|
|
|
void Surface::fillRect(Common::Rect r, uint32 color) {
|
2004-11-25 23:33:21 +00:00
|
|
|
r.clip(w, h);
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-11-25 23:33:21 +00:00
|
|
|
if (!r.isValidRect())
|
|
|
|
return;
|
|
|
|
|
|
|
|
int width = r.width();
|
2010-04-20 20:22:33 +00:00
|
|
|
int lineLen = width;
|
2004-11-25 23:33:21 +00:00
|
|
|
int height = r.height();
|
2010-04-20 20:22:33 +00:00
|
|
|
bool useMemset = true;
|
2004-11-25 23:33:21 +00:00
|
|
|
|
2011-04-17 15:30:44 +00:00
|
|
|
if (format.bytesPerPixel == 2) {
|
2010-04-20 20:22:33 +00:00
|
|
|
lineLen *= 2;
|
|
|
|
if ((uint16)color != ((color & 0xff) | (color & 0xff) << 8))
|
|
|
|
useMemset = false;
|
2011-04-17 15:30:44 +00:00
|
|
|
} else if (format.bytesPerPixel == 4) {
|
2010-08-21 20:14:46 +00:00
|
|
|
useMemset = false;
|
2011-04-17 15:30:44 +00:00
|
|
|
} else if (format.bytesPerPixel != 1) {
|
2011-05-19 22:37:24 +00:00
|
|
|
error("Surface::fillRect: bytesPerPixel must be 1, 2, or 4");
|
2010-04-20 20:22:33 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (useMemset) {
|
2004-11-25 23:33:21 +00:00
|
|
|
byte *ptr = (byte *)getBasePtr(r.left, r.top);
|
|
|
|
while (height--) {
|
2010-04-20 20:22:33 +00:00
|
|
|
memset(ptr, (byte)color, lineLen);
|
2004-11-25 23:33:21 +00:00
|
|
|
ptr += pitch;
|
|
|
|
}
|
2010-04-20 20:22:33 +00:00
|
|
|
} else {
|
2011-04-17 15:30:44 +00:00
|
|
|
if (format.bytesPerPixel == 2) {
|
2010-08-21 20:14:46 +00:00
|
|
|
uint16 *ptr = (uint16 *)getBasePtr(r.left, r.top);
|
|
|
|
while (height--) {
|
2011-11-16 17:06:30 +00:00
|
|
|
Common::fill(ptr, ptr + width, (uint16)color);
|
2011-05-19 22:37:24 +00:00
|
|
|
ptr += pitch / 2;
|
2010-08-21 20:14:46 +00:00
|
|
|
}
|
|
|
|
} else {
|
|
|
|
uint32 *ptr = (uint32 *)getBasePtr(r.left, r.top);
|
|
|
|
while (height--) {
|
2011-11-16 17:06:30 +00:00
|
|
|
Common::fill(ptr, ptr + width, color);
|
2010-08-21 20:14:46 +00:00
|
|
|
ptr += pitch / 4;
|
|
|
|
}
|
2004-11-25 23:33:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-05-02 18:00:05 +00:00
|
|
|
void Surface::frameRect(const Common::Rect &r, uint32 color) {
|
2011-05-19 22:37:24 +00:00
|
|
|
hLine(r.left, r.top, r.right - 1, color);
|
|
|
|
hLine(r.left, r.bottom - 1, r.right - 1, color);
|
|
|
|
vLine(r.left, r.top, r.bottom - 1, color);
|
|
|
|
vLine(r.right - 1, r.top, r.bottom - 1, color);
|
2004-11-25 23:33:21 +00:00
|
|
|
}
|
|
|
|
|
2006-06-21 11:33:04 +00:00
|
|
|
void Surface::move(int dx, int dy, int height) {
|
|
|
|
// Short circuit check - do we have to do anything anyway?
|
|
|
|
if ((dx == 0 && dy == 0) || height <= 0)
|
|
|
|
return;
|
|
|
|
|
2011-05-19 22:33:00 +00:00
|
|
|
if (format.bytesPerPixel != 1 && format.bytesPerPixel != 2 && format.bytesPerPixel != 4)
|
|
|
|
error("Surface::move: bytesPerPixel must be 1, 2, or 4");
|
2010-10-01 20:44:58 +00:00
|
|
|
|
2006-06-21 11:33:04 +00:00
|
|
|
byte *src, *dst;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
// vertical movement
|
|
|
|
if (dy > 0) {
|
|
|
|
// move down - copy from bottom to top
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
dst = (byte *)pixels + (height - 1) * pitch;
|
|
|
|
src = dst - dy * pitch;
|
2006-06-21 11:33:04 +00:00
|
|
|
for (y = dy; y < height; y++) {
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
memcpy(dst, src, pitch);
|
|
|
|
src -= pitch;
|
|
|
|
dst -= pitch;
|
2006-06-21 11:33:04 +00:00
|
|
|
}
|
|
|
|
} else if (dy < 0) {
|
|
|
|
// move up - copy from top to bottom
|
|
|
|
dst = (byte *)pixels;
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
src = dst - dy * pitch;
|
2006-06-21 11:33:04 +00:00
|
|
|
for (y = -dy; y < height; y++) {
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
memcpy(dst, src, pitch);
|
|
|
|
src += pitch;
|
|
|
|
dst += pitch;
|
2006-06-21 11:33:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// horizontal movement
|
|
|
|
if (dx > 0) {
|
|
|
|
// move right - copy from right to left
|
2011-04-17 15:30:44 +00:00
|
|
|
dst = (byte *)pixels + (pitch - format.bytesPerPixel);
|
|
|
|
src = dst - (dx * format.bytesPerPixel);
|
2006-06-21 11:33:04 +00:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = dx; x < w; x++) {
|
2011-04-17 15:30:44 +00:00
|
|
|
if (format.bytesPerPixel == 1) {
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
*dst-- = *src--;
|
2011-04-17 15:30:44 +00:00
|
|
|
} else if (format.bytesPerPixel == 2) {
|
2010-10-01 20:44:41 +00:00
|
|
|
*(uint16 *)dst = *(const uint16 *)src;
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
src -= 2;
|
|
|
|
dst -= 2;
|
2011-05-19 22:33:00 +00:00
|
|
|
} else if (format.bytesPerPixel == 4) {
|
|
|
|
*(uint32 *)dst = *(const uint32 *)src;
|
|
|
|
src -= 4;
|
|
|
|
dst -= 4;
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
}
|
2006-06-21 11:33:04 +00:00
|
|
|
}
|
2011-04-17 15:30:44 +00:00
|
|
|
src += pitch + (pitch - dx * format.bytesPerPixel);
|
|
|
|
dst += pitch + (pitch - dx * format.bytesPerPixel);
|
2006-06-21 11:33:04 +00:00
|
|
|
}
|
|
|
|
} else if (dx < 0) {
|
|
|
|
// move left - copy from left to right
|
|
|
|
dst = (byte *)pixels;
|
2011-04-17 15:30:44 +00:00
|
|
|
src = dst - (dx * format.bytesPerPixel);
|
2006-06-21 11:33:04 +00:00
|
|
|
for (y = 0; y < height; y++) {
|
|
|
|
for (x = -dx; x < w; x++) {
|
2011-04-17 15:30:44 +00:00
|
|
|
if (format.bytesPerPixel == 1) {
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
*dst++ = *src++;
|
2011-04-17 15:30:44 +00:00
|
|
|
} else if (format.bytesPerPixel == 2) {
|
2010-10-01 20:44:41 +00:00
|
|
|
*(uint16 *)dst = *(const uint16 *)src;
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
src += 2;
|
|
|
|
dst += 2;
|
2011-05-19 22:33:00 +00:00
|
|
|
} else if (format.bytesPerPixel == 4) {
|
|
|
|
*(uint32 *)dst = *(const uint32 *)src;
|
|
|
|
src += 4;
|
|
|
|
dst += 4;
|
SCUMM/FM-TOWNS: fix palette and other graphics issues
This commit should fix at least the following bugs/feature requests: #1032859, #1252088, #1055391, #1315968, #1315938, #1742106, #812891.
The FM-Towns version of Scumm games use a mixed graphics mode with 2 layers (one with 32767 colors and one with 16 colors). Among other things I have added a screen output class which emulates this dual layer approach which allows specific hardware effects like enabling and disabling layers (e.g. in the voodoo priestess scene in MI1).
Old savegames (saved before this update) will load, but you’ll encounter palette glitches in the verb/inventory screen, since the 16 color palette for layer 2 is not contained in your savegame. This will be true at least for version 5 games. Certain scene change actions (which require the verb/inventory part to be redrawn) might correct this (e.g. try looking at the treasure map in MI1 and closing it). Version 3 games should be okay, since they use a static text palette which is never changed and which will be reset after loading a savegame.
This update requires a USE_RGB_COLORS setting for proper operation. 8 bit users will get a warning that they’ll have to expect palette glitches . Apart from that the engine in 8 bit mode should not only still work okay, but also benefit from some of the other (non palette related) improvements (e.g. bug #1032859 should be fixed even in 8 bit mode).
Japanese font drawing hasn’t been improved much yet. This will be a separate task.
svn-id: r52966
2010-10-01 19:24:52 +00:00
|
|
|
}
|
2006-06-21 11:33:04 +00:00
|
|
|
}
|
2011-04-17 15:30:44 +00:00
|
|
|
src += pitch - (pitch + dx * format.bytesPerPixel);
|
|
|
|
dst += pitch - (pitch + dx * format.bytesPerPixel);
|
2006-06-21 11:33:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-07-14 04:03:04 +00:00
|
|
|
void Surface::convertToInPlace(const PixelFormat &dstFormat, const byte *palette) {
|
|
|
|
// Do not convert to the same format and ignore empty surfaces.
|
|
|
|
if (format == dstFormat || pixels == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (format.bytesPerPixel == 0 || format.bytesPerPixel > 4)
|
|
|
|
error("Surface::convertToInPlace(): Can only convert from 1Bpp, 2Bpp, 3Bpp, and 4Bpp");
|
|
|
|
|
|
|
|
if (dstFormat.bytesPerPixel != 2 && dstFormat.bytesPerPixel != 4)
|
|
|
|
error("Surface::convertToInPlace(): Can only convert to 2Bpp and 4Bpp");
|
|
|
|
|
|
|
|
// In case the surface data needs more space allocate it.
|
|
|
|
if (dstFormat.bytesPerPixel > format.bytesPerPixel) {
|
|
|
|
void *const newPixels = realloc(pixels, w * h * dstFormat.bytesPerPixel);
|
|
|
|
if (!newPixels) {
|
|
|
|
error("Surface::convertToInPlace(): Out of memory");
|
|
|
|
}
|
|
|
|
pixels = newPixels;
|
|
|
|
}
|
|
|
|
|
|
|
|
// We take advantage of the fact that pitch is always w * format.bytesPerPixel.
|
|
|
|
// This is assured by the logic of Surface::create.
|
|
|
|
|
|
|
|
// We need to handle 1 Bpp surfaces special here.
|
|
|
|
if (format.bytesPerPixel == 1) {
|
|
|
|
assert(palette);
|
|
|
|
|
|
|
|
for (int y = h; y > 0; --y) {
|
|
|
|
const byte *srcRow = (const byte *)pixels + y * pitch - 1;
|
|
|
|
byte *dstRow = (byte *)pixels + y * w * dstFormat.bytesPerPixel - dstFormat.bytesPerPixel;
|
|
|
|
|
|
|
|
for (int x = 0; x < w; x++) {
|
|
|
|
byte index = *srcRow--;
|
|
|
|
byte r = palette[index * 3];
|
|
|
|
byte g = palette[index * 3 + 1];
|
|
|
|
byte b = palette[index * 3 + 2];
|
|
|
|
|
|
|
|
uint32 color = dstFormat.RGBToColor(r, g, b);
|
|
|
|
|
|
|
|
if (dstFormat.bytesPerPixel == 2)
|
|
|
|
*((uint16 *)dstRow) = color;
|
|
|
|
else
|
|
|
|
*((uint32 *)dstRow) = color;
|
|
|
|
|
|
|
|
dstRow -= dstFormat.bytesPerPixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
crossBlit((byte *)pixels, (const byte *)pixels, w * dstFormat.bytesPerPixel, pitch, w, h, dstFormat, format);
|
|
|
|
}
|
|
|
|
|
|
|
|
// In case the surface data got smaller, free up some memory.
|
|
|
|
if (dstFormat.bytesPerPixel < format.bytesPerPixel) {
|
|
|
|
void *const newPixels = realloc(pixels, w * h * dstFormat.bytesPerPixel);
|
|
|
|
if (!newPixels) {
|
|
|
|
error("Surface::convertToInPlace(): Freeing memory failed");
|
|
|
|
}
|
|
|
|
pixels = newPixels;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Update the surface specific data.
|
|
|
|
format = dstFormat;
|
|
|
|
pitch = w * dstFormat.bytesPerPixel;
|
|
|
|
}
|
|
|
|
|
2011-06-30 12:12:39 +00:00
|
|
|
Graphics::Surface *Surface::convertTo(const PixelFormat &dstFormat, const byte *palette) const {
|
|
|
|
assert(pixels);
|
|
|
|
|
|
|
|
Graphics::Surface *surface = new Graphics::Surface();
|
|
|
|
|
|
|
|
// If the target format is the same, just copy
|
|
|
|
if (format == dstFormat) {
|
|
|
|
surface->copyFrom(*this);
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
2012-03-08 03:00:22 +00:00
|
|
|
if (format.bytesPerPixel == 0 || format.bytesPerPixel > 4)
|
|
|
|
error("Surface::convertTo(): Can only convert from 1Bpp, 2Bpp, 3Bpp, and 4Bpp");
|
|
|
|
|
2011-06-30 12:12:39 +00:00
|
|
|
if (dstFormat.bytesPerPixel != 2 && dstFormat.bytesPerPixel != 4)
|
2012-03-08 03:00:22 +00:00
|
|
|
error("Surface::convertTo(): Can only convert to 2Bpp and 4Bpp");
|
2011-06-30 12:12:39 +00:00
|
|
|
|
|
|
|
surface->create(w, h, dstFormat);
|
|
|
|
|
|
|
|
if (format.bytesPerPixel == 1) {
|
|
|
|
// Converting from paletted to high color
|
|
|
|
assert(palette);
|
|
|
|
|
|
|
|
for (int y = 0; y < h; y++) {
|
2012-04-03 23:54:05 +00:00
|
|
|
const byte *srcRow = (const byte *)getBasePtr(0, y);
|
2011-06-30 12:12:39 +00:00
|
|
|
byte *dstRow = (byte *)surface->getBasePtr(0, y);
|
|
|
|
|
|
|
|
for (int x = 0; x < w; x++) {
|
|
|
|
byte index = *srcRow++;
|
|
|
|
byte r = palette[index * 3];
|
|
|
|
byte g = palette[index * 3 + 1];
|
|
|
|
byte b = palette[index * 3 + 2];
|
|
|
|
|
|
|
|
uint32 color = dstFormat.RGBToColor(r, g, b);
|
|
|
|
|
|
|
|
if (dstFormat.bytesPerPixel == 2)
|
|
|
|
*((uint16 *)dstRow) = color;
|
|
|
|
else
|
|
|
|
*((uint32 *)dstRow) = color;
|
|
|
|
|
|
|
|
dstRow += dstFormat.bytesPerPixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// Converting from high color to high color
|
|
|
|
for (int y = 0; y < h; y++) {
|
2012-04-03 23:54:05 +00:00
|
|
|
const byte *srcRow = (const byte *)getBasePtr(0, y);
|
2011-06-30 12:12:39 +00:00
|
|
|
byte *dstRow = (byte *)surface->getBasePtr(0, y);
|
|
|
|
|
|
|
|
for (int x = 0; x < w; x++) {
|
|
|
|
uint32 srcColor;
|
|
|
|
if (format.bytesPerPixel == 2)
|
2012-03-08 03:00:22 +00:00
|
|
|
srcColor = READ_UINT16(srcRow);
|
|
|
|
else if (format.bytesPerPixel == 3)
|
|
|
|
srcColor = READ_UINT24(srcRow);
|
2011-06-30 12:12:39 +00:00
|
|
|
else
|
2012-03-08 03:00:22 +00:00
|
|
|
srcColor = READ_UINT32(srcRow);
|
2011-06-30 12:12:39 +00:00
|
|
|
|
|
|
|
srcRow += format.bytesPerPixel;
|
|
|
|
|
|
|
|
// Convert that color to the new format
|
|
|
|
byte r, g, b, a;
|
|
|
|
format.colorToARGB(srcColor, a, r, g, b);
|
|
|
|
uint32 color = dstFormat.ARGBToColor(a, r, g, b);
|
|
|
|
|
|
|
|
if (dstFormat.bytesPerPixel == 2)
|
|
|
|
*((uint16 *)dstRow) = color;
|
|
|
|
else
|
|
|
|
*((uint32 *)dstRow) = color;
|
|
|
|
|
|
|
|
dstRow += dstFormat.bytesPerPixel;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return surface;
|
|
|
|
}
|
|
|
|
|
2016-06-14 18:29:50 +00:00
|
|
|
FloodFill::FloodFill(Graphics::Surface *surface, uint32 oldColor, uint32 fillColor, bool maskMode) {
|
2016-06-02 21:44:43 +00:00
|
|
|
_surface = surface;
|
|
|
|
_oldColor = oldColor;
|
|
|
|
_fillColor = fillColor;
|
|
|
|
_w = surface->w;
|
|
|
|
_h = surface->h;
|
|
|
|
|
2016-06-03 14:39:03 +00:00
|
|
|
_mask = nullptr;
|
2016-06-14 18:29:50 +00:00
|
|
|
_maskMode = maskMode;
|
2016-06-03 14:39:03 +00:00
|
|
|
|
2016-06-14 18:45:09 +00:00
|
|
|
if (_maskMode) {
|
|
|
|
_mask = new Graphics::Surface();
|
|
|
|
_mask->create(_w, _h, Graphics::PixelFormat::createFormatCLUT8()); // Uses calloc()
|
|
|
|
}
|
|
|
|
|
2016-06-02 21:44:43 +00:00
|
|
|
_visited = (byte *)calloc(_w * _h, 1);
|
|
|
|
}
|
|
|
|
|
|
|
|
FloodFill::~FloodFill() {
|
|
|
|
while(!_queue.empty()) {
|
|
|
|
Common::Point *p = _queue.front();
|
|
|
|
|
|
|
|
delete p;
|
|
|
|
_queue.pop_front();
|
|
|
|
}
|
|
|
|
|
|
|
|
free(_visited);
|
2016-06-03 14:39:03 +00:00
|
|
|
|
|
|
|
if (_mask)
|
|
|
|
delete _mask;
|
2016-06-02 21:44:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void FloodFill::addSeed(int x, int y) {
|
|
|
|
if (x >= 0 && x < _w && y >= 0 && y < _h) {
|
|
|
|
if (!_visited[y * _w + x]) {
|
|
|
|
_visited[y * _w + x] = 1;
|
2016-06-03 14:39:03 +00:00
|
|
|
void *src = _surface->getBasePtr(x, y);
|
|
|
|
void *dst;
|
2016-06-03 13:52:48 +00:00
|
|
|
bool changed = false;
|
2016-06-02 21:44:43 +00:00
|
|
|
|
2016-06-03 14:39:03 +00:00
|
|
|
if (_maskMode)
|
|
|
|
dst = _mask->getBasePtr(x, y);
|
|
|
|
else
|
|
|
|
dst = src;
|
|
|
|
|
2016-06-02 21:44:43 +00:00
|
|
|
if (_surface->format.bytesPerPixel == 1) {
|
2016-06-03 14:39:03 +00:00
|
|
|
if (*((byte *)src) == _oldColor) {
|
|
|
|
*((byte *)dst) = _maskMode ? 255 : _fillColor;
|
2016-06-03 13:52:48 +00:00
|
|
|
changed = true;
|
|
|
|
}
|
2016-06-02 21:44:43 +00:00
|
|
|
} else if (_surface->format.bytesPerPixel == 2) {
|
2016-06-03 14:39:03 +00:00
|
|
|
if (READ_UINT16(src) == _oldColor) {
|
|
|
|
if (!_maskMode)
|
|
|
|
WRITE_UINT16(src, _fillColor);
|
|
|
|
else
|
|
|
|
*((byte *)dst) = 255;
|
|
|
|
|
2016-06-03 13:52:48 +00:00
|
|
|
changed = true;
|
|
|
|
}
|
2016-06-02 21:44:43 +00:00
|
|
|
} else if (_surface->format.bytesPerPixel == 4) {
|
2016-06-03 14:39:03 +00:00
|
|
|
if (READ_UINT32(src) == _oldColor) {
|
|
|
|
if (!_maskMode)
|
|
|
|
WRITE_UINT32(src, _fillColor);
|
|
|
|
else
|
|
|
|
*((byte *)dst) = 255;
|
|
|
|
|
2016-06-03 13:52:48 +00:00
|
|
|
changed = true;
|
|
|
|
}
|
2016-06-02 21:44:43 +00:00
|
|
|
} else {
|
|
|
|
error("Unsupported bpp in FloodFill");
|
|
|
|
}
|
|
|
|
|
2016-06-03 13:52:48 +00:00
|
|
|
if (changed) {
|
|
|
|
Common::Point *pt = new Common::Point(x, y);
|
2016-06-02 21:44:43 +00:00
|
|
|
|
2016-06-03 13:52:48 +00:00
|
|
|
_queue.push_back(pt);
|
|
|
|
}
|
2016-06-02 21:44:43 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void FloodFill::fill() {
|
|
|
|
while (!_queue.empty()) {
|
|
|
|
Common::Point *p = _queue.front();
|
|
|
|
_queue.pop_front();
|
|
|
|
addSeed(p->x , p->y - 1);
|
|
|
|
addSeed(p->x - 1, p->y );
|
|
|
|
addSeed(p->x , p->y + 1);
|
|
|
|
addSeed(p->x + 1, p->y );
|
|
|
|
|
|
|
|
delete p;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-03 14:39:03 +00:00
|
|
|
void FloodFill::fillMask() {
|
|
|
|
_maskMode = true;
|
|
|
|
|
2016-06-14 18:45:09 +00:00
|
|
|
if (!_mask) {
|
|
|
|
_mask = new Graphics::Surface();
|
|
|
|
_mask->create(_w, _h, Graphics::PixelFormat::createFormatCLUT8()); // Uses calloc()
|
|
|
|
}
|
|
|
|
|
2016-06-03 14:39:03 +00:00
|
|
|
fill();
|
|
|
|
}
|
|
|
|
|
2004-11-25 23:33:21 +00:00
|
|
|
} // End of namespace Graphics
|