[comp.sys.amiga.tech] Memory Utilization in a program using MakeBob

rap@peck.ardent.com (Rob Peck) (08/17/89)

This is directed towards anyone who has used the MakeBob function found
in either the Amiga ROM Kernel manual or in the Programmer's Guide To
The Amiga.  There is a small improvement in memory utilization that can
be made by the simple addition of one parameter and changing an associated
line in the MakeBob function.  (I had to rework this a little because I
am working on a magazine article about AnimComps and AnimObs.... more
changes likely to come out of this.)

Problem:  If the Bob data is only 2 planes deep, because of the way that
	  the original (that is, PRINTED) version of MakeBob does things,
	  one must provide X (depth of bitmap into which the Bob will be
	  rendered) planes worth of data, where X minus 2 planes worth
	  of data must be zeros or else the image mask will not be calculated
	  correctly.

Solution: Add the parameter "screendepth" to the list of parameters
	  accepted by MakeBob:

		MakeBob(........., x, y, flags, screendepth)

	  When specifying "imagedepth", (when using MakeBob), specify
	  the ACTUAL depth of the image instead of the actual number
	  of planes for the screen as is required in the printed version.
	  So in the example in the Programmer's Guide, imagedepth = 2
	  instead of 5.

	  Then, in MakeBob, substitute "screendepth" for the parameter
	  "imagedepth" in the call that allocates memory for saving and
	  restoring the background.  Even a 1 plane image rendered into
	  a 5 plane screen requires 5 planes of data save/restore because
	  of the effect that the Bob drawing functions have on the background.

I'll post my new version of MakeBob in about a month, when this
is all finished.  It will probably be renamed CreateBob because of the
changes.  The most significant change I think will be to replace the
"bobdata" item with a pointer to a BitMap data structure... why?  Well,
as it is now, the data for the bob MUST be organized as a contiguous set
of plane1, plane2... planeN where if I use a BitMap data structure, the
data for each plane can be anywhere.   AND, I could attach a RastPort to
that same BitMap and draw into the Bob on the fly if necessary.

Rob Peck