Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!think!ames!pasteur!ucbvax!TIS.COM!dmb
From: dmb@TIS.COM (David M. Baggett)
Newsgroups: comp.sys.atari.st
Subject: Yet More on Animation
Message-ID: <8809282323.AA10646@TIS.COM>
Date: 28 Sep 88 23:23:32 GMT
Sender: daemon@ucbvax.BERKELEY.EDU
Organization: The Internet
Lines: 47


   There was some discussion about Setscreen waiting for the vertical
blank before returning.  I tried a few things to see how Setscreen
behaves in practice, and I still believe that

   Setscreen returns immediately.

   If Setscreen waited for the vertical blank when you set the
physical screen base, the following code would take about 1 minute:

	for (i = 0; i < 3600; i++) {
		Setscreen((char *) -1L, Physbase(), -1);
	}

It doesn't.  It takes about 2 seconds.  This means that Setscreen does
_not_ wait for the vertical blank to return.
   It _is_ true that the physical screen base doesn't actually set until
the vertical blank.  This is because Setscreen simply writes a value into
a location in page 4.  The _vertical blank routine_ looks at this location
and sets the physical base.  We're talking about an interrupt here.
   So you do have to Vsync after setting the physcial screen to be sure
you won't get flicker.  To illustrate:

	C statement executed			Status of VBI

	for (;;) {
		/*
		 * Do stuff			Yet to come
		 */

		Setscreen(...)			Yet to come
		Vsync();			It happens
		
		/*
 		 * Do stuff			Just finished (now
		 */				previous Setscreen
						has taken effect)
	}

If you don't explicitly Vsync, some of your Setscreen calls won't
ever take effect (they will be "overwriten" by the next Setscreen
call).
   Unless my compiler is different from everyone else's (I'm usnig
Laser C), this is how Setscreen works.

			David Baggett
			dmb@TIS.COm (arpanet)