[comp.sys.amiga.tech] BltMaskBitMapRastPort

jojo@astroatc.UUCP (Jon Wesener) (10/20/88)

    1st, where is the documentation for this routine because I can't find
it in any of the manuals?  What I did find was a function call and
parameter list in a description of the amiga library calls that came
with my MANX compiler.

    I'm trying to use BltMaskBitMapRastPort() to blitter a source A,
through a Mask B into a destination C.  I'd like the minterm to do
the equivalent of D = AB | (~B)C where I'm assuming the destination is
C.  Thing is, all I can seem to get happen is C = ~A. 

	To make things easier for myself, I wrote a program which uses longs
as the bitmaps so that I can feed the program a few numbers (really bit 
patterns) and see what the results are by printing the value of the longs
out after the operation.

	What follows is the simple code (about a page) which should compile
without a problem.  I use a precompiled header file so there aren't any
include files mentioned.  Anyway, can someone tell me what I'm doing
wrong, and or explain how the above function is used/called?  Or
show me another way of doing what I'm trying to do?

thanx in advance,
--j

#------------< Cut here for minterm.c >----------------------------------#

/*
 * Minterm.c -- this file test the blitter mask routine.
 */

#include "stdio.h"

#define DEPTH 1L      
#define WIDTH 4*8L   
#define HEIGHT 1L

struct RastPort crast;
struct BitMap amap, bmap, cmap;
long * al, * bl, * cl;

struct GfxBase *GfxBase;

main(ac, av)
	int ac;
	char *av[];
{
	int minterm;

	if( ac != 5 ) {
		printf("usage: %s a b c minterm\n",av[0]);
		exit( 1 );
	}

	/* Open the graphics library. */
	GfxBase = (struct GfxBase *)OpenLibrary("graphics.library",0L);
	if( GfxBase == NULL ) 
		exit( 1 );

	/* Init bit map (for rasinfo and rastport). */
	InitBitMap(&amap, DEPTH, WIDTH, HEIGHT);
	InitBitMap(&bmap, DEPTH, WIDTH, HEIGHT);
	InitBitMap(&cmap, DEPTH, WIDTH, HEIGHT);

	amap.Planes[0] = (PLANEPTR) AllocRaster(WIDTH, HEIGHT);
	bmap.Planes[0] = (PLANEPTR) AllocRaster(WIDTH, HEIGHT);
	cmap.Planes[0] = (PLANEPTR) AllocRaster(WIDTH, HEIGHT);

	InitRastPort(&crast);
	crast.BitMap = &cmap;

	al = (long *)amap.Planes[0];
	bl = (long *)bmap.Planes[0];
	cl = (long *)cmap.Planes[0];

	*al = atol( av[1] );
	*bl = atol( av[2] );
	*cl = atol( av[3] );
	minterm = atol( av[4] );

	printf("a = 0x%x b = 0x%x c = 0x%x minterm = 0x%x.\n",
		*al, *bl, *cl, minterm);

	(void)BltMaskBitMapRastPort( &amap, 0, 0, &crast, 
		0, 0, WIDTH, HEIGHT, minterm, &bmap );

	printf("a = 0x%x b = 0x%x c = 0x%x minterm = 0x%x.\n",
		*al, *bl, *cl, minterm);

	FreeRaster(amap.Planes[0], WIDTH, HEIGHT);
	FreeRaster(bmap.Planes[0], WIDTH, HEIGHT);
	FreeRaster(cmap.Planes[0], WIDTH, HEIGHT);

	CloseLibrary(GfxBase);

	exit( 0 );
}   

#-------------------------< end of minterm.c >----------------------#
-- 
... {seismo | harvard } ! {uwvax | cs.wisc.edu} ! astroatc!jojo
"And when the sky is blue, there'll be no cocktails for you.
 But when the sky is black, you can have your bottle back..."

bart@amiga.UUCP (Barry A. Whitebook) (10/21/88)

) astroatc!jojo rightly points out that the current RKM does not have this
) autodoc: for those of you who dont have the 1.2 enhancer documentation,
) here it is...

