HDMA: Improved HDMA init timing (and fixed potential problems caused by running it in the middle of a PPU cycle)

This commit is contained in:
Sour 2019-03-25 22:59:18 -04:00
parent e0b0ac3a96
commit 713b83c1fb

View file

@ -140,7 +140,6 @@ void Ppu::Exec()
if(_mosaicEnabled) {
_mosaicStartScanline = 0;
}
_console->GetDmaController()->InitHdmaChannels();
}
if(_regs->IsVerticalIrqEnabled() && !_regs->IsHorizontalIrqEnabled() && _scanline == _regs->GetVerticalTimer()) {
@ -165,13 +164,18 @@ void Ppu::Exec()
}
}
if(_cycle == 278 && _scanline <= (_overscanMode ? 239 : 224)) {
if(_scanline != 0) {
RenderScanline();
}
if(!_forcedVblank) {
EvaluateNextLineSprites();
_console->GetDmaController()->ProcessHdmaChannels();
if(_scanline <= (_overscanMode ? 239 : 224)) {
if(_cycle == 278) {
if(_scanline != 0) {
RenderScanline();
}
if(!_forcedVblank) {
EvaluateNextLineSprites();
_console->GetDmaController()->ProcessHdmaChannels();
}
} else if(_scanline == 0 && _cycle == 6) {
//TODO : To verify: Do HDMA channels get initialized even in forced blank?
_console->GetDmaController()->InitHdmaChannels();
}
} else if((_cycle == 134 || _cycle == 135) && (_console->GetMemoryManager()->GetMasterClock() & 0x07) == 0) {
//TODO Approximation (DRAM refresh timing is not exact)