[comp.sys.amiga.tech] Copper list switching

wayneck@tekig5.PEN.TEK.COM (Wayne Knapp) (01/13/89)

I'm doing some copper list stuff now and have run into a
little hitch.  I have my copper list, but what is the
fastest proper way to install it.  It is easy to just
set up the hardware address register but is this the
correct way. 

My program can not afford the wait involved in letting
the system building the copper list from the ViewPorts.
So I build my own custom list to do want I want.  In
fact I have two copper lists and I plan to do page
flipping by switching copper lists.  So my real 
question is what is the fastest safe way to switch
the copper lists.  
 
                             Thank you,	
                                Wayne Knapp  


Ps. Durning the time my program is messing with copper
lists, I'd shut down the multitasking.  This because 
what I'm trying to do requires every cycle that Amiga
can give.

billk@pnet01.cts.com (Bill W. Kelly) (01/14/89)

Since you have essentially shut down Exec, I see absolutely nothing wrong
with loading Cop1Lc or Cop2Lc and strobing CopJmp1 or CopJmp2.  (If you are
going to strobe one of the CopJmp registers, you should do so during VBlank,
however.)  You can add a server to the vertical blanking interrupt, or have
the Copper interrupt the 68000 at the appropriate time.

Anyway, it seems ok to me.  I've done my own hardware copper list stuff and
have had no problems with it.  
--
NAME: Bill W. Kelly
UUCP: {nosc ucsd hplabs!hp-sdd}!crash!pnet01!billk
ARPA: crash!pnet01!billk@nosc.mil
INET: billk@pnet01.cts.com

"main() {printf(&unix["\021%six\012\0"],(unix)["have"]+"fun"-0x60);}"
                                            -- David Korn, AT&T Bell Labs

aaron@madnix.UUCP (Aaron Avery) (01/14/89)

In article <3668@tekig5.PEN.TEK.COM> wayneck@tekig5.PEN.TEK.COM (Wayne Knapp) writes:
>I'm doing some copper list stuff now and have run into a
>little hitch.  I have my copper list, but what is the
>fastest proper way to install it.  It is easy to just
>set up the hardware address register but is this the
>correct way. 

No. This is not the proper way to do it. This way will work, and I've done it
this way, but you'd sure better not let anything else happen (Disable()) after
you've done this. If you do it this way, the place to find the old copper
list's pointer is in GfxBase->copinit. If you do it this way, you need to be
sure that the sprites are initialized to be blank in your copper list, or that
you turn off sprite DMA, or else you'll have random sprites on top of your
display.
 
>My program can not afford the wait involved in letting
>the system building the copper list from the ViewPorts.
>So I build my own custom list to do want I want.  In
>fact I have two copper lists and I plan to do page
>flipping by switching copper lists.  So my real 
>question is what is the fastest safe way to switch
>the copper lists.  

There are a couple of levels at which you can do this within the OS. The
safest one I know of is to replace GfxBase->ActiView with your own valid
View structure. I don't know how much of it needs to be valid (like ViewPorts
and RasInfo structures it would normally point to) to make it perfectly safe.
You would then place a pointer to your own copper list (in CHIP ram, I hope!)
in View->LOFCprList. Then you'd do a LoadView(View), and there would be
your display. You can then use the above two-step process to switch between
two copper lists, or have two Views set up and just use LoadView() alternating
between them. LoadView() has the VBlank interrupt routine do its work, so you'd
better have interrupts enabled, or this won't work.
The biggest problem with letting the system run after this, is that it may
do a MrgCop(GfxBase->ActiView) at some point, at which time, you'd better have
valid structures being pointed to. The problem with not replacing ActiView,
is that the system may at some point do a LoadView(GfxBase->ActiView), which
would then supercede your display, and perhaps cause other problems as well.

Unless you're doing some funky things which can't be described using the
ViewPort system, I think that's the way to go. The MrgCop(), LoadView()
sequence is quite quick for a simple display. You could set up two valid
ViewPorts (with associated RasInfo and BitMap structures), and switch
between them with View->ViewPort. Follow such a switch with MrgCop(View), then
LoadView(View), and you will have switched between the ViewPorts. If you've
already done the MakeVPort() for each ViewPort, the MrgCop() by itself should
be fast enough. You should have replaced ActiView with your View while doing
this. I think this will even survive the Left-Amiga-M and Left-Amiga-N keys,
but I could be wrong.

>Durning the time my program is messing with copper
>lists, I'd shut down the multitasking.  This because 
>what I'm trying to do requires every cycle that Amiga
>can give.

I sure hope you really do NEED to do this. Not very hospitable of you! When
no interrupts are occurring, almost anything is safe to do. But if you intend
to allow VBlank interrupts to occur, or need some of the devices to be active,
the hardware register method is probably not the way to go.

Sorry to go on like this, but there are many levels at which to approach this
problem. You can go all the way down to the BitMap pointer in the RasInfo
structure, but then switching gets much slower, because of the MakeVPort().

If you want to see this done wrong, take a look at Epyx's StreetSports
Basketball. If you hit a Left-Amiga-N to bring the Workbench to the front
during the player selection screen, you will crash things quite easily. They're
using a custom copper list to have the two screens with two different
pallettes. They should have trapped the keyboard events, as they even have
the keyboard.device open at the time! Anyway, I was once associated with that
project, and I'm now glad that I can say I probably didn't write any of what
was released. I can't really know, as they got my source when I stopped doing
it, but only my design decisions for the player select screen went into it.

-- 
Aaron Avery, ASDG Inc.         "A mime is a terrible thing to waste."
                                                             -- Robin Williams
UUCP: {harvard|rutgers|ucbvax}!uwvax!nicmad!madnix!aaron
ARPA: madnix!aaron@cs.wisc.edu