/****** graphics.library/BltMaskBitMapRastPort ********************************
*
*   NAME
*
*   	BltMaskBitMapRastPort -- blit from source bitmap to destination rastport
*				with masking of source image.
*
*   SYNOPSIS
*
*	BltMaskBitMapRastPort
*	    (srcbm,srcx,srcy,destrp,destX,destY,sizeX,sizeY,minterm,bltmask)
*	     a0    d0   d1   a1     d2    d3    d4    d5    d6      a2 
*
*	struct BitMap *srcbm;
*	SHORT srcx,srcy;
*	struct RastPort *destrp;
*	SHORT destX,destY;
*	SHORT sizeX,sizeY;
*	UBYTE	minterm;
*	APTR	bltmask;	* chip memory *
*
*   FUNCTION
*	Blits from source bitmap to position specified in destination rastport	
*	using bltmask to determine where source overlays destination, and 
*	minterm to determine whether to copy the source image "as is" or
*	to "invert" the sense of the source image when copying. In either
*	case, blit only occurs where the mask is non-zero.	
*
*
*   INPUTS
*	srcbm - a pointer to the source bitmap
*	srcx  - x offset into source bitmap
*	srcy  - y offset into source bitmap
*	destrp - a pointer to the destination rastport
*	destX - x offset into dest rastport
*	destY - y offset into dest rastport
*	sizeX - width of blit in pixels
*	sizeY - height of blit in rows 
*	minterm - either (ABC|ABNC|ANBC) if copy source and blit thru mask
*		  or     (ANBC)        if invert source and blit thru mask
*	bltmask - pointer to the single bit-plane mask, which must be the
*		  same size and dimensions as the planes of the
*		  source bitmap.
*
*   RETURNS
*
*   BUGS
*
*   SEE ALSO
*   BltBitMapRastPort	graphics/gfx.h graphics/rastport.h
*
******************************************************************************/

jesup@cbmvax.UUCP (Randell Jesup) (10/22/88)

In article <1232@astroatc.UUCP> jojo@astroatc.UUCP (Jon Wesener) writes:
>
>    1st, where is the documentation for this routine because I can't find
>it in any of the manuals?  What I did find was a function call and
>parameter list in a description of the amiga library calls that came
>with my MANX compiler.

	It's mentioned in the 1.2 Enhancer docs, and is defined in the
AutoDocs, available from CATS.  It will also be in the new RKMs coming from
Addison-Wesley.

>    I'm trying to use BltMaskBitMapRastPort() to blitter a source A,
>through a Mask B into a destination C.  I'd like the minterm to do
>the equivalent of D = AB | (~B)C where I'm assuming the destination is
>C.  Thing is, all I can seem to get happen is C = ~A. 

Here's the AutoDoc for the call:

/****** graphics.library/BltMaskBitMapRastPort ********************************
*
*   NAME
*
*   	BltMaskBitMapRastPort -- blit from source bitmap to destination rastport
*				with masking of source image.
*
*   SYNOPSIS
*
*	BltMaskBitMapRastPort
*	    (srcbm,srcx,srcy,destrp,destX,destY,sizeX,sizeY,minterm,bltmask)
*	     a0    d0   d1   a1     d2    d3    d4    d5    d6      a2 
*
*	struct BitMap *srcbm;
*	SHORT srcx,srcy;
*	struct RastPort *destrp;
*	SHORT destX,destY;
*	SHORT sizeX,sizeY;
*	UBYTE	minterm;
*	APTR	bltmask;	* chip memory *
*
*   FUNCTION
*	Blits from source bitmap to position specified in destination rastport	
*	using bltmask to determine where source overlays destination, and 
*	minterm to determine whether to copy the source image "as is" or
*	to "invert" the sense of the source image when copying. In either
*	case, blit only occurs where the mask is non-zero.	
*
*
*   INPUTS
*	srcbm - a pointer to the source bitmap
*	srcx  - x offset into source bitmap
*	srcy  - y offset into source bitmap
*	destrp - a pointer to the destination rastport
*	destX - x offset into dest rastport
*	destY - y offset into dest rastport
*	sizeX - width of blit in pixels
*	sizeY - height of blit in rows 
*	minterm - either (ABC|ABNC|ANBC) if copy source and blit thru mask
*		  or     (ANBC)        if invert source and blit thru mask
*	bltmask - pointer to the single bit-plane mask, which must be the
*		  same size and dimensions as the planes of the
*		  source bitmap.
*
*   RETURNS
*
*   BUGS
*
*   SEE ALSO
*   BltBitMapRastPort	graphics/gfx.h graphics/rastport.h
*
******************************************************************************/

Note: BMBMRP is not currently the fastest routine in the world.  To avoid
using big tmprasts, it does 3 blits, and may cause the destination to flash
(even areas masked out, but within the destination rectangle).  This may
improve in future releases.

-- 
You've heard of CATS? Well, I'm a member of DOGS: Developers Of Great Software.
Randell Jesup, Commodore Engineering {uunet|rutgers|allegra}!cbmvax!jesup