moving inline function definition in header file and using C++ for instead of for_each for screen rendering

This commit is contained in:
Clément Le Bihan
2021-07-13 23:03:29 +02:00
parent f094b57c87
commit 5784f86457
4 changed files with 11 additions and 12 deletions
+5 -4
View File
@@ -306,13 +306,14 @@ namespace ComSquare::PPU
int i = 0;
int j = 0;
std::for_each(this->_screen.begin(), this->_screen.end(), [this, &i, &j](const auto &row) {
std::for_each(row.begin(), row.end(), [this, &i, &j](const auto &pixel) {
for (const auto &row : this->_screen) {
for (const auto &pixel : row) {
this->_renderer.putPixel(i, j++, pixel);
});
};
j = 0;
i++;
});
};
/*
+2 -2
View File
@@ -57,9 +57,9 @@ namespace ComSquare::PPU
Background _backgrounds[4];
//! @brief Main Screen buffer
std::array<std::array<uint32_t, 1024>, 1024> _mainScreen;
std::array<std::array<unsigned char, 1024>, 1024> _mainScreenLevelMap;
std::array<std::array<uint8_t, 1024>, 1024> _mainScreenLevelMap;
//! @brief Sub Screen buffer
std::array<std::array<unsigned char, 1024>, 1024> _subScreenLevelMap;
std::array<std::array<uint8_t, 1024>, 1024> _subScreenLevelMap;
std::array<std::array<uint32_t, 1024>, 1024> _subScreen;
//! @brief Final Screen buffer
std::array<std::array<uint32_t, 1024>, 1024> _screen;
-5
View File
@@ -7,11 +7,6 @@
namespace ComSquare::PPU::Utils
{
inline uint8_t to8Bit(int color)
{
return static_cast<uint8_t>((color << 3) + (color >> 2));
}
uint32_t CGRAMColorToRGBA(uint16_t CGRAMColor)
{
uint8_t b = to8Bit(CGRAMColor >> 10);
+4 -1
View File
@@ -20,7 +20,10 @@ 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);
inline uint8_t to8Bit(int color)
{
return static_cast<uint8_t>((color << 3) + (color >> 2));
}
//! @brief Transform SNES color code BGR to uint32_t RGBA
//! @param CGRAMColor The color of the CGRAM
//! @return The CGRAM color to RGBA format