general clean up

This commit is contained in:
Clément Le Bihan
2021-07-08 00:48:10 +02:00
parent 5527a19348
commit 3964da9526
4 changed files with 37 additions and 34 deletions
-2
View File
@@ -86,8 +86,6 @@ namespace ComSquare::PPU
tileData.raw = data;
//if (tileData.tilePriority != this->_priority)
// return;
this->tilesPriority[indexOffset.y][indexOffset.x] = tileData.tilePriority;
this->_drawTileFromMemoryToTileBuffer(tileData);
+3 -2
View File
@@ -127,10 +127,11 @@ namespace ComSquare::PPU
return;
}
pixelLevel = backgroundSrc.isPriorityPixel(i, j) ? levelHigh : levelLow;
auto &pixelInitialLevel = pixelDestinationLevelMap[i][j];
if (pixelLevel >= pixelDestinationLevelMap[i][j]) {
if (pixelLevel >= pixelInitialLevel) {
bufferDest[i][j] = pixel;
pixelDestinationLevelMap[i][j] = pixelLevel;
pixelInitialLevel = pixelLevel;
}
j++;
});
+24 -13
View File
@@ -32,7 +32,7 @@ namespace ComSquare::PPU
{
this->_registers._isLowByte = true;
Utils::Debug::populateEnvironment(*this, 1);
Utils::Debug::populateEnvironment(*this, 0);
}
uint8_t PPU::read(uint24_t addr)
@@ -309,20 +309,33 @@ namespace ComSquare::PPU
this->renderMainAndSubScreen();
Utils::addBuffer(this->_screen, this->_subScreen);
Utils::addBuffer(this->_screen, this->_mainScreen);
//this->_backgrounds[2].renderBackground();
//add_buffer(this->_screen, this->_backgrounds[2].buffer);
int i = 0;
int j = 0;
std::for_each(this->_screen.begin(), this->_screen.end(), [this, &i, &j](const auto &row) {
std::for_each(row.begin(), row.end(), [this, &i, &j](const auto &pixel) {
this->_renderer.putPixel(i, j++, pixel);
});
j = 0;
i++;
});
/*
// loop used for debug
for (unsigned long i = 0; i < this->_screen.size(); i++) {
for (unsigned long j = 0; j < this->_screen[i].size(); j++) {
this->_renderer.putPixel(i + 200, j, this->_screen[i][j]);
this->_renderer.putPixel(i, j, this->_screen[i][j]);
}
if (i > 500)
break;
//if (i > 500)
// break;
}
*/
this->_renderer.drawScreen();
for (auto &i : this->_mainScreen)
i.fill(0XFF);
for (auto &i : this->_subScreen)
i.fill(0XFF);
for (auto &row : this->_mainScreen)
row.fill(0XFF);
for (auto &row : this->_subScreen)
row.fill(0XFF);
}
std::string PPU::getName() const
@@ -649,7 +662,7 @@ namespace ComSquare::PPU
// Not implemented
throw std::runtime_error("not implemented");
default:
break;
throw std::runtime_error("Bg mode not implemented or commented (bg nb " + std::to_string(this->_registers._bgmode.bgMode) + ")");
}
}
@@ -658,9 +671,7 @@ namespace ComSquare::PPU
if (this->_registers._t[0].raw & (1U << (bg.getBgNumber() - 1U))) {
Background::mergeBackgroundBuffer(this->_mainScreen, this->_mainScreenLevelMap, bg, level.x, level.y);
}
// Utils::addBuffer(this->_mainScreen, bg.buffer);
if (this->_registers._t[1].raw & (1U << (bg.getBgNumber() - 1U))) {
//Utils::addBuffer(this->_subScreen, bg.buffer);
Background::mergeBackgroundBuffer(this->_subScreen, this->_subScreenLevelMap, bg, level.x, level.y);
}
}
+10 -17
View File
@@ -3833,31 +3833,24 @@ namespace ComSquare::PPU::Utils::Debug
//registers tic tac toe
ppu._registers._bgmode.bgMode = 0;
ppu._backgrounds[0].setBpp(ppu.getBPP(1));
ppu._backgrounds[1].setBpp(ppu.getBPP(1));
ppu._backgrounds[2].setBpp(ppu.getBPP(2));
ppu._backgrounds[3].setBpp(ppu.getBPP(2));
ppu._backgrounds[4].setBpp(ppu.getBPP(3));
ppu._backgrounds[5].setBpp(ppu.getBPP(3));
ppu._backgrounds[6].setBpp(ppu.getBPP(4));
ppu._backgrounds[7].setBpp(ppu.getBPP(4));
ppu._backgrounds[1].setBpp(ppu.getBPP(2));
ppu._backgrounds[2].setBpp(ppu.getBPP(3));
ppu._backgrounds[3].setBpp(ppu.getBPP(4));
ppu._registers._bgmode.characterSizeBg1 = true;
ppu._registers._bgmode.characterSizeBg2 = true;
ppu._backgrounds[0].setCharacterSize(ppu.getCharacterSize(1));
ppu._backgrounds[1].setCharacterSize(ppu.getCharacterSize(1));
ppu._backgrounds[2].setCharacterSize(ppu.getCharacterSize(2));
ppu._backgrounds[3].setCharacterSize(ppu.getCharacterSize(2));
ppu._backgrounds[4].setCharacterSize(ppu.getCharacterSize(3));
ppu._backgrounds[5].setCharacterSize(ppu.getCharacterSize(3));
ppu._backgrounds[6].setCharacterSize(ppu.getCharacterSize(4));
ppu._backgrounds[7].setCharacterSize(ppu.getCharacterSize(4));
ppu._backgrounds[1].setCharacterSize(ppu.getCharacterSize(2));
ppu._backgrounds[2].setCharacterSize(ppu.getCharacterSize(3));
ppu._backgrounds[3].setCharacterSize(ppu.getCharacterSize(4));
ppu._registers._bgsc[0].tilemapAddress = 0x4000 >> 10U;
ppu._registers._bgsc[1].tilemapAddress = 0x6000 >> 10U;
ppu._backgrounds[0].setTileMapStartAddress(ppu.getTileMapStartAddress(1));
ppu._backgrounds[1].setTileMapStartAddress(ppu.getTileMapStartAddress(1));
ppu._backgrounds[2].setTileMapStartAddress(ppu.getTileMapStartAddress(2));
ppu._backgrounds[3].setTileMapStartAddress(ppu.getTileMapStartAddress(2));
ppu._backgrounds[1].setTileMapStartAddress(ppu.getTileMapStartAddress(2));
ppu._backgrounds[2].setTileMapStartAddress(ppu.getTileMapStartAddress(3));
ppu._backgrounds[3].setTileMapStartAddress(ppu.getTileMapStartAddress(4));
//ppu._registers._bgofs[2].raw = 0x03E0;
//ppu._registers._bgofs[3].raw = 0x03DF;