#22364 - kanelo - Sat Jun 19, 2004 1:23 pm
Hi people from gbadev.
I'm using HAM, but without ham libraries. I set up interrupts like this:
INT_DISABLE;
// load the address of the interrupt handler
INT_DIR = (u32) IRQHandler;
// set wich interrupts could trigger interrupt handler
SET_INT(INT_VBLANK);
// enable vblank interrupt in REG_DISPSTAT
REG_DISPSTAT |= 0x8;
// enable interrupts
INT_ENABLE;
The Upper case are macros, or defines. So I set a funtion where to jump when an interrupt occurs, IRQHandler. Inside this function I check which one happened and do something.
void IRQHandler(void)
{
INT_DISABLE;
if( REG_IF == INT_VBLANK )
{
g_NewFrame = TRUE;
}
INT_ENABLE;
}
It wroks nice, but I wanted to know which is the best way to do this. I know this is not the best way. I also wanted some advice about interrupts, based on experience ^_^
Thank you for your time.
I'm using HAM, but without ham libraries. I set up interrupts like this:
INT_DISABLE;
// load the address of the interrupt handler
INT_DIR = (u32) IRQHandler;
// set wich interrupts could trigger interrupt handler
SET_INT(INT_VBLANK);
// enable vblank interrupt in REG_DISPSTAT
REG_DISPSTAT |= 0x8;
// enable interrupts
INT_ENABLE;
The Upper case are macros, or defines. So I set a funtion where to jump when an interrupt occurs, IRQHandler. Inside this function I check which one happened and do something.
void IRQHandler(void)
{
INT_DISABLE;
if( REG_IF == INT_VBLANK )
{
g_NewFrame = TRUE;
}
INT_ENABLE;
}
It wroks nice, but I wanted to know which is the best way to do this. I know this is not the best way. I also wanted some advice about interrupts, based on experience ^_^
Thank you for your time.