diff --git a/Cocoa/Preferences.xib b/Cocoa/Preferences.xib index e7d96aa..7eb0587 100644 --- a/Cocoa/Preferences.xib +++ b/Cocoa/Preferences.xib @@ -152,6 +152,7 @@ + @@ -203,7 +204,7 @@ - + @@ -459,7 +460,7 @@ - + diff --git a/Core/display.c b/Core/display.c index 8072f37..0ed973e 100644 --- a/Core/display.c +++ b/Core/display.c @@ -133,7 +133,7 @@ static void display_vblank(GB_gameboy_t *gb) if (!GB_is_sgb(gb)) { uint32_t color = 0; if (GB_is_cgb(gb)) { - color = gb->rgb_encode_callback(gb, 0xFF, 0xFF, 0xFF); + color = GB_convert_rgb15(gb, 0x7FFF, false); } else { color = is_ppu_stopped ? @@ -261,7 +261,21 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border) } new_r = r; new_b = b; - if (gb->color_correction_mode == GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS) { + if (gb->color_correction_mode == GB_COLOR_CORRECTION_REDUCE_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 * (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_PRESERVE_BRIGHTNESS) { uint8_t old_max = MAX(r, MAX(g, b)); uint8_t new_max = MAX(new_r, MAX(new_g, new_b)); diff --git a/Core/display.h b/Core/display.h index d539881..4c37f99 100644 --- a/Core/display.h +++ b/Core/display.h @@ -50,6 +50,7 @@ typedef enum { GB_COLOR_CORRECTION_CORRECT_CURVES, GB_COLOR_CORRECTION_EMULATE_HARDWARE, GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS, + GB_COLOR_CORRECTION_REDUCE_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); diff --git a/SDL/gui.c b/SDL/gui.c index 6646a17..b6b0f03 100644 --- a/SDL/gui.c +++ b/SDL/gui.c @@ -422,7 +422,7 @@ const char *current_scaling_mode(unsigned index) const char *current_color_correction_mode(unsigned index) { - return (const char *[]){"Disabled", "Correct Color Curves", "Emulate Hardware", "Preserve Brightness"} + return (const char *[]){"Disabled", "Correct Color Curves", "Emulate Hardware", "Preserve Brightness", "Reduce Contrast"} [configuration.color_correction_mode]; } @@ -462,7 +462,7 @@ void cycle_scaling_backwards(unsigned index) static void cycle_color_correction(unsigned index) { - if (configuration.color_correction_mode == GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS) { + if (configuration.color_correction_mode == GB_COLOR_CORRECTION_REDUCE_CONTRAST) { configuration.color_correction_mode = GB_COLOR_CORRECTION_DISABLED; } else { @@ -473,7 +473,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_PRESERVE_BRIGHTNESS; + configuration.color_correction_mode = GB_COLOR_CORRECTION_REDUCE_CONTRAST; } else { configuration.color_correction_mode--; diff --git a/libretro/libretro.c b/libretro/libretro.c index 59dfdc4..8cd1324 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -202,7 +202,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; off|correct curves|emulate hardware|preserve brightness" }, + { "sameboy_color_correction_mode", "Color correction; off|correct curves|emulate hardware|preserve brightness|reduce contrast" }, { "sameboy_high_pass_filter_mode", "High-pass filter; off|accurate|remove dc offset" }, { "sameboy_model", "Emulated model; Auto|Game Boy|Game Boy Color|Game Boy Advance|Super Game Boy|Super Game Boy 2" }, { "sameboy_border", "Super Game Boy border; enabled|disabled" }, @@ -497,6 +497,8 @@ static void check_variables() GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE); else if (strcmp(var.value, "preserve brightness") == 0) GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); + else if (strcmp(var.value, "reduce_contrast") == 0) + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST); } var.key = "sameboy_high_pass_filter_mode"; @@ -561,6 +563,8 @@ static void check_variables() GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE); else if (strcmp(var.value, "preserve brightness") == 0) GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); + else if (strcmp(var.value, "reduce_contrast") == 0) + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST); } var.key = "sameboy_color_correction_mode_2"; @@ -575,6 +579,9 @@ static void check_variables() GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_EMULATE_HARDWARE); else if (strcmp(var.value, "preserve brightness") == 0) GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); + else if (strcmp(var.value, "reduce_contrast") == 0) + GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_REDUCE_CONTRAST); + } var.key = "sameboy_high_pass_filter_mode_1";