Changeset - r2226:707d4149e087
[Not reviewed]
master
0 1 0
tron - 19 years ago 2005-07-29 10:16:49
tron@openttd.org
(svn r2746) -Fix: SDL_SetColors() has the number of palette entries to change as parameter, not one beyond the last entry to change
1 file changed with 8 insertions and 9 deletions:
0 comments (0 inline, 0 general)
video/sdl_v.c
Show inline comments
 
@@ -13,73 +13,72 @@
 
#include "../window.h"
 
#include "../network.h"
 
#include "../variables.h"
 
#include "sdl_v.h"
 
#include <SDL.h>
 

	
 
static SDL_Surface *_sdl_screen;
 
static bool _all_modes;
 

	
 
#define MAX_DIRTY_RECTS 100
 
static SDL_Rect _dirty_rects[MAX_DIRTY_RECTS];
 
static int _num_dirty_rects;
 

	
 
static void SdlVideoMakeDirty(int left, int top, int width, int height)
 
{
 
	if (_num_dirty_rects < MAX_DIRTY_RECTS) {
 
		_dirty_rects[_num_dirty_rects].x = left;
 
		_dirty_rects[_num_dirty_rects].y = top;
 
		_dirty_rects[_num_dirty_rects].w = width;
 
		_dirty_rects[_num_dirty_rects].h = height;
 
	}
 
	_num_dirty_rects++;
 
}
 

	
 
static SDL_Color pal[256];
 

	
 
static void UpdatePalette(uint start, uint end)
 
static void UpdatePalette(uint start, uint count)
 
{
 
	SDL_Color pal[256];
 
	uint i;
 

	
 
	for (i = start; i != end; i++) {
 
		pal[i].r = _cur_palette[i].r;
 
		pal[i].g = _cur_palette[i].g;
 
		pal[i].b = _cur_palette[i].b;
 
	for (i = 0; i != count; i++) {
 
		pal[i].r = _cur_palette[start + i].r;
 
		pal[i].g = _cur_palette[start + i].g;
 
		pal[i].b = _cur_palette[start + i].b;
 
		pal[i].unused = 0;
 
	}
 

	
 
	SDL_CALL SDL_SetColors(_sdl_screen, pal, start, end);
 
	SDL_CALL SDL_SetColors(_sdl_screen, pal, start, count);
 
}
 

	
 
static void InitPalette(void)
 
{
 
	UpdatePalette(0, 256);
 
}
 

	
 
static void CheckPaletteAnim(void)
 
{
 
	if(_pal_last_dirty != -1) {
 
		UpdatePalette(_pal_first_dirty, _pal_last_dirty + 1);
 
		UpdatePalette(_pal_first_dirty, _pal_last_dirty - _pal_first_dirty + 1);
 
		_pal_last_dirty = -1;
 
	}
 
}
 

	
 
static void DrawSurfaceToScreen(void)
 
{
 
	int n = _num_dirty_rects;
 
	if (n != 0) {
 
		_num_dirty_rects = 0;
 
		if (n > MAX_DIRTY_RECTS)
 
			SDL_CALL SDL_UpdateRect(_sdl_screen, 0, 0, 0, 0);
 
		else
 
			SDL_CALL SDL_UpdateRects(_sdl_screen, n, _dirty_rects);
 
	}
 
}
 

	
 
static const uint16 default_resolutions[][2] = {
 
	{ 640,  480},
 
	{ 800,  600},
 
	{1024,  768},
 
	{1152,  864},
 
	{1280,  800},
 
	{1280,  960},
 
	{1280, 1024},
0 comments (0 inline, 0 general)