mirror of
https://github.com/libretro/gambatte-libretro.git
synced 2024-11-23 16:00:06 +00:00
Merge pull request #30 from askotx/master
Fixed on game reload and a custom palette was used, it was lost on reset...
This commit is contained in:
commit
a3d458036a
@ -123,7 +123,7 @@ void retro_set_environment(retro_environment_t cb)
|
||||
|
||||
static const struct retro_variable vars[] = {
|
||||
{ "gb_gbamode", "GBA mode; disabled|enabled" },
|
||||
{ "gb_colorization", "GB Colorization; disabled|enabled" },
|
||||
{ "gb_colorization", "GB Colorization; disabled|enabled|custom" },
|
||||
{ "gbc_color_correction", "Color correction; enabled|disabled" },
|
||||
{ NULL, NULL },
|
||||
};
|
||||
@ -211,7 +211,7 @@ static bool startswith(const std::string s1, const std::string prefix)
|
||||
return s1.compare(0, prefix.length(), prefix) == 0;
|
||||
}
|
||||
|
||||
static bool gb_colorization_enable = false;
|
||||
static int gb_colorization_enable = 0;
|
||||
|
||||
static std::string rom_path;
|
||||
char internal_game_name[17];
|
||||
@ -240,10 +240,10 @@ static void check_palette(void)
|
||||
palette_file.open(custom_palette_path.c_str());
|
||||
}
|
||||
|
||||
if (!palette_file.is_open() && !findGbcTitlePal(internal_game_name))
|
||||
if (!palette_file.is_open())// && !findGbcTitlePal(internal_game_name))
|
||||
{
|
||||
// try again with default.pal
|
||||
// only if no specific title palette from the GBC BIOS is found
|
||||
//- removed last line if colorization is enabled
|
||||
custom_palette_path = system_directory + "/palettes/" + "default.pal";
|
||||
palette_file.open(custom_palette_path.c_str());
|
||||
}
|
||||
@ -342,12 +342,14 @@ static void check_variables(void)
|
||||
return;
|
||||
|
||||
// else it is a GB-mono game -> set a color palette
|
||||
bool gb_colorization_old = gb_colorization_enable;
|
||||
//bool gb_colorization_old = gb_colorization_enable;
|
||||
|
||||
if (strcmp(var.value, "disabled") == 0)
|
||||
gb_colorization_enable = false;
|
||||
gb_colorization_enable = 0;
|
||||
else if (strcmp(var.value, "enabled") == 0)
|
||||
gb_colorization_enable = true;
|
||||
gb_colorization_enable = 1;
|
||||
else if (strcmp(var.value, "custom") == 0)
|
||||
gb_colorization_enable = 2;
|
||||
|
||||
//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.)
|
||||
@ -355,18 +357,27 @@ static void check_variables(void)
|
||||
// load a GBC BIOS builtin palette
|
||||
unsigned short* gbc_bios_palette = NULL;
|
||||
|
||||
if (gb_colorization_enable)
|
||||
{
|
||||
switch (gb_colorization_enable){
|
||||
case 1:
|
||||
gbc_bios_palette = const_cast<unsigned short*>(findGbcTitlePal(internal_game_name));
|
||||
if (!gbc_bios_palette)
|
||||
{
|
||||
// no custom palette found, load the default (blue)
|
||||
gbc_bios_palette = const_cast<unsigned short*>(findGbcDirPal("GBC - Blue"));
|
||||
}
|
||||
}
|
||||
else
|
||||
gbc_bios_palette = const_cast<unsigned short*>(findGbcDirPal("GBC - Grayscale"));
|
||||
break;
|
||||
|
||||
case 2:
|
||||
check_palette();
|
||||
break;
|
||||
|
||||
default:
|
||||
gbc_bios_palette = const_cast<unsigned short*>(findGbcDirPal("GBC - Grayscale"));
|
||||
break;
|
||||
}
|
||||
//gambatte is using custom colorization then we have a previously palette loaded,
|
||||
//skip this loop then
|
||||
if (gb_colorization_enable != 2){
|
||||
unsigned rgb32 = 0;
|
||||
for (unsigned palnum = 0; palnum < 3; ++palnum)
|
||||
{
|
||||
@ -376,6 +387,7 @@ static void check_variables(void)
|
||||
gb.setDmgPaletteColor(palnum, colornum, rgb32);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static unsigned pow2ceil(unsigned n) {
|
||||
@ -433,7 +445,7 @@ 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();
|
||||
//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();
|
||||
|
Loading…
Reference in New Issue
Block a user