Skip to content

H-blank IRQs appear to fire too early? #2310

@fleroviux

Description

@fleroviux

I attempted to measure some PPU timings to make sense of the Metal Max 2 Kai (first revision) bug that mGBA used to have and NanoBoyAdvance still has. In particular I was interested in the H-blank IRQ timing due to the nature of the race condition.

I compared measurements between HW, mGBA and NBA and found what I believe means that mGBA could fire the H-blank IRQ ~48 cycles too early.

My test ROM synchronizes to the start of a scanline (when VCOUNT changes) and then triggers an immediate DMA to pull samples from REG_IF into a buffer. The lower 8-bits of the samples are then dumped into SRAM.

For mGBA the H-blank IRQ bit is asserted during sample 0x1D0
grafik

While on real hardware it is asserted during sample 0x1E8
grafik

Each sample should amount to 2 cycles (1 REG_IF read and 1 IWRAM write)

Here is the test ROM I've used. The source code also contains two additional tests which are commented out but there didn't appear to be any issues with them.
newhblankirq.zip

Of course raising the IRQ at a later time would most likely have influence on the Metal Max 2 Kai race condition, so this needs to be approached carefully. I don't yet know how to fire the H-blank IRQ at the right point in time and also have that game work...

Metadata

Metadata

Assignees

No one assigned

    Labels

    platform:GBAGame Boy Advance-related issues

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions