fixing some issues from those reported by the pr

This commit is contained in:
Clément Le Bihan
2021-05-21 00:12:00 +02:00
parent 89c9d71168
commit 11bca5fe97
3 changed files with 81 additions and 57 deletions

View File

@@ -19,26 +19,48 @@ namespace ComSquare::PPU
{
class PPU;
class Background {
#define NB_CHARACTER_WIDTH 32
#define NB_CHARACTER_HEIGHT 32
#define TILE_PIXEL_WIDTH 8U
#define TILE_PIXEL_HEIGHT 8U
#define TILE_SIZE 8
#define NB_TILE_PER_ROW 16
//! @brief The number of character a TileMap has in width
static constexpr int NbCharacterWidth = 32;
//! @brief The number of character a TileMap has in height
static constexpr int NbCharacterHeight = 32;
//! @brief The minimum number of pixel a tile can have in width
static constexpr int TileNbPixelsWidth = 8;
//! @brief The minimum number of pixel a tile can have in height
static constexpr int TileNbPixelsHeight = 8;
//! @brief The number of bytes used by a range of pixels (1 pixel per byte)
//! @note Used like: bpp * TileBaseByteSize to get the size of byte of 1 row of pixels
static constexpr unsigned TileBaseByteSize = 8;
//! @brief The number of rows in one line of VRAM
//! @note If you're lost by this description, open a tile viewer in an emulator, and set the number of tiles in width to 16 graphics
static constexpr unsigned NbTilePerRow = 16;
//! @brief The size of a TileMap in memory
static constexpr unsigned short TileMapByteSize = 0x800;
private:
Vector2<int> _tileMaps;
Vector2<int> _characterSize;
int _bpp;
bool _directColor;
bool _highRes;
uint16_t _tileMapStartAddress;
uint16_t _tilesetAddress;
bool _priority;
int _bgNumber;
//! @brief the ppu used to get registers values (ex: bg scroll)
ComSquare::PPU::PPU &_ppu;
//! @brief The tilemap configuration nb of tileMap vertically and horizontally
Vector2<int> _tileMapsConfig;
//! @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;
// TODO make better doc for direct color & high res
//! @brief PPU official direct color mode
bool _directColor;
//! @brief PPU offical highRes mode
bool _highRes;
//! @brief The first address of the tilemap data
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 the access to vram
std::shared_ptr<Ram::Ram> _vram;
//! @brief The access to cgram
std::shared_ptr<Ram::Ram> _cgram;
//! @brief Draw a tile on the screen at x y pos
void drawBgTile(uint16_t data, Vector2<int> pos);
@@ -61,7 +83,9 @@ namespace ComSquare::PPU
//! @param offset The rendering offeset in pixels
void drawBasicTileMap(uint16_t baseAddress, Vector2<int> offset);
public:
Vector2<int> backgroundSize;
//! @brief The size of the background (x, y)
Vector2<unsigned> backgroundSize;
//! @brief The output buffer (pixels are written on it)
std::array<std::array<uint32_t, 1024>, 1024> buffer;
Background(ComSquare::PPU::PPU &_ppu, int backGroundNumber, bool hasPriority);
//! @brief Render a background on his internal buffer