src/blitter/32bpp_anim.cpp
author smatz
Wed, 18 Jun 2008 13:11:02 +0000
changeset 11008 c8174672193e
parent 10429 1b99254f9607
child 11013 71b7f7c475db
permissions -rw-r--r--
(svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
8587
6db234b2b897 (svn r11652) -Codechange: add the svn $ header for several files
smatz
parents: 8054
diff changeset
     1
/* $Id$ */
6db234b2b897 (svn r11652) -Codechange: add the svn $ header for several files
smatz
parents: 8054
diff changeset
     2
10429
1b99254f9607 (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: 8760
diff changeset
     3
/** @file 32bpp_anim.cpp Implementation of the optimized 32 bpp blitter with animation support. */
1b99254f9607 (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: 8760
diff changeset
     4
7467
cb1801e91c3d (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"
8626
440dfcd14c4a (svn r11691) -Codechange: move+rename helpers.hpp and only include it when it is really needed.
rubidium
parents: 8619
diff changeset
     6
#include "../core/alloc_func.hpp"
11008
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
     7
#include "../core/math_func.hpp"
8619
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8587
diff changeset
     8
#include "../gfx_func.h"
c2434269c3eb (svn r11684) -Codechange: split gfx.h in a type and functional header.
rubidium
parents: 8587
diff changeset
     9
#include "../zoom_func.h"
7467
cb1801e91c3d (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
    10
#include "../debug.h"
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7634
diff changeset
    11
#include "../video/video_driver.hpp"
7467
cb1801e91c3d (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
#include "32bpp_anim.hpp"
cb1801e91c3d (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
    13
8760
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8745
diff changeset
    14
#include "../table/sprites.h"
ce0891c412ce (svn r11828) -Codechange: include table/* as the last includes and remove an unneeded include from openttd.h.
rubidium
parents: 8745
diff changeset
    15
7467
cb1801e91c3d (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
static FBlitter_32bppAnim iFBlitter_32bppAnim;
cb1801e91c3d (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
cb1801e91c3d (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
void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
cb1801e91c3d (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
    19
{
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
    20
	if (_screen_disable_anim) {
8052
3056e53dfe42 (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: 8051
diff changeset
    21
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
3056e53dfe42 (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: 8051
diff changeset
    22
		Blitter_32bppOptimized::Draw(bp, mode, zoom);
3056e53dfe42 (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: 8051
diff changeset
    23
		return;
3056e53dfe42 (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: 8051
diff changeset
    24
	}
8053
2e4ea3db6b9c (svn r11082) -Fix r11081: save before commit (yeah, whitelines are important too!)
truelight
parents: 8052
diff changeset
    25
7467
cb1801e91c3d (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
	const SpriteLoader::CommonPixel *src, *src_line;
cb1801e91c3d (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
    27
	uint32 *dst, *dst_line;
8052
3056e53dfe42 (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: 8051
diff changeset
    28
	uint8 *anim, *anim_line;
7467
cb1801e91c3d (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
cb1801e91c3d (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
	if (_screen.width != this->anim_buf_width || _screen.height != this->anim_buf_height) {
cb1801e91c3d (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
		/* The size of the screen changed; we can assume we can wipe all data from our buffer */
cb1801e91c3d (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
		free(this->anim_buf);
cb1801e91c3d (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 = CallocT<uint8>(_screen.width * _screen.height);
cb1801e91c3d (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_width = _screen.width;
cb1801e91c3d (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
		this->anim_buf_height = _screen.height;
cb1801e91c3d (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
	}
cb1801e91c3d (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
cb1801e91c3d (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
	/* Find where to start reading in the source sprite */
cb1801e91c3d (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
	src_line = (const SpriteLoader::CommonPixel *)bp->sprite + (bp->skip_top * bp->sprite_width + bp->skip_left) * ScaleByZoom(1, zoom);
cb1801e91c3d (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
	dst_line = (uint32 *)bp->dst + bp->top * bp->pitch + bp->left;
cb1801e91c3d (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
	anim_line = this->anim_buf + ((uint32 *)bp->dst - (uint32 *)_screen.dst_ptr) + bp->top * this->anim_buf_width + bp->left;
cb1801e91c3d (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
cb1801e91c3d (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
	for (int y = 0; y < bp->height; y++) {
cb1801e91c3d (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 = dst_line;
cb1801e91c3d (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
		dst_line += bp->pitch;
cb1801e91c3d (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
cb1801e91c3d (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 = src_line;
cb1801e91c3d (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
		src_line += bp->sprite_width * ScaleByZoom(1, zoom);
cb1801e91c3d (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
cb1801e91c3d (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 = anim_line;
cb1801e91c3d (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
		anim_line += this->anim_buf_width;
cb1801e91c3d (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
cb1801e91c3d (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
    53
		for (int x = 0; x < bp->width; x++) {
8049
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    54
			if (src->a == 0) {
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    55
				/* src->r is 'misused' here to indicate how much more pixels are following with an alpha of 0 */
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    56
				int skip = UnScaleByZoom(src->r, zoom);
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    57
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    58
				dst  += skip;
8052
3056e53dfe42 (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: 8051
diff changeset
    59
				anim += skip;
8049
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    60
				x    += skip - 1;
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    61
				src  += ScaleByZoom(1, zoom) * skip;
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    62
				continue;
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    63
			}
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    64
7467
cb1801e91c3d (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
			switch (mode) {
cb1801e91c3d (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
				case BM_COLOUR_REMAP:
cb1801e91c3d (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
					/* In case the m-channel is zero, do not remap this pixel in any way */
cb1801e91c3d (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
    68
					if (src->m == 0) {
8049
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    69
						*dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
8051
ec4e97b7b70c (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 8050
diff changeset
    70
						*anim = 0;
7467
cb1801e91c3d (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
					} else {
cb1801e91c3d (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
						if (bp->remap[src->m] != 0) {
cb1801e91c3d (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
    73
							*dst = ComposeColourPA(this->LookupColourInPalette(bp->remap[src->m]), src->a, *dst);
8051
ec4e97b7b70c (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 8050
diff changeset
    74
							*anim = bp->remap[src->m];
7467
cb1801e91c3d (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
						}
cb1801e91c3d (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
					}
cb1801e91c3d (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
					break;
cb1801e91c3d (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
cb1801e91c3d (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
				case BM_TRANSPARENT:
cb1801e91c3d (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
					/* TODO -- We make an assumption here that the remap in fact is transparency, not some color.
cb1801e91c3d (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
					 *  This is never a problem with the code we produce, but newgrfs can make it fail... or at least:
cb1801e91c3d (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
					 *  we produce a result the newgrf maker didn't expect ;) */
cb1801e91c3d (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
cb1801e91c3d (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
    84
					/* Make the current color a bit more black, so it looks like this image is transparent */
8049
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    85
					*dst = MakeTransparent(*dst, 192);
8051
ec4e97b7b70c (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 8050
diff changeset
    86
					*anim = bp->remap[*anim];
7467
cb1801e91c3d (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
					break;
cb1801e91c3d (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
cb1801e91c3d (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
    89
				default:
8049
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    90
					/* Above 217 is palette animation */
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    91
					if (src->m >= 217) *dst = ComposeColourPA(this->LookupColourInPalette(src->m), src->a, *dst);
00faaf0c0b52 (svn r11078) -Add: added 32bpp-optimized, which is almost twice as fast as 32bpp-simple (based on the work of frosch)
truelight
parents: 8048
diff changeset
    92
					else               *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *dst);
8051
ec4e97b7b70c (svn r11080) -Fix r11079: fix it, still dirty, correctly, as the last commit was ... wrong ;)
truelight
parents: 8050
diff changeset
    93
					*anim = src->m;
7467
cb1801e91c3d (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
					break;
cb1801e91c3d (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
			}
cb1801e91c3d (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
    96
			dst++;
8052
3056e53dfe42 (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: 8051
diff changeset
    97
			anim++;
7467
cb1801e91c3d (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
			src += ScaleByZoom(1, zoom);
cb1801e91c3d (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
		}
cb1801e91c3d (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
	}
cb1801e91c3d (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
}
cb1801e91c3d (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
   102
7481
699607d457a0 (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: 7475
diff changeset
   103
void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, int pal)
699607d457a0 (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: 7475
diff changeset
   104
{
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   105
	if (_screen_disable_anim) {
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   106
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColorMappingRect() */
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   107
		Blitter_32bppOptimized::DrawColorMappingRect(dst, width, height, pal);
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   108
		return;
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   109
	}
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   110
7481
699607d457a0 (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: 7475
diff changeset
   111
	uint32 *udst = (uint32 *)dst;
699607d457a0 (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: 7475
diff changeset
   112
	uint8 *anim;
699607d457a0 (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: 7475
diff changeset
   113
699607d457a0 (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: 7475
diff changeset
   114
	anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
699607d457a0 (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: 7475
diff changeset
   115
699607d457a0 (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: 7475
diff changeset
   116
	if (pal == PALETTE_TO_TRANSPARENT) {
699607d457a0 (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: 7475
diff changeset
   117
		do {
699607d457a0 (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: 7475
diff changeset
   118
			for (int i = 0; i != width; i++) {
8048
7547093f21e6 (svn r11076) -Fix: MakeTransparent of 32bpp blitter used 0..100; using 0..255 makes it much faster (frosch)
truelight
parents: 7666
diff changeset
   119
				*udst = MakeTransparent(*udst, 154);
7481
699607d457a0 (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: 7475
diff changeset
   120
				*anim = 0;
699607d457a0 (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: 7475
diff changeset
   121
				udst++;
699607d457a0 (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: 7475
diff changeset
   122
				anim++;
699607d457a0 (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: 7475
diff changeset
   123
			}
699607d457a0 (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: 7475
diff changeset
   124
			udst = udst - width + _screen.pitch;
699607d457a0 (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: 7475
diff changeset
   125
			anim = anim - width + this->anim_buf_width;
699607d457a0 (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: 7475
diff changeset
   126
		} while (--height);
699607d457a0 (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: 7475
diff changeset
   127
		return;
699607d457a0 (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: 7475
diff changeset
   128
	}
699607d457a0 (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: 7475
diff changeset
   129
	if (pal == PALETTE_TO_STRUCT_GREY) {
699607d457a0 (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: 7475
diff changeset
   130
		do {
699607d457a0 (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: 7475
diff changeset
   131
			for (int i = 0; i != width; i++) {
699607d457a0 (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: 7475
diff changeset
   132
				*udst = MakeGrey(*udst);
699607d457a0 (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: 7475
diff changeset
   133
				*anim = 0;
699607d457a0 (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: 7475
diff changeset
   134
				udst++;
699607d457a0 (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: 7475
diff changeset
   135
				anim++;
699607d457a0 (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: 7475
diff changeset
   136
			}
699607d457a0 (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: 7475
diff changeset
   137
			udst = udst - width + _screen.pitch;
699607d457a0 (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: 7475
diff changeset
   138
			anim = anim - width + this->anim_buf_width;
699607d457a0 (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: 7475
diff changeset
   139
		} while (--height);
699607d457a0 (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: 7475
diff changeset
   140
		return;
699607d457a0 (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: 7475
diff changeset
   141
	}
699607d457a0 (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: 7475
diff changeset
   142
699607d457a0 (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: 7475
diff changeset
   143
	DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this color table ('%d')", pal);
699607d457a0 (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: 7475
diff changeset
   144
}
699607d457a0 (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: 7475
diff changeset
   145
7467
cb1801e91c3d (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
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 color)
cb1801e91c3d (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
{
cb1801e91c3d (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
   148
	*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   149
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   150
	/* Set the color in the anim-buffer too, if we are rendering to the screen */
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   151
	if (_screen_disable_anim) return;
7467
cb1801e91c3d (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
	this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
cb1801e91c3d (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
}
cb1801e91c3d (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
cb1801e91c3d (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
void Blitter_32bppAnim::SetPixelIfEmpty(void *video, int x, int y, uint8 color)
cb1801e91c3d (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
{
cb1801e91c3d (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
	uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
cb1801e91c3d (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
	if (*dst == 0) {
cb1801e91c3d (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
   159
		*dst = LookupColourInPalette(color);
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   160
		/* Set the color in the anim-buffer too, if we are rendering to the screen */
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   161
		if (_screen_disable_anim) return;
7467
cb1801e91c3d (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
		this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
cb1801e91c3d (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
	}
cb1801e91c3d (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
}
cb1801e91c3d (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
cb1801e91c3d (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
void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color)
cb1801e91c3d (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
   167
{
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   168
	if (_screen_disable_anim) {
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   169
		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   170
		Blitter_32bppOptimized::DrawRect(video, width, height, color);
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   171
		return;
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   172
	}
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   173
7467
cb1801e91c3d (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
	uint32 color32 = LookupColourInPalette(color);
cb1801e91c3d (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
	uint8 *anim_line;
cb1801e91c3d (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
cb1801e91c3d (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
	anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
cb1801e91c3d (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
cb1801e91c3d (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
	do {
cb1801e91c3d (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
		uint32 *dst = (uint32 *)video;
cb1801e91c3d (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
		uint8 *anim = anim_line;
cb1801e91c3d (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
cb1801e91c3d (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
		for (int i = width; i > 0; i--) {
cb1801e91c3d (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
			*dst = color32;
cb1801e91c3d (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
			/* Set the color in the anim-buffer too */
cb1801e91c3d (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
			*anim = color;
cb1801e91c3d (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
			dst++;
cb1801e91c3d (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
			anim++;
cb1801e91c3d (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
		}
cb1801e91c3d (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
		video = (uint32 *)video + _screen.pitch;
cb1801e91c3d (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
		anim_line += this->anim_buf_width;
cb1801e91c3d (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
	} while (--height);
cb1801e91c3d (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
}
cb1801e91c3d (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
   194
7481
699607d457a0 (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: 7475
diff changeset
   195
void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
699607d457a0 (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: 7475
diff changeset
   196
{
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   197
	assert(!_screen_disable_anim);
7481
699607d457a0 (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: 7475
diff changeset
   198
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
699607d457a0 (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: 7475
diff changeset
   199
	uint32 *dst = (uint32 *)video;
699607d457a0 (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: 7475
diff changeset
   200
	uint32 *usrc = (uint32 *)src;
699607d457a0 (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: 7475
diff changeset
   201
	uint8 *anim_line;
699607d457a0 (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: 7475
diff changeset
   202
699607d457a0 (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: 7475
diff changeset
   203
	anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
699607d457a0 (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: 7475
diff changeset
   204
699607d457a0 (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: 7475
diff changeset
   205
	for (; height > 0; height--) {
699607d457a0 (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: 7475
diff changeset
   206
		memcpy(dst, usrc, width * sizeof(uint32));
699607d457a0 (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: 7475
diff changeset
   207
		usrc += width;
699607d457a0 (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: 7475
diff changeset
   208
		dst += _screen.pitch;
699607d457a0 (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: 7475
diff changeset
   209
		/* Copy back the anim-buffer */
699607d457a0 (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: 7475
diff changeset
   210
		memcpy(anim_line, usrc, width * sizeof(uint8));
699607d457a0 (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: 7475
diff changeset
   211
		usrc = (uint32 *)((uint8 *)usrc + width);
699607d457a0 (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: 7475
diff changeset
   212
		anim_line += this->anim_buf_width;
699607d457a0 (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: 7475
diff changeset
   213
	}
699607d457a0 (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: 7475
diff changeset
   214
699607d457a0 (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: 7475
diff changeset
   215
	/* We update the palette (or the pixels that do animation) immediatly, to avoid graphical glitches */
699607d457a0 (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: 7475
diff changeset
   216
	this->PaletteAnimate(217, _use_dos_palette ? 38 : 28);
699607d457a0 (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: 7475
diff changeset
   217
}
699607d457a0 (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: 7475
diff changeset
   218
699607d457a0 (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: 7475
diff changeset
   219
void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
699607d457a0 (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: 7475
diff changeset
   220
{
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   221
	assert(!_screen_disable_anim);
7481
699607d457a0 (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: 7475
diff changeset
   222
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
699607d457a0 (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: 7475
diff changeset
   223
	uint32 *udst = (uint32 *)dst;
699607d457a0 (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: 7475
diff changeset
   224
	uint32 *src = (uint32 *)video;
699607d457a0 (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: 7475
diff changeset
   225
	uint8 *anim_line;
699607d457a0 (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: 7475
diff changeset
   226
7482
ec4c1ff22d83 (svn r10242) -Fix: avoid a segfault if you move your mouse at startup with 32bpp-anim
truelight
parents: 7481
diff changeset
   227
	if (this->anim_buf == NULL) return;
ec4c1ff22d83 (svn r10242) -Fix: avoid a segfault if you move your mouse at startup with 32bpp-anim
truelight
parents: 7481
diff changeset
   228
7481
699607d457a0 (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: 7475
diff changeset
   229
	anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
699607d457a0 (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: 7475
diff changeset
   230
699607d457a0 (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: 7475
diff changeset
   231
	for (; height > 0; height--) {
699607d457a0 (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: 7475
diff changeset
   232
		memcpy(udst, src, width * sizeof(uint32));
699607d457a0 (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: 7475
diff changeset
   233
		src += _screen.pitch;
699607d457a0 (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: 7475
diff changeset
   234
		udst += width;
699607d457a0 (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: 7475
diff changeset
   235
		/* Copy the anim-buffer */
699607d457a0 (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: 7475
diff changeset
   236
		memcpy(udst, anim_line, width * sizeof(uint8));
699607d457a0 (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: 7475
diff changeset
   237
		udst = (uint32 *)((uint8 *)udst + width);
699607d457a0 (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: 7475
diff changeset
   238
		anim_line += this->anim_buf_width;
699607d457a0 (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: 7475
diff changeset
   239
	}
699607d457a0 (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: 7475
diff changeset
   240
}
699607d457a0 (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: 7475
diff changeset
   241
7467
cb1801e91c3d (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
void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
cb1801e91c3d (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
   243
{
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   244
	assert(!_screen_disable_anim);
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   245
	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
7467
cb1801e91c3d (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
	uint8 *dst, *src;
cb1801e91c3d (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
cb1801e91c3d (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
	/* We need to scroll the anim-buffer too */
cb1801e91c3d (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
	if (scroll_y > 0) {
cb1801e91c3d (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
		dst = this->anim_buf + left + (top + height - 1) * this->anim_buf_width;
cb1801e91c3d (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
		src = dst - scroll_y * this->anim_buf_width;
cb1801e91c3d (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
cb1801e91c3d (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
		/* Adjust left & width */
cb1801e91c3d (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
		if (scroll_x >= 0) dst += scroll_x;
cb1801e91c3d (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
		else               src -= scroll_x;
cb1801e91c3d (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
cb1801e91c3d (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 tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
cb1801e91c3d (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
		uint th = height - scroll_y;
cb1801e91c3d (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
		for (; th > 0; th--) {
cb1801e91c3d (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
			memcpy(dst, src, tw * sizeof(uint8));
cb1801e91c3d (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
			src -= this->anim_buf_width;
cb1801e91c3d (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
			dst -= this->anim_buf_width;
cb1801e91c3d (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
		}
cb1801e91c3d (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
	} else {
cb1801e91c3d (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
		/* Calculate pointers */
cb1801e91c3d (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
		dst = this->anim_buf + left + top * this->anim_buf_width;
cb1801e91c3d (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
		src = dst - scroll_y * this->anim_buf_width;
cb1801e91c3d (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
cb1801e91c3d (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
		/* Adjust left & width */
cb1801e91c3d (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
		if (scroll_x >= 0) dst += scroll_x;
cb1801e91c3d (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
		else               src -= scroll_x;
cb1801e91c3d (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
cb1801e91c3d (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
		/* the y-displacement may be 0 therefore we have to use memmove,
cb1801e91c3d (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
		 * because source and destination may overlap */
cb1801e91c3d (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 tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
cb1801e91c3d (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
		uint th = height + scroll_y;
cb1801e91c3d (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
		for (; th > 0; th--) {
cb1801e91c3d (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
			memmove(dst, src, tw * sizeof(uint8));
cb1801e91c3d (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
			src += this->anim_buf_width;
cb1801e91c3d (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
			dst += this->anim_buf_width;
cb1801e91c3d (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
		}
cb1801e91c3d (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
	}
cb1801e91c3d (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
cb1801e91c3d (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
	Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
cb1801e91c3d (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
}
cb1801e91c3d (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
   286
7484
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   287
int Blitter_32bppAnim::BufferSize(int width, int height)
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   288
{
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   289
	return width * height * (sizeof(uint32) + sizeof(uint8));
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   290
}
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   291
7467
cb1801e91c3d (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
void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
cb1801e91c3d (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
   293
{
8745
0c897b4e651e (svn r11813) -Fix [FS#1602]: Switch _screen to the output buffer and disable usage of 32bpp-anim animation buffer during giant screenshots.
frosch
parents: 8626
diff changeset
   294
	assert(!_screen_disable_anim);
11008
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   295
	assert(_screen.width == this->anim_buf_width && _screen.height == this->anim_buf_height);
7467
cb1801e91c3d (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
   296
7475
7a7a5b807fcb (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: 7467
diff changeset
   297
	/* Never repaint the transparency pixel */
11008
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   298
	if (start == 0) {
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   299
		start++;
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   300
		count--;
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   301
	}
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   302
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   303
	const uint8 *anim = this->anim_buf;
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   304
	uint32 *dst = (uint32 *)_screen.dst_ptr;
7475
7a7a5b807fcb (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: 7467
diff changeset
   305
7467
cb1801e91c3d (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
	/* Let's walk the anim buffer and try to find the pixels */
11008
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   307
	for (int y = this->anim_buf_height; y != 0 ; y--) {
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   308
		for (int x = this->anim_buf_width; x != 0 ; x--) {
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   309
			uint colour = *anim;
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   310
			if (IsInsideBS(colour, start, count)) {
7467
cb1801e91c3d (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
   311
				/* Update this pixel */
11008
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   312
				*dst = LookupColourInPalette(colour);
7467
cb1801e91c3d (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
			}
11008
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   314
			dst++;
7467
cb1801e91c3d (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
			anim++;
cb1801e91c3d (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
		}
11008
c8174672193e (svn r13564) -Codechange: do not use SetPixel in PaletteAnimate, access destination directly instead. Makes palette animation ~40% faster.
smatz
parents: 10429
diff changeset
   317
		dst += _screen.pitch - _screen.width;
7467
cb1801e91c3d (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
   318
	}
cb1801e91c3d (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
   319
cb1801e91c3d (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
   320
	/* Make sure the backend redraws the whole screen */
7666
a5fccd76176a (svn r10444) -Codechange: switch to c++ classes and inheritance for sound/music/video drivers, using self-registration based on the blitter-model.
peter1138
parents: 7634
diff changeset
   321
	_video_driver->MakeDirty(0, 0, _screen.width, _screen.height);
7467
cb1801e91c3d (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
   322
}
cb1801e91c3d (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
   323
cb1801e91c3d (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
   324
Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
cb1801e91c3d (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
   325
{
cb1801e91c3d (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
   326
	return Blitter::PALETTE_ANIMATION_BLITTER;
cb1801e91c3d (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
   327
}