Skip to content

Instantly share code, notes, and snippets.

@bashaus
Last active August 29, 2015 14:27
Show Gist options
  • Select an option

  • Save bashaus/af263b4266ea4094e5e1 to your computer and use it in GitHub Desktop.

Select an option

Save bashaus/af263b4266ea4094e5e1 to your computer and use it in GitHub Desktop.
Enable, disable and switch between interrupts (LCD, VBLANK) in GBDK (Game Boy C)
void (*VBLANKListener)();
void noop() { /* Do nothing */ }
void MainVBLANK() {
disable_interrupts();
(*VBLANKListener)();
enable_interrupts();
}
void main() {
VBLANKListener = noop;
add_VBL(MainVBLANK);
}
disable_interrupts();
VBLANKListener = noop;
enable_interrupts();
void WorldVBLANK() {
/* Interrupt code goes here */
}
disable_interrupts();
VBLANKListener = WorldVBLANK;
enable_interrupts();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment