Re: [Tuxnes-devel] Smoother scrolling
Brought to you by:
tmmm
From: Jason D. S. <jd...@us...> - 2004-01-20 17:13:32
|
Mike Mestnik wrote: > Yes you are correct, how ever tuxnes takes care of counting ticks in the ASM. Every time we draw > a frame it's been 1/60 of a second nes time, so we just need to make the real computer emulate > that. In most video games timing will be constant, this way we don't get into complex > acceleration equations and such. Too take care of the time we spend when were not sleeping we put > the gettime as close as posible to where we sleep. > > Also I don't normally keep track of total time. I don't know how different the 2 methods are, but > I know my way doesn't get overflowed. What I do is reset my tick ctr to 0 every time I sleep, I > use the current time to populate basetime(Renamed to lasttime). See my patch for an example that > includes a hybrid method. I think it would be safe to remove the "if ( frame > 1800 )", I'd like > to here your comments. > > --- digression --- > > Yes you are correct, how ever video games use polling. It's not clear what to do with a move once > the frame(round) is over, so processing(scoring) of that move MUST wait for the next round. We > could take the input and differ scoring, but this would only make the usleep for this round a bit > less. It's ok to ignore the input until it's round is being scored. > > Also the nes uses polling, so we poll when it asks us too. It would be cool to make this script > able for things like up-up-down-down... Think mric type nes scripting :) > > I've attached what I committed it's should hit the backup CVS server in 2 days. > + if (usec > 0) { > + if ( frame > 1800 ) /* Every 30 seconds */ > + { > + frame = 0; > + renderer_data.basetime.tv_sec = now.tv_sec; > + renderer_data.basetime.tv_usec = now.tv_usec; > + } > + usleep(usec); I think this update needs to come *after* the usleep. if (frame > 1800) { frame = 0; renderer_data.basetime.tv_sec = now.tv_sec; renderer_data.basetime.tv_usec = now.tv_usec + usec. } The time "now" is not significant. The correct time is the time we're usleeping to, which is the time of the start of the current frame (frame 0). Otherwise it'll consistently be off by 1/100 of a second every 30 seconds :-). The next step is probably making it possible to change doublespeed/halfspeed while the game is running. This shouldn't be too hard: when the values are changed reset the frame to 0 and start counting anew. jason |