mirror of https://github.com/LIJI32/SameBoy.git
Rename several color correction modes, add a new accurate mode
This commit is contained in:
parent
0894c1dcda
commit
3f7bcb9af2
|
@ -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),
|
||||
|
|
|
@ -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];
|
||||
}
|
||||
|
|
|
@ -187,11 +187,14 @@
|
|||
<menuItem title="Disabled" state="on" id="D2J-wV-1vu">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<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"/>
|
||||
<menuItem title="Harsh reality (low contrast)" id="98I-hs-vP2"/>
|
||||
<menuItem title="Correct color curves" tag="1" id="B3Q-x1-VRl"/>
|
||||
<menuItem isSeparatorItem="YES" id="GB2-3g-Igu"/>
|
||||
<menuItem title="Modern – Balanced" tag="2" id="XBL-hS-7ke"/>
|
||||
<menuItem title="Modern – Accurate" tag="6" id="EpK-Wq-IcU"/>
|
||||
<menuItem title="Modern – Boost Contrast" tag="3" id="tlx-WB-Bkw"/>
|
||||
<menuItem isSeparatorItem="YES" id="pcU-NR-Tno"/>
|
||||
<menuItem title="Reduce contrast" tag="4" id="wuO-Xv-0mQ"/>
|
||||
<menuItem title="Harsh reality (low contrast)" tag="5" id="98I-hs-vP2"/>
|
||||
</items>
|
||||
</menu>
|
||||
</popUpButtonCell>
|
||||
|
|
|
@ -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));
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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,};
|
||||
|
|
|
@ -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,
|
||||
|
|
14
SDL/gui.c
14
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--;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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";
|
||||
|
|
|
@ -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)" },
|
||||
|
|
Loading…
Reference in New Issue