gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > swiWaitForVBlank() problem

#62830 - Dannon - Tue Dec 06, 2005 7:56 am

When I run swiWaitForVBlank() my code stopped.

Code:

int main(void)
{
   if ( !Initialise() )
      return Exit();

   while( 1 )
   {
//      Vertical Blank
      swiWaitForVBlank();

//      Update world   
      pWorld->Update();
   }
   
   return Exit();
}


I added:

Code:

bool Initialise()
{
//   Initialise the interrupt system
   irqInit();
//   install our simple vblank handler
   irqSet(IRQ_VBLANK, VBlank);
//    Enable the interrupt
   irqEnable(IRQ_VBLANK);
}

void VBlank
{

}


and now it kind of works, but the screen flickers alot

--Dannon

#62835 - doublec - Tue Dec 06, 2005 9:12 am

In your VBlank function you need to note that you've processed the VBlank call by setting a value at a memory location. The BIOS SWI call spins on this and then returns when the value has changed appropriately. For example:

Code:
VBLANK_INTR_WAIT_FLAGS |= IRQ_VBLANK;


See:

http://www.double.co.nz/nintendo_ds/nds_develop8.html

for more info.

#62841 - Dannon - Tue Dec 06, 2005 9:46 am

Well I have added that and gone through your tutorial but I am still getting a lot of scan line problems, there is a lot of flickering and I can't really see the screen

--Dannon

#62848 - wintermute - Tue Dec 06, 2005 12:03 pm

doublec wrote:
In your VBlank function you need to note that you've processed the VBlank call by setting a value at a memory location. The BIOS SWI call spins on this and then returns when the value has changed appropriately. For example:

Code:
VBLANK_INTR_WAIT_FLAGS |= IRQ_VBLANK;


See:

http://www.double.co.nz/nintendo_ds/nds_develop8.html

for more info.


Uh, have you looked at the dispatcher source?

You don't need to touch the flags.

#62849 - wintermute - Tue Dec 06, 2005 12:05 pm

Dannon wrote:
Well I have added that and gone through your tutorial but I am still getting a lot of scan line problems, there is a lot of flickering and I can't really see the screen

--Dannon


pWorld->Update is obviously taking more than a vblank period to update. You've given insufficent code to determine the problem.

I assume you're drawing to a bitmap mode, in which case consider double buffering.

#62878 - Dannon - Tue Dec 06, 2005 5:59 pm

I'll get double buffereing sorted this afternoon and see if that helps at all, can both screens be double buffered at the same time?

--Dannon