fix movie rtc

This commit is contained in:
zeromus 2009-05-04 05:32:23 +00:00
parent 317a08df77
commit d1a33184ef
1 changed files with 16 additions and 20 deletions

View File

@ -79,33 +79,29 @@ struct movietime {
struct movietime movie; struct movietime movie;
int oldframeCounter;
u64 totalcycles=2904024960000ULL;//noon
int totalseconds;
bool moviemode=false; bool moviemode=false;
void InitMovieTime(void)
void InitMovieTime(void) { {
movie.year=9;
movie.year=9; movie.month=1;
movie.month=1; movie.monthday=1;
movie.monthday=1; movie.weekday=4;
movie.weekday=4; }
oldframeCounter=0;
}
#ifdef WIN32 #ifdef WIN32
static void MovieTime(void) { static void MovieTime(void) {
if(currFrameCounter > oldframeCounter) { //now, you might think it is silly to go through all these conniptions
int difference; //when we could just assume that there are 60fps and base the seconds on frameCounter/60
difference=currFrameCounter-oldframeCounter; //but, we were imagining that one day we might need more precision
oldframeCounter=currFrameCounter;
totalcycles+=((560190<<1)*difference);
}
totalseconds=totalcycles / 67222800; //one second const u32 arm9rate = 560190<<1;
const u64 noon = (u64)arm9rate * 60 * 60 * 12;
u64 frameCycles = (u64)arm9rate * currFrameCounter;
u64 totalcycles = frameCycles + noon;
u32 totalseconds=totalcycles/arm9rate;
movie.sec=totalseconds % 60; movie.sec=totalseconds % 60;
movie.minute=totalseconds/60; movie.minute=totalseconds/60;