Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!mailrus!cs.utexas.edu!uwm.edu!uakari.primate.wisc.edu!ctrsol!lll-winken!ubvax!ardent!peck!rap
From: rap@peck.ardent.com (Rob Peck)
Newsgroups: comp.sys.amiga.tech
Subject: Re: dual playfields under Intuition
Message-ID: <8472@ardent.UUCP>
Date: 29 Sep 89 17:43:33 GMT
References: <2413@goanna.oz>
Sender: news@ardent.UUCP
Reply-To: rap@peck.ardent.com (Rob Peck)
Organization: Ardent Computer Corp., Sunnyvale, CA
Lines: 91

In article <2413@goanna.oz> phi@goanna.oz (Philip Hingston) writes:
>	How do you go about setting up a dual playfield display under
>	Intuition?
>	The Intuition manual suggests it's possible, but doesn't give details.
>The RKM shows how to set up a dual playfield display but not with Intuition.
>	Are there any wise people out there who can suggest the "correct" way
>to do this thing?


Creating A Dual Playfield Display
 
(on a custom screen, without making Intuition barf)

1. You open your custom screen WITHOUT the DUALPF bit set in view modes.
   The maximum depth of your bitmap of the custom screen must be 3 or
   less, because in dual playfield mode, there are a maximum of 6 bitplanes.

2. If you open the screen as a SCREENBEHIND, nobody will see the munging
   that you do before it is displayed.  But when Jim Mackraz's example
   does munging, the display did not flash or anything so this part
   might not be necessary.

3. Allocate additional rasters (AllocRaster) to be used as the second
   playfield.  They should preferably be the same size as that of the
   first playfield (it IS possible to make the second set of rasters
   larger or smaller -- I have done it, but not in an Intuition-compatible
   example).  The number of rasters allocated must be the same as or
   one fewer than the number allocated to the first playfield because
   the system will allocate bitmaps to playfields (a hardware limitation)
   as: 

	Total Planes: 1 2 3 4 5 6

	Playfield 1:  1 1 2 2 3 3
        Playfield 2:  0 1 1 2 2 3 
  
   The default value used by Intuition for custom.bplcon2 places Playfield
   1 in front of Playfield 2.  This is a value of 0x24.  Regarding playfields,
   The only critical bit is bit 6 of this value.   Bits 0-5 control the
   priority of the placement of the sprites with respect to the playfields.
   (See the Amiga Hardware Manual, System Control Hardware, for more info).
   For those bits you want values of (binary) 100100 to make sure that
   all of your sprites can be seen, regardless of the placement of the
   Playfields.

   Playfield 1's colors come from color registers 0-7, and any place where
   color 0 is used, Playfield 1 becomes transparent.

   Playfield 2's colors come from color registers 8-15.  These are "real"
   colors, where even color 8 shows up when drawn.  If a RastPort is
   created and attached to the bitmap that defines playfield 2, the
   pen colors 0-7 of that bitmap (assuming a 3 plane deep second playfield
   display) are mapped to colors 8-15.

4. Allocate a rasinfo structure (rasinfo2) and a bitmap structure (bitmap2)
   that will be associated with the second playfield.  Initialize the
   bitmap to correspond to the size and depth of plane set to which it will
   be attached.  Then point the planes pointers in the bitmap to the
   planepointers obtained from AllocRaster.
   
5. Allocate a RastPort and attach it to the same bitmap (bitmap2) so that
   you can draw into the second playfield.

6. SetRGB4 some colors in registers 8-15 for the second playfield.

7. Forbid(), attach the new rasinfo structure to the existing one in
   the viewport of the custom screen, set the DUALPF bit in the viewport
   modes in for the custom screen.  Permit(), MakeScreen(screen) and
   RethinkDisplay().

   Now you can render into either the screen (or open windows or whatever),
   or you can render into the background playfield using the new RastPort.
   Intuition won't know you were foolin' around at all. The screen
   remains pushable, draggable etc.

   Before you close the screen, however:  Forbid(), reset the DUALPF
   bit to zero in the viewport modes, reset the rasinfo->Next pointer
   to NULL, Permit(), MakeScreen(screen), RethinkDisplay();  And
   free the rasters, bitmaps and rasinfo you allocated for this second
   playfield.

Jim Mackraz provided the example that folks have been talking about,
for which he turns the Workbench into a dualplayfield (2 + 1) display.
I have modified his example to do this to a custom screen, as a 3 + 3,
320 by 200.  Though I believe that all of the details above are accurate,
there is nothing like a functioning example to let folks figure it out on
their own and with which to experiment.  THAT will be posted (with Jimm's
permission) on Monday, with my mods installed.


Rob Peck