Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!think.com!paperboy!hsdndev!dartvax!idgeast!lectroid!transfer!crackers!m2c!umvlsi!umaecs!amh!djvelleman From: djvelleman@amherst.bitnet Newsgroups: comp.sys.mac.programmer Subject: Re: Animation Message-ID: <11971.27b2e2ae@amherst.bitnet> Date: 8 Feb 91 17:41:02 GMT References: <9102030634.AA09598@enuxha.eas.asu.edu> <1991Feb7.093610.12594@ecmwf.co.uk> <1991Feb7.233344.7781@umiami.ir.miami.edu> Lines: 44 In article <1991Feb7.233344.7781@umiami.ir.miami.edu>, dweisman@umiami.ir.miami.edu (Ordinary Man) writes: > In article <1991Feb7.093610.12594@ecmwf.co.uk>, mab@ecmwf.co.uk (Baudoin Raoult) writes: [stuff deleted] >> To avoid flickery animation, you must synchronise your CopyBits with the video spot. >> The simplest way is to use TickCount, as the tick counter is updated every 60th of >> second, each time the video spot starts to update new screen. So just write: >> >> tmp := TickCount; >> while tmp=Tickcount do { nothing } ; >> >> CopyBits(.....) > > This is fine except for a minor detail. As it says in IM Vol. I... > > "...don't rely on the tick count being incremented to a certain value, such > as testing whether it has become equal to its old value plus 1; check for > 'greater than or equal to' (since an interrupt task may keep control for > more than one tick)." > > So instead say: > > tmp:=TickCount; > repeat until TickCount>=(tmp+1); > > CopyBits..... > > ==Dan Sorry Dan, but you've missed the point of the warning in IM. IM says not to rely on the tick count being INCREMENTED TO a certain value, because it might skip over values if an interrupt task keeps control for more than one tick. But the proposed code doesn't rely on TickCount being incremented to the value stored in tmp. TickCount already has that value, and the code relies on it eventually being incremented to a different value, which is just fine. Your code is OK too. What IM was warning against was something like this: tmp:=TickCount; repeat until TickCount=tmp+1; CopyBits... This could turn into an infinite loop if TickCount goes right from tmp to tmp+2. By the way, the THINK Pascal procedure Synch will take care of this for you. -Dan Velleman