Add "Harsh Reality" color correction mode

This commit is contained in:
Lior Halphon 2021-06-25 19:57:56 +03:00
parent a2d34c9bd9
commit 94add1d172
6 changed files with 31 additions and 8 deletions

View File

@ -171,6 +171,7 @@
<menuItem title="Emulate hardware" id="XBL-hS-7ke"/>
<menuItem title="Preserve brightness" id="tlx-WB-Bkw"/>
<menuItem title="Reduce contrast" id="wuO-Xv-0mQ"/>
<menuItem title="Harsh reality (low contrast)" id="98I-hs-vP2"/>
</items>
</menu>
</popUpButtonCell>

View File

@ -292,12 +292,24 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border)
new_r = new_r * 7 / 8 + ( g + b) / 16;
new_g = new_g * 7 / 8 + (r + b) / 16;
new_b = new_b * 7 / 8 + (r + g ) / 16;
new_r = new_r * (224 - 32) / 255 + 32;
new_g = new_g * (220 - 36) / 255 + 36;
new_b = new_b * (216 - 40) / 255 + 40;
}
else if (gb->color_correction_mode == GB_COLOR_CORRECTION_LOW_CONTRAST) {
r = new_r;
g = new_r;
b = new_r;
new_r = new_r * 7 / 8 + ( g + b) / 16;
new_g = new_g * 7 / 8 + (r + b) / 16;
new_b = new_b * 7 / 8 + (r + g ) / 16;
new_r = new_r * (162 - 67) / 255 + 67;
new_g = new_g * (167 - 62) / 255 + 62;
new_b = new_b * (157 - 58) / 255 + 58;
}
else if (gb->color_correction_mode == GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS) {
uint8_t old_max = MAX(r, MAX(g, b));
uint8_t new_max = MAX(new_r, MAX(new_g, new_b));

View File

@ -51,6 +51,7 @@ typedef enum {
GB_COLOR_CORRECTION_EMULATE_HARDWARE,
GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS,
GB_COLOR_CORRECTION_REDUCE_CONTRAST,
GB_COLOR_CORRECTION_LOW_CONTRAST,
} GB_color_correction_mode_t;
void GB_draw_tileset(GB_gameboy_t *gb, uint32_t *dest, GB_palette_type_t palette_type, uint8_t palette_index);

View File

@ -549,7 +549,7 @@ const char *current_default_scale(unsigned index)
const char *current_color_correction_mode(unsigned index)
{
return (const char *[]){"Disabled", "Correct Color Curves", "Emulate Hardware", "Preserve Brightness", "Reduce Contrast"}
return (const char *[]){"Disabled", "Correct Color Curves", "Emulate Hardware", "Preserve Brightness", "Reduce Contrast", "Harsh Reality"}
[configuration.color_correction_mode];
}
@ -624,7 +624,7 @@ void cycle_default_scale_backwards(unsigned index)
static void cycle_color_correction(unsigned index)
{
if (configuration.color_correction_mode == GB_COLOR_CORRECTION_REDUCE_CONTRAST) {
if (configuration.color_correction_mode == GB_COLOR_CORRECTION_LOW_CONTRAST) {
configuration.color_correction_mode = GB_COLOR_CORRECTION_DISABLED;
}
else {
@ -635,7 +635,7 @@ static void cycle_color_correction(unsigned index)
static void cycle_color_correction_backwards(unsigned index)
{
if (configuration.color_correction_mode == GB_COLOR_CORRECTION_DISABLED) {
configuration.color_correction_mode = GB_COLOR_CORRECTION_REDUCE_CONTRAST;
configuration.color_correction_mode = GB_COLOR_CORRECTION_LOW_CONTRAST;
}
else {
configuration.color_correction_mode--;

View File

@ -719,7 +719,7 @@ int main(int argc, char **argv)
fclose(prefs_file);
/* Sanitize for stability */
configuration.color_correction_mode %= GB_COLOR_CORRECTION_REDUCE_CONTRAST +1;
configuration.color_correction_mode %= GB_COLOR_CORRECTION_LOW_CONTRAST +1;
configuration.scaling_mode %= GB_SDL_SCALING_MAX;
configuration.default_scale %= GB_SDL_DEFAULT_SCALE_MAX + 1;
configuration.blending_mode %= GB_FRAME_BLENDING_MODE_ACCURATE + 1;

View File

@ -232,7 +232,7 @@ static retro_environment_t environ_cb;
/* variables for single cart mode */
static const struct retro_variable vars_single[] = {
{ "sameboy_color_correction_mode", "Color correction; emulate hardware|preserve brightness|reduce contrast|off|correct curves" },
{ "sameboy_color_correction_mode", "Color correction; emulate hardware|preserve brightness|reduce contrast|harsh reality|off|correct curves" },
{ "sameboy_high_pass_filter_mode", "High-pass filter; accurate|remove dc offset|off" },
{ "sameboy_model", "Emulated model (Restart game); Auto|Game Boy|Game Boy Color|Game Boy Advance|Super Game Boy|Super Game Boy 2" },
{ "sameboy_border", "Display border; Super Game Boy only|always|never" },
@ -249,8 +249,8 @@ static const struct retro_variable vars_dual[] = {
{ "sameboy_audio_output", "Audio output; Game Boy #1|Game Boy #2" },
{ "sameboy_model_1", "Emulated model for Game Boy #1 (Restart game); Auto|Game Boy|Game Boy Color|Game Boy Advance" },
{ "sameboy_model_2", "Emulated model for Game Boy #2 (Restart game); Auto|Game Boy|Game Boy Color|Game Boy Advance" },
{ "sameboy_color_correction_mode_1", "Color correction for Game Boy #1; emulate hardware|preserve brightness|reduce contrast|off|correct curves" },
{ "sameboy_color_correction_mode_2", "Color correction for Game Boy #2; emulate hardware|preserve brightness|reduce contrast|off|correct curves" },
{ "sameboy_color_correction_mode_1", "Color correction for Game Boy #1; emulate hardware|preserve brightness|reduce contrast|harsh reality|off|correct curves" },
{ "sameboy_color_correction_mode_2", "Color correction for Game Boy #2; emulate hardware|preserve brightness|harsh reality|off|correct curves" },
{ "sameboy_high_pass_filter_mode_1", "High-pass filter for Game Boy #1; accurate|remove dc offset|off" },
{ "sameboy_high_pass_filter_mode_2", "High-pass filter for Game Boy #2; accurate|remove dc offset|off" },
{ "sameboy_rumble_1", "Enable rumble for Game Boy #1; rumble-enabled games|all games|never" },
@ -580,6 +580,9 @@ static void check_variables()
else if (strcmp(var.value, "reduce contrast") == 0) {
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
}
else if (strcmp(var.value, "harsh reality") == 0) {
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_LOW_CONTRAST);
}
}
var.key = "sameboy_rumble";
@ -686,6 +689,9 @@ static void check_variables()
else if (strcmp(var.value, "reduce contrast") == 0) {
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
}
else if (strcmp(var.value, "harsh reality") == 0) {
GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_LOW_CONTRAST);
}
}
var.key = "sameboy_color_correction_mode_2";
@ -706,6 +712,9 @@ static void check_variables()
else if (strcmp(var.value, "reduce contrast") == 0) {
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_REDUCE_CONTRAST);
}
else if (strcmp(var.value, "harsh reality") == 0) {
GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_LOW_CONTRAST);
}
}