src/blitter/32bpp_anim.cpp
author rubidium
Sun, 25 May 2008 19:17:03 +0000
changeset 9354 845e07db4549
parent 9111 48ce04029fe4
child 9548 eae9545bf02c
permissions -rw-r--r--
(svn r13251) -Codechange: rename _patches to _settings as that is more logic.
-Codechange: move all Settings into substructs of _settings in a way that they are logically grouped.
8091
674be8638d74 (svn r11652) -Codechange: add the svn $ header for several files
smatz
parents: 7558
diff changeset
     1
/* $Id$ */
674be8638d74 (svn r11652) -Codechange: add the svn $ header for several files
smatz
parents: 7558
diff changeset
     2
9111
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8264
diff changeset
     3
/** @file 32bpp_anim.cpp Implementation of the optimized 32 bpp blitter with animation support. */
48ce04029fe4 (svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents: 8264
diff changeset
     4
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
     5
#include "../stdafx.h"
8130
d2eb7d04f6e1 (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8123
diff changeset
     6
#include "../core/alloc_func.hpp"
8123
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8091
diff changeset
     7
#include "../gfx_func.h"
ce31d2843a95 (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8091
diff changeset
     8
#include "../zoom_func.h"
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
     9
#include "../debug.h"
7170
923946ec324f (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7138
diff changeset
    10
#include "../video/video_driver.hpp"
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    11
#include "32bpp_anim.hpp"
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    12
8264
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8249
diff changeset
    13
#include "../table/sprites.h"
b1e85998c7d3 (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8249
diff changeset
    14
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    15
static FBlitter_32bppAnim iFBlitter_32bppAnim;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    16
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    17
void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    18
{
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
    19
	if (_screen_disable_anim) {
7556
7224575e68fb (svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
truelight
parents: 7555
diff changeset
    20
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
7224575e68fb (svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
truelight
parents: 7555
diff changeset
    21
		Blitter_32bppOptimized::Draw(bp, mode, zoom);
7224575e68fb (svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
truelight
parents: 7555
diff changeset
    22
		return;
7224575e68fb (svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
truelight
parents: 7555
diff changeset
    23
	}
7557
4b3f3b4c613e (svn r11082) -Fix r11081: save before commit (yeah, whitelines are important too!)
truelight
parents: 7556
diff changeset
    24
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    25
	const SpriteLoader::CommonPixel *src, *src_line;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    26
	uint32 *dst, *dst_line;
7556
7224575e68fb (svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
truelight
parents: 7555
diff changeset
    27
	uint8 *anim, *anim_line;
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    28
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    29
	if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    30
		/* The size of the screen changed; we can assume we can wipe all data from our buffer */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    31
		free(this->anim_buf);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    32
		this->anim_buf = CallocT<uint8>(_screen.width * _screen.height);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    33
		this->anim_buf_width = _screen.width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    34
		this->anim_buf_height = _screen.height;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    35
	}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    36
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    37
	/* Find where to start reading in the source sprite */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    38
	src_line = (const SpriteLoader::CommonPixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    39
	dst_line = (uint32 *)bp->dst + bp->top * bp->pitch + bp->left;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    40
	anim_line = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    41
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    42
	for (int y = 0; y < bp->height; y++) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    43
		dst = dst_line;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    44
		dst_line += bp->pitch;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    45
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    46
		src = src_line;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    47
		src_line += bp->sprite_width * ScaleByZoom(1, zoom);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    48
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    49
		anim = anim_line;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    50
		anim_line += this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    51
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    52
		for (int x = 0; x < bp->width; x++) {
7553
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    53
			if (src->a == 0) {
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    54
				/* src->r is 'misused' here to indicate how much more pixels are following with an alpha of 0 */
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    55
				int skip = UnScaleByZoom(src->r, zoom);
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    56
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    57
				dst  += skip;
7556
7224575e68fb (svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
truelight
parents: 7555
diff changeset
    58
				anim += skip;
7553
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    59
				x    += skip - 1;
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    60
				src  += ScaleByZoom(1, zoom) * skip;
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    61
				continue;
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    62
			}
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    63
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    64
			switch (mode) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    65
				case BM_COLOUR_REMAP:
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    66
					/* In case the m-channel is zero, do not remap this pixel in any way */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    67
					if (src->m == 0) {
7553
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    68
						*dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
7555
85e72f9c20cb (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 7554
diff changeset
    69
						*anim = 0;
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    70
					} else {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    71
						if (bp->remap[src->m] != 0) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    72
							*dst = ComposeColourPA(this->LookupColourInPalette(bp->remap[src->m]), src->a, *dst);
7555
85e72f9c20cb (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 7554
diff changeset
    73
							*anim = bp->remap[src->m];
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    74
						}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    75
					}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    76
					break;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    77
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    78
				case BM_TRANSPARENT:
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    79
					/* TODO -- We make an assumption here that the remap in fact is transparency, not some color.
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    80
					 *  This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    81
					 *  we produce a result the newgrf maker didn't expect ;) */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    82
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    83
					/* Make the current color a bit more black, so it looks like this image is transparent */
7553
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    84
					*dst = MakeTransparent(*dst, 192);
7555
85e72f9c20cb (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 7554
diff changeset
    85
					*anim = bp->remap[*anim];
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    86
					break;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    87
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    88
				default:
7553
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    89
					/* Above 217 is palette animation */
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    90
					if (src->m >= 217) *dst = ComposeColourPA(this->LookupColourInPalette(src->m), src->a, *dst);
63d4424de5d7 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 7552
diff changeset
    91
					else               *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
7555
85e72f9c20cb (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 7554
diff changeset
    92
					*anim = src->m;
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    93
					break;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    94
			}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    95
			dst++;
7556
7224575e68fb (svn r11081) -Fix r11080: now solved the problem in a pretty way: don't do animation if we are not drawing to the screen-pointer
truelight
parents: 7555
diff changeset
    96
			anim++;
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    97
			src += ScaleByZoom(1, zoom);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    98
		}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
    99
	}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   100
}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   101
6985
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   102
void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, int pal)
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   103
{
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   104
	if (_screen_disable_anim) {
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   105
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColorMappingRect() */
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   106
		Blitter_32bppOptimized::DrawColorMappingRect(dst, width, height, pal);
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   107
		return;
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   108
	}
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   109
6985
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   110
	uint32 *udst = (uint32 *)dst;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   111
	uint8 *anim;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   112
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   113
	anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   114
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   115
	if (pal == PALETTE_TO_TRANSPARENT) {
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   116
		do {
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   117
			for (int i = 0; i != width; i++) {
7552
56aa62dba204 (svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents: 7170
diff changeset
   118
				*udst = MakeTransparent(*udst, 154);
6985
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   119
				*anim = 0;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   120
				udst++;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   121
				anim++;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   122
			}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   123
			udst = udst - width + _screen.pitch;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   124
			anim = anim - width + this->anim_buf_width;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   125
		} while (--height);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   126
		return;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   127
	}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   128
	if (pal == PALETTE_TO_STRUCT_GREY) {
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   129
		do {
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   130
			for (int i = 0; i != width; i++) {
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   131
				*udst = MakeGrey(*udst);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   132
				*anim = 0;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   133
				udst++;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   134
				anim++;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   135
			}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   136
			udst = udst - width + _screen.pitch;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   137
			anim = anim - width + this->anim_buf_width;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   138
		} while (--height);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   139
		return;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   140
	}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   141
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   142
	DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this color table ('%d')", pal);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   143
}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   144
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   145
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 color)
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   146
{
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   147
	*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   148
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   149
	/* Set the color in the anim-buffer too, if we are rendering to the screen */
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   150
	if (_screen_disable_anim) return;
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   151
	this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   152
}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   153
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   154
void Blitter_32bppAnim::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   155
{
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   156
	uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   157
	if (*dst == 0) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   158
		*dst = LookupColourInPalette(color);
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   159
		/* Set the color in the anim-buffer too, if we are rendering to the screen */
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   160
		if (_screen_disable_anim) return;
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   161
		this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   162
	}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   163
}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   164
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   165
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color)
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   166
{
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   167
	if (_screen_disable_anim) {
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   168
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   169
		Blitter_32bppOptimized::DrawRect(video, width, height, color);
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   170
		return;
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   171
	}
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   172
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   173
	uint32 color32 = LookupColourInPalette(color);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   174
	uint8 *anim_line;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   175
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   176
	anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   177
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   178
	do {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   179
		uint32 *dst = (uint32 *)video;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   180
		uint8 *anim = anim_line;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   181
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   182
		for (int i = width; i > 0; i--) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   183
			*dst = color32;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   184
			/* Set the color in the anim-buffer too */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   185
			*anim = color;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   186
			dst++;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   187
			anim++;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   188
		}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   189
		video = (uint32 *)video + _screen.pitch;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   190
		anim_line += this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   191
	} while (--height);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   192
}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   193
6985
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   194
void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   195
{
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   196
	assert(!_screen_disable_anim);
6985
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   197
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   198
	uint32 *dst = (uint32 *)video;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   199
	uint32 *usrc = (uint32 *)src;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   200
	uint8 *anim_line;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   201
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   202
	anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   203
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   204
	for (; height > 0; height--) {
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   205
		memcpy(dst, usrc, width * sizeof(uint32));
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   206
		usrc += width;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   207
		dst += _screen.pitch;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   208
		/* Copy back the anim-buffer */
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   209
		memcpy(anim_line, usrc, width * sizeof(uint8));
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   210
		usrc = (uint32 *)((uint8 *)usrc + width);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   211
		anim_line += this->anim_buf_width;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   212
	}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   213
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   214
	/* We update the palette (or the pixels that do animation) immediatly, to avoid graphical glitches */
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   215
	this->PaletteAnimate(217, _use_dos_palette ? 38 : 28);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   216
}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   217
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   218
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   219
{
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   220
	assert(!_screen_disable_anim);
6985
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   221
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   222
	uint32 *udst = (uint32 *)dst;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   223
	uint32 *src = (uint32 *)video;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   224
	uint8 *anim_line;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   225
6986
56897f817855 (svn r10242) -Fix: avoid a segfault if you move your mouse at startup with 32bpp-anim
truelight
parents: 6985
diff changeset
   226
	if (this->anim_buf == NULL) return;
56897f817855 (svn r10242) -Fix: avoid a segfault if you move your mouse at startup with 32bpp-anim
truelight
parents: 6985
diff changeset
   227
6985
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   228
	anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   229
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   230
	for (; height > 0; height--) {
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   231
		memcpy(udst, src, width * sizeof(uint32));
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   232
		src += _screen.pitch;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   233
		udst += width;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   234
		/* Copy the anim-buffer */
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   235
		memcpy(udst, anim_line, width * sizeof(uint8));
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   236
		udst = (uint32 *)((uint8 *)udst + width);
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   237
		anim_line += this->anim_buf_width;
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   238
	}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   239
}
d50d59dca7c1 (svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
truelight
parents: 6979
diff changeset
   240
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   241
void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   242
{
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   243
	assert(!_screen_disable_anim);
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   244
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   245
	uint8 *dst, *src;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   246
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   247
	/* We need to scroll the anim-buffer too */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   248
	if (scroll_y > 0) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   249
		dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   250
		src = dst - scroll_y * this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   251
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   252
		/* Adjust left & width */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   253
		if (scroll_x >= 0) dst += scroll_x;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   254
		else               src -= scroll_x;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   255
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   256
		uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   257
		uint th = height - scroll_y;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   258
		for (; th > 0; th--) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   259
			memcpy(dst, src, tw * sizeof(uint8));
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   260
			src -= this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   261
			dst -= this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   262
		}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   263
	} else {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   264
		/* Calculate pointers */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   265
		dst = this->anim_buf + left + top * this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   266
		src = dst - scroll_y * this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   267
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   268
		/* Adjust left & width */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   269
		if (scroll_x >= 0) dst += scroll_x;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   270
		else               src -= scroll_x;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   271
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   272
		/* the y-displacement may be 0 therefore we have to use memmove,
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   273
		 * because source and destination may overlap */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   274
		uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   275
		uint th = height + scroll_y;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   276
		for (; th > 0; th--) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   277
			memmove(dst, src, tw * sizeof(uint8));
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   278
			src += this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   279
			dst += this->anim_buf_width;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   280
		}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   281
	}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   282
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   283
	Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   284
}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   285
6988
980738eadcc2 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 6986
diff changeset
   286
int Blitter_32bppAnim::BufferSize(int width, int height)
980738eadcc2 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 6986
diff changeset
   287
{
980738eadcc2 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 6986
diff changeset
   288
	return width * height * (sizeof(uint32) + sizeof(uint8));
980738eadcc2 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 6986
diff changeset
   289
}
980738eadcc2 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 6986
diff changeset
   290
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   291
void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   292
{
8249
90bd3316062f (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8130
diff changeset
   293
	assert(!_screen_disable_anim);
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   294
	uint8 *anim = this->anim_buf;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   295
6979
c4abd9b85a7a (svn r10235) -Fix: the 32bpp-anim blitter repainted pixel color 0, which is transparency and therefor should never be repainted (spotted by Rubidium)
truelight
parents: 6971
diff changeset
   296
	/* Never repaint the transparency pixel */
c4abd9b85a7a (svn r10235) -Fix: the 32bpp-anim blitter repainted pixel color 0, which is transparency and therefor should never be repainted (spotted by Rubidium)
truelight
parents: 6971
diff changeset
   297
	if (start == 0) start++;
c4abd9b85a7a (svn r10235) -Fix: the 32bpp-anim blitter repainted pixel color 0, which is transparency and therefor should never be repainted (spotted by Rubidium)
truelight
parents: 6971
diff changeset
   298
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   299
	/* Let's walk the anim buffer and try to find the pixels */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   300
	for (int y = 0; y < this->anim_buf_height; y++) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   301
		for (int x = 0; x < this->anim_buf_width; x++) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   302
			if (*anim >= start && *anim <= start + count) {
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   303
				/* Update this pixel */
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   304
				this->SetPixel(_screen.dst_ptr, x, y, *anim);
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   305
			}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   306
			anim++;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   307
		}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   308
	}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   309
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   310
	/* Make sure the backend redraws the whole screen */
7170
923946ec324f (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7138
diff changeset
   311
	_video_driver->MakeDirty(0, 0, _screen.width, _screen.height);
6971
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   312
}
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   313
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   314
Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   315
{
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   316
	return Blitter::PALETTE_ANIMATION_BLITTER;
6dd4632b7c1d (svn r10227) -Add: added 32bpp-anim blitter, a 32bpp blitter that does palette animation (at the cost of an animation-buffer to keep track of the 'm'-channel of all sprites)
truelight
parents:
diff changeset
   317
}