src/blitter/32bpp_anim.cpp
author truelight
Thu, 21 Jun 2007 13:31:41 +0000
changeset 7484 cdf0450632a1
parent 7482 ec4c1ff22d83
child 7634 d167f8ce8dbb
permissions -rw-r--r--
(svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
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
     1
#include "../stdafx.h"
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
     2
#include "../zoom.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
     3
#include "../gfx.h"
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
     4
#include "../debug.h"
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 "../table/sprites.h"
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
     6
#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
     7
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
     8
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
     9
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
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
    11
{
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
	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
    13
	uint32 *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
    14
	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
    15
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
	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
    17
		/* 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
    18
		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
    19
		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
    20
		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
    21
		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
    22
	}
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
    23
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
    24
	/* 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
    25
	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
    26
	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
    27
	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
    28
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
	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
    30
		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
    31
		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
    32
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
		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
    34
		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
    35
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
		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
    37
		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
    38
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
		for (int x = 0; x < bp->width; 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
    40
			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
    41
				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
    42
					/* 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
    43
					if (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
    44
						if (src->a != 0) *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *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
    45
						*anim = 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
    46
					} 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
    47
						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
    48
							*dst = ComposeColourPA(this->LookupColourInPalette(bp->remap[src->m]), src->a, *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
    49
							*anim = bp->remap[src->m];
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
						}
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
					}
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
					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
    53
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
    54
				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
    55
					/* 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
    56
					 *  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
    57
					 *  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
    58
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
    59
					/* Make the current color a bit more black, so it looks like this image is 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
    60
					if (src->a != 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
    61
						*dst = MakeTransparent(*dst, 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
    62
						*anim = bp->remap[*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
    63
					}
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
    64
					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
    65
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
				default:
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
					if (src->a != 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
    68
						/* Above 217 is palette animation */
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
    69
						if (src->m >= 217) *dst = ComposeColourPA(this->LookupColourInPalette(src->m), src->a, *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
    70
						else               *dst = ComposeColourRGBA(src->r, src->g, src->b, src->a, *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
    71
						*anim = src->m;
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
					}
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
					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
    74
			}
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
			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
    76
			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
    77
			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
    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
	}
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
}
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
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
    82
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
    83
{
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
    84
	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
    85
	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
    86
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
    87
	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
    88
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
    89
	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
    90
		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
    91
			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
    92
				*udst = MakeTransparent(*udst, 60);
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
    93
				*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
    94
				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
    95
				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
    96
			}
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
    97
			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
    98
			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
    99
		} 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
   100
		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
   101
	}
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
   102
	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
   103
		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
   104
			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
   105
				*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
   106
				*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
   107
				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
   108
				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
   109
			}
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
   110
			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
   111
			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
   112
		} 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
   113
		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
   114
	}
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
	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
   117
}
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
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
   119
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
   120
{
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
   121
	*((uint32 *)video + x + y * _screen.pitch) = 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
   122
	/* 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
   123
	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
   124
}
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
   125
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
   126
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
   127
{
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
   128
	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
   129
	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
   130
		*dst = 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
   131
		/* 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
   132
		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
   133
	}
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
   134
}
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
   135
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
   136
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
   137
{
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
   138
	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
   139
	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
   140
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
   141
	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
   142
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
   143
	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
   144
		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
   145
		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
   146
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
		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
   148
			*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
   149
			/* 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
   150
			*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
   151
			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
   152
			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
   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
		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
   155
		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
   156
	} 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
   157
}
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
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
   159
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
   160
{
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
   161
	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
   162
	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
   163
	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
   164
	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
   165
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
   166
	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
   167
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
   168
	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
   169
		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
   170
		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
   171
		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
   172
		/* 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
   173
		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
   174
		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
   175
		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
   176
	}
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
   177
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
   178
	/* 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
   179
	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
   180
}
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
   181
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
   182
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
   183
{
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
   184
	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
   185
	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
   186
	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
   187
	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
   188
7482
ec4c1ff22d83 (svn r10242) -Fix: avoid a segfault if you move your mouse at startup with 32bpp-anim
truelight
parents: 7481
diff changeset
   189
	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
   190
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
   191
	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
   192
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
   193
	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
   194
		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
   195
		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
   196
		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
   197
		/* 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
   198
		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
   199
		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
   200
		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
   201
	}
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
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
   204
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
   205
{
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
   206
	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
   207
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
   208
	/* 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
   209
	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
   210
		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
   211
		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
   212
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
   213
		/* 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
   214
		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
   215
		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
   216
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
   217
		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
   218
		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
   219
		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
   220
			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
   221
			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
   222
			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
   223
		}
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
   224
	} 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
   225
		/* 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
   226
		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
   227
		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
   228
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
   229
		/* 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
   230
		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
   231
		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
   232
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
   233
		/* 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
   234
		 * 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
   235
		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
   236
		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
   237
		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
   238
			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
   239
			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
   240
			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
   241
		}
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
	}
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
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
   244
	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
   245
}
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
7484
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   247
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
   248
{
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   249
	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
   250
}
cdf0450632a1 (svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
truelight
parents: 7482
diff changeset
   251
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
   252
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
   253
{
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
	uint8 *anim = 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
   255
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
   256
	/* Never repaint the transparency pixel */
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
   257
	if (start == 0) start++;
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
   258
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
   259
	/* Let's walk the anim buffer and try to find the pixels */
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
	for (int y = 0; y < this->anim_buf_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
   261
		for (int x = 0; x < this->anim_buf_width; 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
   262
			if (*anim >= start && *anim <= start + 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
   263
				/* Update this pixel */
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
				this->SetPixel(_screen.dst_ptr, x, y, *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
   265
			}
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
			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
   267
		}
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
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
	/* Make sure the backend redraws the whole screen */
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
	_video_driver->make_dirty(0, 0, _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
   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
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
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
   275
{
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
	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
   277
}