jeremyBanks / 0dmg

Learning Rust by building a partial Game Boy emulator.
MIT License
18 stars 2 forks source link

Interrupts #3

Open jeremyBanks opened 6 years ago

jeremyBanks commented 6 years ago

What are interrupts?

The Game Boy defines five types of "interrupts". Each is a type of event that can occur during execution. Each interrupt type has a constant handler address. When an interrupt is triggered, the CPU jumps to the handler instead of executing the next instruction. It will also temporarily disable interrupts, so that your interrupt doesn't itself get interrupted, although this can be toggled back if desired. Each interrupt handler routine typically ends with a RETI instruction to jump back to the original instruction address and re-enable interrupts.

An interrupt is "triggered", either manually or automatically, by setting the appropriate bit of the interrupt trigger flag register at 0xFF0F. The corresponding bit in the interrupt enable flag register at 0xFFFF must be set, or else the request is ignored. If the interrupt is triggered, the corresponding request flag bit is cleared, but if it's ignored it remains set, and may be triggered if the corresponding enable bit becomes set later.

What do I need to implement?

jeremyBanks commented 6 years ago