Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!rutgers!ames!ucbcad!ucbvax!CORY.BERKELEY.EDU!dillon From: dillon@CORY.BERKELEY.EDU (Matt Dillon) Newsgroups: comp.sys.amiga Subject: Re: Blitter (general discussion of double buffering techniques) Message-ID: <8612041959.AA22053@cory.Berkeley.EDU> Date: Thu, 4-Dec-86 14:59:20 EST Article-I.D.: cory.8612041959.AA22053 Posted: Thu Dec 4 14:59:20 1986 Date-Received: Fri, 5-Dec-86 05:09:36 EST Sender: daemon@ucbvax.BERKELEY.EDU Organization: University of California at Berkeley Lines: 109 Double buffering is nice, but either uses up half your planes or uses double the memory, depending on which method of double buffering you do. Let me explain the two methods: Method 1: Use half the planes for buffer 1, the other half for buffer 2. (Assume 4 planes total in this example) Double buffering is accomplished by setting the color palette such that the pixels in the 2 inactive planes do not effect the color displayed by the 2 active planes. To switch which 2 planes are active (make the 2 active planes inactive and the 2 inactive planes active), simply re-arrange the color palette. Advantages: Less memory Disadvantages: You are limited to half the number of planes on your screen for the actual game or simulation or whatever. Method 2: Have two entirely separate display bitmaps. (Assume four bit planes per bitmap on this example). Double buffering is accomplished by simply changing the planes pointers in the display to the second bitmap. Advantages: You have full use of all 4 bit planes Disadvantages: It takes double the memory. METHOD 1 METHOD 2 SCREEN MEMORY PLANES MEMORY PLANES 320x200x4 32K 2 64K 4 640x200x2 32K 1 64K 2 640x200x4 64K 2 128K 4 640x400x4 128K 2 256K 4 (Where PLANES is planes available for the application) (note: Method 2 on interlace screens may be difficult) As you can see, a 320x200x4 plane double buffered display using method 2 uses only 64K, which seems reasonable. Additionaly, you get 4 usable bit planes to play around with. So, for instance, if you are blitting a Jet on top of Carrier, you can simply put the Carrier in plane 0 and the jet in plane 1 (assuming mono colored objects). Only one blit need be done, and since the objects are on different planes, they don't destructively modify each other. You can setup the color registers to effectively prioritize the bitplanes. Priority Example: 2 bit planes Object A in plane 0 Object B in plane 1 You want object B to have priority over object A plane0 plane1 COLOR Color Reg 0 0 0 BACKGROUND Color Reg 1 1 0 OBJECT A's color Color Reg 2 0 1 OBJECT B's color Color Reg 3 1 1 OBJECT B's color (B has priority) 4 bit planes, 4 objects Object A in plane 0 Object B in plane 1 Object C in plane 2 Object D in plane 3 D over C over B over A bits set in planes plane0 plane1 plane2 plane3 COLOR Color Reg 0 0 0 0 0 BACKGROUND Color Reg 1 1 0 0 0 OBJECT A Color Reg 2 0 1 0 0 OBJECT B Color Reg 3 1 1 0 0 OBJECT B Color Reg 4 0 0 1 0 OBJECT C Color Reg 5 1 0 1 0 OBJECT C Color Reg 6 0 1 1 0 OBJECT C Color Reg 7 1 1 1 0 OBJECT C Color Reg 8 0 0 0 1 OBJECT D Color Reg 9 1 0 0 1 OBJECT D Color Reg 10 0 1 0 1 OBJECT D Color Reg 11 1 1 0 1 OBJECT D Color Reg 12 0 0 1 1 OBJECT D Color Reg 13 1 0 1 1 OBJECT D Color Reg 14 0 1 1 1 OBJECT D Color Reg 15 1 1 1 1 OBJECT D example comments: Color 15 = all four objects overlapping at this pixel Color 9 = Objects A and D overlapping at this pixel etc... Usually, you can arrange it so no complex blitting is required, causing your game/simulation to screeeeeeammm. Generally, the more colors per object, the more blitting required. Additionaly, since these are custom screens with little chance of intuition screwing things up, so you don't need a ClipRect in your RastPort structures (remember however that this means you absolutely cannot specify anything out of bounds). It makes graphics calls go much faster. Finally, you can control the blitter manually... Via OwnBlitter(), and optimize. The neat thing is you can do all of this without compromising the Amiga's multi-tasking. -Matt