mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 05:35:02 -05:00
rockboy: fix wrong colors on some targets
This bug was found and located by a forum user, see https://forums.rockbox.org/index.php/topic,54776.0.html The old code used the FB_SCALARPACK macro which doesn't respect swapped byte order. Using FB_RGBPACK fixes it and furthermore makes the fb.cc[] array superfluous. I added a small optimization for 16 bit targets, since the gameboy colors almost fit perfectly (5 bit per color). Change-Id: If96b3943cb4ab902b880ff3d471add25e138fe8e
This commit is contained in:
parent
e0cc87fd3f
commit
5e7a4290b2
3 changed files with 14 additions and 33 deletions
|
|
@ -10,12 +10,7 @@
|
||||||
|
|
||||||
struct fb
|
struct fb
|
||||||
{
|
{
|
||||||
#ifdef HAVE_LCD_COLOR
|
#ifndef HAVE_LCD_COLOR
|
||||||
struct
|
|
||||||
{
|
|
||||||
int l, r;
|
|
||||||
} cc[3];
|
|
||||||
#else
|
|
||||||
int mode;
|
int mode;
|
||||||
#endif
|
#endif
|
||||||
int enabled;
|
int enabled;
|
||||||
|
|
|
||||||
|
|
@ -1020,21 +1020,23 @@ static void updatepalette(int i)
|
||||||
fb_data px;
|
fb_data px;
|
||||||
|
|
||||||
c = (lcd.pal[i<<1] | ((int)lcd.pal[(i<<1)|1] << 8)) & 0x7FFF;
|
c = (lcd.pal[i<<1] | ((int)lcd.pal[(i<<1)|1] << 8)) & 0x7FFF;
|
||||||
|
#if LCD_PIXELFORMAT == RGB565 || LCD_PIXELFORMAT == RGB565SWAPPED
|
||||||
|
/* extract color channels to 5 bit red and blue, and 6 bit green */
|
||||||
|
r = c & 0x001F;
|
||||||
|
g = (c & 0x03E0) >> 4;
|
||||||
|
b = c >> 10;
|
||||||
|
g |= (g >> 5);
|
||||||
|
px = FB_RGBPACK_LCD(r, g, b);
|
||||||
|
#else
|
||||||
|
/* extract color channels and normalize to 8-bit */
|
||||||
r = (c & 0x001F) << 3;
|
r = (c & 0x001F) << 3;
|
||||||
g = (c & 0x03E0) >> 2;
|
g = (c & 0x03E0) >> 2;
|
||||||
b = (c & 0x7C00) >> 7;
|
b = c >> 7;
|
||||||
r |= (r >> 5);
|
r |= (r >> 5);
|
||||||
g |= (g >> 5);
|
g |= (g >> 5);
|
||||||
b |= (b >> 5);
|
b |= (b >> 5);
|
||||||
|
px = FB_RGBPACK(r, g, b);
|
||||||
r = (r >> fb.cc[0].r) << fb.cc[0].l;
|
#endif
|
||||||
g = (g >> fb.cc[1].r) << fb.cc[1].l;
|
|
||||||
b = (b >> fb.cc[2].r) << fb.cc[2].l;
|
|
||||||
|
|
||||||
c = r|g|b;
|
|
||||||
|
|
||||||
px = FB_SCALARPACK_LCD(c);
|
|
||||||
|
|
||||||
/* updatepalette might get called, but the pallete does not necessarily
|
/* updatepalette might get called, but the pallete does not necessarily
|
||||||
* need to be updated.
|
* need to be updated.
|
||||||
*/
|
*/
|
||||||
|
|
|
||||||
|
|
@ -255,23 +255,7 @@ void vid_init(void)
|
||||||
{
|
{
|
||||||
fb.enabled=1;
|
fb.enabled=1;
|
||||||
|
|
||||||
#if defined(HAVE_LCD_COLOR)
|
#if !defined(HAVE_LCD_COLOR)
|
||||||
#if LCD_DEPTH >= 24
|
|
||||||
fb.cc[0].r = 0; /* 8-8 (wasted bits on red) */
|
|
||||||
fb.cc[0].l = 16; /* this is the offset to the R bits (24-8) */
|
|
||||||
fb.cc[1].r = 0; /* 8-6 (wasted bits on green) */
|
|
||||||
fb.cc[1].l = 8; /* This is the offset to the G bits (24-8-8) */
|
|
||||||
fb.cc[2].r = 0; /* 8-5 (wasted bits on red) */
|
|
||||||
fb.cc[2].l = 0; /* This is the offset to the B bits (24-8-8-8) */
|
|
||||||
#else
|
|
||||||
fb.cc[0].r = 3; /* 8-5 (wasted bits on red) */
|
|
||||||
fb.cc[0].l = 11; /* this is the offset to the R bits (16-5) */
|
|
||||||
fb.cc[1].r = 2; /* 8-6 (wasted bits on green) */
|
|
||||||
fb.cc[1].l = 5; /* This is the offset to the G bits (16-5-6) */
|
|
||||||
fb.cc[2].r = 3; /* 8-5 (wasted bits on red) */
|
|
||||||
fb.cc[2].l = 0; /* This is the offset to the B bits (16-5-6-5) */
|
|
||||||
#endif
|
|
||||||
#else
|
|
||||||
fb.mode=3;
|
fb.mode=3;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue