diff --git a/src/blitter/40bpp_anim.cpp b/src/blitter/40bpp_anim.cpp --- a/src/blitter/40bpp_anim.cpp +++ b/src/blitter/40bpp_anim.cpp @@ -11,6 +11,7 @@ #include "../zoom_func.h" #include "../settings_type.h" #include "../video/video_driver.hpp" +#include "../palette_func.h" #include "40bpp_anim.hpp" #include "common.hpp" @@ -234,10 +235,6 @@ inline void Blitter_40bppAnim::Draw(cons 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 */ src_n += n; if (src_px->a == 255) { @@ -263,6 +260,28 @@ inline void Blitter_40bppAnim::Draw(cons } break; + case BM_TRANSPARENT_REMAP: + /* Apply custom transparency remap. */ + src_n += n; + if (src_px->a != 0) { + src_px += n; + do { + if (*anim != 0) { + *anim = bp->remap[*anim]; + } else { + *dst = this->LookupColourInPalette(bp->remap[GetNearestColourIndex(*dst)]); + *anim = 0; + } + anim++; + dst++; + } while (--n != 0); + } else { + dst += n; + anim += n; + src_px += n; + } + break; + default: if (src_px->a == 255) { do { @@ -323,6 +342,7 @@ void Blitter_40bppAnim::Draw(Blitter::Bl case BM_NORMAL: Draw (bp, zoom); return; case BM_COLOUR_REMAP: Draw(bp, zoom); return; case BM_TRANSPARENT: Draw (bp, zoom); return; + case BM_TRANSPARENT_REMAP: Draw(bp, zoom); return; case BM_CRASH_REMAP: Draw (bp, zoom); return; case BM_BLACK_REMAP: Draw (bp, zoom); return; }