Changeset - r6988:8026972849a3
[Not reviewed]
master
0 3 0
truelight - 17 years ago 2007-06-21 13:31:41
truelight@openttd.org
(svn r10244) -Fix: make sure to let 32bpp-anim report the increased buffer-size it needs
3 files changed with 7 insertions and 1 deletions:
0 comments (0 inline, 0 general)
src/blitter/32bpp_anim.cpp
Show inline comments
 
@@ -223,48 +223,53 @@ void Blitter_32bppAnim::ScrollBuffer(voi
 
		}
 
	} else {
 
		/* Calculate pointers */
 
		dst = this->anim_buf + left + top * this->anim_buf_width;
 
		src = dst - scroll_y * this->anim_buf_width;
 

	
 
		/* Adjust left & width */
 
		if (scroll_x >= 0) dst += scroll_x;
 
		else               src -= scroll_x;
 

	
 
		/* the y-displacement may be 0 therefore we have to use memmove,
 
		 * because source and destination may overlap */
 
		uint tw = width + (scroll_x >= 0 ? -scroll_x : scroll_x);
 
		uint th = height + scroll_y;
 
		for (; th > 0; th--) {
 
			memmove(dst, src, tw * sizeof(uint8));
 
			src += this->anim_buf_width;
 
			dst += this->anim_buf_width;
 
		}
 
	}
 

	
 
	Blitter_32bppBase::ScrollBuffer(video, left, top, width, height, scroll_x, scroll_y);
 
}
 

	
 
int Blitter_32bppAnim::BufferSize(int width, int height)
 
{
 
	return width * height * (sizeof(uint32) + sizeof(uint8));
 
}
 

	
 
void Blitter_32bppAnim::PaletteAnimate(uint start, uint count)
 
{
 
	uint8 *anim = this->anim_buf;
 

	
 
	/* Never repaint the transparency pixel */
 
	if (start == 0) start++;
 

	
 
	/* Let's walk the anim buffer and try to find the pixels */
 
	for (int y = 0; y < this->anim_buf_height; y++) {
 
		for (int x = 0; x < this->anim_buf_width; x++) {
 
			if (*anim >= start && *anim <= start + count) {
 
				/* Update this pixel */
 
				this->SetPixel(_screen.dst_ptr, x, y, *anim);
 
			}
 
			anim++;
 
		}
 
	}
 

	
 
	/* Make sure the backend redraws the whole screen */
 
	_video_driver->make_dirty(0, 0, _screen.width, _screen.height);
 
}
 

	
 
Blitter::PaletteAnimation Blitter_32bppAnim::UsePaletteAnimation()
 
{
src/blitter/32bpp_anim.hpp
Show inline comments
 
@@ -8,36 +8,37 @@
 
#include "32bpp_simple.hpp"
 
#include "factory.hpp"
 

	
 
class Blitter_32bppAnim : public Blitter_32bppSimple {
 
private:
 
	uint8 *anim_buf; ///< In this buffer we keep track of the 8bpp indexes so we can do palette animation
 
	int anim_buf_width;
 
	int anim_buf_height;
 

	
 
public:
 
	Blitter_32bppAnim() :
 
		anim_buf(NULL),
 
		anim_buf_width(0),
 
		anim_buf_height(0)
 
	{}
 

	
 
	/* virtual */ void Draw(Blitter::BlitterParams *bp, BlitterMode mode, ZoomLevel zoom);
 
	/* virtual */ void DrawColorMappingRect(void *dst, int width, int height, int pal);
 
	/* virtual */ void SetPixel(void *video, int x, int y, uint8 color);
 
	/* virtual */ void SetPixelIfEmpty(void *video, int x, int y, uint8 color);
 
	/* virtual */ void DrawRect(void *video, int width, int height, uint8 color);
 
	/* virtual */ void CopyFromBuffer(void *video, const void *src, int width, int height);
 
	/* virtual */ void CopyToBuffer(const void *video, void *dst, int width, int height);
 
	/* virtual */ void ScrollBuffer(void *video, int &left, int &top, int &width, int &height, int scroll_x, int scroll_y);
 
	/* virtual */ int BufferSize(int width, int height);
 
	/* virtual */ void PaletteAnimate(uint start, uint count);
 
	/* virtual */ Blitter::PaletteAnimation UsePaletteAnimation();
 
};
 

	
 
class FBlitter_32bppAnim: public BlitterFactory<FBlitter_32bppAnim> {
 
public:
 
	/* virtual */ const char *GetName() { return "32bpp-anim"; }
 
	/* virtual */ const char *GetDescription() { return "32bpp Animation Blitter (palette animation)"; }
 
	/* virtual */ Blitter *CreateInstance() { return new Blitter_32bppAnim(); }
 
};
 

	
 
#endif /* BLITTER_32BPP_ANIM_HPP */
src/texteff.cpp
Show inline comments
 
@@ -34,49 +34,49 @@ struct TextEffect {
 
	int32 right;
 
	int32 bottom;
 
	uint16 duration;
 
	uint32 params_1;
 
	uint32 params_2;
 
};
 

	
 

	
 
struct TextMessage {
 
	char message[MAX_TEXTMESSAGE_LENGTH];
 
	uint16 color;
 
	Date end_date;
 
};
 

	
 
static TextEffect _text_effect_list[MAX_TEXT_MESSAGES];
 
static TextMessage _textmsg_list[MAX_CHAT_MESSAGES];
 
TileIndex _animated_tile_list[MAX_ANIMATED_TILES];
 

	
 
static bool _textmessage_dirty = false;
 
static bool _textmessage_visible = false;
 

	
 
/* The chatbox grows from the bottom so the coordinates are pixels from
 
 * the left and pixels from the bottom. The height is the maximum height */
 
static const Oblong _textmsg_box = {10, 30, 500, 150};
 
static uint8 _textmessage_backup[150 * 500 * 5]; // (height * width)
 
static uint8 _textmessage_backup[150 * 500 * 6]; // (height * width)
 

	
 
static inline uint GetTextMessageCount()
 
{
 
	uint i;
 

	
 
	for (i = 0; i < MAX_CHAT_MESSAGES; i++) {
 
		if (_textmsg_list[i].message[0] == '\0') break;
 
	}
 

	
 
	return i;
 
}
 

	
 
/* Add a text message to the 'chat window' to be shown
 
 * @param color The colour this message is to be shown in
 
 * @param duration The duration of the chat message in game-days
 
 * @param message message itself in printf() style */
 
void CDECL AddTextMessage(uint16 color, uint8 duration, const char *message, ...)
 
{
 
	char buf[MAX_TEXTMESSAGE_LENGTH];
 
	const char *bufp;
 
	va_list va;
 
	uint msg_count;
 
	uint16 lines;
 

	
0 comments (0 inline, 0 general)