From 2440cd51916351d714dbbc8d7f612bba4efddf54 Mon Sep 17 00:00:00 2001 From: "simon.kagstrom" Date: Mon, 4 May 2009 15:54:02 +0000 Subject: [PATCH] Make sure the palette values does not overflow --- SDL/src/video/wii/SDL_wiivideo.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/SDL/src/video/wii/SDL_wiivideo.c b/SDL/src/video/wii/SDL_wiivideo.c index ae47b2c..0a684fd 100644 --- a/SDL/src/video/wii/SDL_wiivideo.c +++ b/SDL/src/video/wii/SDL_wiivideo.c @@ -577,11 +577,11 @@ int WII_SetColors(_THIS, int first_color, int color_count, SDL_Color *colors) for (component = first_color; component != last_color; ++component) { const SDL_Color* const in = &colors[component - first_color]; - const unsigned int r = in->r; - const unsigned int g = in->g; - const unsigned int b = in->b; + const unsigned int r = (in->r >> 3) & 0x1f; + const unsigned int g = (in->g >> 2) & 0x3f; + const unsigned int b = (in->b >> 3) & 0x1f; - palette[component] = ((r >> 3) << 11) | ((g >> 2) << 5) | (b >> 3); + palette[component] = (r << 11) | (g << 5) | b; } return(1);