Loading...
Searching...
No Matches
interrupt.h File Reference

SNES Interrupt Handling. More...

#include <snes/types.h>

Go to the source code of this file.

Typedefs

typedef void(* VBlankCallback) (void)
 VBlank callback function pointer type.
 

Functions

void nmiClear (void)
 Clear the VBlank callback.
 
void nmiSet (VBlankCallback callback)
 Register a VBlank callback function.
 
void nmiSetBank (VBlankCallback callback, u8 bank)
 Register a VBlank callback with explicit bank.
 

Detailed Description

SNES Interrupt Handling.

Manages NMI (VBlank), IRQ, and other interrupts.

Author
OpenSNES Team

Typedef Documentation

◆ VBlankCallback

typedef void(* VBlankCallback) (void)

VBlank callback function pointer type.

Functions of this type can be registered with nmiSet() to be called automatically during every VBlank interrupt.

Function Documentation

◆ nmiClear()

void nmiClear ( void  )

Clear the VBlank callback.

Equivalent to nmiSet(NULL).

◆ nmiSet()

void nmiSet ( VBlankCallback  callback)

Register a VBlank callback function.

The registered callback will be called during every VBlank interrupt, BEFORE the vblank_flag is set. This allows time-critical operations (like DMA transfers) to be performed reliably during VBlank.

Parameters
callbackFunction to call during VBlank, or NULL to disable
void myVBlankHandler(void) {
// DMA transfer, scroll updates, etc.
}
int main(void) {
nmiSet(myVBlankHandler);
while (1) {
// Game logic here
}
}
int main(void)
Entry point — initialize audio, display controls, run transport loop.
Definition main.c:37
void consoleInit(void)
Initialize SNES hardware.
void WaitForVBlank(void)
Wait for next VBlank period.
void nmiSet(VBlankCallback callback)
Register a VBlank callback function.
Note
Keep callbacks short! VBlank time is limited (~2200 CPU cycles on NTSC)
Callback runs with interrupts disabled
The callback function must be in the same ROM bank as the main code (bank 0). For larger projects, use nmiSetBank() to specify the bank explicitly.

◆ nmiSetBank()

void nmiSetBank ( VBlankCallback  callback,
u8  bank 
)

Register a VBlank callback with explicit bank.

Use this when the callback function might not be in bank 0.

Parameters
callbackFunction to call during VBlank
bankROM bank where the callback is located (0-255)