From 9692120626e35db3c38b70d1d9b0b77db7b8f657 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Le=20Bihan?= Date: Tue, 13 Jul 2021 22:18:55 +0200 Subject: [PATCH] misc fixes --- sources/PPU/Background.cpp | 28 +++++++++------------------- sources/PPU/Background.hpp | 26 +++++++++----------------- sources/PPU/PPU.cpp | 8 ++++---- 3 files changed, 22 insertions(+), 40 deletions(-) diff --git a/sources/PPU/Background.cpp b/sources/PPU/Background.cpp index 08deada..d7cb004 100644 --- a/sources/PPU/Background.cpp +++ b/sources/PPU/Background.cpp @@ -10,22 +10,22 @@ namespace ComSquare::PPU { - Background::Background(ComSquare::PPU::PPU &ppu, int backGroundNumber, bool hasPriority) + Background::Background(ComSquare::PPU::PPU &ppu, int backgroundNumber) : _ppu(ppu), - _tileMapMirroring(ppu.getBackgroundMirroring(backGroundNumber)), - _characterNbPixels(ppu.getCharacterSize(backGroundNumber)), - _bpp(ppu.getBPP(backGroundNumber)), + _tileMapMirroring(ppu.getBackgroundMirroring(backgroundNumber)), + _characterNbPixels(ppu.getCharacterSize(backgroundNumber)), + _bpp(ppu.getBPP(backgroundNumber)), _directColor(false), _highRes(false), - _tileMapStartAddress(ppu.getTileMapStartAddress(backGroundNumber)), - _tilesetAddress(ppu.getTilesetAddress(backGroundNumber)), - _priority(hasPriority), - _bgNumber(backGroundNumber), + _tileMapStartAddress(ppu.getTileMapStartAddress(backgroundNumber)), + _tilesetAddress(ppu.getTilesetAddress(backgroundNumber)), + _bgNumber(backgroundNumber), _tileBuffer({{{0}}}), _vram(ppu.vram), _cgram(ppu.cgram), _tileRenderer(this->_vram, this->_cgram), - buffer({{{0}}}) + buffer({{{0}}}), + tilesPriority({{{false}}}) {} void Background::renderBackground() @@ -155,16 +155,6 @@ namespace ComSquare::PPU return this->_bgNumber; } - void Background::setPriority(bool priority) - { - this->_priority = priority; - } - - bool Background::getPriority() const - { - return this->_priority; - } - bool Background::isPriorityPixel(int y, int x) const { return this->tilesPriority[y / this->_characterNbPixels.y][x / this->_characterNbPixels.x]; diff --git a/sources/PPU/Background.hpp b/sources/PPU/Background.hpp index 6ec57e7..1687b88 100644 --- a/sources/PPU/Background.hpp +++ b/sources/PPU/Background.hpp @@ -8,10 +8,10 @@ #include #include #include "Models/Vector2.hpp" -#include "TileRenderer.hpp" +#include "PPU/TileRenderer.hpp" #include "Ram/Ram.hpp" -#include "PPU.hpp" -#include "PPUUtils.hpp" +#include "PPU/PPU.hpp" +#include "PPU/PPUUtils.hpp" namespace ComSquare::PPU { @@ -35,7 +35,7 @@ namespace ComSquare::PPU //! @brief The tilemap configuration nb of tileMap vertically and horizontally //! @note members are set to true if the tilemap is expended in their direction Vector2 _tileMapMirroring; - //! @brief The number of pixels of a character (x: height, y:width) + //! @brief The number of pixels of a character (x: width, y: height) Vector2 _characterNbPixels; //! @brief The number of bits per pixels to currently look for each pixel int _bpp; @@ -48,8 +48,6 @@ namespace ComSquare::PPU uint16_t _tileMapStartAddress; //! @brief The first address for tileset data uint16_t _tilesetAddress; - //! @brief If pixel from this background should be treated as primarily - bool _priority; //! @brief The bg number (used to get the corresponding scroll) int _bgNumber; //! @brief Buffer if we have tiles that are more than 8x8 @@ -76,11 +74,11 @@ namespace ComSquare::PPU Vector2 backgroundSize; //! @brief The output buffer (pixels are written on it) std::array, 1024> buffer; - + //! @brief The buffer of tile priority level std::array, 64> tilesPriority; - bool isPriorityPixel(int x, int y) const; - + //! @brief Tells if a pixel has high priority + [[nodiscard]] bool isPriorityPixel(int x, int y) const; //! @brief Render a background on his internal buffer void renderBackground(); //! @brief Set the tileMap start address @@ -100,13 +98,7 @@ namespace ComSquare::PPU //! @brief Get the BackGround Number //! @return the current Background number - int getBgNumber() const; - //! @brief set the Background priority - //! @param bgNumber the new Background priority - void setPriority(bool priority); - //! @brief Get the Background priority - //! @return the current Background priority - bool getPriority() const; + [[nodiscard]] int getBgNumber() const; //! @brief Add a bg buffer to another buffer @@ -141,7 +133,7 @@ namespace ComSquare::PPU } //! @brief ctor - Background(PPU &_ppu, int backGroundNumber, bool hasPriority); + Background(PPU &_ppu, int backgroundNumber); //! @brief Default copy ctor Background(const Background &) = default; //! @brief Default destructor diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index b073435..5c2f738 100644 --- a/sources/PPU/PPU.cpp +++ b/sources/PPU/PPU.cpp @@ -21,10 +21,10 @@ namespace ComSquare::PPU cgram(CGRamSize, ComSquare::CGRam, "CGRAM"), _renderer(renderer), _backgrounds{ - Background(*this, 1, false), - Background(*this, 2, false), - Background(*this, 3, false), - Background(*this, 4, false), + Background(*this, 1), + Background(*this, 2), + Background(*this, 3), + Background(*this, 4), }, _mainScreen({{{0}}}), _subScreen({{{0}}})