Merge pull request #42 from netux79/master

Expose Internal Palettes
This commit is contained in:
Twinaphex 2015-07-05 11:24:12 +02:00
commit 8f04c9188e
2 changed files with 40 additions and 6 deletions

View File

@ -333,6 +333,25 @@ static const unsigned short p51C[] = {
PACK15_4(0xFFFFFF, 0x63A5FF, 0x0000FF, 0x000000)
};
// Extra palettes
static const unsigned short pExt1[] = {
PACK15_4(0xE5EA93, 0xC4C641, 0x5E7C39, 0x21442A),
PACK15_4(0xE5EA93, 0xC4C641, 0x5E7C39, 0x21442A),
PACK15_4(0xE5EA93, 0xC4C641, 0x5E7C39, 0x21442A)
};
static const unsigned short pExt2[] = {
PACK15_4(0xF8F8F8, 0x83C656, 0x187890, 0x000000),
PACK15_4(0xF8F8F8, 0xE18096, 0x7F3848, 0x000000),
PACK15_4(0xF8F8F8, 0xFFDA03, 0x958401, 0x000000)
};
static const unsigned short pExt3[] = {
PACK15_4(0xF8F8F8, 0xA59E8C, 0x49726C, 0x000000),
PACK15_4(0xF8F8F8, 0xE49685, 0x6E241E, 0x000000),
PACK15_4(0xF8F8F8, 0xD7543C, 0x7D3023, 0x000000)
};
#undef PACK15_4
#undef PACK15_1
#undef TO5BIT
@ -352,6 +371,9 @@ static const GbcPaletteEntry gbcDirPalettes[] = {
{ "GBC - Pastel Mix", p017 },
{ "GBC - Red", p510 },
{ "GBC - Yellow", p51A },
{ "Special 1", pExt1 },
{ "Special 2", pExt2 },
{ "Special 3", pExt3 },
};
static const GbcPaletteEntry gbcTitlePalettes[] = {

View File

@ -147,7 +147,8 @@ void retro_set_environment(retro_environment_t cb)
environ_cb = cb;
static const struct retro_variable vars[] = {
{ "gambatte_gb_colorization", "GB Colorization; disabled|enabled|custom" },
{ "gambatte_gb_colorization", "GB Colorization; disabled|auto|internal|custom" },
{ "gambatte_gb_internal_palette", "Internal Palette; GBC - Blue|GBC - Brown|GBC - Dark Blue|GBC - Dark Brown|GBC - Dark Green|GBC - Grayscale|GBC - Green|GBC - Inverted|GBC - Orange|GBC - Pastel Mix|GBC - Red|GBC - Yellow|Special 1|Special 2|Special 3" },
{ "gambatte_gbc_color_correction", "Color correction; enabled|disabled" },
{ "gambatte_gb_hwmode", "Emulated hardware; Auto|GB|GBA" }, // unfortunately, libgambatte does not have a 'force GBC' flag
{ NULL, NULL },
@ -252,7 +253,7 @@ static int gb_colorization_enable = 0;
static std::string rom_path;
char internal_game_name[17];
static void check_palette(void)
static void load_custom_palette(void)
{
unsigned rgb32 = 0;
@ -377,10 +378,12 @@ static void check_variables(void)
if (strcmp(var.value, "disabled") == 0)
gb_colorization_enable = 0;
else if (strcmp(var.value, "enabled") == 0)
else if (strcmp(var.value, "auto") == 0)
gb_colorization_enable = 1;
else if (strcmp(var.value, "custom") == 0)
gb_colorization_enable = 2;
else if (strcmp(var.value, "internal") == 0)
gb_colorization_enable = 3;
//std::string internal_game_name = gb.romTitle(); // available only in latest Gambatte
//std::string internal_game_name = reinterpret_cast<const char *>(info->data + 0x134); // buggy with some games ("YOSSY NO COOKIE", "YOSSY NO PANEPON, etc.)
@ -400,7 +403,16 @@ static void check_variables(void)
break;
case 2:
check_palette();
load_custom_palette();
break;
case 3:
var.key = "gambatte_gb_internal_palette";
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var) && var.value)
{
// Load the selected internal palette
gbc_bios_palette = const_cast<unsigned short*>(findGbcDirPal(var.value));
}
break;
default:
@ -409,7 +421,8 @@ static void check_variables(void)
}
//gambatte is using custom colorization then we have a previously palette loaded,
//skip this loop then
if (gb_colorization_enable != 2){
if (gb_colorization_enable != 2)
{
unsigned rgb32 = 0;
for (unsigned palnum = 0; palnum < 3; ++palnum)
{
@ -493,7 +506,6 @@ bool retro_load_game(const struct retro_game_info *info)
log_cb(RETRO_LOG_INFO, "[Gambatte]: Got internal game name: %s.\n", internal_game_name);
check_variables();
//check_palette();
//Ugly hack alert: This entire thing depends upon cartridge.cpp and memptrs.cpp not changing in weird ways.
unsigned sramsize = gb.savedata_size();