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 > Synchronization

#172544 - Kensai - Thu Feb 11, 2010 8:25 pm

I'm using Mode 4 and my game is faster or slower depending on the number of objects/images that have to be drawn. And because this number of objects/images diverges heavily, I'd like to synchronize the display somehow. Perhaps there is an internal clock that could be used?

Code:

My idea:
                      if(t%C==0) {Draw all objects} else {nop}
                      ↓
t=0        t=C        t=2C       t=3C       t=4C
|----------|----------|----------|----------|----------> t
 dddddwwwww dddddddddw dwwwwwwwww wwwwwwwwww dddddddwww

d = draw objects
w = wait / no operation

#172556 - samel - Sat Feb 13, 2010 10:46 am

This

[code]if(t%C==0) {Draw all objects} else {nop}

t=0 t=C t=2C t=3C t=4C
|----------|----------|----------|----------|----------> t
dddddwwwww dddddddddw dwwwwwwwww wwwwwwwwww dddddddwww[/code]

should be

[code]if(t%C==0) {Draw all objects} else {nop}

t=0 t=C t=2C t=3C t=4C
|----------|----------|----------|----------|----------> t
dwwwww dwwwww dwwwww dwwwww dwwwww[/code]

Anyway, you can use timer and v-blank:

Timer
http://tobw.net/dswiki/index.php?title=How_to_set_up_a_timer

V-Blank
http://www.dev-scene.com/NDS/Tutorials_Day_3