[comp.sys.amiga] Another Blitter Question

keithd@cadovax.UUCP (Keith Doyle) (10/16/87)

Here's another one for the blitter gurus out there: 

Ok.  With the blitter, if you are doing a 2 word transfer out of a
source image, to a destination image which becomes a 3 word transfer
because of the alignment has changed because the image is being
moved, you have to setup to do a 3 word transfer.  Problem:  How
do you correctly apply the last-word-mask, which you normally
apply to the source, when the word you really want to mask from
the source is the next-to-last-word.  The last word from the
source needs to be completely masked out, along with some trailing
bits in the previous word.

Here'a a visual example:

src words:  |____xxxxxxxxxxxx|xxxxxxxxxxxx____|________________|

dst words:  |____________yyyy|yyyyyyyyyyyyyyyy|yyyy____________|

If you are blitting xxxxx to yyyyy, (using shift etc. to re-align
the bits) you can see that the 3rd word of the source contains no
useful information, and the last-word-mask wants to be applied
to the second source word, not the last.  How do you do this?
Do you have to use up one of your precious blitter sources to
do this with a mask plane?  If so, it seems that the last-word-mask
concept is pretty useless for arbitrary transfers.  Or is there some 
way to accomplish this more directly?


Keith Doyle
#  {ucbvax,decvax}!trwrb!cadovax!keithd  Contel Business Systems 213-323-8170

rokicki@rocky.STANFORD.EDU (Tomas Rokicki) (10/17/87)

> Ok.  With the blitter, if you are doing a 2 word transfer out of a
> source image, to a destination image which becomes a 3 word transfer
> because of the alignment has changed because the image is being
> moved, you have to setup to do a 3 word transfer.  Problem:  How
> do you correctly apply the last-word-mask, which you normally
> apply to the source, when the word you really want to mask from
> the source is the next-to-last-word.  The last word from the
> source needs to be completely masked out, along with some trailing
> bits in the previous word.
> 
> Here'a a visual example:
> 
> src words:  |____xxxxxxxxxxxx|xxxxxxxxxxxx____|________________|
> 
> dst words:  |____________yyyy|yyyyyyyyyyyyyyyy|yyyy____________|

I'm doing this from memory, so excuse any errors.  There are two
cases like this.  To let everyone know what's happening, I'm
going to show the other case first, and then illustrate this.

When doing arbitrary-rectangle copy operations, you need all four
DMA channels, but only three actually fetch memory.  A is used
strictly as a mask.  You need to initialize the ADAT register to
0xffff.  B is used to fetch the source.  C is used to fetch the
destination, and D is used to store the destination.

Only A and B can be shifted.  B is always shifted the appropriate
amount; whether you shift A or not depends on whether you want the
mask operation to mask the source or the destination, so to speak.

For the first case:

src words:  |____________xxxx|xxxxxxxxxxxxxxxx|xxxx____________|

dst words:  |___yyyyyyyyyyyyy|yyyyyyyyyyy_____|________________|

In this case, you set up a three-word transfer.  The source
comes from B; the destination comes from C and goes to D.
The address you put in D is actually one word (2 bytes) less
than the actual start address in the picture above, since shifts
are always to the right.  We need shift of 7.  We need to mask the
source (since it spans three words), so we set the A shift equal to
the B shift of 7.  The FWM is 0x000f; the LWM is 0xf000.  And you
blit (with terms (AB+~AC) and everything works.

> src words:  |___xxxxxxxxxxxxx|xxxxxxxxxxx_____|________________|
> 
> dst words:  |____________yyyy|yyyyyyyyyyyyyyyy|yyyy____________|

In this case, you again set up a three-word transfer.  The source
comes from B; the destination comes from C and goes to D.
Here we use a shift of 10.  We need to mask the destination this
time (since it spans the three words), so we set the A shift equal
to 0, the FWM to 0x000f, and the LWM to 0xf000.  You blit again,
and everything works.

Get BlitLab on one of the fish disks; it has full documentation on
how the blitter works.  Oh, and that use of the A channel for masking;
that's free in terms of time.

keithd@cadovax.UUCP (Keith Doyle) (10/20/87)

In article <678@rocky.STANFORD.EDU> rokicki@rocky.UUCP (Tomas Rokicki) writes:
>> src words:  |___xxxxxxxxxxxxx|xxxxxxxxxxx_____|________________|
>> 
>> dst words:  |____________yyyy|yyyyyyyyyyyyyyyy|yyyy____________|
>
>In this case, you again set up a three-word transfer.  The source
>comes from B; the destination comes from C and goes to D.
>Here we use a shift of 10.  We need to mask the destination this
>time (since it spans the three words), so we set the A shift equal
>to 0, the FWM to 0x000f, and the LWM to 0xf000.  You blit again,
>and everything works.

This implies that if the A shift is 0, then the FWM and LWM are applied
after shifting?  No, more likely since the FWM and LWM seem to be applied
before shifting if you ARE shifting A, that you are assuming that A will
always be 0xffff, and the FWM, LWM will be generated by masking it at
the appropriate times.  Unfortunately, I am trying to use the A channel 
as a source mask plane which won't allow me to use it in that manner.
Looks like what I'm trying to do can't be done  (A=src mask plane, B=src,
C=dest, arbitrary rectangle blit)  The system routine that does this 
flashes horribly, must be because it has to do it in two passes or
something.

>Get BlitLab on one of the fish disks; it has full documentation on
>how the blitter works.  

That's where I started.  The stuff on the shifting and FWM/LWM was
a little to terse to glean such answers.


>Oh, and that use of the A channel for masking; that's free in terms of time.

But if I had other plans for it, it's not so free.  I have to take the time
that it takes to do two operations.  Oh well.

Keith Doyle
#  {ucbvax,decvax}!trwrb!cadovax!keithd  Contel Business Systems 213-323-8170