git.y1.nz

SameBoy

Accurate GB/GBC emulator
download: https://git.y1.nz/archives/sameboy.tar.gz
README | Files | Log | Refs | LICENSE

commit e0436e33d4b2ad203ec358e040fc194afc999918
parent 43e1e8517985743517c7d7c9cf8479b2ebebd721
Author: Lior Halphon <LIJI32@gmail.com>
Date:   Mon, 25 Jul 2022 19:55:31 +0300

Use gamma correct (and nearly gamma correct) color mixing

Diffstat:
MCore/display.c13+++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)

diff --git a/Core/display.c b/Core/display.c @@ -281,12 +281,21 @@ 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; + 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 = (g * 5 + b) / 6; + new_g = pow((pow(g / 255.0, gamma) * 5 + pow(b / 255.0, gamma)) / 6, 1 / gamma) * 255; } else { - new_g = (g * 3 + b) / 4; + new_g = pow((pow(g / 255.0, gamma) * 3 + pow(b / 255.0, gamma)) / 4, 1 / gamma) * 255; } + new_r = r; new_b = b; if (gb->color_correction_mode == GB_COLOR_CORRECTION_REDUCE_CONTRAST) {

This webpage is intended to be an accessible preview of this repository. To get a fuller picture, clone it and use the git CLI.