From e14704181c1f68537ca66e26670c080aae29b969 Mon Sep 17 00:00:00 2001 From: profi200 Date: Mon, 29 Jan 2024 17:43:58 +0100 Subject: [PATCH] Round the gamma table entries instead of discarding the fraction part. --- source/arm11/open_agb_firm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/arm11/open_agb_firm.c b/source/arm11/open_agb_firm.c index 2701509..02b3e45 100644 --- a/source/arm11/open_agb_firm.c +++ b/source/arm11/open_agb_firm.c @@ -169,8 +169,8 @@ static void adjustGammaTableForGba(void) // Adjust i with brightness and convert to target gamma. const float adjusted = powf((float)i / 255 + brightness, targetGamma); - // Apply contrast, convert to LCD gamma and clamp. - const u32 res = clamp_s32(powf(contrastInTargetGamma * adjusted, lcdGamma) * 255, 0, 255); + // Apply contrast, convert to LCD gamma, round to nearest and clamp. + const u32 res = clamp_s32(lroundf(powf(contrastInTargetGamma * adjusted, lcdGamma) * 255), 0, 255); // Same adjustment for red/green/blue. REG_LCD_PDC0_GTBL_FIFO = res<<16 | res<<8 | res;