#42650 - Impatient - Fri May 13, 2005 7:53 pm
How do I setup a standard VBLANK that I can use in all GBA demos, samples and games? I assume a vblank just waits for the vblank to happen and then returns? you guys have a vblank() you call before any updates, am I right?
#42663 - Kyoufu Kawa - Fri May 13, 2005 9:25 pm
Method 1
A while loop that checks for the current scanline value to land in the VBlank region.
Method 2
An SWI call. That's what I use.
Both can be wrapped in a handy-dandy function.
#42674 - Impatient - Fri May 13, 2005 11:05 pm
Could you post a code sample of the version you use?
#42728 - Kyoufu Kawa - Sat May 14, 2005 10:10 am
I use method 2 and can't remember the specifics. And even if I did, I've been told not to tell.
Will somebody please give this guy an SWI Vblank sample?
#42854 - yuriks - Sun May 15, 2005 7:11 pm
Use interrupts:
Code: |
void vsync_int() {
// do stuff
}
void handle_int() {
// if its an VBLANK interrupt...
if (REG_IF & IE_VBL) {
// Flag it as handled...
REG_IF |= IE_VBL;
// And call our handler function.
vsync_irq();
}
}
int main() {
// Enable the VBLANK interrupt in the video register.
REG_DISPSTAT = (LCDC_VBL);
// Enable the VBLANK interrupt in the interrupt register.
REG_IE = (IE_VBL);
// Tell the GBA that we want this function to handle interrupts.
INT_VECTOR = &handle_int;
// Enable interrupts.
REG_IME = 1;
// Rest.
while (1) { }
}
|
Study the code. Hope I helped.
_________________
---yuriks---
#42858 - Kyoufu Kawa - Sun May 15, 2005 7:43 pm
...and that would be the third method.