diff --git a/Cocoa/GBApp.m b/Cocoa/GBApp.m index adb4d9c..8c85c52 100644 --- a/Cocoa/GBApp.m +++ b/Cocoa/GBApp.m @@ -63,7 +63,7 @@ static uint32_t color_to_int(NSColor *color) @"GBSlow-Motion": @(kVK_Shift), @"GBFilter": @"NearestNeighbor", - @"GBColorCorrection": @(GB_COLOR_CORRECTION_EMULATE_HARDWARE), + @"GBColorCorrection": @(GB_COLOR_CORRECTION_MODERN_BALANCED), @"GBHighpassFilter": @(GB_HIGHPASS_REMOVE_DC_OFFSET), @"GBRewindLength": @(10), @"GBFrameBlendingMode": @([defaults boolForKey:@"DisableFrameBlending"]? GB_FRAME_BLENDING_MODE_DISABLED : GB_FRAME_BLENDING_MODE_ACCURATE), diff --git a/Cocoa/GBPreferencesWindow.m b/Cocoa/GBPreferencesWindow.m index b76e125..2b6b070 100644 --- a/Cocoa/GBPreferencesWindow.m +++ b/Cocoa/GBPreferencesWindow.m @@ -101,7 +101,7 @@ { _colorCorrectionPopupButton = colorCorrectionPopupButton; NSInteger mode = [[NSUserDefaults standardUserDefaults] integerForKey:@"GBColorCorrection"]; - [_colorCorrectionPopupButton selectItemAtIndex:mode]; + [_colorCorrectionPopupButton selectItemWithTag:mode]; } @@ -402,7 +402,7 @@ static inline NSString *keyEquivalentString(NSMenuItem *item) - (IBAction)colorCorrectionChanged:(id)sender { - [[NSUserDefaults standardUserDefaults] setObject:@([sender indexOfSelectedItem]) + [[NSUserDefaults standardUserDefaults] setObject:@([sender selectedItem].tag) forKey:@"GBColorCorrection"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"GBColorCorrectionChanged" object:nil]; } diff --git a/Cocoa/Preferences.xib b/Cocoa/Preferences.xib index 36738a3..464de27 100644 --- a/Cocoa/Preferences.xib +++ b/Cocoa/Preferences.xib @@ -187,11 +187,14 @@ - - - - - + + + + + + + + diff --git a/Core/display.c b/Core/display.c index d397e0b..b0dca98 100644 --- a/Core/display.c +++ b/Core/display.c @@ -282,18 +282,18 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border) if (gb->color_correction_mode != GB_COLOR_CORRECTION_CORRECT_CURVES) { uint8_t new_r, new_g, new_b; if (g != b) { // Minor optimization - double gamma = 2.2; - if (gb->color_correction_mode < GB_COLOR_CORRECTION_REDUCE_CONTRAST) { - /* Don't use absolutely gamma-correct mixing for the high-contrast - modes, to prevent the blue hues from being too washed out */ - gamma = 1.6; - } - - // TODO: Optimze pow out using a LUT - if (agb) { + double gamma = 2.2; + if (gb->color_correction_mode < GB_COLOR_CORRECTION_REDUCE_CONTRAST) { + /* Don't use absolutely gamma-correct mixing for the high-contrast + modes, to prevent the blue hues from being too washed out */ + gamma = 1.6; + } + + // TODO: Optimze pow out using a LUT + if (agb) { new_g = round(pow((pow(g / 255.0, gamma) * 5 + pow(b / 255.0, gamma)) / 6, 1 / gamma) * 255); - } - else { + } + else { new_g = round(pow((pow(g / 255.0, gamma) * 3 + pow(b / 255.0, gamma)) / 4, 1 / gamma) * 255); } } @@ -343,7 +343,7 @@ uint32_t GB_convert_rgb15(GB_gameboy_t *gb, uint16_t color, bool for_border) new_b = new_b * (157 - 38) / 255 + 38; } } - else if (gb->color_correction_mode == GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS) { + else if (gb->color_correction_mode == GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST) { 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 bf0c83d..0c5c64e 100644 --- a/Core/display.h +++ b/Core/display.h @@ -55,12 +55,16 @@ typedef struct { typedef enum { GB_COLOR_CORRECTION_DISABLED, GB_COLOR_CORRECTION_CORRECT_CURVES, - GB_COLOR_CORRECTION_EMULATE_HARDWARE, - GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS, + GB_COLOR_CORRECTION_MODERN_BALANCED, + GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST, GB_COLOR_CORRECTION_REDUCE_CONTRAST, GB_COLOR_CORRECTION_LOW_CONTRAST, + GB_COLOR_CORRECTION_MODERN_ACCURATE, } GB_color_correction_mode_t; +static const GB_color_correction_mode_t __attribute__((deprecated("Use GB_COLOR_CORRECTION_MODERN_BALANCED instead"))) GB_COLOR_CORRECTION_EMULATE_HARDWARE = GB_COLOR_CORRECTION_MODERN_BALANCED; +static const GB_color_correction_mode_t __attribute__((deprecated("Use GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST instead"))) GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS = GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST; + void GB_draw_tileset(GB_gameboy_t *gb, uint32_t *dest, GB_palette_type_t palette_type, uint8_t palette_index); void GB_draw_tilemap(GB_gameboy_t *gb, uint32_t *dest, GB_palette_type_t palette_type, uint8_t palette_index, GB_map_type_t map_type, GB_tileset_type_t tileset_type); uint8_t GB_get_oam_info(GB_gameboy_t *gb, GB_oam_info_t *dest, uint8_t *object_height); diff --git a/QuickLook/get_image_for_rom.c b/QuickLook/get_image_for_rom.c index f6e53fa..6c9ac91 100755 --- a/QuickLook/get_image_for_rom.c +++ b/QuickLook/get_image_for_rom.c @@ -59,7 +59,7 @@ int get_image_for_rom(const char *filename, const char *boot_path, uint32_t *out GB_set_rgb_encode_callback(&gb, rgb_encode); GB_set_async_input_callback(&gb, async_input_callback); GB_set_log_callback(&gb, log_callback); - GB_set_color_correction_mode(&gb, GB_COLOR_CORRECTION_EMULATE_HARDWARE); + GB_set_color_correction_mode(&gb, GB_COLOR_CORRECTION_MODERN_BALANCED); size_t length = strlen(filename); char extension[4] = {0,}; diff --git a/SDL/configuration.c b/SDL/configuration.c index d8ca1bd..35ad299 100644 --- a/SDL/configuration.c +++ b/SDL/configuration.c @@ -38,7 +38,7 @@ configuration_t configuration = 0, 1, }, - .color_correction_mode = GB_COLOR_CORRECTION_EMULATE_HARDWARE, + .color_correction_mode = GB_COLOR_CORRECTION_MODERN_BALANCED, .highpass_mode = GB_HIGHPASS_ACCURATE, .scaling_mode = GB_SDL_SCALING_INTEGER_FACTOR, .blending_mode = GB_FRAME_BLENDING_MODE_ACCURATE, diff --git a/SDL/gui.c b/SDL/gui.c index 873696c..fbeb15b 100644 --- a/SDL/gui.c +++ b/SDL/gui.c @@ -566,7 +566,7 @@ static 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", "Harsh Reality"} + return (const char *[]){"Disabled", "Correct Color Curves", "Modern - Balanced", "Modern - Boost Contrast", "Reduce Contrast", "Harsh Reality", "Modern - Accurate"} [configuration.color_correction_mode]; } @@ -647,6 +647,12 @@ static void cycle_color_correction(unsigned index) if (configuration.color_correction_mode == GB_COLOR_CORRECTION_LOW_CONTRAST) { configuration.color_correction_mode = GB_COLOR_CORRECTION_DISABLED; } + else if (configuration.color_correction_mode == GB_COLOR_CORRECTION_MODERN_BALANCED) { + configuration.color_correction_mode = GB_COLOR_CORRECTION_MODERN_ACCURATE; + } + else if (configuration.color_correction_mode == GB_COLOR_CORRECTION_MODERN_ACCURATE) { + configuration.color_correction_mode = GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST; + } else { configuration.color_correction_mode++; } @@ -657,6 +663,12 @@ static void cycle_color_correction_backwards(unsigned index) if (configuration.color_correction_mode == GB_COLOR_CORRECTION_DISABLED) { configuration.color_correction_mode = GB_COLOR_CORRECTION_LOW_CONTRAST; } + else if (configuration.color_correction_mode == GB_COLOR_CORRECTION_MODERN_ACCURATE) { + configuration.color_correction_mode = GB_COLOR_CORRECTION_MODERN_BALANCED; + } + else if (configuration.color_correction_mode == GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST) { + configuration.color_correction_mode = GB_COLOR_CORRECTION_MODERN_ACCURATE; + } else { configuration.color_correction_mode--; } diff --git a/SDL/main.c b/SDL/main.c index 93da163..7b87392 100644 --- a/SDL/main.c +++ b/SDL/main.c @@ -889,7 +889,7 @@ int main(int argc, char **argv) fclose(prefs_file); /* Sanitize for stability */ - configuration.color_correction_mode %= GB_COLOR_CORRECTION_LOW_CONTRAST + 1; + configuration.color_correction_mode %= GB_COLOR_CORRECTION_MODERN_ACCURATE + 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; diff --git a/libretro/libretro.c b/libretro/libretro.c index 3899864..2f51bd8 100644 --- a/libretro/libretro.c +++ b/libretro/libretro.c @@ -768,10 +768,10 @@ static void check_variables() GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_CORRECT_CURVES); } else if (strcmp(var.value, "emulate hardware") == 0) { - GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE); + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_MODERN_BALANCED); } else if (strcmp(var.value, "preserve brightness") == 0) { - GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST); } else if (strcmp(var.value, "reduce contrast") == 0) { GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST); @@ -779,6 +779,9 @@ static void check_variables() else if (strcmp(var.value, "harsh reality") == 0) { GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_LOW_CONTRAST); } + else if (strcmp(var.value, "accurate") == 0) { + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_MODERN_ACCURATE); + } } var.key = "sameboy_light_temperature"; @@ -1049,10 +1052,10 @@ static void check_variables() GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_CORRECT_CURVES); } else if (strcmp(var.value, "emulate hardware") == 0) { - GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_EMULATE_HARDWARE); + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_MODERN_BALANCED); } else if (strcmp(var.value, "preserve brightness") == 0) { - GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST); } else if (strcmp(var.value, "reduce contrast") == 0) { GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_REDUCE_CONTRAST); @@ -1060,6 +1063,9 @@ static void check_variables() else if (strcmp(var.value, "harsh reality") == 0) { GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_LOW_CONTRAST); } + else if (strcmp(var.value, "accurate") == 0) { + GB_set_color_correction_mode(&gameboy[0], GB_COLOR_CORRECTION_MODERN_ACCURATE); + } } var.key = "sameboy_color_correction_mode_2"; @@ -1072,10 +1078,10 @@ static void check_variables() GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_CORRECT_CURVES); } else if (strcmp(var.value, "emulate hardware") == 0) { - GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_EMULATE_HARDWARE); + GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_MODERN_BALANCED); } else if (strcmp(var.value, "preserve brightness") == 0) { - GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_PRESERVE_BRIGHTNESS); + GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_MODERN_BOOST_CONTRAST); } else if (strcmp(var.value, "reduce contrast") == 0) { GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_REDUCE_CONTRAST); @@ -1083,6 +1089,9 @@ static void check_variables() else if (strcmp(var.value, "harsh reality") == 0) { GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_LOW_CONTRAST); } + else if (strcmp(var.value, "accurate") == 0) { + GB_set_color_correction_mode(&gameboy[1], GB_COLOR_CORRECTION_MODERN_ACCURATE); + } } var.key = "sameboy_light_temperature_1"; diff --git a/libretro/libretro_core_options.inc b/libretro/libretro_core_options.inc index cf6e0b3..94e1474 100644 --- a/libretro/libretro_core_options.inc +++ b/libretro/libretro_core_options.inc @@ -147,8 +147,9 @@ struct retro_core_option_v2_definition option_defs_us[] = { NULL, "video", { - { "emulate hardware", "Emulate Hardware" }, - { "preserve brightness", "Preserve Brightness" }, + { "emulate hardware", "Modern – Balanced" }, + { "accurate", "Modern – Accurate" }, + { "preserve brightness", "Modern – Boost Contrast" }, { "reduce contrast", "Reduce Contrast" }, { "correct curves", "Correct Color Curves" }, { "harsh reality", "Harsh Reality (Low Contrast)" }, @@ -425,8 +426,9 @@ struct retro_core_option_v2_definition option_defs_us[] = { NULL, "video", { - { "emulate hardware", "Emulate Hardware" }, - { "preserve brightness", "Preserve Brightness" }, + { "emulate hardware", "Modern – Balanced" }, + { "accurate", "Modern – Accurate" }, + { "preserve brightness", "Modern – Boost Contrast" }, { "reduce contrast", "Reduce Contrast" }, { "correct curves", "Correct Color Curves" }, { "harsh reality", "Harsh Reality (Low Contrast)" }, @@ -443,8 +445,9 @@ struct retro_core_option_v2_definition option_defs_us[] = { NULL, "video", { - { "emulate hardware", "Emulate Hardware" }, - { "preserve brightness", "Preserve Brightness" }, + { "emulate hardware", "Modern – Balanced" }, + { "accurate", "Modern – Accurate" }, + { "preserve brightness", "Modern – Boost Contrast" }, { "reduce contrast", "Reduce Contrast" }, { "correct curves", "Correct Color Curves" }, { "harsh reality", "Harsh Reality (Low Contrast)" },