src/blitter/32bpp_anim.cpp
branchNewGRF_ports
changeset 6872 1c4a4a609f85
parent 6870 ca3fd1fbe311
child 10724 68a692eacf22
--- a/src/blitter/32bpp_anim.cpp	Mon Dec 03 23:39:38 2007 +0000
+++ b/src/blitter/32bpp_anim.cpp	Tue Jan 22 21:00:30 2008 +0000
@@ -1,16 +1,20 @@
+/* $Id$ */
+
 #include "../stdafx.h"
-#include "../zoom.hpp"
-#include "../gfx.h"
+#include "../core/alloc_func.hpp"
+#include "../gfx_func.h"
+#include "../zoom_func.h"
 #include "../debug.h"
-#include "../table/sprites.h"
 #include "../video/video_driver.hpp"
 #include "32bpp_anim.hpp"
 
+#include "../table/sprites.h"
+
 static FBlitter_32bppAnim iFBlitter_32bppAnim;
 
 void Blitter_32bppAnim::Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom)
 {
-	if (bp->dst < _screen.dst_ptr || bp->dst > (uint32 *)_screen.dst_ptr + _screen.width * _screen.height) {
+	if (_screen_disable_anim) {
 		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent Draw() */
 		Blitter_32bppOptimized::Draw(bp, mode, zoom);
 		return;
@@ -95,6 +99,12 @@
 
 void Blitter_32bppAnim::DrawColorMappingRect(void *dst, int width, int height, int pal)
 {
+	if (_screen_disable_anim) {
+		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawColorMappingRect() */
+		Blitter_32bppOptimized::DrawColorMappingRect(dst, width, height, pal);
+		return;
+	}
+
 	uint32 *udst = (uint32 *)dst;
 	uint8 *anim;
 
@@ -133,7 +143,9 @@
 void Blitter_32bppAnim::SetPixel(void *video, int x, int y, uint8 color)
 {
 	*((uint32 *)video + x + y * _screen.pitch) = LookupColourInPalette(color);
-	/* Set the color in the anim-buffer too */
+
+	/* Set the color in the anim-buffer too, if we are rendering to the screen */
+	if (_screen_disable_anim) return;
 	this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
 }
 
@@ -142,13 +154,20 @@
 	uint32 *dst = (uint32 *)video + x + y * _screen.pitch;
 	if (*dst == 0) {
 		*dst = LookupColourInPalette(color);
-		/* Set the color in the anim-buffer too */
+		/* Set the color in the anim-buffer too, if we are rendering to the screen */
+		if (_screen_disable_anim) return;
 		this->anim_buf[((uint32 *)video - (uint32 *)_screen.dst_ptr) + x + y * this->anim_buf_width] = color;
 	}
 }
 
 void Blitter_32bppAnim::DrawRect(void *video, int width, int height, uint8 color)
 {
+	if (_screen_disable_anim) {
+		/* This means our output is not to the screen, so we can't be doing any animation stuff, so use our parent DrawRect() */
+		Blitter_32bppOptimized::DrawRect(video, width, height, color);
+		return;
+	}
+
 	uint32 color32 = LookupColourInPalette(color);
 	uint8 *anim_line;
 
@@ -172,6 +191,7 @@
 
 void Blitter_32bppAnim::CopyFromBuffer(void *video, const void *src, int width, int height)
 {
+	assert(!_screen_disable_anim);
 	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 	uint32 *dst = (uint32 *)video;
 	uint32 *usrc = (uint32 *)src;
@@ -195,6 +215,7 @@
 
 void Blitter_32bppAnim::CopyToBuffer(const void *video, void *dst, int width, int height)
 {
+	assert(!_screen_disable_anim);
 	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 	uint32 *udst = (uint32 *)dst;
 	uint32 *src = (uint32 *)video;
@@ -217,6 +238,8 @@
 
 void Blitter_32bppAnim::ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y)
 {
+	assert(!_screen_disable_anim);
+	assert(video >= _screen.dst_ptr && video <= (uint32 *)_screen.dst_ptr + _screen.width + _screen.height * _screen.pitch);
 	uint8 *dst, *src;
 
 	/* We need to scroll the anim-buffer too */
@@ -265,6 +288,7 @@
 
 void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
 {
+	assert(!_screen_disable_anim);
 	uint8 *anim = this->anim_buf;
 
 	/* Never repaint the transparency pixel */