[comp.sys.amiga] Info on Blitter Line Drawing

Chad_The-Walrus_Netzer@cup.portal.com (01/11/88)

      I need some information about blitter line drawing (get out your
Hardware Manual's).  Basically, I'm writing a program where I want to
use a bitmap/buffer as a mask to use in some collision detection.  I
want to know if the blitter (in line drawing mode) can somehow be made
to draw a line in a bitmap, without actually affecting that bitmap (I
just want to read the BZERO bit in DMACONR, to check if the line would
draw into an area that has already been writen to).
       In other words, can I draw a non damaging line into the bitmap,
and still check to see if that line would cross any area with a pixel
set?
	In particular, I would like to know if how the SET/CLR bit in
DMACONR operates.  If I set it, will a line be generated by drawing
zeros instead of ones?  I've done some preliminary tests after slightly
modifying Tom Rokiki's "Blitlab" program, and it didn't produce any
favorable results.
	Also, I want to know exactly what sets the BZERO bit in DMACONR
when in line mode.  Since the blitter's line drawer operates on blocks
of memory, will this bit be set if there are ones in ANY area that the
blitter operated on, or just on the actual line that was drawn.
	The sooner you answer, the sooner I can get my program into the
public domain (I'm working on an Amiga version of the game "Qix").  If I
need to be more descriptive or specific, let me know!   Thanx.


          Chad Netzer
          "If I weren't crazy, I'd just go nuts!"

steveb@cbmvax.UUCP (Steve Beats) (01/12/88)

In article <2374@cup.portal.com> Chad_The-Walrus_Netzer@cup.portal.com writes:
>
>      I need some information about blitter line drawing (get out your
>Hardware Manual's).  Basically, I'm writing a program where I want to
>use a bitmap/buffer as a mask to use in some collision detection.  I
>want to know if the blitter (in line drawing mode) can somehow be made
>to draw a line in a bitmap, without actually affecting that bitmap (I
>just want to read the BZERO bit in DMACONR, to check if the line would
>draw into an area that has already been writen to).

Yeah, no problem.  Instead of using USEA|USEC|USED in bltcon0 leave off the
USED term.  Set everything else up to draw a line as normal, your minterms
will be NAC+B (~a^c|b I think) which works out to a code of $ca.  Leaving
out the USED term disables the output (though the blitter will still read
the source bitmap from bltcpth and mask it with the line bit in bltadat).
Of course, you will have to do this for every bit plane in your display.
I haven't tried this but I see no reason why it shouldn't work, suck it and
see.  I have some assembler source for line drawing which I can provide if
needed.

	Steve

rap@dana.UUCP (Rob Peck) (01/14/88)

In article <3131@cbmvax.UUCP>, steveb@cbmvax.UUCP (Steve Beats) writes:
> In article <2374@cup.portal.com> Chad_The-Walrus_Netzer@cup.portal.com writes:
> >
> >want to know if the blitter (in line drawing mode) can somehow be made
> >to draw a line in a bitmap, without actually affecting that bitmap (I
> >just want to read the BZERO bit in DMACONR, to check if the line would
> >draw into an area that has already been writen to).
> 
> Yeah, no problem.  Instead of using USEA|USEC|USED in bltcon0 leave off the
> USED term.  Set everything else up to draw a line as normal, your minterms
> 
> 	Steve

If indeed the collision detection routines in the DoCollision dont handle
inter-object collisions "completely correctly" as indicated in the
autodocs (and as people have evidently found out the hard way), it seems
that interobject collisions can be detected using the blitter by disabling
the USE-D flag as Steve has noted.  Most likely though that one would
have to go through the QBlit functions in order to get temporary custody
of the blitter as well as access to the critical BZERO flag immediately
following the blit.   Also, since in a Bob or VSprite, the system will
create a mask for you  (all of the planes, OR'd together for masking
the object - as 1 wherever there was a 1 in the object and zeros
[transparent] elsewhere) this mask can be used - one plane at a time -
against the other thing you want to test for collision bits.    Or
better still, to minimize the total number of user-blitter passes,
how about this:  for objects that are "suspected to be colliding",
do a single plane blit of the first object's mask into an empty
rectangular work area, then using the method Steve Beats mentioned,
blit the second object into the work area and check for BZERO.
Sounds like one plane, two blits to test each suspected collision.
Plane size = (object1.width + object2.width) by (ob1.ht + ob2.ht)

Food for thought for advanced version of GelTools, sometime in the
next few months unless someone else Beats (grin) me to it.

Rob Peck		...ihnp4!hplabs!dana!rap

rap@dana.UUCP (Rob Peck) (01/14/88)

In my last posting, I forgot to add that the USE_D omission need
not be done if the collision detect is being done between two masks
of objects in a contrived background plane, and the AND function
between the second object and the background is used.  If you
are looking at collisions between an object and a background item
that is not defined as an object, there is a lot more work involved.
For QIX, I would believe that there is a lot less overhead to checking
the collisions between the end points of the line and the locations of
predrawn boxes than the overhead involved in setting up the blitter.

Rob Peck				...ihnp4!hplabs!dana!rap

dillon@cory.Berkeley.EDU (Matt Dillon) (01/15/88)

	This brings up a good point for the next (or some other) release
of the OS ... one should be able to retrieve the BZERO status from standard
graphics calls.  There are major uses for the zero-detect and better it be
supported graphics.library calls rather than custom routines, no?

				-Matt

Chad_The-Walrus_Netzer@cup.portal.com (01/20/88)

      Well, Steve.  I've been fooling around with the line functions and I'm
pretty confidant that turning off the USED bit in BLTCON0 has no (noticeable)
effect in Line Drawing Mode...  However, I believe the algorithim will work
almost as good in the normal mode (where I CAN turn off USED), so I'll probably
go that route (unless i get some proof that USED can be shunted in line draw...
)  Thanks for the help, though.. (I got some Ideas from some other stuff you
said...)

    P.S. -- My postings have been going all over the place for some reason, so
I'm not sure if you read any previous messages (or remember anything in
connection with this one...sigh :-)