Add another color correction mode

This commit is contained in:
Lior Halphon 2020-03-25 20:33:13 +02:00
parent 84e8e45b7b
commit e94e7cc501
5 changed files with 31 additions and 8 deletions

View File

@ -152,6 +152,7 @@
<menuItem title="Correct color curves" id="B3Q-x1-VRl"/>
<menuItem title="Emulate hardware" id="XBL-hS-7ke"/>
<menuItem title="Preserve brightness" id="tlx-WB-Bkw"/>
<menuItem title="Reduce contrast" id="wuO-Xv-0mQ"/>
</items>
</menu>
</popUpButtonCell>
@ -203,7 +204,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<popUpButtonCell key="cell" type="push" title="Never" bezelStyle="rounded" alignment="left" lineBreakMode="truncatingTail" state="on" borderStyle="borderAndBezel" tag="1" imageScaling="proportionallyDown" inset="2" selectedItem="heL-AV-0az" id="DY9-2D-h1L">
<behavior key="behavior" lightByBackground="YES" lightByGray="YES"/>
<font key="font" metaFont="system"/>
<font key="font" metaFont="menu"/>
<menu key="menu" id="Rgf-mF-K9q">
<items>
<menuItem title="Never" state="on" tag="1" id="heL-AV-0az">
@ -459,7 +460,7 @@
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMinY="YES"/>
<clipView key="contentView" focusRingType="none" ambiguous="YES" drawsBackground="NO" id="AMs-PO-nid">
<rect key="frame" x="1" y="1" width="238" height="209"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<tableView focusRingType="none" appearanceType="vibrantLight" verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnAutoresizingStyle="lastColumnOnly" columnReordering="NO" columnResizing="NO" multipleSelection="NO" emptySelection="NO" autosaveColumns="NO" typeSelect="NO" id="UDd-IJ-fxX">
<rect key="frame" x="0.0" y="0.0" width="238" height="209"/>

View File

@ -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));

View File

@ -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);

View File

@ -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--;

View File

@ -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";