(svn r2534) Small cleanup
This commit is contained in:
		
							
								
								
									
										32
									
								
								gfx.c
									
									
									
									
									
								
							
							
						
						
									
										32
									
								
								gfx.c
									
									
									
									
									
								
							@@ -1659,28 +1659,33 @@ void RedrawScreenRect(int left, int top, int right, int bottom)
 | 
				
			|||||||
void DrawDirtyBlocks(void)
 | 
					void DrawDirtyBlocks(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	byte *b = _dirty_blocks;
 | 
						byte *b = _dirty_blocks;
 | 
				
			||||||
	int x = 0;
 | 
					 | 
				
			||||||
	int y = 0;
 | 
					 | 
				
			||||||
	const int w = (_screen.width + 63) & ~63;
 | 
						const int w = (_screen.width + 63) & ~63;
 | 
				
			||||||
	const int h = (_screen.height + 7) & ~7;
 | 
						const int h = (_screen.height + 7) & ~7;
 | 
				
			||||||
 | 
						int x;
 | 
				
			||||||
 | 
						int y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						y = 0;
 | 
				
			||||||
 | 
						do {
 | 
				
			||||||
 | 
							x = 0;
 | 
				
			||||||
		do {
 | 
							do {
 | 
				
			||||||
			if (*b != 0) {
 | 
								if (*b != 0) {
 | 
				
			||||||
			int left,top;
 | 
									int left;
 | 
				
			||||||
 | 
									int top;
 | 
				
			||||||
				int right = x + 64;
 | 
									int right = x + 64;
 | 
				
			||||||
				int bottom = y;
 | 
									int bottom = y;
 | 
				
			||||||
				byte *p = b;
 | 
									byte *p = b;
 | 
				
			||||||
				int h2;
 | 
									int h2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// First try coalescing downwards
 | 
									// First try coalescing downwards
 | 
				
			||||||
				do {
 | 
									do {
 | 
				
			||||||
					*p = 0;
 | 
										*p = 0;
 | 
				
			||||||
					p += DIRTY_BYTES_PER_LINE;
 | 
										p += DIRTY_BYTES_PER_LINE;
 | 
				
			||||||
					bottom += 8;
 | 
										bottom += 8;
 | 
				
			||||||
			} while (bottom != h && *p);
 | 
									} while (bottom != h && *p != 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				// Try coalescing to the right too.
 | 
									// Try coalescing to the right too.
 | 
				
			||||||
				h2 = (bottom - y) >> 3;
 | 
									h2 = (bottom - y) >> 3;
 | 
				
			||||||
			assert(h2>0);
 | 
									assert(h2 > 0);
 | 
				
			||||||
				p = b;
 | 
									p = b;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				while (right != w) {
 | 
									while (right != w) {
 | 
				
			||||||
@@ -1690,7 +1695,7 @@ void DrawDirtyBlocks(void)
 | 
				
			|||||||
					do {
 | 
										do {
 | 
				
			||||||
						if (!*p2) goto no_more_coalesc;
 | 
											if (!*p2) goto no_more_coalesc;
 | 
				
			||||||
						p2 += DIRTY_BYTES_PER_LINE;
 | 
											p2 += DIRTY_BYTES_PER_LINE;
 | 
				
			||||||
				} while (--h);
 | 
										} while (--h != 0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
					// Wohoo, can combine it one step to the right!
 | 
										// Wohoo, can combine it one step to the right!
 | 
				
			||||||
					// Do that, and clear the bits.
 | 
										// Do that, and clear the bits.
 | 
				
			||||||
@@ -1701,24 +1706,25 @@ void DrawDirtyBlocks(void)
 | 
				
			|||||||
					do {
 | 
										do {
 | 
				
			||||||
						*p2 = 0;
 | 
											*p2 = 0;
 | 
				
			||||||
						p2 += DIRTY_BYTES_PER_LINE;
 | 
											p2 += DIRTY_BYTES_PER_LINE;
 | 
				
			||||||
				} while (--h);
 | 
										} while (--h != 0);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			no_more_coalesc:;
 | 
									no_more_coalesc:
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				left = x;
 | 
									left = x;
 | 
				
			||||||
				top = y;
 | 
									top = y;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			if (left < _invalid_rect.left)left = _invalid_rect.left;
 | 
									if (left   < _invalid_rect.left  ) left   = _invalid_rect.left;
 | 
				
			||||||
			if (top < _invalid_rect.top)	top = _invalid_rect.top;
 | 
									if (top    < _invalid_rect.top   ) top    = _invalid_rect.top;
 | 
				
			||||||
			if (right > _invalid_rect.right)right = _invalid_rect.right;
 | 
									if (right  > _invalid_rect.right ) right  = _invalid_rect.right;
 | 
				
			||||||
			if (bottom > _invalid_rect.bottom)bottom = _invalid_rect.bottom;
 | 
									if (bottom > _invalid_rect.bottom) bottom = _invalid_rect.bottom;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
				if (left < right && top < bottom) {
 | 
									if (left < right && top < bottom) {
 | 
				
			||||||
					RedrawScreenRect(left, top, right, bottom);
 | 
										RedrawScreenRect(left, top, right, bottom);
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
	} while (b++, (x+=64) != w || (x=0,b+=-(w>>6)+DIRTY_BYTES_PER_LINE,(y+=8) != h));
 | 
							} while (b++, (x += 64) != w);
 | 
				
			||||||
 | 
						} while (b += -(w >> 6) + DIRTY_BYTES_PER_LINE, (y += 8) != h);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	_invalid_rect.left = w;
 | 
						_invalid_rect.left = w;
 | 
				
			||||||
	_invalid_rect.top = h;
 | 
						_invalid_rect.top = h;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
#define M(r, g, b) { r, g, b }
 | 
					#define M(r, g, b) { r, g, b }
 | 
				
			||||||
static Colour _palettes[][256] = {
 | 
					static const Colour _palettes[][256] = {
 | 
				
			||||||
	/* palette 1 (TTD Windows) */
 | 
						/* palette 1 (TTD Windows) */
 | 
				
			||||||
	{
 | 
						{
 | 
				
			||||||
		M(  0,   0,   0), M(212,   0, 212), M(212,   0, 212), M(212,   0, 212),
 | 
							M(  0,   0,   0), M(212,   0, 212), M(212,   0, 212), M(212,   0, 212),
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user