Path: utzoo!mnetor!uunet!mcvax!unido!rmi!kkaempf From: kkaempf@rmi.UUCP (Klaus Kaempf) Newsgroups: comp.sys.amiga Subject: Re: Double Buffering Message-ID: <812@rmi.UUCP> Date: 2 Dec 87 14:29:01 GMT References: <7768@steinmetz.steinmetz.UUCP> <782@mitsumi.UUCP> Reply-To: kkaempf@rmi.UUCP (Klaus Kaempf) Organization: RMI Net, Aachen, W.Germany Lines: 79 Keywords: copperlists, multitasking, interlace This message is being forwarded by me for a friend who has no access to the UseNet (yet!). Feel free to send replies to me. Klaus Kaempf kkaempf@rmi.UUCP - - - - - - - - - In article <782@mitsumi.UUCP> jimm@mitsumi.UUCP (Jim Mackraz) writes: > In article <7768@steinmetz.steinmetz.UUCP> > guilford@csv.rpi.edu (james d guilford) writes: >> I am planning to write some animation-type software, and >> so I looked up double buffering in the RKM. It suggested >> that I create two screens and two sets of copper lists, >> and then to flip screens, I just replace the copper list >> pointers. If you do so, you will certainly run into the same troubles, almost all other programs that use double-buffering have. No-one knows, if there isn't anyone else doing the same thing to the copperlists, you are doing right now. This will result in the same crash the JUGGLER etc. will end up with, if you just try to drag the screen or use Amiga-M/Amiga-N. Intuition will remove and deallocate the copperlist YOU installed and next time YOU need it ... Of course you cannot use MakeVPort()/RethinkDisplay() each and every frame (you might as well display the "zz" cloud then), but I used two approaches to solve this problem in my programs: Scan the copperlists (AND the intermediate copperlists!!!) for the MOVE instructions, that will install your bitplanes, and replace the arguments to these directly (Disable(), of course). You will also have to set up the "struct BitMap" in your ViewPort to reflect these new circumstances, because someone else might call "RemakeDisplay()". DO NOT assume a fixed layout of the copperlists! This one should be written in assembler. The second approach will only "MrgCop()", if the pointers to the copperlists within the View have been changed by someone else since the last time, your program exchanged them. I wrote an example to demonstrate this some time ago and if anyone is interested, I will post the source for it ( <10 KB highly readable C source for both Lattice and Aztec). This method might sometimes miss a change (resulting in flickering) and is certainly VERY SLOW, IF TWO programs behave this way, but at least it won't crash! How about a public semaphore in 1.3? Or something like a "ChangeCount" to check out, if the copperlists have been changed recently. Hey Leo! Don't _you_ have a better idea 'bout this? > Note that the copper list pointers you replace are in > graphics base, unless you also want to replace the vblank > interrupt routine which re-installs them (and handles > interlace). One way to do this is use LoadView(). This was true for 1.1. If you were running at a higher interrupt priority level than the vblank interrupt or simply disabled it, only every second line of an interlace screen was being displayed (this looked rather funny, try it yourself). Under Kickstart 1.2 the copperlists will exchange each other themselves after they did their job for the single frame - so no need for vblank and processor any longer (except for synchronization). !ralph Ralph Babel | sys64824 Falkenweg 3 | (!#X3F0001)() D-6204 Taunusstein | (**((void (**)(void))0xfc0004))();