src/blitter/32bpp_anim.cpp
changeset 11008 c8174672193e
parent 10429 1b99254f9607
child 11013 71b7f7c475db
equal deleted inserted replaced
11006:a369d65b9f59 11008:c8174672193e
     2 
     2 
     3 /** @file 32bpp_anim.cpp Implementation of the optimized 32 bpp blitter with animation support. */
     3 /** @file 32bpp_anim.cpp Implementation of the optimized 32 bpp blitter with animation support. */
     4 
     4 
     5 #include "../stdafx.h"
     5 #include "../stdafx.h"
     6 #include "../core/alloc_func.hpp"
     6 #include "../core/alloc_func.hpp"
       
     7 #include "../core/math_func.hpp"
     7 #include "../gfx_func.h"
     8 #include "../gfx_func.h"
     8 #include "../zoom_func.h"
     9 #include "../zoom_func.h"
     9 #include "../debug.h"
    10 #include "../debug.h"
    10 #include "../video/video_driver.hpp"
    11 #include "../video/video_driver.hpp"
    11 #include "32bpp_anim.hpp"
    12 #include "32bpp_anim.hpp"
   289 }
   290 }
   290 
   291 
   291 void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
   292 void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
   292 {
   293 {
   293 	assert(!_screen_disable_anim);
   294 	assert(!_screen_disable_anim);
   294 	uint8 *anim = this->anim_buf;
   295 	assert(_screen.width == this->anim_buf_width && _screen.height == this->anim_buf_height);
   295 
   296 
   296 	/* Never repaint the transparency pixel */
   297 	/* Never repaint the transparency pixel */
   297 	if (start == 0) start++;
   298 	if (start == 0) {
       
   299 		start++;
       
   300 		count--;
       
   301 	}
       
   302 
       
   303 	const uint8 *anim = this->anim_buf;
       
   304 	uint32 *dst = (uint32 *)_screen.dst_ptr;
   298 
   305 
   299 	/* Let's walk the anim buffer and try to find the pixels */
   306 	/* Let's walk the anim buffer and try to find the pixels */
   300 	for (int y = 0; y < this->anim_buf_height; y++) {
   307 	for (int y = this->anim_buf_height; y != 0 ; y--) {
   301 		for (int x = 0; x < this->anim_buf_width; x++) {
   308 		for (int x = this->anim_buf_width; x != 0 ; x--) {
   302 			if (*anim >= start && *anim <= start + count) {
   309 			uint colour = *anim;
       
   310 			if (IsInsideBS(colour, start, count)) {
   303 				/* Update this pixel */
   311 				/* Update this pixel */
   304 				this->SetPixel(_screen.dst_ptr, x, y, *anim);
   312 				*dst = LookupColourInPalette(colour);
   305 			}
   313 			}
       
   314 			dst++;
   306 			anim++;
   315 			anim++;
   307 		}
   316 		}
       
   317 		dst += _screen.pitch - _screen.width;
   308 	}
   318 	}
   309 
   319 
   310 	/* Make sure the backend redraws the whole screen */
   320 	/* Make sure the backend redraws the whole screen */
   311 	_video_driver->MakeDirty(0, 0, _screen.width, _screen.height);
   321 	_video_driver->MakeDirty(0, 0, _screen.width, _screen.height);
   312 }
   322 }