[comp.sys.amiga.tech] Blitter twiddling questions

nsw@cbnewsm.ATT.COM (Neil Weinstock) (11/09/89)

Hi, y'all.  I'm playing with the blitter (directly) for the first time,
and there's a few things I'm unclear on.

First, how long is OK to own the blitter?  I don't want to be unfriendly.

Next, what is the best way to set up the blitter to either clear a bitplane
or set it to all ones?  If I turn off all the sources, what gets written
to the destination?

Finally, for source A I want the equivalent of a 1-bit shift to the left,
and there will be an unshifted B and C source and destination.
(Ack.  I may have it confused, I'm assuming the shift direction for A and B
is normally a right shift.  If I'm backwards, the question probably doesn't
apply, though I also want to do a right shift).  It seems the way to shift
"against the grain" is to specify a shift value of 15 and offset the beginning
of the blit area by one.  My problem arises when considering the boundary
conditions.

In the hideously inadequate pictures below, assume each dot is a bit, the ">"
represents the start of the bitplane data for the blitter.

If no shifting is done, the start of the blit looks like this:

	>0...............1................2...	A
case1:
	>0...............1................2...	B

Now, if we apply a shift of 15 to A, it looks like this:

		       >0...............1................2...	A
case2:
	>0...............1...............2...	B

Now we decide to start the source A one word to the right, to correct for the
offset:
		       >1...............2................3...	A
case3:
	>0...............1...............2...	B

Everythings OK, but we haven't done anything useful to the first word of B.
So what is the solution?  Offset both A and B one word to the left:

			>0...............1................2...	A
case4:
	>-1...............0...............1................2... B

Now, everything's great, but the destination, not shown, will have to look
like B, and I will be writing into the -1'st word in a bitplane, a word
that I have not allocated.  No good.  I could overallocate the bitplane,
but it seems like there should be another way.

The only thing I can think of is if I use case 3, but preload the blitter's
A data register with A[0], so that A[0] gets used as the "old" value that
appears in the block diagram in the hardware manual:

	0.."old" data..>1...............2................3...	A
case3:
	>0...............1...............2...	B

Now, everything would seem to be OK, I think.  Is this reasonable?  
Am I going about this the right way? (god, I hope this all makes some sense).

Thanks for any input.

    ________________    __________________    ____________________________
////                \\//                  \\//                            \\\\
\\\\ Neil Weinstock //\\ att!cord!nsw  or //\\ "Oh dear, now I shall have ////
//// AT&T Bell Labs \\// nsw@cord.att.com \\//  to create more Martians." \\\\
\\\\________________//\\__________________//\\____________________________////

rogers@iris.ucdavis.edu (Brewski Rogers) (11/10/89)

In article <6344@cbnewsm.ATT.COM> nsw@cbnewsm.ATT.COM (Neil Weinstock) writes:
>Hi, y'all.  I'm playing with the blitter (directly) for the first time,
>and there's a few things I'm unclear on.
>
>First, how long is OK to own the blitter?  I don't want to be unfriendly.
as long as you want. Of course, nothing else will get blitted while you own
it. It's always good to avoid doing printf's while you have control,
since your code will lock up.

>
>Next, what is the best way to set up the blitter to either clear a bitplane
>or set it to all ones?  If I turn off all the sources, what gets written
>to the destination?

All the source registers have a temporary word that the data gets read
from. You can set this word yourself if you have the source off.
set the a data register to all 1 or 0, then run the blit with no sources.
should be pretty quick. 4 cycles per word I think.

>
>Finally, for source A I want the equivalent of a 1-bit shift to the left,
>and there will be an unshifted B and C source and destination.
>of the blit area by one.  My problem arises when considering the boundary
>conditions.
>like B, and I will be writing into the -1'st word in a bitplane, a word
>that I have not allocated.  No good.  I could overallocate the bitplane,
>but it seems like there should be another way.

With all this bit shifting, you'll probably want the cookie-cut mask,
$c8 (i think) With this, it is possible to mask out the data that would have
written to location -1. Actually, it would read the data, OR it with some
mask (that should be zero for the parts you don't want to write on) then write
the data back out.
Hopefully, you could mask your data against one of your unshifted sources...
However, the fastest way (if you don't mind trashing a few bytes) IS to alloc
a few extra bytes, and use an $f0 a->d copy which takes 4 cycles, as opposed
the 8 that a+b+c->d takes.
>
>Thanks for any input.
>\\\\ Neil Weinstock //\\ att!cord!nsw  or //\\ "Oh dear, now I shall have ////
>//// AT&T Bell Labs \\// nsw@cord.att.com \\//  to create more Martians." \\\\
Hope the input wasn't too fuzzy!

------------------------------------------------------          Quantum _\/_
2727 Eel                   Bruce (6502 RULES!) Rogers        |\  Duck  ( 0 0)
Davis, Ca 95616            Quantum Duck Software,           |\ \______/ / \\\
916-756-2684               rogers@iris.ucdavis.edu         |\ <  <     |   \/
"It's better to be the real thing than the right thing."     \________/  Quark!