PPU: Fixed palette selection for BG2/3/4 in mode 0

This commit is contained in:
Sour 2019-02-19 22:44:05 -05:00
parent 221bc44700
commit 4264779b26
2 changed files with 9 additions and 9 deletions

View file

@ -170,16 +170,16 @@ void Ppu::RenderScanline()
case 0: case 0:
DrawSprites<3, true>(); DrawSprites<3, true>();
RenderTilemap<0, 2, true, true>(); RenderTilemap<0, 2, true, true>();
RenderTilemap<1, 2, true, true>(); RenderTilemap<1, 2, true, true, 64>();
DrawSprites<2, true>(); DrawSprites<2, true>();
RenderTilemap<0, 2, false, true>(); RenderTilemap<0, 2, false, true>();
RenderTilemap<1, 2, false, true>(); RenderTilemap<1, 2, false, true, 64>();
DrawSprites<1, true>(); DrawSprites<1, true>();
RenderTilemap<2, 2, true, true>(); RenderTilemap<2, 2, true, true, 128>();
RenderTilemap<3, 2, true, true>(); RenderTilemap<3, 2, true, true, 192>();
DrawSprites<0, true>(); DrawSprites<0, true>();
RenderTilemap<2, 2, false, true>(); RenderTilemap<2, 2, false, true, 128>();
RenderTilemap<3, 2, false, true>(); RenderTilemap<3, 2, false, true, 192>();
RenderBgColor<true>(); RenderBgColor<true>();
break; break;
@ -372,7 +372,7 @@ void Ppu::RenderBgColor()
} }
} }
template<uint8_t layerIndex, uint8_t bpp, bool processHighPriority, bool forMainScreen> template<uint8_t layerIndex, uint8_t bpp, bool processHighPriority, bool forMainScreen, uint16_t basePaletteOffset>
void Ppu::RenderTilemap() void Ppu::RenderTilemap()
{ {
if(forMainScreen) { if(forMainScreen) {
@ -431,7 +431,7 @@ void Ppu::RenderTilemap()
} }
if(color > 0) { if(color > 0) {
uint16_t paletteRamOffset = (palette * (1 << bpp) + color) * 2; uint16_t paletteRamOffset = basePaletteOffset + (palette * (1 << bpp) + color) * 2;
uint16_t paletteColor = _cgram[paletteRamOffset] | (_cgram[paletteRamOffset + 1] << 8); uint16_t paletteColor = _cgram[paletteRamOffset] | (_cgram[paletteRamOffset + 1] << 8);
if(forMainScreen) { if(forMainScreen) {

View file

@ -86,7 +86,7 @@ private:
template<bool forMainScreen> template<bool forMainScreen>
void RenderBgColor(); void RenderBgColor();
template<uint8_t layerIndex, uint8_t bpp, bool processHighPriority, bool forMainScreen> template<uint8_t layerIndex, uint8_t bpp, bool processHighPriority, bool forMainScreen, uint16_t basePaletteOffset = 0>
void RenderTilemap(); void RenderTilemap();
template<uint8_t priority, bool forMainScreen> template<uint8_t priority, bool forMainScreen>