[comp.sys.amiga.tech] Copper Programming

brett@umd5.umd.edu (Brett Bourbin) (06/24/89)

	What I have been trying to do is write a short User Copper list that
calls my private hardware copper list.  The User Copper list simply waits for
the first line of the screen, where the changes need to be made, then loads
COP2LC with the address of the private list, finally accesses COPJMP2.  When
I use the following code, the screen gets all jarbled:

	if ( !( vp->UCopIns = (struct UCopList *)
		AllocMem( (long) sizeof (struct UCopList),
			MEMF_CHIP|MEMF_CLEAR ))) goto FAIL;

	ucl = vp->UCopIns;
	CINIT( ucl, 10L );
	CWAIT( ucl, (long) STARTLINE-1, (long) width-1 );
	CMOVE( ucl, custom.cop2lc, (long) (privatecop >> 16) & 0xffff );
	CMOVE( ucl, (*((UWORD *) &custom.cop2lc+1)), (long) privatecop &0xffff );
	CMOVE( ucl, custom.copjmp2, 0L );
	CEND( ucl );

	Can someone tell me where I am going wrong?  It looks to me like the
correct way to do it, but since it doesn't work, I guess there is a better
way.  8^)

-- 

--Brett S Bourbin, Instructional Computing Programs -- Univ of Maryland
            Computer Science Center, College Park, MD 20742
       INTERNET: brett@umd5.umd.edu  BIX: brettb  DELPHI: brettb

jimm@amiga.UUCP (Jim Mackraz) (06/25/89)

In article <5050@umd5.umd.edu> brett@umd5.umd.edu (Brett Bourbin) writes:
)
)	What I have been trying to do is write a short User Copper list that
)calls my private hardware copper list.  The User Copper list simply waits for
)the first line of the screen, where the changes need to be made, then loads
)COP2LC with the address of the private list, finally accesses COPJMP2.  When
)I use the following code, the screen gets all jarbled:

)	if ( !( vp->UCopIns = (struct UCopList *)
)		AllocMem( (long) sizeof (struct UCopList),
)			MEMF_CHIP|MEMF_CLEAR ))) goto FAIL;
)
)	ucl = vp->UCopIns;
)	CINIT( ucl, 10L );
)	CWAIT( ucl, (long) STARTLINE-1, (long) width-1 );
********* key point: what values for STARTLINE?

)	CMOVE( ucl, custom.cop2lc, (long) (privatecop >> 16) & 0xffff );
)	CMOVE( ucl, (*((UWORD *) &custom.cop2lc+1)), (long)privatecop &0xffff );
********* difficult syntax: would be nice if CMOVE were not indirect.

)	CMOVE( ucl, custom.copjmp2, 0L );
)	CEND( ucl );
)

This is what I do (recently, so I stil remember the pitfalls ;^).
First, if you are using Lattice, and in any case, you might toss the
macros and use CMove() and CBump() directly: it simplifies the
register address syntax of CMOVE(), esp for low/high register pairs.

I assume you have your basic UCL stuff at hand: you can change color 0
wherever you want.

I had some problems depending on STARTLINE.  I think the UCL can get
merged in before the real viewport instructions.  Try a 1, or for
that matter, 20.  Without knowing your value for STARTLINE, I'm reluctant
to wager that this is your problem, but it confused me.  I use
CWait( ucl, 1L, 0L ).

The next question is whether your hardware copper list is sound.
Again, jam color 0 (then do the Big Wait).  You can copy these right
out of DCop or another copper list disassembler, for absolute certainty.

Oh, yes: don't pull this stunt in interlaced mode. 

If you're going to hit all the problems I stumbled on, I can also help
by saying yes, you're going to have to poke that copper list of yours
at interrupt time, and when you do so, don't forget to turn off compiler
stack checking, like I did.

	jimm
-- 
Jim Mackraz, I and I Computing	   	"He's hidden now, but you can see
{cbmvax,well,oliveb}!amiga!jimm          The bubbles where he breathes."
							- Shriekback
Opinions are my own.  Comments are not to be taken as Commodore official policy.

bartonr@jove.cs.pdx.edu (Robert Barton) (06/26/89)

 brett@umd5.umd.edu (Brett Bourbin) writes:

>    if ( !( vp->UCopIns = (struct UCopList *)
>       AllocMem( (long) sizeof (struct UCopList),
>          MEMF_CHIP|MEMF_CLEAR ))) goto FAIL;
> 
>    ucl = vp->UCopIns;
>    CINIT( ucl, 10L );
>    CWAIT( ucl, (long) STARTLINE-1, (long) width-1 );
>    CMOVE( ucl, custom.cop2lc, (long) (privatecop >> 16) & 0xffff );
>    CMOVE( ucl, (*((UWORD *) &custom.cop2lc+1)), (long) privatecop &0xffff );
>    CMOVE( ucl, custom.copjmp2, 0L );
>    CEND( ucl );
> 
>    Can someone tell me where I am going wrong?  It looks to me like the
> correct way to do it, but since it doesn't work, I guess there is a better
> way.  8^)

  Your UCopList structure doesn't need to be in CHIP memory, but it should be
PUBLIC and CLEAR.  But that wouldn't cause your problem.  These might:
1) Your 'privatecop' should point to CHIP memory.
2) How are you measuring 'width'?  It should be in 'color clocks'.
3) Shouldn't the second CMOVE be &custom.cop2lc+2 ?


(*
f
i
l
l
e
r
*)