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.

Beginners > V-Sync

#55501 - nuffer - Wed Sep 28, 2005 10:00 pm

I'm having issues with my sprites. I have anywhere from none to 70 or so on screen at a time, and every once in a while they all move up one pixel at a time (this is the desired behavior at least). The problem is sometimes they visibly skip, and half move up before the screen is refreshed and the other half after that. It looks like I'm not properly syncing with the GBA's drawing routine. How would I do that?

#55516 - DiscoStew - Thu Sep 29, 2005 12:18 am

Yes, you hit the spot. Because you have nothing halting your code execution in your main loop, your code continues to do its thing multiple times before the GBA actually gets to the point of drawing, and even during that time, it still continues.

To fix this, just add a line or 2 that checks for the V-Blank at the beginning of your main loop, or wherever you choose. I'm assuming there are a lot of posts on this subject in the forums, so a little Searching should not be a problem.
_________________
DS - It's all about DiscoStew

#55607 - nuffer - Thu Sep 29, 2005 10:45 pm

I'm syncing things up, but I still seem to be having issues when the screen is nearly full.

I call:

haltUntilVSync();
draw();

and draw() contains the following code:

for(deque<vector<BlockSpace*> >::iterator i = mBlockSpaces.begin(); i != mBlockSpaces.end(); ++i)
for(vector<BlockSpace*>::iterator j = i->begin(); j != i->end(); ++j)
if((*j)->isBlock())
(*j)->block()->draw();

for(vector<Block*>::iterator i = mGreyRow.begin(); i != mGreyRow.end(); ++i)
(*i)->draw();

where mBlockSpaces is a deque of size 11, which each vector in it size 6, and mGreyRow is a vector of size 6. All Block::draw() does is update the y-position on the OAM. Is this just too much to be updating during one V-Blank?