[comp.sys.atari.st] Physbase vs. Logbase

jrd@STONY-BROOK.SCRC.SYMBOLICS.COM (John R. Dunning) (01/07/90)

Can anyone tell me what's the difference between Physbase() and
Logbase()?  When can I expect them to be the same/different?  

Thanks in advance...

soohoo@cory.Berkeley.EDU (Ken "nmi" Soohoo) (01/10/90)

In article <19900107151543.2.JRD@CORD.SCRC.Symbolics.COM> jrd@STONY-BROOK.SCRC.SYMBOLICS.COM (John R. Dunning) writes:
>Can anyone tell me what's the difference between Physbase() and
>Logbase()?  When can I expect them to be the same/different?  
>
>Thanks in advance...

jrd,
These are the same under normal operation, but they _mean_ the following:

char *Physbase() returns the actual location of the screen in memory, where the
display hardware goes looking for screen data when it wants to draw the screen.
Note that you can set the Physbase with certain alignment restrictions on
the ST, but in the STE and TT these restrictions (page boundries I believe)
have been lifted.

char *Logbase() returns what the VDI thinks is the screen location in
memory, which, under normal operation, will be exactly the same as Physbase.
It's useful to change Physbase so that you can build your screen on the
side (without the user seeing the drawing in action), and then flip the
screens to show the user a completely new screen.

So, for page flipping for animation, you'd be using
Setscreen(log,phy,res) with res set to -1 to indicate no change, and
log and phy set appropriately to draw to one virtual screen, and look
at another, and look at a new one and draw to the old...

Hope this helps!
--Kenneth "kens" Soohoo				(soohoo@cory.Berkeley.Edu)
  Atari Hacker (Atari's Hacker...)
  "It could be worse, you could get hit by a bus..."
  My opinions are my OWN, _not_ necessarily Atari's. But "hey", who knows?

latornell@MECH.UBC.CA (Doug Latornell) (01/11/90)

In response to the question by:
John R. Dunning <jrd@STONY-BROOK.SCRC.Symbolics.COM>

regarding: Physbase vs Logbase


Physbase() is the XBIOS call to get the physical base address of the
screen while Logbase() is the call (also XBIOS) to get the logical
base address of the screen.

Physbase() returns a long that is the screen's physical address in
memory at te next vertical blank interupt after the call.  Logbase()
immediately returns a long that is the screen's logical address.  To
actually do anything with these call you need to know about
Setscreen() too.  

Setscreen() has 3 arguments, log_base, phys_base and res.  log_base
points to the screen buffer on which writes operate, phys_base points
to the buffer that is displayed.  If they are the same then a write
operation will appear on the screen as it is done.  If they are
different, you won't see the result of the write until you change the
physical base to show that logical screen.  res sets the resolution.
A -1L for *_base or -1 for res leaves the current value unchanged.

Perhaps an example will make things clearer.  I've used this to do
primitive animation, the sort where you flip back and forth between 2
screen buffers, displaying one while drawing the next frame on the
other.  An outline of the code goes something like:

	/* globals */
	char	*screen1,	/* logical base of current screen */
		*screen2;	/* logical base of new screen */

	set_bases()
	{
	  long new_buffer;

	  new_buffer = Malloc(32256L);
	  /*  some code to make sure new_buffer starts on
	      a half page boundary */
	  screen1 = Logbase();
	  screen2 = (char *)new_buffer;
       }

	main()
	{
	  set_bases();
	  while( /* not stop animation condition */ )
	  {
	      /* show screen 1 while drawing on screen 2; leave res alone */
	    Setscreen(screen2, screen1, -1);
	      /* draw next frame */
		....
	      /* show screen 2 while drawing on screen 1 */
	    Setscreen(screen1, screen2, -1);
	      /* draw next frame */
		...
	  }
	    /* put logical ad physical bases back to original values */
	  Setscreen(screen1, screen1, -1);
	    /* release memory used for 2nd buffer */
	  Mfree(screen2);
	}

Hope this helps.  Check out Pollack and Weber, "Atari ST Application 
Programming", Bantam, 1987 for further details.

Doug Latornell
latornell@mech.ubc.ca    (this address works for everybody I know!)

kloppen@gmdzi.UUCP (Jelske Kloppenburg) (01/12/90)

jrd@STONY-BROOK.SCRC.SYMBOLICS.COM (John R. Dunning) writes:

>Can anyone tell me what's the difference between Physbase() and
>Logbase()?  When can I expect them to be the same/different?  

Normally physbase and logbase point to the same memory. If You
set one of them to another screen memory then what you see is
shown from Physbase() and what You draw (VDI etc.) is drawn to
Logbase(). That can be used for animation: Show one screen, draw
the next image to another, then flip the Screens.

greetings, j.k.

      Kloppenburg@kmx.gmd.dbp.de
UUCP: kloppen@gmdzi
                                  In real life: Jelske Kloppenburg

buggs@cup.portal.com (William Edward JuneJr) (01/15/90)

>Doug Latornell 
>latornell@mech.ubc.ca    (this address works for everybody I know!)
>Check out Pollack and Weber, "Atari ST Application Programming",
>Bantam, 1987 for further details.

Unfortunately this book is out of print and NOT available.
If ANYONE knows where to get a copy, I WANT one!

Ed June
 
71171,1311 CI$       -or-  404-471-9230, bbs, HST, Fido node 1:133/403