mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-02 10:15:45 +00:00
moving inline function definition in header file and using C++ for instead of for_each for screen rendering
This commit is contained in:
+5
-4
@@ -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
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user