#86770 - Exophase - Fri Jun 09, 2006 3:28 am
GBATEK clearly says they don't occur, but both No$GBA and VBA seem to be generating them, which one is it on actual hardware? If I'm wrong about the emulators please correct me as well, but it definitely seems to be the case (and a glance at VBA's source backs this up).. it's be weird for No$GBA to behave that way when the doc by the very same author contradicts it though.
#86778 - tepples - Fri Jun 09, 2006 5:49 am
Hblank interrupts do occur during vblank. Hblank DMA does not occur during vblank.
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#86784 - Ant6n - Fri Jun 09, 2006 7:17 am
so when the screen is done drawing you can actually have an hblank and vblank interrupt happening at the same time (i.e. two bits set in IF) ?
I always thought that this is very unlikely to happen.
#86799 - Exophase - Fri Jun 09, 2006 1:11 pm
Thanks, that's very good to know (writing an emulator), GBATEK really should be corrected then, this is what it says:
"Note that no H-Blank interrups are generated within V-Blank period."
Ant6n; I don't think that'll happen, as far as I'm aware the vblank will start (and thus the interrupt will occur) at the beginning of the "virtual" vertical refresh period of line 160, while the hblank won't start until the last 68 "virtual" pixels of that line. Besides that I don't think interrupts can really occur at the same time anyway, not with the way the hardware works, even if they're to happen at the same time one will get to the CPU first and the other will have to wait for interrupts to be enabled again.
#86858 - edwdig - Fri Jun 09, 2006 11:21 pm
Ant6n wrote: |
so when the screen is done drawing you can actually have an hblank and vblank interrupt happening at the same time (i.e. two bits set in IF) ?
I always thought that this is very unlikely to happen. |
Mutliple interrupts can definitely occur at the same time. I had a bug that took me forever to track down where once every several thousand frames one of my interrupts wouldn't trigger. Turns out a lot of the interrupt handlers you find floating on the net don't cope with multiple simultaneous interrupts.
#87362 - Ultima2876 - Tue Jun 13, 2006 3:52 pm
I have this bug too... how did you fix it?
#87366 - tepples - Tue Jun 13, 2006 4:02 pm
A GBA multiple interrupt service routine will look like this:
Code: |
void isr(void) {
unsigned int interrupts = REG_IF;
if (interrupts & INT_TIMER1) {
// switch the audio buffer
}
if (interrupts & INT_HBLANK) {
// hblank code goes here, although it may be faster to use hdma
}
if (interrupts & INT_SERIAL) {
// add the received data to a ring buffer
// send the next byte of the packet
}
if (interrupts & INT_VBLANK) {
// vblank code goes here
}
// Acknowledge those interrupts that we handled to the BIOS...
VBLANK_INTR_WAIT_FLAGS |= interrupts; // notice: |= not =
// ...and to the hardware.
REG_IF = interrupts; // notice: = not |=
} |
_________________
-- Where is he?
-- Who?
-- You know, the human.
-- I think he moved to Tilwick.
#87459 - Ant6n - Wed Jun 14, 2006 12:45 am
PERN has a working one, at leas that's what they told me in the asm thread.