mirror of
https://github.com/zoriya/ComSquare.git
synced 2025-12-20 22:25:11 +00:00
starting implementing bg scroll
This commit is contained in:
@@ -30,7 +30,7 @@ namespace ComSquare::PPU
|
|||||||
void Background::renderBackground()
|
void Background::renderBackground()
|
||||||
{
|
{
|
||||||
uint16_t vramAddress = this->_tileMapStartAddress;
|
uint16_t vramAddress = this->_tileMapStartAddress;
|
||||||
Vector2<int> offset(0, 0);
|
Vector2<int> offset = this->_ppu.getBgScroll(this->_bgNumber);
|
||||||
this->backgroundSize.x = this->_tileMaps.x * this->_characterSize.x * NB_CHARACTER_WIDTH;
|
this->backgroundSize.x = this->_tileMaps.x * this->_characterSize.x * NB_CHARACTER_WIDTH;
|
||||||
this->backgroundSize.y = this->_tileMaps.y * this->_characterSize.y * NB_CHARACTER_HEIGHT;
|
this->backgroundSize.y = this->_tileMaps.y * this->_characterSize.y * NB_CHARACTER_HEIGHT;
|
||||||
|
|
||||||
|
|||||||
@@ -141,6 +141,8 @@ namespace ComSquare::PPU
|
|||||||
this->_backgrounds[2].setTileMapStartAddress(this->getTileMapStartAddress(2));
|
this->_backgrounds[2].setTileMapStartAddress(this->getTileMapStartAddress(2));
|
||||||
this->_backgrounds[3].setTileMapStartAddress(this->getTileMapStartAddress(2));
|
this->_backgrounds[3].setTileMapStartAddress(this->getTileMapStartAddress(2));
|
||||||
|
|
||||||
|
//this->_registers._bgofs[2].raw = 0x03E0;
|
||||||
|
//this->_registers._bgofs[3].raw = 0x03DF;
|
||||||
this->_registers._t[0].enableWindowDisplayBg1 = true;
|
this->_registers._t[0].enableWindowDisplayBg1 = true;
|
||||||
this->_registers._t[0].enableWindowDisplayBg2 = true;
|
this->_registers._t[0].enableWindowDisplayBg2 = true;
|
||||||
|
|
||||||
@@ -699,8 +701,11 @@ namespace ComSquare::PPU
|
|||||||
{
|
{
|
||||||
uint16_t colorPalette;
|
uint16_t colorPalette;
|
||||||
// should only render backgrounds needed (depending of th bgMode)
|
// should only render backgrounds needed (depending of th bgMode)
|
||||||
for (auto & _background : this->_backgrounds)
|
int i = 0;
|
||||||
|
for (auto &_background : this->_backgrounds) {
|
||||||
|
i++;
|
||||||
_background.renderBackground();
|
_background.renderBackground();
|
||||||
|
}
|
||||||
// TODO make a function getDefaultBgColor
|
// TODO make a function getDefaultBgColor
|
||||||
colorPalette = this->cgram->read_internal(0);
|
colorPalette = this->cgram->read_internal(0);
|
||||||
colorPalette += this->cgram->read_internal(1) << 8U;
|
colorPalette += this->cgram->read_internal(1) << 8U;
|
||||||
@@ -824,4 +829,9 @@ namespace ComSquare::PPU
|
|||||||
this->_vramReadBuffer = this->vram->read_internal(this->getVramAddress());
|
this->_vramReadBuffer = this->vram->read_internal(this->getVramAddress());
|
||||||
this->_vramReadBuffer += this->vram->read_internal(this->getVramAddress() + 1) << 8;
|
this->_vramReadBuffer += this->vram->read_internal(this->getVramAddress() + 1) << 8;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vector2<int> PPU::getBgScroll(int bgNumber) const
|
||||||
|
{
|
||||||
|
return Vector2<int>(this->_registers._bgofs[(bgNumber - 1) * 2].offsetBg, this->_registers._bgofs[(bgNumber - 1) * 2 + 1].offsetBg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -627,6 +627,8 @@ namespace ComSquare::PPU
|
|||||||
int getBgMode() const;
|
int getBgMode() const;
|
||||||
//! @brief update the Vram buffer
|
//! @brief update the Vram buffer
|
||||||
void updateVramReadBuffer();
|
void updateVramReadBuffer();
|
||||||
|
//! @brief update the Vram buffer
|
||||||
|
Vector2<int> getBgScroll(int bgNumber) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user