miker00lz wrote:
EDIT: Another question I have is, why is there a VBlank interrupt enable flag in both FF41 LCDC register, AND in the IE at FFFF? Do they both need to enabled
$FF41 is STAT, which can generate an IRQ in response to the PPU entering any of four different conditions: hblank (mode 0), vblank (mode 1), OAM scan (mode 2), or LY=LYC (scanline counter). Games typically use this for LY=LYC or hblank, not vblank, because (as you figured out) vblank already has a separate interrupt vector. To use STAT interrupts, you need to both enable a condition ($FF41 bits 6-3) and enable STAT interrupts in general ($FFFF bit 1).
If one STAT condition occurs, and a second STAT condition begins at or before the end of the first, you won't get another STAT IRQ. The way it works is all four conditions are OR'd together, and only a 0 to 1 transition of the result causes an interrupt. Thus if hblank and OAM scan are enabled, you'll get only one interrupt for OAM scan per frame, on line 0, and only the hblank interrupt at the end of lines 0-143. Similarly for OAM scan and LY=LYC or LY=LYC and hblank, as LY=LYC begins one cycle after the start of OAM scan.