🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.sys.amiga.tech
Article #11257

Re: blitting bitmaps

#11257
From: Randell Jesup
Date: Mon, 30 Jan 1989 21:17
56 lines
2966 bytes
In article <503@hvrunix.UUCP> ahinds@hvrunix.UUCP (Alexander Hinds) writes:
>
>	I'm involved in a game port, and I need to be able to blit
>bitmaps (or rasters).  The problem is that I want to copy a whole
>source BitMap, except for color 14 to a destination BitMap.  The RKM's
>weren't too clear on how or if this can be done.  I'd appreciate any help,
>whatsoever.  Mail would be better.  Thanks in advance.

	I think this might be of general interest.

	The first thing to realize is the blitting occurs on bitplanes, not
bitmaps.  Therefor, the blitter doesn't know about colors.  So you have to
contruct a mask of where color 14 is and is not.  One way might be this:

	Create a mask bitplane and a bitmap structure for it (InitBitMap, etc).
		(I'll call this Bitmap bmask)
	set bmask's bitplane (BltClr or whatever) to all 1 bits.
	Create another bitmap structure similar to the first (no bitplane).
		(I'll call this Bitmap btemp)
	for (i = 0; i < #planes in source; i++)
	{
		Set the bitplane pointer 0 of bmask to source bitmap plane[i]
		if ((1L << i) & color)	/* color = 14 */
			BltBitMap(btemp,0,0,bdest,0,0,SIZEX,SIZEY,
		  		  ABC,0xff,NULL);
		else
			BltBitMap(btemp,0,0,bdest,0,0,SIZEX,SIZEY,
		  		  ANBC,0xff,NULL);
	}
	/* btemp now has a 1-bitplane mask with 1's where color is. */
	/* now use the mask to copy */
/*
 * there are three ways to do this:
 * 1.	BltMaskBitMapRastPort - slow but easy to use.  Does 3 blits, and
 *		temporarily modifies the source in the process (fixes it
 *		up when done.)  "glitchy" looking destination during blit.
 * 2.	One blit to clear part of the desination, using 0x20, and a faked
 *		bitmap that has pointers to the mask plane in all the plane
 *		pointers, and says it's the same size as the source.  Second
 *		blit from source, using 0xE0 for a minterm. Faster
 *		by a bit (2 passes versus 3), doesn't modify source ever.
 *		Less glitchy than 1, but still has glitches in masked area.
 * 3.	OwnBlitter(); WaitBlit(), do a cookie cutter blit.  Requires the
 *		bitmaps be alligned conveniently so an next-to-last-word
 *		mask in the A source isn't needed.  Tom Rokicki recently
 *		posted about this, I believe.  Fastest, least glitches (though
 *		as with all blits, there may be some).  Toughest to code
 *		(hitting the blitter registers).
 */

Note: written off the top of my head, without error-checking.  Caveat User.

	Hope this helps!

-- 
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup
Technical Details
Message-ID: <5853@cbmvax.UUCP>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!cbmvax!jesup
References: <503@hvrunix.UUCP>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!rutgers!cbmvax!jesup
From: jesup@cbmvax.UUCP (Randell Jesup)
Newsgroups: comp.sys.amiga.tech
Subject: Re: blitting bitmaps
Keywords: How?
Message-ID: <5853@cbmvax.UUCP>
Date: 30 Jan 89 21:17:05 GMT
References: <503@hvrunix.UUCP>
Reply-To: jesup@cbmvax.UUCP (Randell Jesup)
Organization: Commodore Technology, West Chester, PA
Lines: 56