diff --git a/source.list b/source.list
index 7a500c3d97..83144a9b2b 100644
--- a/source.list
+++ b/source.list
@@ -906,8 +906,8 @@ script/api/script_window.cpp
#else
blitter/16bpp_base.cpp
blitter/16bpp_base.hpp
-# blitter/16bpp_anim.cpp
-# blitter/16bpp_anim.hpp
+blitter/16bpp_anim.cpp
+blitter/16bpp_anim.hpp
blitter/16bpp_simple.cpp
blitter/16bpp_simple.hpp
blitter/32bpp_anim.cpp
diff --git a/src/blitter/16bpp_anim.cpp b/src/blitter/16bpp_anim.cpp
new file mode 100644
index 0000000000..2b077ef475
--- /dev/null
+++ b/src/blitter/16bpp_anim.cpp
@@ -0,0 +1,386 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD 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, version 2.
+ * OpenTTD 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 OpenTTD. If not, see .
+ */
+
+/** @file 16bpp_anim.cpp Implementation of the optimized 32 bpp blitter with animation support. */
+
+#include "../stdafx.h"
+#include "../video/video_driver.hpp"
+#include "../zoom_func.h"
+#include "16bpp_anim.hpp"
+
+#include "../table/sprites.h"
+
+/** Instantiation of the 16bpp with animation blitter factory. */
+static FBlitter_16bppAnim iFBlitter_16bppAnim;
+
+template
+void Blitter_16bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
+{
+ const Pixel *src, *src_line;
+ Colour16 *dst, *dst_line;
+ Anim *anim, *anim_line;
+
+ /* Find where to start reading in the source sprite */
+ src_line = (const Pixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
+ dst_line = (Colour16 *)bp->dst + bp->top * bp->pitch + bp->left;
+ anim_line = this->anim_buf + ((Colour16 *)bp->dst - (Colour16 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
+
+ for (int y = 0; y < bp->height; y++) {
+ dst = dst_line;
+ dst_line += bp->pitch;
+
+ src = src_line;
+ src_line += bp->sprite_width * ScaleByZoom(1, zoom);
+
+ anim = anim_line;
+ anim_line += this->anim_buf_width;
+
+ for (int x = 0; x < bp->width; x++) {
+ switch (mode) {
+ case BM_COLOUR_REMAP:
+ /* In case the m-channel is zero, do not remap this pixel in any way */
+ anim->m = 0;
+ anim->v = 0;
+ if (src->m == 0) {
+ if (src->a != 0) *dst = ComposeColourPA(src->c, src->a, *dst);
+ } else {
+ uint8 r = bp->remap[src->m];
+ if (r != 0) {
+ *dst = ComposeColourPA(AdjustBrightness(LookupColourInPalette(r), src->v), src->a, *dst);
+ if (src->a == 15 && r >= PALETTE_ANIM_START) {
+ anim->m = r - PALETTE_ANIM_START + 1;
+ anim->v = src->v >> 1;
+ }
+ }
+ }
+ break;
+
+ case BM_TRANSPARENT:
+ /* TODO -- We make an assumption here that the remap in fact is transparency, not some colour.
+ * This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
+ * we produce a result the newgrf maker didn't expect ;) */
+
+ /* Make the current colour a bit more black, so it looks like this image is transparent */
+ if (src->a != 0) *dst = MakeTransparent(*dst, 192);
+ anim->m = 0;
+ anim->v = 0;
+ break;
+
+ default:
+ if (src->a == 15 && src->m >= PALETTE_ANIM_START) {
+ *dst = AdjustBrightness(LookupColourInPalette(src->m), src->v);
+ anim->m = src->m - PALETTE_ANIM_START + 1;
+ anim->v = src->v >> 1;
+ } else {
+ if (src->a != 0) {
+ if (src->m >= PALETTE_ANIM_START) {
+ *dst = ComposeColourPANoCheck(AdjustBrightness(LookupColourInPalette(src->m), src->v), src->a, *dst);
+ } else {
+ *dst = ComposeColourPA(src->c, src->a, *dst);
+ }
+ }
+ anim->m = 0;
+ anim->v = 0;
+ }
+ break;
+ }
+ dst++;
+ src += ScaleByZoom(1, zoom);
+ }
+ }
+}
+
+void Blitter_16bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
+{
+ if (_screen_disable_anim) {
+ /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
+ Blitter_16bppOptimized::Draw(bp, mode, zoom);
+ return;
+ }
+
+ switch (mode) {
+ default: NOT_REACHED();
+ case BM_NORMAL: Draw (bp, zoom); return;
+ case BM_COLOUR_REMAP: Draw(bp, zoom); return;
+ case BM_TRANSPARENT: Draw (bp, zoom); return;
+ }
+}
+
+void Blitter_16bppAnim::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
+{
+ if (_screen_disable_anim) {
+ /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColourMappingRect() */
+ Blitter_16bppOptimized::DrawColourMappingRect(dst, width, height, pal);
+ return;
+ }
+
+ Colour16 *udst = (Colour16 *)dst;
+ Anim *anim;
+
+ anim = this->anim_buf + ((Colour16 *)dst - (Colour16 *)_screen.dst_ptr);
+
+ if (pal == PALETTE_TO_TRANSPARENT) {
+ do {
+ for (int i = 0; i != width; i++) {
+ *udst = MakeTransparent(*udst, 154);
+ anim->m = 0;
+ anim->v = 0;
+ udst++;
+ anim++;
+ }
+ udst = udst - width + _screen.pitch;
+ anim = anim - width + this->anim_buf_width;
+ } while (--height);
+ return;
+ }
+ if (pal == PALETTE_NEWSPAPER) {
+ do {
+ for (int i = 0; i != width; i++) {
+ *udst = MakeGrey(*udst);
+ anim->m = 0;
+ anim->v = 0;
+ udst++;
+ anim++;
+ }
+ udst = udst - width + _screen.pitch;
+ anim = anim - width + this->anim_buf_width;
+ } while (--height);
+ return;
+ }
+
+ DEBUG(misc, 0, "16bpp blitter doesn't know how to draw this colour table ('%d')", pal);
+}
+
+void Blitter_16bppAnim::SetPixel(void *video, int x, int y, uint8 colour)
+{
+ *((Colour16 *)video + x + y * _screen.pitch) = LookupColourInPalette(colour);
+
+ /* Set the colour in the anim-buffer too, if we are rendering to the screen */
+ if (_screen_disable_anim) return;
+ Anim *anim = this->anim_buf + ((Colour16 *)video - (Colour16 *)_screen.dst_ptr) + x + y * this->anim_buf_width;
+ if (colour >= PALETTE_ANIM_START) {
+ anim->m = colour - PALETTE_ANIM_START + 1;
+ anim->v = DEFAULT_BRIGHTNESS >> 1;
+ } else {
+ anim->m = 0;
+ anim->v = 0;
+ }
+}
+
+void Blitter_16bppAnim::DrawRect(void *video, int width, int height, uint8 colour)
+{
+ if (_screen_disable_anim) {
+ /* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
+ Blitter_16bppOptimized::DrawRect(video, width, height, colour);
+ return;
+ }
+
+ Colour16 colour16 = LookupColourInPalette(colour);
+ Anim *anim_line = this->anim_buf + ((Colour16 *)video - (Colour16 *)_screen.dst_ptr);
+
+ do {
+ Colour16 *dst = (Colour16 *)video;
+ Anim *anim = anim_line;
+
+ for (int i = width; i > 0; i--) {
+ *dst = colour16;
+ /* Set the colour in the anim-buffer too */
+ if (colour >= PALETTE_ANIM_START) {
+ anim->m = colour - PALETTE_ANIM_START + 1;
+ anim->v = DEFAULT_BRIGHTNESS >> 1;
+ } else {
+ anim->m = 0;
+ anim->v = 0;
+ }
+ dst++;
+ anim++;
+ }
+ video = (Colour16 *)video + _screen.pitch;
+ anim_line += this->anim_buf_width;
+ } while (--height);
+}
+
+void Blitter_16bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
+{
+ assert(!_screen_disable_anim);
+ assert(video >= _screen.dst_ptr && video <= (Colour16 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
+ Colour16 *dst = (Colour16 *)video;
+ const uint8 *usrc = (const uint8 *)src;
+ Anim *anim_line = this->anim_buf + ((Colour16 *)video - (Colour16 *)_screen.dst_ptr);
+
+ for (; height > 0; height--) {
+ /* We need to keep those for palette animation. */
+ Colour16 *dst_pal = dst;
+ Anim *anim_pal = anim_line;
+
+ memcpy(dst, usrc, width * sizeof(Colour16));
+ usrc += width * sizeof(Colour16);
+ dst += _screen.pitch;
+ /* Copy back the anim-buffer */
+ memcpy(anim_line, usrc, width * sizeof(Anim));
+ usrc += width * sizeof(Anim);
+ anim_line += this->anim_buf_width;
+
+ /* Okay, it is *very* likely that the image we stored is using
+ * the wrong palette animated colours. There are two things we
+ * can do to fix this. The first is simply reviewing the whole
+ * screen after we copied the buffer, i.e. run PaletteAnimate,
+ * however that forces a full screen redraw which is expensive
+ * for just the cursor. This just copies the implementation of
+ * palette animation, much cheaper though slightly nastier. */
+ for (int i = 0; i < width; i++) {
+ uint8 colour = anim_pal->m;
+ if (colour) {
+ /* Update this pixel */
+ *dst_pal = AdjustBrightness(LookupColourInPalette(colour + PALETTE_ANIM_START - 1), anim_pal->v << 1);
+ }
+ dst_pal++;
+ anim_pal++;
+ }
+ }
+}
+
+void Blitter_16bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
+{
+ assert(!_screen_disable_anim);
+ assert(video >= _screen.dst_ptr && video <= (Colour16 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
+ uint8 *udst = (uint8 *)dst;
+ const Colour16 *src = (const Colour16 *)video;
+ const Anim *anim_line = this->anim_buf + ((const Colour16 *)video - (Colour16 *)_screen.dst_ptr);
+
+ for (; height > 0; height--) {
+ memcpy(udst, src, width * sizeof(Colour16));
+ src += _screen.pitch;
+ udst += width * sizeof(Colour16);
+ /* Copy the anim-buffer */
+ memcpy(udst, anim_line, width * sizeof(Anim));
+ udst += width * sizeof(Anim);
+ anim_line += this->anim_buf_width;
+ }
+}
+
+void Blitter_16bppAnim::ScrollBuffer(void *video, int &left_ref, int &top_ref, int &width_ref, int &height_ref, int scroll_x, int scroll_y)
+{
+ assert(!_screen_disable_anim);
+ assert(video >= _screen.dst_ptr && video <= (Colour16 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
+ const Anim *src;
+ Anim *dst;
+ int left = left_ref, top = top_ref, width = width_ref, height = height_ref;
+
+ /* We need to scroll the anim-buffer too */
+ if (scroll_y > 0) {
+ /* Calculate pointers */
+ dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_width;
+ src = dst - scroll_y * this->anim_buf_width;
+
+ /* Decrease height and increase top */
+ top += scroll_y;
+ height -= scroll_y;
+ assert(height > 0);
+
+ /* Adjust left & width */
+ if (scroll_x >= 0) {
+ dst += scroll_x;
+ left += scroll_x;
+ width -= scroll_x;
+ } else {
+ src -= scroll_x;
+ width += scroll_x;
+ }
+
+ for (int h = height; h > 0; h--) {
+ memcpy(dst, src, width * sizeof(Anim));
+ src -= this->anim_buf_width;
+ dst -= this->anim_buf_width;
+ }
+ } else {
+ /* Calculate pointers */
+ dst = this->anim_buf + left + top * this->anim_buf_width;
+ src = dst - scroll_y * this->anim_buf_width;
+
+ /* Decrease height. (scroll_y is <=0). */
+ height += scroll_y;
+ assert(height > 0);
+
+ /* Adjust left & width */
+ if (scroll_x >= 0) {
+ dst += scroll_x;
+ left += scroll_x;
+ width -= scroll_x;
+ } else {
+ src -= scroll_x;
+ width += scroll_x;
+ }
+
+ /* the y-displacement may be 0 therefore we have to use memmove,
+ * because source and destination may overlap */
+ for (int h = height; h > 0; h--) {
+ memmove(dst, src, width * sizeof(Anim));
+ src += _screen.pitch;
+ dst += _screen.pitch;
+ }
+ }
+
+ Blitter_16bppOptimized::ScrollBuffer(video, left_ref, top_ref, width_ref, height_ref, scroll_x, scroll_y);
+}
+
+int Blitter_16bppAnim::BufferSize(int width, int height)
+{
+ return width * height * (sizeof(Anim) + sizeof(Colour16));
+}
+
+void Blitter_16bppAnim::PaletteAnimate(const Palette &palette)
+{
+ assert(!_screen_disable_anim);
+
+ /* If first_dirty is 0, it is for 8bpp indication to send the new
+ * palette. However, only the animation colours might possibly change.
+ * Especially when going between toyland and non-toyland. */
+ assert(palette.first_dirty == PALETTE_ANIM_START || palette.first_dirty == 0);
+
+ for (int i = 0; i < 256; i++) {
+ this->palette[i] = To16(palette.palette[i]);
+ }
+
+ const Anim *anim = this->anim_buf;
+ Colour16 *dst = (Colour16 *)_screen.dst_ptr;
+
+ /* Let's walk the anim buffer and try to find the pixels */
+ for (int y = this->anim_buf_height; y != 0 ; y--) {
+ for (int x = this->anim_buf_width; x != 0 ; x--) {
+ uint8 colour = anim->m;
+ if (colour) {
+ /* Update this pixel */
+ *dst = AdjustBrightness(LookupColourInPalette(colour + PALETTE_ANIM_START - 1), anim->v << 1);
+ }
+ dst++;
+ anim++;
+ }
+ dst += _screen.pitch - this->anim_buf_width;
+ }
+
+ /* Make sure the backend redraws the whole screen */
+ _video_driver->MakeDirty(0, 0, _screen.width, _screen.height);
+}
+
+Blitter::PaletteAnimation Blitter_16bppAnim::UsePaletteAnimation()
+{
+ return Blitter::PALETTE_ANIMATION_BLITTER;
+}
+
+void Blitter_16bppAnim::PostResize()
+{
+ if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
+ /* The size of the screen changed; we can assume we can wipe all data from our buffer */
+ free(this->anim_buf);
+ this->anim_buf = CallocT(_screen.width * _screen.height);
+ this->anim_buf_width = _screen.width;
+ this->anim_buf_height = _screen.height;
+ }
+}
diff --git a/src/blitter/16bpp_anim.hpp b/src/blitter/16bpp_anim.hpp
new file mode 100644
index 0000000000..80bf6e5df5
--- /dev/null
+++ b/src/blitter/16bpp_anim.hpp
@@ -0,0 +1,75 @@
+/* $Id$ */
+
+/*
+ * This file is part of OpenTTD.
+ * OpenTTD 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, version 2.
+ * OpenTTD 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 OpenTTD. If not, see .
+ */
+
+/** @file 16bpp_anim.hpp A 16 bpp blitter with animation support. */
+
+#ifndef BLITTER_16BPP_ANIM_HPP
+#define BLITTER_16BPP_ANIM_HPP
+
+#include "16bpp_simple.hpp"
+
+class Blitter_16bppOptimized: public Blitter_16bppSimple {
+ // TODO: implement that
+};
+
+/** The optimised 16 bpp blitter with palette animation. */
+class Blitter_16bppAnim : public Blitter_16bppOptimized {
+protected:
+ // PALETTE_ANIM_SIZE is less than 32, so we'll use 5 bits for color index, and 3 bits for brightness, losing 1 bit compared to struct Pixel
+ struct Anim {
+ unsigned m : 5 __attribute__((packed)); ///< Color index channel, packed 5 bits, 0 = no animation, 1 = PALETTE_ANIM_START
+ unsigned v : 3 __attribute__((packed)); ///< Brightness-channel, packed 3 bits
+ };
+
+ Anim *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
+ int anim_buf_width; ///< The width of the animation buffer.
+ int anim_buf_height; ///< The height of the animation buffer.
+ Colour16 palette[256]; ///< The current palette.
+
+public:
+ Blitter_16bppAnim() :
+ anim_buf(NULL),
+ anim_buf_width(0),
+ anim_buf_height(0)
+ {}
+
+ /* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
+ /* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
+ /* virtual */ void SetPixel(void *video, int x, int y, uint8 colour);
+ /* virtual */ void DrawRect(void *video, int width, int height, uint8 colour);
+ /* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
+ /* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
+ /* virtual */ void ScrollBuffer(void *video, int &left_ref, int &top_ref, int &width_ref, int &height_ref, int scroll_x, int scroll_y);
+ /* virtual */ int BufferSize(int width, int height);
+ /* virtual */ void PaletteAnimate(const Palette &palette);
+ /* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
+ /* virtual */ int GetBytesPerPixel() { return 3; }
+
+ /* virtual */ const char *GetName() { return "16bpp-anim"; }
+ /* virtual */ void PostResize();
+
+ /**
+ * Look up the colour in the current palette.
+ */
+ inline Colour16 LookupColourInPalette(uint8 index)
+ {
+ return this->palette[index];
+ }
+
+ template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
+};
+
+/** Factory for the 16bpp blitter with animation. */
+class FBlitter_16bppAnim : public BlitterFactory {
+public:
+ FBlitter_16bppAnim() : BlitterFactory("16bpp-anim-broken", "16bpp Animation Blitter, currently broken (palette animation)") {}
+ /* virtual */ Blitter *CreateInstance() { return new Blitter_16bppAnim(); }
+};
+
+#endif /* BLITTER_16BPP_ANIM_HPP */
diff --git a/src/blitter/16bpp_base.cpp b/src/blitter/16bpp_base.cpp
index 69424fad4d..9161ce92c4 100644
--- a/src/blitter/16bpp_base.cpp
+++ b/src/blitter/16bpp_base.cpp
@@ -74,12 +74,12 @@ void Blitter_16bppBase::CopyImageToBuffer(const void *video, void *dst, int widt
void Blitter_16bppBase::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
{
- const uint16 *src;
- uint16 *dst;
+ const Colour16 *src;
+ Colour16 *dst;
if (scroll_y > 0) {
/* Calculate pointers */
- dst = (uint16 *)video + left + (top + height - 1) * _screen.pitch;
+ dst = (Colour16 *)video + left + (top + height - 1) * _screen.pitch;
src = dst - scroll_y * _screen.pitch;
/* Decrease height and increase top */
@@ -98,13 +98,13 @@ void Blitter_16bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt
}
for (int h = height; h > 0; h--) {
- memcpy(dst, src, width * sizeof(uint16));
+ memcpy(dst, src, width * sizeof(Colour16));
src -= _screen.pitch;
dst -= _screen.pitch;
}
} else {
/* Calculate pointers */
- dst = (uint16 *)video + left + top * _screen.pitch;
+ dst = (Colour16 *)video + left + top * _screen.pitch;
src = dst - scroll_y * _screen.pitch;
/* Decrease height. (scroll_y is <=0). */
@@ -124,7 +124,7 @@ void Blitter_16bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt
/* the y-displacement may be 0 therefore we have to use memmove,
* because source and destination may overlap */
for (int h = height; h > 0; h--) {
- memmove(dst, src, width * sizeof(uint16));
+ memmove(dst, src, width * sizeof(Colour16));
src += _screen.pitch;
dst += _screen.pitch;
}
@@ -133,7 +133,7 @@ void Blitter_16bppBase::ScrollBuffer(void *video, int &left, int &top, int &widt
int Blitter_16bppBase::BufferSize(int width, int height)
{
- return width * height * sizeof(uint16);
+ return width * height * sizeof(Colour16);
}
void Blitter_16bppBase::PaletteAnimate(const Palette &palette)
diff --git a/src/blitter/16bpp_base.hpp b/src/blitter/16bpp_base.hpp
index e5425d809f..e7a5b5e7a9 100644
--- a/src/blitter/16bpp_base.hpp
+++ b/src/blitter/16bpp_base.hpp
@@ -26,7 +26,7 @@ public:
unsigned b : 5 __attribute__((packed)); ///< Blue-channel, packed 5 bits
unsigned g : 6 __attribute__((packed)); ///< Green-channel, packed 6 bits
unsigned r : 5 __attribute__((packed)); ///< Red-channel, packed 5 bits
- Colour16(uint8 r, uint8 g, uint8 b):
+ Colour16(uint8 r = 0, uint8 g = 0, uint8 b = 0):
b(b), g(g), r(r)
{
}
diff --git a/src/blitter/16bpp_simple.cpp b/src/blitter/16bpp_simple.cpp
index a3e1f4d0ed..36f90f17b6 100644
--- a/src/blitter/16bpp_simple.cpp
+++ b/src/blitter/16bpp_simple.cpp
@@ -12,16 +12,14 @@
#include "../stdafx.h"
#include "../zoom_func.h"
#include "16bpp_simple.hpp"
-#include "32bpp_base.hpp"
#include "../table/sprites.h"
-#include
-
/** Instantiation of the simple 16bpp blitter factory. */
static FBlitter_16bppSimple iFBlitter_16bppSimple;
-void Blitter_16bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
+template
+void Blitter_16bppSimple::Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom)
{
const Pixel *src, *src_line;
Colour16 *dst, *dst_line;
@@ -44,7 +42,7 @@ void Blitter_16bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
if (src->m == 0) {
if (src->a != 0) *dst = ComposeColourPA(src->c, src->a, *dst);
} else {
- if (bp->remap[src->m] != 0) *dst = ComposeColourPA(this->AdjustBrightness(this->LookupColourInPalette(bp->remap[src->m]), src->v), src->a, *dst);
+ if (bp->remap[src->m] != 0) *dst = ComposeColourPA(AdjustBrightness(LookupColourInPalette(bp->remap[src->m]), src->v), src->a, *dst);
}
break;
@@ -67,6 +65,16 @@ void Blitter_16bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
}
}
+void Blitter_16bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
+{
+ switch (mode) {
+ default: NOT_REACHED();
+ case BM_NORMAL: Draw (bp, zoom); return;
+ case BM_COLOUR_REMAP: Draw(bp, zoom); return;
+ case BM_TRANSPARENT: Draw (bp, zoom); return;
+ }
+}
+
void Blitter_16bppSimple::DrawColourMappingRect(void *dst, int width, int height, PaletteID pal)
{
Colour16 *udst = (Colour16 *)dst;
@@ -122,18 +130,18 @@ Sprite *Blitter_16bppSimple::Encode(const SpriteLoader::Sprite *sprite, Allocato
use 32bpp AdjustBrightness() variant for better colors,
because this function is not called each frame */
if (rgb_max == 0) rgb_max = Blitter_32bppBase::DEFAULT_BRIGHTNESS;
- dst[i].c = To16(Blitter_32bppBase::AdjustBrightness(this->LookupColourInPalette32(src->m), rgb_max));
+ dst[i].c = To16(Blitter_32bppBase::AdjustBrightness(LookupColourInPalette32(src->m), rgb_max));
dst[i].v = rgb_max / 16;
#endif
rgb_max /= 16;
- /* Black pixel (8bpp or old 16bpp image), so use default value */
+ /* Black pixel (8bpp or old 32bpp image), so use default value */
if (rgb_max == 0) rgb_max = DEFAULT_BRIGHTNESS;
/* Pre-convert the mapping channel to a RGB value,
use 32bpp AdjustBrightness() variant for better colors,
because this function is not called each frame */
- dst[i].c = AdjustBrightness(this->LookupColourInPalette(src->m), rgb_max);
+ dst[i].c = AdjustBrightness(LookupColourInPalette(src->m), rgb_max);
dst[i].v = rgb_max;
dst[i].a = src->a / 16;
diff --git a/src/blitter/16bpp_simple.hpp b/src/blitter/16bpp_simple.hpp
index e708ce9a93..9feb934062 100644
--- a/src/blitter/16bpp_simple.hpp
+++ b/src/blitter/16bpp_simple.hpp
@@ -21,6 +21,7 @@ public:
/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
/* virtual */ void DrawColourMappingRect(void *dst, int width, int height, PaletteID pal);
/* virtual */ Sprite *Encode(const SpriteLoader::Sprite *sprite, AllocatorProc *allocator);
+ template void Draw(const Blitter::BlitterParams *bp, ZoomLevel zoom);
/* virtual */ const char *GetName() { return "16bpp-simple"; }
};
@@ -32,4 +33,4 @@ public:
/* virtual */ Blitter *CreateInstance() { return new Blitter_16bppSimple(); }
};
-#endif /* BLITTER_32BPP_SIMPLE_HPP */
+#endif /* BLITTER_16BPP_SIMPLE_HPP */