summaryrefslogtreecommitdiff
path: root/src/blitter/32bpp_anim.cpp
diff options
context:
space:
mode:
authortruelight <truelight@openttd.org>2007-06-21 12:36:46 +0000
committertruelight <truelight@openttd.org>2007-06-21 12:36:46 +0000
commit3fa3d2e3653f351ba071152a4fa8ff19e31aa14f (patch)
tree32794e63c78972c1d43b56d335b38c6f56fad413 /src/blitter/32bpp_anim.cpp
parent3b12e7b6b0a6b71a7b085c60c3b4ac4ffbe1dc44 (diff)
downloadopenttd-3fa3d2e3653f351ba071152a4fa8ff19e31aa14f.tar.xz
(svn r10241) -Codechange: CopyToBuffer now produces a buffer that is unreadable from outside the blitter, so the blitter can store anything he likes
-Codechange: added CopyImageToBuffer, which produces a readable buffer for screenshots -Fix: 32bpp-anim now holds animation on transparent objects to avoid strange graphical effects -Fix: 32bpp-anim now works correct on mouse-movement (it holds the palette animation correctly)
Diffstat (limited to 'src/blitter/32bpp_anim.cpp')
-rw-r--r--src/blitter/32bpp_anim.cpp80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/blitter/32bpp_anim.cpp b/src/blitter/32bpp_anim.cpp
index c27377bf0..d207173d3 100644
--- a/src/blitter/32bpp_anim.cpp
+++ b/src/blitter/32bpp_anim.cpp
@@ -79,6 +79,43 @@ void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomL
}
}
+void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, int pal)
+{
+ uint32 *udst = (uint32 *)dst;
+ uint8 *anim;
+
+ anim = this->anim_buf + ((uint32 *)dst - (uint32 *)_screen.dst_ptr);
+
+ if (pal == PALETTE_TO_TRANSPARENT) {
+ do {
+ for (int i = 0; i != width; i++) {
+ *udst = MakeTransparent(*udst, 60);
+ *anim = 0;
+ udst++;
+ anim++;
+ }
+ udst = udst - width + _screen.pitch;
+ anim = anim - width + this->anim_buf_width;
+ } while (--height);
+ return;
+ }
+ if (pal == PALETTE_TO_STRUCT_GREY) {
+ do {
+ for (int i = 0; i != width; i++) {
+ *udst = MakeGrey(*udst);
+ *anim = 0;
+ udst++;
+ anim++;
+ }
+ udst = udst - width + _screen.pitch;
+ anim = anim - width + this->anim_buf_width;
+ } while (--height);
+ return;
+ }
+
+ DEBUG(misc, 0, "32bpp blitter doesn't know how to draw this color table ('%d')", pal);
+}
+
void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 color)
{
*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
@@ -119,6 +156,49 @@ void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color
} while (--height);
}
+void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
+{
+ assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
+ uint32 *dst = (uint32 *)video;
+ uint32 *usrc = (uint32 *)src;
+ uint8 *anim_line;
+
+ anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
+
+ for (; height > 0; height--) {
+ memcpy(dst, usrc, width * sizeof(uint32));
+ usrc += width;
+ dst += _screen.pitch;
+ /* Copy back the anim-buffer */
+ memcpy(anim_line, usrc, width * sizeof(uint8));
+ usrc = (uint32 *)((uint8 *)usrc + width);
+ anim_line += this->anim_buf_width;
+ }
+
+ /* We update the palette (or the pixels that do animation) immediatly, to avoid graphical glitches */
+ this->PaletteAnimate(217, _use_dos_palette ? 38 : 28);
+}
+
+void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
+{
+ assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
+ uint32 *udst = (uint32 *)dst;
+ uint32 *src = (uint32 *)video;
+ uint8 *anim_line;
+
+ anim_line = ((uint32 *)video - (uint32 *)_screen.dst_ptr) + this->anim_buf;
+
+ for (; height > 0; height--) {
+ memcpy(udst, src, width * sizeof(uint32));
+ src += _screen.pitch;
+ udst += width;
+ /* Copy the anim-buffer */
+ memcpy(udst, anim_line, width * sizeof(uint8));
+ udst = (uint32 *)((uint8 *)udst + width);
+ anim_line += this->anim_buf_width;
+ }
+}
+
void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
{
uint8 *dst, *src;