libretro: Add colour adjustment core options

This commit is contained in:
Rupert Carmichael 2024-06-15 11:09:50 -04:00
parent df246532d8
commit 87ca842eb9
4 changed files with 112 additions and 5 deletions

View File

@ -465,6 +465,33 @@ static void update_variables(void)
}
}
var.key = "bsnes_video_luminance";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
{
int val = atoi(var.value);
program->luminance = val / 100.0;
}
var.key = "bsnes_video_saturation";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
{
int val = atoi(var.value);
program->saturation = val / 100.0;
}
var.key = "bsnes_video_gamma";
var.value = NULL;
if (environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var))
{
int val = atoi(var.value);
program->gamma = val / 100.0;
}
update_option_visibility();
}
@ -763,6 +790,7 @@ void retro_run()
{
update_variables();
update_geometry();
program->updateVideoPalette();
}
bool is_fast_forwarding = false;

View File

@ -153,6 +153,85 @@ struct retro_core_option_v2_definition option_defs_us[] = {
},
"None"
},
{
"bsnes_video_luminance",
"Color Adjustment - Luminance",
NULL,
"Adjust Luminance",
NULL,
"video",
{
{ "0", "0%" },
{ "10", "10%" },
{ "20", "20%" },
{ "30", "30%" },
{ "40", "40%" },
{ "50", "50%" },
{ "60", "60%" },
{ "70", "70%" },
{ "80", "80%" },
{ "90", "90%" },
{ "100", "100% (Default)" },
{ NULL, NULL },
},
"100"
},
{
"bsnes_video_saturation",
"Color Adjustment - Saturation",
NULL,
"Adjust Saturation",
NULL,
"video",
{
{ "0", "0%" },
{ "10", "10%" },
{ "20", "20%" },
{ "30", "30%" },
{ "40", "40%" },
{ "50", "50%" },
{ "60", "60%" },
{ "70", "70%" },
{ "80", "80%" },
{ "90", "90%" },
{ "100", "100% (Default)" },
{ "110", "110%" },
{ "120", "120%" },
{ "130", "130%" },
{ "140", "140%" },
{ "150", "150%" },
{ "160", "160%" },
{ "170", "170%" },
{ "180", "180%" },
{ "190", "190%" },
{ "200", "200%" },
{ NULL, NULL },
},
"100"
},
{
"bsnes_video_gamma",
"Color Adjustment - Gamma",
NULL,
"Adjust Gamma",
NULL,
"video",
{
{ "100", "100%" },
{ "110", "110%" },
{ "120", "120%" },
{ "130", "130%" },
{ "140", "140%" },
{ "150", "150% (Default)" },
{ "160", "160%" },
{ "170", "170%" },
{ "180", "180%" },
{ "190", "190%" },
{ "200", "200%" },
{ NULL, NULL },
},
"150"
},
{
"bsnes_ppu_fast",
"PPU (Video) - Fast Mode",

View File

@ -808,10 +808,6 @@ auto Program::hackPatchMemory(vector<uint8_t>& data) -> void
}
auto Program::updateVideoPalette() -> void {
double luminance = 100.0 / 100.0;
double saturation = 100.0 / 100.0;
double gamma = 150.0 / 100.0;
uint depth = 24;
for(uint color : range(32768)) {

View File

@ -40,7 +40,7 @@ struct Program : Emulator::Platform
string base_name;
bool overscan = false;
bool overscan{false};
public:
struct Game {
@ -77,4 +77,8 @@ public:
Filter::Render filterRender;
Filter::Size filterSize;
double luminance{1.0};
double saturation{1.0};
double gamma{1.5};
};