misc fixes

This commit is contained in:
Clément Le Bihan
2021-07-13 22:18:55 +02:00
parent 2913e9eb2c
commit 9692120626
3 changed files with 22 additions and 40 deletions
+9 -19
View File
@@ -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];
+9 -17
View File
@@ -8,10 +8,10 @@
#include <vector>
#include <iostream>
#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<bool> _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<int> _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<unsigned> backgroundSize;
//! @brief The output buffer (pixels are written on it)
std::array<std::array<uint32_t, 1024>, 1024> buffer;
//! @brief The buffer of tile priority level
std::array<std::array<bool, 64>, 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
+4 -4
View File
@@ -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}}})