From ecc5d648dfefd7949b7508c724790dd452814fb2 Mon Sep 17 00:00:00 2001 From: frosch Date: Sat, 28 Jun 2008 15:44:24 +0000 Subject: (svn r13649) -Codechange: Split the GfxFillRect() special flags from 'color' into their own parameter. --- src/gfx.cpp | 39 +++++++++++++++++++++++++++++---------- 1 file changed, 29 insertions(+), 10 deletions(-) (limited to 'src/gfx.cpp') diff --git a/src/gfx.cpp b/src/gfx.cpp index b1e7517bf..2fca52bfe 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -89,7 +89,21 @@ void GfxScroll(int left, int top, int width, int height, int xo, int yo) } -void GfxFillRect(int left, int top, int right, int bottom, int color) +/** + * Applies a certain FillRectMode-operation to a rectangle [left, right] x [top, bottom] on the screen. + * + * @pre dpi->zoom == ZOOM_LVL_NORMAL, right >= left, bottom >= top + * @param left Minimum X (inclusive) + * @param top Minimum Y (inclusive) + * @param right Maximum X (inclusive) + * @param bottom Maximum Y (inclusive) + * @param color A 8 bit palette index (FILLRECT_OPAQUE and FILLRECT_CHECKER) or a recolor spritenumber (FILLRECT_RECOLOR) + * @param mode + * FILLRECT_OPAQUE: Fill the rectangle with the specified color + * FILLRECT_CHECKER: Like FILLRECT_OPAQUE, but only draw every second pixel (used to grey out things) + * FILLRECT_RECOLOR: Apply a recolor sprite to every pixel in the rectangle currently on screen + */ +void GfxFillRect(int left, int top, int right, int bottom, int color, FillRectMode mode) { Blitter *blitter = BlitterFactoryBase::GetCurrentBlitter(); const DrawPixelInfo *dpi = _cur_dpi; @@ -116,18 +130,23 @@ void GfxFillRect(int left, int top, int right, int bottom, int color) dst = blitter->MoveTo(dpi->dst_ptr, left, top); - if (!HasBit(color, PALETTE_MODIFIER_GREYOUT)) { - if (!HasBit(color, USE_COLORTABLE)) { + switch (mode) { + default: // FILLRECT_OPAQUE blitter->DrawRect(dst, right, bottom, (uint8)color); - } else { + break; + + case FILLRECT_RECOLOR: blitter->DrawColorMappingRect(dst, right, bottom, GB(color, 0, PALETTE_WIDTH)); + break; + + case FILLRECT_CHECKER: { + byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; + do { + for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)color); + dst = blitter->MoveTo(dst, 0, 1); + } while (--bottom > 0); + break; } - } else { - byte bo = (oleft - left + dpi->left + otop - top + dpi->top) & 1; - do { - for (int i = (bo ^= 1); i < right; i += 2) blitter->SetPixel(dst, i, 0, (uint8)color); - dst = blitter->MoveTo(dst, 0, 1); - } while (--bottom > 0); } } -- cgit v1.2.3-54-g00ecf