Round the gamma table entries instead of discarding the fraction part.

This commit is contained in:
profi200 2024-01-29 17:43:58 +01:00
parent 63e4422db1
commit e14704181c
No known key found for this signature in database
GPG Key ID: FD2BAB7782919B0A
1 changed files with 2 additions and 2 deletions

View File

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