adding test for render in 2bpp and using mesen formula for getRealColor function

This commit is contained in:
Clément Le Bihan
2021-07-11 20:10:39 +02:00
parent 8a84258c5a
commit 09520658a1
4 changed files with 68 additions and 28 deletions
+10 -9
View File
@@ -7,16 +7,17 @@
namespace ComSquare::PPU::Utils
{
uint32_t getRealColor(uint16_t color)
uint8_t To8Bit(int color)
{
uint8_t blue = (color & 0x7D00U) >> 10U;
uint8_t green = (color & 0x03E0U) >> 5U;
uint8_t red = (color & 0x001FU);
uint32_t pixelTmp = 0xFF;
return (uint)((color << 3) + (color >> 2));
}
pixelTmp += (red * 255U / 31U) << 24U;
pixelTmp += (green * 255U / 31U) << 16U;
pixelTmp += (blue * 255U / 31U) << 8U;
return pixelTmp;
uint32_t getRealColor(uint16_t cgramColor)
{
uint b = To8Bit(cgramColor >> 10);
uint g = To8Bit((cgramColor >> 5) & 0x1F);
uint r = To8Bit(cgramColor & 0x1F);
return (0x000000FF | (r << 24) | (g << 16) | (b << 8));
}
}
+2 -2
View File
@@ -18,8 +18,8 @@ namespace ComSquare::PPU
namespace ComSquare::PPU::Utils
{
//! @brief Transform SNES color code BGR to uint32_t RGB
uint32_t getRealColor(uint16_t color);
//! @brief Transform SNES color code BGR to uint32_t RGBA
uint32_t getRealColor(uint16_t cgramColor);
//! @brief Used to parse easily VRAM Tile information
union TileData {
struct {