NMI: Prevent NMI being skipped when $4210 is read during the first dot of the NMI scanline (fixes issues in Terranigma)
This commit is contained in:
parent
4602ae331f
commit
24beded73d
1 changed files with 10 additions and 4 deletions
|
@ -107,11 +107,17 @@ uint8_t InternalRegisters::Read(uint16_t addr)
|
|||
{
|
||||
switch(addr) {
|
||||
case 0x4210: {
|
||||
uint8_t value =
|
||||
(_nmiFlag ? 0x80 : 0) |
|
||||
0x02; //CPU revision
|
||||
constexpr uint8_t cpuRevision = 0x02;
|
||||
|
||||
uint8_t value = (_nmiFlag ? 0x80 : 0) | cpuRevision;
|
||||
|
||||
//Reading $4210 on any cycle turns the NMI signal off (except presumably on the first PPU cycle (first 4 master clocks) of the NMI scanline.)
|
||||
//i.e: reading $4210 at the same it gets set will return it as set, and will keep it set.
|
||||
//Without this, Terranigma has corrupted sprites on some frames.
|
||||
if(_memoryManager->GetHClock() >= 4 || _ppu->GetScanline() != _ppu->GetNmiScanline()) {
|
||||
SetNmiFlag(false);
|
||||
}
|
||||
|
||||
SetNmiFlag(false);
|
||||
return value | (_memoryManager->GetOpenBus() & 0x70);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue