diff --git a/libgambatte/include/gambatte.h b/libgambatte/include/gambatte.h index 3e4d0da..eb3abf2 100644 --- a/libgambatte/include/gambatte.h +++ b/libgambatte/include/gambatte.h @@ -107,6 +107,8 @@ private: GB(const GB &); GB & operator=(const GB &); }; + +video_pixel_t gbcToRgb32(const unsigned bgr15); } #endif diff --git a/libgambatte/libretro/gbcpalettes.h b/libgambatte/libretro/gbcpalettes.h index b423fec..6808c53 100644 --- a/libgambatte/libretro/gbcpalettes.h +++ b/libgambatte/libretro/gbcpalettes.h @@ -495,12 +495,4 @@ static const unsigned short * findGbcPal(const char *const title) { return findGbcTitlePal(title); } -static unsigned long gbcToRgb32(const unsigned rgb15) { - const unsigned long r = rgb15 >> 10 & 0x1F; - const unsigned long g = rgb15 >> 5 & 0x1F; - const unsigned long b = rgb15 & 0x1F; - - return ((r * 13 + g * 2 + b) >> 1) << 16 | (g * 3 + b) << 9 | (r * 3 + g * 2 + b * 11) >> 1; -} - } diff --git a/libgambatte/libretro/libretro.cpp b/libgambatte/libretro/libretro.cpp index 79b07cf..7416461 100644 --- a/libgambatte/libretro/libretro.cpp +++ b/libgambatte/libretro/libretro.cpp @@ -1,8 +1,7 @@ #include "libretro.h" #include "blipper.h" -#include "gbcpalettes.h" - #include +#include "gbcpalettes.h" #include #include @@ -256,6 +255,11 @@ static void check_palette(void) fprintf(stderr, "[Gambatte]: unable to read palette color in %s, line %d (color left as default).\n", custom_palette_path.c_str(), line_count); continue; } +#ifdef VIDEO_RGB565 + rgb32=(rgb32&0x0000F8)>>3 |//red + (rgb32&0x00FC00)>>5 |//green + (rgb32&0xF80000)>>8;//blue +#endif if (startswith(line, "Background0=")) gb.setDmgPaletteColor(0, 0, rgb32); @@ -328,7 +332,7 @@ static void check_variables(void) { for (unsigned colornum = 0; colornum < 4; ++colornum) { - rgb32 = gbcToRgb32(gbc_bios_palette[palnum * 4 + colornum]); + rgb32 = gambatte::gbcToRgb32(gbc_bios_palette[palnum * 4 + colornum]); gb.setDmgPaletteColor(palnum, colornum, rgb32); } } diff --git a/libgambatte/src/video.cpp b/libgambatte/src/video.cpp index d07cd93..b33d2df 100644 --- a/libgambatte/src/video.cpp +++ b/libgambatte/src/video.cpp @@ -30,7 +30,7 @@ void LCD::setDmgPalette(video_pixel_t *const palette, const video_pixel_t *const palette[3] = dmgColors[data >> 6 & 3]; } -static video_pixel_t gbcToRgb32(const unsigned bgr15) { +video_pixel_t gbcToRgb32(const unsigned bgr15) { #ifdef VIDEO_RGB565 //If (whatever made the Gambatte devs create this somewhat arcane configuration) is not a concern, it can be replaced with simply 'return bgr15'. const unsigned r = bgr15 & 0x1F;