From: alex@bilver.uucp (Alex Matulich)
Subject: <<HELP!>> Intuition/copper interference w/double buffers
Organization: W. J. Vermillion - Winter Park, FL
Date: Tue, 6 Oct 1992 16:07:53 GMT


Please help.  The next 26 lines describe the situation, and following that
is my problem.

I have written some routines to do double buffering, using an Intuition
window as one of the view buffers.  There are 3 basic routines:

InitNBuff() - initializes another buffer (rastport and bitmap), generates
a copper list for it, and returns the rastport for the new buffer.
Buffer 0 is associated with the Intuition Window and RastPort.
Calling InitNBuff() with an argument of 0 will simply call MakeScreen()
then MrgCop() and LoadView() to generate the copperlists for the Intuition
window, and returns the Window Rastport pointer (after saving the
copperlists).  Otherwise, a new bitmap and rastport are allocated, the
view BitMap pointer is set to point to the new BitMap, and MakeVPort() is
called, followed by MrgCop() and LoadView() to generate the copperlists
for this view, which are then saved away.  Yes, I am zeroing out the
copperlists first.

ShowView(n) - displays buffer n, by setting the pointers LOFCprList and
SHFCprList in the Intuition View structure to the appropriate global
copper lists saved by InitNBuff, setting the rasinfo bitmap (i.e.
Screen->Viewport.RasInfo->BitMap) to point to the appropriate bitmap
associated with buffer n, and calling LoadView() to display it.
You can create more than 2 buffers and display each one by passing
the appropriate index to ShowView().

FreeNBuff() - frees a buffer and its associated copperlists, to be called
when the program is finished.  Nothing is freed for buffer 0, because it
belongs to Intuition (REALLY does bad things if you try).

Now, here is the problem:  My program will run JUST FINE, with no errors,
and it will leave the system memory *exactly* like it found it, PROVIDED
THAT INTUITION WASN'T INTERFERED WITH.  That is, if I press left-amiga-M
or left-Amiga-N to switch back and forth between workbench and my program
while my program is running, the computer will lock up (and GOMF reports a
corrupt memory list).  If I let the program run to completion without
interference, nothing goes wrong.

Likewise, if I try to run my program with the cpr debugger, it locks up
when ShowView() is called.  The debugger does its own display switching.
Again, GOMF reports a corrupt memory list before the system dies.

You may ask:  Why am I bothering using an Intuition window as one of my
buffers?  The answers are: (1) I need to do console I/O in this buffer as
well as other stuff, and (2) I want to be able to use those neat Intuition
gadgets in my program.  Naturally console I/O and gadgetry are not done
while double-buffered animation is going on - only during "dead times"
where the user must set things up.  Even during dead times, the computer
locks up if the Workbench screen is toggled in or out.

I have tried surrounding calls to ShowView() with Forbid() and Permit()
but that didn't help.  Is there a way to disable Intuition from switching
views when other tasks tell it to do so?  I'd like to avoid disabling that
because then the user has access only to my program and nothing else.

Thanks very much in advance for any advice anybody can offer.

PS - I obtained the DBuff.c example from the Fish disks.  DBuff is what
prompted me to write my own routines, because DBuff was wrong.  The author
was assuming that MrgCop() did the display switching, when all it actually
does is generate final copperlists which must then be loaded.  He was not
saving the copperlists away, only the Intuition ones.  His demo program
didn't switch views at all (made obvious by setting one buffer to a
different color and watching for flickers).  His demo program works
perfectly when modified to use my routines.

-- 
 _ |__  Alex Matulich    alex.matulich@oau.org
 /(+__>  Unicorn Research Corp, 4621 N Landmark Dr, Orlando, FL 32817
//| \     UUCP:  alex@bilver.uucp   {peora|ge-dab|uunet!tous}!bilver!alex
///__)     Internet:  alex@bilver.oau.org | alex%bilver@peora.sdc.ccur.com
Newsgroups: comp.sys.amiga.programmer