debugging weird error i think i found something

This commit is contained in:
Clément Le Bihan
2021-07-03 15:59:55 +02:00
parent c3d4638ce3
commit 59829a7c0c
3 changed files with 16 additions and 9 deletions
+1
View File
@@ -40,6 +40,7 @@ namespace ComSquare::PPU
this->backgroundSize.y = this->_tileMapsConfig.y * this->_characterNbPixels.y * NbCharacterHeight;
for (int i = 0; i < 4; i++) {
// TODO fix detection ()it's broken and do call with a wring offset that cause the drawbg to draw on another background (set bgNumber 1 to 0)
if (!(i == 1 && this->_tileMapsConfig.x == 1) && !(i > 1 && this->_tileMapsConfig.y == 1)) {
_drawBasicTileMap(vramAddress, offset);
}
+1
View File
@@ -31,6 +31,7 @@ namespace ComSquare::PPU
//! @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
//! @note members are set to 1 if the tilemap is expended in their direction
Vector2<int> _tileMapsConfig;
//! @brief The number of pixels of a character (x: width, y:height)
Vector2<int> _characterNbPixels;
+14 -9
View File
@@ -36,7 +36,7 @@ namespace ComSquare::PPU
{
this->_registers._isLowByte = true;
Utils::Debug::populateEnvironment(*this, 0);
//Utils::Debug::populateEnvironment(*this, 0);
}
uint8_t PPU::read(uint24_t addr)
@@ -123,12 +123,18 @@ namespace ComSquare::PPU
case PpuRegisters::bg2sc:
case PpuRegisters::bg3sc:
case PpuRegisters::bg4sc:
this->_registers._bgsc[addr - 0x07].raw = data;
this->_registers._bgsc[addr - PpuRegisters::bg1sc].raw = data;
// update background tilemap address
this->_backgrounds[addr - 0x07].setTileMapStartAddress(this->getTileMapStartAddress(addr - 0x07 + 1));
this->_backgrounds[addr - 0x07 + 1].setTileMapStartAddress(this->getTileMapStartAddress(addr - 0x07 + 1));
this->_backgrounds[addr - 0x07].setTilemaps({this->_registers._bgsc[addr - 0x07].tilemapHorizontalMirroring, this->_registers._bgsc[addr - 0x07].tilemapVerticalMirroring});
this->_backgrounds[addr - 0x07 + 1].setTilemaps({this->_registers._bgsc[addr - 0x07].tilemapHorizontalMirroring, this->_registers._bgsc[addr - 0x07].tilemapVerticalMirroring});
this->_backgrounds[addr - PpuRegisters::bg1sc].setTileMapStartAddress(
this->getTileMapStartAddress(addr - PpuRegisters::bg1sc + 1));
this->_backgrounds[addr - PpuRegisters::bg1sc + 1].setTileMapStartAddress(
this->getTileMapStartAddress(addr - PpuRegisters::bg1sc + 1));
this->_backgrounds[addr - PpuRegisters::bg1sc].setTilemaps(
{this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapHorizontalMirroring,
this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapVerticalMirroring});
this->_backgrounds[addr - PpuRegisters::bg1sc + 1].setTilemaps(
{this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapHorizontalMirroring,
this->_registers._bgsc[addr - PpuRegisters::bg1sc].tilemapVerticalMirroring});
break;
case PpuRegisters::bg12nba:
case PpuRegisters::bg34nba:
@@ -303,7 +309,6 @@ namespace ComSquare::PPU
{
(void)cycles;
this->renderMainAndSubScreen();
this->add_buffer(this->_screen, this->_subScreen);
this->add_buffer(this->_screen, this->_mainScreen);
@@ -548,9 +553,9 @@ namespace ComSquare::PPU
{
uint16_t colorPalette;
// should only render backgrounds needed (depending of th bgMode)
//int i = 0;
int i = 0;
for (auto &_background : this->_backgrounds) {
//i++;
i++;
_background.renderBackground();
}
// TODO make a function getDefaultBgColor