src/blitter/32bpp_anim.cpp
branchnoai
changeset 9703 d2a6acdbd665
parent 9631 8a2d1c2ceb88
child 9723 eee46cb39750
--- a/src/blitter/32bpp_anim.cpp	Sun Sep 09 21:14:29 2007 +0000
+++ b/src/blitter/32bpp_anim.cpp	Sun Sep 23 07:37:38 2007 +0000
@@ -10,6 +10,12 @@
 
 void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 {
+	if (bp->dst < _screen.dst_ptr || bp->dst > (uint32 *)_screen.dst_ptr + _screen.width * _screen.height) {
+		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
+		Blitter_32bppOptimized::Draw(bp, mode, zoom);
+		return;
+	}
+
 	const SpriteLoader::CommonPixel *src, *src_line;
 	uint32 *dst, *dst_line;
 	uint8 *anim, *anim_line;
@@ -38,11 +44,22 @@
 		anim_line += this->anim_buf_width;
 
 		for (int x = 0; x < bp->width; x++) {
+			if (src->a == 0) {
+				/* src->r is 'misused' here to indicate how much more pixels are following with an alpha of 0 */
+				int skip = UnScaleByZoom(src->r, zoom);
+
+				dst  += skip;
+				anim += skip;
+				x    += skip - 1;
+				src  += ScaleByZoom(1, zoom) * skip;
+				continue;
+			}
+
 			switch (mode) {
 				case BM_COLOUR_REMAP:
 					/* In case the m-channel is zero, do not remap this pixel in any way */
 					if (src->m == 0) {
-						if (src->a != 0) *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
+						*dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
 						*anim = 0;
 					} else {
 						if (bp->remap[src->m] != 0) {
@@ -58,19 +75,15 @@
 					 *  we produce a result the newgrf maker didn't expect ;) */
 
 					/* Make the current color a bit more black, so it looks like this image is transparent */
-					if (src->a != 0) {
-						*dst = MakeTransparent(*dst, 75);
-						*anim = bp->remap[*anim];
-					}
+					*dst = MakeTransparent(*dst, 192);
+					*anim = bp->remap[*anim];
 					break;
 
 				default:
-					if (src->a != 0) {
-						/* Above 217 is palette animation */
-						if (src->m >= 217) *dst = ComposeColourPA(this->LookupColourInPalette(src->m), src->a, *dst);
-						else               *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
-						*anim = src->m;
-					}
+					/* Above 217 is palette animation */
+					if (src->m >= 217) *dst = ComposeColourPA(this->LookupColourInPalette(src->m), src->a, *dst);
+					else               *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
+					*anim = src->m;
 					break;
 			}
 			dst++;
@@ -90,7 +103,7 @@
 	if (pal == PALETTE_TO_TRANSPARENT) {
 		do {
 			for (int i = 0; i != width; i++) {
-				*udst = MakeTransparent(*udst, 60);
+				*udst = MakeTransparent(*udst, 154);
 				*anim = 0;
 				udst++;
 				anim++;