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.

Coding > VBA or Boycott advance

#8294 - whodoo - Mon Jul 07, 2003 2:14 pm

I use this code to sleep for x seconds
void WaitSeconds(int seconds)
{
REG_TM3CNT = TIME_FREQUENCY_1024 | TIME_ENABLE;
REG_TM3D = 0;
while(seconds--)
{
while(REG_TM3D <= 16386){}
REG_TM3D = 0;
}
}

it works great with Boycott Advance, but in VBA it will only sleep for one seconds, no matter how many seconds I tell it to wait..is there any setting in VBA I got to do or a bug or something?

#8297 - Quirky - Mon Jul 07, 2003 3:08 pm

I remember having trouble with timers for this sort of thing on VBA - have you tested this on hardware as well?

In the end, I gave up and used vblank as the "wait" timing. It's the best method for a couple of reasons: it works as predicted on hardware and all emulators and it saves batteries by not spin waiting - an empty "while {}" is the equivalent of having the accelerator pressed with the hand brake on!

#8298 - Touchstone - Mon Jul 07, 2003 4:09 pm

You have to turn off the timer before you can write anything to it's "counter" register, if you even _can_ write to it's counter-register, I don't remember. Besides, if you are waiting for seconds, or even 1/60 of a second you are probably better of counting vblanks and use the timer for something else.
_________________
You can't beat our meat

#8344 - cappeca - Tue Jul 08, 2003 8:04 pm

Before all that, check if you're missing some "volatile" declarations on the REG_TIMER stuff. If you don't do that, no matter what you put in the address, the machine will never check it. Dovoto's #include files didn't have them, and I had a few headaches because of that.

Cesar.