(svn r26969) -Fix (r26869): black palette didn't work very well with unmasked 32bpp sprites

This commit is contained in:
rubidium
2014-10-06 18:45:51 +00:00
parent 485f60bb9f
commit eabb35a874
9 changed files with 82 additions and 3 deletions

View File

@@ -175,6 +175,16 @@ inline void Blitter_32bppAnim::Draw(const Blitter::BlitterParams *bp, ZoomLevel
}
break;
case BM_BLACK_REMAP:
do {
*dst++ = Colour(0, 0, 0);
*anim++ = 0;
anim++;
dst++;
} while (--n != 0);
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:
@@ -251,6 +261,7 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP> (bp, zoom); return;
}
}

View File

@@ -334,6 +334,19 @@ bmcr_alpha_blend_single:
anim++;
}
break;
case BM_BLACK_REMAP:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src->a != 0) {
*dst = Colour(0, 0, 0);
*anim = 0;
}
src_mv++;
dst++;
src++;
anim++;
}
break;
}
next_line:
@@ -395,6 +408,7 @@ bm_normal:
break;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP, RM_NONE, BT_NONE, true, true>(bp, zoom); return;
}
}

View File

@@ -177,6 +177,15 @@ inline void Blitter_32bppOptimized::Draw(const Blitter::BlitterParams *bp, ZoomL
}
break;
case BM_BLACK_REMAP:
do {
*dst = Colour(0, 0, 0);
dst++;
src_px++;
src_n++;
} while (--n != 0);
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:
@@ -241,6 +250,7 @@ void Blitter_32bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode,
case BM_COLOUR_REMAP: Draw<BM_COLOUR_REMAP>(bp, zoom); return;
case BM_TRANSPARENT: Draw<BM_TRANSPARENT> (bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP> (bp, zoom); return;
case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP> (bp, zoom); return;
}
}

View File

@@ -58,6 +58,12 @@ void Blitter_32bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoo
}
break;
case BM_BLACK_REMAP:
if (src->a != 0) {
*dst = Colour(0, 0, 0);
}
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:

View File

@@ -394,6 +394,17 @@ bmcr_alpha_blend_single:
src++;
}
break;
case BM_BLACK_REMAP:
for (uint x = (uint) bp->width; x > 0; x--) {
if (src->a != 0) {
*dst = Colour(0, 0, 0);
}
src_mv++;
dst++;
src++;
}
break;
}
next_line:
@@ -447,6 +458,7 @@ bm_normal:
}
case BM_TRANSPARENT: Draw<BM_TRANSPARENT, RM_NONE, BT_NONE, true>(bp, zoom); return;
case BM_CRASH_REMAP: Draw<BM_CRASH_REMAP, RM_NONE, BT_NONE, true>(bp, zoom); return;
case BM_BLACK_REMAP: Draw<BM_BLACK_REMAP, RM_NONE, BT_NONE, true>(bp, zoom); return;
}
}
#endif /* FULL_ANIMATION */

View File

@@ -13,6 +13,7 @@
#include "../zoom_func.h"
#include "../settings_type.h"
#include "../core/math_func.hpp"
#include "../core/mem_func.hpp"
#include "8bpp_optimized.hpp"
#include "../safeguards.h"
@@ -96,6 +97,11 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
break;
}
case BM_BLACK_REMAP:
MemSetT(dst, 0, pixels);
dst += pixels;
break;
case BM_TRANSPARENT: {
const uint8 *remap = bp->remap;
src += pixels;
@@ -107,7 +113,7 @@ void Blitter_8bppOptimized::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Z
}
default:
memcpy(dst, src, pixels);
MemCpyT(dst, src, pixels);
dst += pixels; src += pixels;
break;
}

View File

@@ -47,6 +47,10 @@ void Blitter_8bppSimple::Draw(Blitter::BlitterParams *bp, BlitterMode mode, Zoom
if (*src != 0) colour = bp->remap[*dst];
break;
case BM_BLACK_REMAP:
colour = 0;
break;
default:
colour = *src;
break;

View File

@@ -21,6 +21,7 @@ enum BlitterMode {
BM_COLOUR_REMAP, ///< Perform a colour remapping.
BM_TRANSPARENT, ///< Perform transparency colour remapping.
BM_CRASH_REMAP, ///< Perform a crash remapping.
BM_BLACK_REMAP, ///< Perform remapping to a completely blackened sprite
};
/**