renaming getRealColor to CGRAMColorToRGBA and finishing great random test on 8bpp rander

This commit is contained in:
Clément Le Bihan
2021-07-12 00:17:12 +02:00
parent 09520658a1
commit 8a158bbeb3
7 changed files with 148 additions and 13 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ namespace ComSquare::Debugger
uint8_t blue = (cgramValue & 0x7D00U) >> 10U;
uint8_t green = (cgramValue & 0x03E0U) >> 5U;
uint8_t red = (cgramValue & 0x001FU);
uint32_t hexColorValue = PPU::Utils::getRealColor(cgramValue);
uint32_t hexColorValue = PPU::Utils::CGRAMColorToRGBA(cgramValue);
this->_ui.indexLineEdit->setText(std::to_string(addr / 2).c_str());
this->_ui.valueLineEdit->setText(Utility::to_hex(cgramValue).c_str());
@@ -90,7 +90,7 @@ namespace ComSquare::Debugger
uint16_t cgramAddress = idDisplayTile / 8 * 16 + (idDisplayTile % 8 * 2);
uint16_t addressValue = this->_ppu.cgramRead(cgramAddress);
addressValue += this->_ppu.cgramRead(cgramAddress + 1) << 8U;
uint32_t color = PPU::Utils::getRealColor(addressValue);
uint32_t color = PPU::Utils::CGRAMColorToRGBA(addressValue);
return QColor(static_cast<int>((color & 0xFF000000) >> 24),
static_cast<int>((color & 0x00FF0000) >> 16),
+1 -1
View File
@@ -559,7 +559,7 @@ namespace ComSquare::PPU
colorPalette = this->cgram.read(0);
colorPalette += this->cgram.read(1) << 8U;
uint32_t color = Utils::getRealColor(colorPalette);
uint32_t color = Utils::CGRAMColorToRGBA(colorPalette);
for (auto &row : this->_subScreen)
row.fill(color);
for (auto &row : this->_mainScreenLevelMap)
+6 -6
View File
@@ -7,16 +7,16 @@
namespace ComSquare::PPU::Utils
{
uint8_t To8Bit(int color)
inline uint8_t to8Bit(int color)
{
return (uint)((color << 3) + (color >> 2));
return static_cast<uint8_t>((color << 3) + (color >> 2));
}
uint32_t getRealColor(uint16_t cgramColor)
uint32_t CGRAMColorToRGBA(uint16_t CGRAMColor)
{
uint b = To8Bit(cgramColor >> 10);
uint g = To8Bit((cgramColor >> 5) & 0x1F);
uint r = To8Bit(cgramColor & 0x1F);
uint8_t b = to8Bit(CGRAMColor >> 10);
uint8_t g = to8Bit((CGRAMColor >> 5) & 0x1F);
uint8_t r = to8Bit(CGRAMColor & 0x1F);
return (0x000000FF | (r << 24) | (g << 16) | (b << 8));
}
+7 -2
View File
@@ -17,9 +17,14 @@ namespace ComSquare::PPU
namespace ComSquare::PPU::Utils
{
//! @brief Transform CGRAM color data to 8bits
//! @note Used with b, g and r values
//! @return The 8 bit value of the color
inline uint8_t to8Bit(int color);
//! @brief Transform SNES color code BGR to uint32_t RGBA
uint32_t getRealColor(uint16_t cgramColor);
//! @param CGRAMColor The color of the CGRAM
//! @return The CGRAM color to RGBA format
uint32_t CGRAMColorToRGBA(uint16_t CGRAMColor);
//! @brief Used to parse easily VRAM Tile information
union TileData {
struct {
+1 -1
View File
@@ -29,7 +29,7 @@ namespace ComSquare::PPU
for (auto &row : this->buffer) {
for (auto &pixel : row) {
uint8_t pixelReference = this->getPixelReferenceFromTile(tileAddress, it++);
pixel = pixelReference ? Utils::getRealColor(palette[pixelReference]) : 0;
pixel = pixelReference ? Utils::CGRAMColorToRGBA(palette[pixelReference]) : 0;
}
}
}
+1 -1
View File
@@ -49,7 +49,7 @@ namespace ComSquare::PPU
//! @param nbPalette The index of the palette wanted
//! @return The array of color of the palette
//! @note The return and argument depends on the current bpp
//! @warning Values are CGRAM colors use PPU::getRealColor function to get the actual real color
//! @warning Values are CGRAM colors use PPU::CGRAMColorToRGBA function to get the actual real color
std::vector<uint16_t> getPalette(int nbPalette);
//! @brief read the 2bpp value for a pixel (used multple times for 4bpp and 8bpp)
//! @param tileRowAddress Address where the read is done. Usage: Address of the tile row to render