diff --git a/sources/PPU/Background.cpp b/sources/PPU/Background.cpp index dc90389..d337717 100644 --- a/sources/PPU/Background.cpp +++ b/sources/PPU/Background.cpp @@ -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); } diff --git a/sources/PPU/Background.hpp b/sources/PPU/Background.hpp index abbc00e..518b622 100644 --- a/sources/PPU/Background.hpp +++ b/sources/PPU/Background.hpp @@ -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 _tileMapsConfig; //! @brief The number of pixels of a character (x: width, y:height) Vector2 _characterNbPixels; diff --git a/sources/PPU/PPU.cpp b/sources/PPU/PPU.cpp index 1cd16aa..284e2b9 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, 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