Quote:
The only trouble I had with it was I messed up acknowledgement of IRQs causing problems.
I may have the same problem. Everything seems to work ok until I get to the first vertical scrolling location in level 1:
If I fiddle with the IRQ counter after the IRQ counter reaches the target scanline, I can sort of get the background to display properly.
Any ideas?
Code:
void Nes::Mapper5::HBlank(int scanline)
{
if (scanline < 241)
{
if(ppu->DrawingEnabled())
{
if (inFrame == 0)
{
inFrame = 1;
irqCounter = 0;
irqPending = 0;
}
else
{
irqCounter++;
if (irqCounter == irqTarget)
{
irqPending = 1;
if (irqEnable)
{
cpu->ExecuteIRQ();
}
}
}
}
else
{
inFrame = 0;
}
}
else if (scanline == 241)
{
inFrame = 0;
irqCounter = 0;
}
}
void Nes::Mapper5::WriteByte(unsigned short address, unsigned char value)
{
switch (address)
{
//...
case 0x5203:
irqTarget = value;
break;
case 0x5204:
if (!irqEnable)
{
irqEnable = value & 0x80;
if (irqPending && irqEnable)
cpu->ExecuteIRQ();
}
break;
//...
}
unsigned char Nes::Mapper5::ReadByte(unsigned short address)
{
switch (address)
{
//...
case 0x5204:
int val = (inFrame << 6) | (irqPending << 7);
irqPending = 0;
return val;
}
//...
}