[comp.sys.atari.st] Animation Revisited

dmb@TIS.COM (David M. Baggett) (09/29/88)

>In article <8809100453.AA01878@TIS.COM>, dmb@TIS.COM (David M. Baggett) writes:
>> 	Setscreen((char *) -1L, (char *) new_phys_base, -1);
>> 	Vsync();
>
>I'm not particularly familiar with the ST, but since SetScreen is asynchronous,
>the following code (based on Amiga code) should work better:
>
>	Generate animation in newscreen;
>	Vsync();	/* wait for previous SetScreen (of oldscreen) to work */
>	SetScreen(newscreen);
>	Go back to generate next screen.
>
>This way you get to do computations while waiting for SetScreen, and there's
>always a screen out there waiting to show up.
>-- 
>		Peter da Silva  `-_-'  peter@sugar.uu.net

   Actually, this doesn't work so well.  The animation will only be
flicker-free when Vsync() comes _after_ the Setscreen call.  It's not
obvious why this is, but I've done several tests that show it to
be the case (I recompiled exisiting programs, only changing the placement
of Vsync).
   Also, I don't understand the argument that you'll get less idle time
by moving the Vsync().  I was thinking of the page flipping occuring in
a loop; for exmaple:

	for (;;) {
		/* 
		 * Do stuff
		 */

		 Setscreen(...);
		 Vsync();

		 /*
		  * Do stuff
		  */
	}

Moving the Vsync shouldn't change how much idle time you get.  In the 
sections commented "do stuff", you have about 1/60th of a second worth
of processing time.  How much time is spent idle depends on how close
you get to filling these sections (if you put too much code in these
sections, you will only hit every other vblank).

			Dave Baggett
			dmb@TIS.COM (arpanet)