[quote author=MetaFox link=board=Dev;num=1107769913;start=0#10 date=02/11/05 at 07:29:08]Is that code correct? (other than the millis typo in the SDL_GetTicks function)
When I try this, I get nothing but a blank screen.
Using Uint32 to initialize the variables gives me an incompatible type warning.
changing it to int32 gets rid of this warning, but still produces a black screen.[/quote]
That's probably not exactly what the code is on my system. I was posting from my mac, and looking at the code on the Linux PC next to it so I didn't bother typing stuff that I had commented out and may have inadvertently introduced an error. The SDL_GetTicks function is definitely declared as Uint32, though.
The only reason I didn't use timer_ms_gettime64() in mine the way Troy did is because SDL_GetTicks() is supposed to return a 32-bit integer, but iirc I essentially did the same thing that timer_ms_gettime64 does - multiply 'secs' by 1000, and add the 'milis' to that, so I have the number of miliseconds since SDL started.
What I'll do is copy + paste the real code in a few minutes when I dig it up again on my other machine.
*edit*
Here's the copy+pasted code.
Code:
void SDL_StartTicks(void)
{
/* Set first ticks value */
/*start = jiffies;*/
/* 138's hack */
Uint32 *milis, *secs;
timer_ms_gettime(secs, milis);
start = ((Uint32)secs*1000)+(Uint32)milis;
}
Uint32 SDL_GetTicks(void)
{
/*return((jiffies-start)*1000/HZ);*/\
/* 138's hack */
Uint32 *milis, *secs;
timer_ms_gettime(secs, milis);
return ((((Uint32)secs*1000)+(Uint32)milis)-start);
}
Sorry, didn't meant to hijack a topic to discuss SDL Timer hacks. :-[
Bookmarks