PPU: Mode 7 Ext BG mode

This commit is contained in:
Sour 2019-02-23 16:04:04 -05:00
parent 39ae565aa1
commit 19a6663ed9
3 changed files with 39 additions and 13 deletions

View file

@ -352,9 +352,15 @@ void Ppu::RenderMode7()
{ {
RenderSprites<3, forMainScreen>(); RenderSprites<3, forMainScreen>();
RenderSprites<2, forMainScreen>(); RenderSprites<2, forMainScreen>();
if(_mode7.ExtBgEnabled) {
RenderTilemapMode7<1, forMainScreen, false, true>();
}
RenderSprites<1, forMainScreen>(); RenderSprites<1, forMainScreen>();
RenderTilemapMode7<0, forMainScreen, false>(); RenderTilemapMode7<0, forMainScreen, false, false>();
RenderSprites<0, forMainScreen>(); RenderSprites<0, forMainScreen>();
if(_mode7.ExtBgEnabled) {
RenderTilemapMode7<1, forMainScreen, false, false>();
}
RenderBgColor<forMainScreen>(); RenderBgColor<forMainScreen>();
} }
@ -619,7 +625,7 @@ void Ppu::RenderTilemap()
} }
} }
template<uint8_t layerIndex, bool forMainScreen, bool applyMosaic> template<uint8_t layerIndex, bool forMainScreen, bool applyMosaic, bool processHighPriority>
void Ppu::RenderTilemapMode7() void Ppu::RenderTilemapMode7()
{ {
uint16_t realY = _mode7.VerticalMirroring ? (255 - _scanline) : _scanline; uint16_t realY = _mode7.VerticalMirroring ? (255 - _scanline) : _scanline;
@ -699,7 +705,18 @@ void Ppu::RenderTilemapMode7()
} }
uint8_t tileIndex = _vram[(((yOffset & ~0x07) << 4) | (xOffset >> 3)) << 1] & tileMask; uint8_t tileIndex = _vram[(((yOffset & ~0x07) << 4) | (xOffset >> 3)) << 1] & tileMask;
uint16_t paletteRamOffset = (_vram[(((tileIndex << 6) + ((yOffset & 0x07) << 3) + (xOffset & 0x07)) << 1) + 1]) << 1; uint16_t paletteRamOffset;
if(layerIndex == 1) {
uint8_t color = _vram[(((tileIndex << 6) + ((yOffset & 0x07) << 3) + (xOffset & 0x07)) << 1) + 1];
if(((uint8_t)processHighPriority << 7) != (color & 0x80)) {
//Wrong priority, skip this pixel
continue;
}
paletteRamOffset = (color & 0x7F) << 1;
} else {
paletteRamOffset = (_vram[(((tileIndex << 6) + ((yOffset & 0x07) << 3) + (xOffset & 0x07)) << 1) + 1]) << 1;
}
if(paletteRamOffset > 0) { if(paletteRamOffset > 0) {
if(forMainScreen) { if(forMainScreen) {
@ -1302,6 +1319,16 @@ void Ppu::Write(uint32_t addr, uint8_t value)
} }
break; break;
case 0x2133:
//SETINI - Screen Mode/Video Select
//_externalSync = (value & 0x80) != 0; //NOT USED
_mode7.ExtBgEnabled = (value & 0x40) != 0;
//_hiresMode = (value & 0x08) != 0; //TODO
//_overscanMode = (value & 0x04) != 0; //TODO
//_objInterlace = (value & 0x02) != 0; //TODO
//_screenInterlace = (value & 0x01) != 0; //TODO
break;
default: default:
MessageManager::DisplayMessage("Debug", "Unimplemented register write: " + HexUtilities::ToHex(addr) + " = " + HexUtilities::ToHex(value)); MessageManager::DisplayMessage("Debug", "Unimplemented register write: " + HexUtilities::ToHex(addr) + " = " + HexUtilities::ToHex(value));
break; break;

View file

@ -164,7 +164,7 @@ private:
template<uint8_t layerIndex, uint8_t bpp, bool processHighPriority, bool forMainScreen, bool largeTiles, uint16_t basePaletteOffset, uint8_t activeWindowCount, bool applyMosaic> template<uint8_t layerIndex, uint8_t bpp, bool processHighPriority, bool forMainScreen, bool largeTiles, uint16_t basePaletteOffset, uint8_t activeWindowCount, bool applyMosaic>
void RenderTilemap(); void RenderTilemap();
template<uint8_t layerIndex, bool forMainScreen, bool applyMosaic> template<uint8_t layerIndex, bool forMainScreen, bool applyMosaic, bool processHighPriority>
void RenderTilemapMode7(); void RenderTilemapMode7();
template<bool applyMosaic> template<bool applyMosaic>

View file

@ -24,21 +24,20 @@ struct LayerConfig
struct Mode7Config struct Mode7Config
{ {
int16_t Matrix[4];
int16_t HScroll; int16_t HScroll;
int16_t VScroll; int16_t VScroll;
bool LargeMap;
bool FillWithTile0;
bool HorizontalMirroring;
bool VerticalMirroring;
int16_t CenterX; int16_t CenterX;
int16_t CenterY; int16_t CenterY;
int16_t Matrix[4];
uint8_t ValueLatch; uint8_t ValueLatch;
bool LargeMap;
bool FillWithTile0;
bool HorizontalMirroring;
bool VerticalMirroring;
bool ExtBgEnabled;
}; };
struct WindowConfig struct WindowConfig