Hi, I'm working on a GB emulator.
I'm trying to understand its interrupt behavior. I'm testing with a simple ROM-only game, Alleyway.
It appears to be doing some initialization, then tries to write a 1 to 0xFF0F. This means it's trying to trigger a VBlank interrupt manually.
HOWEVER, it never seems to set the enable flag for VBlank in the enable register at 0xFFFF.
Right now, it just sits in a tight loop writing 1 to 0xFF0F, but the interrupt never happens because it's not enabled.
If I allow the interrupt to happen anyway, it does continue on to other code and it seems to initialize the game's RAM values.
Three possibilities:
1. The enable flag for VBlank should already be set at startup.
2. I have a different bug than #1.
3. I'm missing something obvious, which I have certainly been known to do!
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, or just one or the other? Maybe this is related to my problem.
EDIT 2: The game is not writing anything to the LCDC yet, so that's not the problem. And nevermind, I get the point of the LCDC VBlank enable flag now. It would trigger a different interrupt vector (0x48 instead of 0x40)
I'm trying to understand its interrupt behavior. I'm testing with a simple ROM-only game, Alleyway.
It appears to be doing some initialization, then tries to write a 1 to 0xFF0F. This means it's trying to trigger a VBlank interrupt manually.
HOWEVER, it never seems to set the enable flag for VBlank in the enable register at 0xFFFF.
Right now, it just sits in a tight loop writing 1 to 0xFF0F, but the interrupt never happens because it's not enabled.
If I allow the interrupt to happen anyway, it does continue on to other code and it seems to initialize the game's RAM values.
Three possibilities:
1. The enable flag for VBlank should already be set at startup.
2. I have a different bug than #1.
3. I'm missing something obvious, which I have certainly been known to do!
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, or just one or the other? Maybe this is related to my problem.
EDIT 2: The game is not writing anything to the LCDC yet, so that's not the problem. And nevermind, I get the point of the LCDC VBlank enable flag now. It would trigger a different interrupt vector (0x48 instead of 0x40)