mirror of
https://github.com/zoriya/ComSquare.git
synced 2026-06-03 02:23:49 +00:00
moving addBuffer to utils
This commit is contained in:
+4
-4
@@ -311,8 +311,8 @@ namespace ComSquare::PPU
|
||||
(void)cycles;
|
||||
|
||||
this->renderMainAndSubScreen();
|
||||
this->addBuffer(this->_screen, this->_subScreen);
|
||||
this->addBuffer(this->_screen, this->_mainScreen);
|
||||
Utils::addBuffer(this->_screen, this->_subScreen);
|
||||
Utils::addBuffer(this->_screen, this->_mainScreen);
|
||||
//this->_backgrounds[2].renderBackground();
|
||||
//add_buffer(this->_screen, this->_backgrounds[2].buffer);
|
||||
for (unsigned long i = 0; i < this->_screen.size(); i++) {
|
||||
@@ -656,9 +656,9 @@ namespace ComSquare::PPU
|
||||
void PPU::addToMainSubScreen(Background &bg)
|
||||
{
|
||||
if (this->_registers._t[0].raw & (1U << (bg.getBgNumber() - 1U)))
|
||||
this->addBuffer(this->_mainScreen, bg.buffer);
|
||||
Utils::addBuffer(this->_mainScreen, bg.buffer);
|
||||
if (this->_registers._t[1].raw & (1U << (bg.getBgNumber() - 1U)))
|
||||
this->addBuffer(this->_subScreen, bg.buffer);
|
||||
Utils::addBuffer(this->_subScreen, bg.buffer);
|
||||
}
|
||||
|
||||
int PPU::getBgMode() const
|
||||
|
||||
@@ -624,18 +624,6 @@ namespace ComSquare::PPU
|
||||
Vector2<bool> getBackgroundMirroring(int bgNumber) const;
|
||||
//! @brief Render the Main and sub screen correctly
|
||||
void renderMainAndSubScreen();
|
||||
//! @brief Add a bg buffer to another buffer
|
||||
template <std::size_t DEST_SIZE_X, std::size_t DEST_SIZE_Y, std::size_t SRC_SIZE_X, std::size_t SRC_SIZE_Y>
|
||||
void addBuffer(std::array<std::array<uint32_t, DEST_SIZE_Y>, DEST_SIZE_X> &bufferDest,
|
||||
const std::array<std::array<uint32_t, SRC_SIZE_Y>, SRC_SIZE_X> &bufferSrc)
|
||||
{
|
||||
for (unsigned long i = 0; i < bufferSrc.size(); i++) {
|
||||
for (unsigned long j = 0; j < bufferSrc[i].size(); j++) {
|
||||
if (bufferSrc[i][j] > 0xFF) // 0xFF correspond to a black pixel with full brightness
|
||||
bufferDest[i][j] = bufferSrc[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
//! @brief Add a bg to the sub and/or main screen
|
||||
void addToMainSubScreen(Background &bg);
|
||||
//! @brief Get the current background Mode
|
||||
|
||||
@@ -78,5 +78,18 @@ namespace ComSquare::PPU::Utils
|
||||
std::reverse(array.begin() + offset.x, array.begin() + offset.x + size.x);
|
||||
}
|
||||
|
||||
//! @brief Add a bg buffer to another buffer
|
||||
template <std::size_t DEST_SIZE_X, std::size_t DEST_SIZE_Y, std::size_t SRC_SIZE_X, std::size_t SRC_SIZE_Y>
|
||||
static void addBuffer(std::array<std::array<uint32_t, DEST_SIZE_Y>, DEST_SIZE_X> &bufferDest,
|
||||
const std::array<std::array<uint32_t, SRC_SIZE_Y>, SRC_SIZE_X> &bufferSrc)
|
||||
{
|
||||
for (unsigned long i = 0; i < bufferSrc.size(); i++) {
|
||||
for (unsigned long j = 0; j < bufferSrc[i].size(); j++) {
|
||||
if (bufferSrc[i][j] > 0xFF) // 0xFF correspond to a black pixel with full brightness
|
||||
bufferDest[i][j] = bufferSrc[i][j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
#endif //COMSQUARE_PPU_UTILS_HPP
|
||||
Reference in New Issue
Block a user