From c5696946ebd225b85983a5fc9ae380eedd6c75cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Sun, 4 Jul 2021 12:09:15 +0200 Subject: [PATCH] adding micro QoL changes segfault found in PPU while running rom --- sources/PPU/Background.cpp | 14 ++++---------- sources/PPU/PPU.cpp | 2 +- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/sources/PPU/Background.cpp b/sources/PPU/Background.cpp index eb3aa87..73277ff 100644 --- a/sources/PPU/Background.cpp +++ b/sources/PPU/Background.cpp @@ -82,7 +82,7 @@ namespace ComSquare::PPU tileOffset.x += 1; } tileOffset.x = 0; - tileOffset.y += 1; + tileOffset.y++; } // todo check why i need to invert vertical and horizontal flips @@ -90,15 +90,9 @@ namespace ComSquare::PPU Utils::HFlipArray(this->_tileBuffer, {this->_characterNbPixels.x, this->_characterNbPixels.y}); if (tileData.horizontalFlip) Utils::VFlipArray(this->_tileBuffer, {this->_characterNbPixels.x, this->_characterNbPixels.y}); - for (int i = 0; i < this->_characterNbPixels.y; i++) { - for (int j = 0; j < this->_characterNbPixels.x; j++) { - //std::copy(this->_tileBuffer.begin(), this->_tileBuffer.begin() + this->_characterNbPixels.x, this->buffer[pos.x].begin() ) - this->buffer[pos.y + i][pos.x + j] = this->_tileBuffer[i][j]; - //pos.x++; - } - //pos.x -= this->_characterNbPixels.x; - //pos.y++; - } + std::for_each(this->_tileBuffer.begin(), this->_tileBuffer.begin() + this->_characterNbPixels.y, [this, &pos](const auto &row) { + std::move(row.begin(), row.begin() + this->_characterNbPixels.x, this->buffer[pos.y++].begin() + pos.x); + }); } void Background::_drawBasicTileMap(uint16_t baseAddress, Vector2 offset) diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index 58344fd..6114322 100644 --- a/sources/PPU/PPU.cpp +++ b/sources/PPU/PPU.cpp @@ -36,7 +36,7 @@ namespace ComSquare::PPU { this->_registers._isLowByte = true; - Utils::Debug::populateEnvironment(*this, 1); + //Utils::Debug::populateEnvironment(*this, 0); } uint8_t PPU::read(uint24_t addr)