Welcome! Log In Create A New Profile


chess : ftime workaround ?

Posted by TheDrev 
chess : ftime workaround ?
January 17, 2011 12:31AM
Hey !

How to the TSCP chess engine had me ported in this chess application [wiibrew.org] since it uses the ftime function in the original code

// get_ms() returns the milliseconds elapsed since midnight,
//   January 1, 1970. 

BOOL ftime_ok = FALSE;  // does ftime return milliseconds?
int get_ms()
	struct timeb timebuffer;
	if (timebuffer.millitm != 0)
		ftime_ok = TRUE;
	return (timebuffer.time * 1000) + timebuffer.millitm;

Ported source code, explanation of a workaround, or how to get the timestamp on libogc is appreciated
Re: chess : ftime workaround ?
January 17, 2011 09:48PM
I guess you want "gettimeofday":
int getTime()
    struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec * 1000 + tv.tv_usec / 1000;
Which is very portable, as it is a POSIX function found in Linux, MacOS, MinGW library for windows and the Wii.
Re: chess : ftime workaround ?
January 18, 2011 01:13PM
tanks alot !
Sorry, only registered users may post in this forum.

Click here to login