From: rittle@supra.comm.mot.com (Loren James Rittle)
Subject: Bug in Flood () or my test program?
Organization: Systems Technology Research, Motorola, Inc.
Date: Thu, 31 Dec 1992 02:17:29 GMT

Please tell me if the bug seen in the program below is in my code or
Flood ().

If in Flood (), is it a known problem that isn't well documented?  Is
there a good work around?  If problem with my code, how do I fix the
problem?

I will report via official channels if it is decided that this is
an OS bug that is not well known.

Thanks for your time,
Loren

/* This test shows what I believe to be a bug in Flood ()
   under OS 3.0 (Kickstart 39.106, Workbench 39.29) on an A4000.
   This has not been tested for under any other OS rev.
   or any other Amiga system.  There is no mention of size
   limitations in the autodocs or RKMs that I can find...
   But, it sure looks like funny things happen if the x size
   gets over about 1024... :-( */

/* compiles under SAS/C 6.x */

/* To allow this to compile with the STRICT ANSI WARNING=ALL options: */
#pragma msg 148 ignore
#pragma msg 149 ignore push
#pragma msg 61 ignore push
#include <proto/exec.h>
#include <proto/dos.h>
#include <proto/intuition.h>
#include <proto/graphics.h>
/* As an aside, I wish someone at C= or SAS would fix the standard system
   includes...  The 2.04 standard system includes are *NOT* ANSI compliant!
   To avoid finger pointing between SAS and C=, let me point out
   that the problems do appear to lie in the standard C= includes
   that the SAS proto/#?.h files pull in, I use proto/#?.h because
   they are easier to get right (less typing, etc.). */
#pragma msg 149 pop
#pragma msg 61 pop
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

/* Thanks to Chris Green: */
LoadRGB32 (struct ViewPort *, unsigned long *table);
#pragma libcall GfxBase LoadRGB32 372 9802

int main (void)
{
  int rc = 0;

  UWORD t[] = {0xffff};
  struct Screen *s = OpenScreenTags (NULL, SA_Width, 1280, SA_Height, 710,
			SA_AutoScroll, TRUE, SA_Overscan, OSCAN_TEXT,
			SA_Pens, t, SA_SysFont, 1,
			SA_Title, "Flood () test by Loren J. Rittle <rittle@comm.mot.com>",
			SA_DisplayID, HIRESLACE_KEY, SA_Depth, 4, TAG_DONE);

  if (s)
    {
      struct Window *w = OpenWindowTags (NULL, WA_CustomScreen, s,
		WA_IDCMP, IDCMP_MOUSEBUTTONS | IDCMP_VANILLAKEY, WA_Backdrop, 1,
		WA_Borderless, 1, WA_Activate, TRUE, TAG_DONE);

      if (w)
	{
	  struct RastPort *rp = w->RPort;
	  int i, j, k;
	  static ULONG ct[1 + 64 * 3 + 1];

	  ct[0] = (8 << 16) + 8;
	  for (i = 0; i < 2; i++)
	    for (j = 0; j < 2; j++)
	      for (k = 0; k < 2; k++)
		{
		  ct[(k * 4 + j * 2 + i) * 3 + 1] = i ? 0xffffffff : 0;
		  ct[(k * 4 + j * 2 + i) * 3 + 2] = j ? 0xffffffff : 0;
		  ct[(k * 4 + j * 2 + i) * 3 + 3] = k ? 0xffffffff : 0;
		}
	  LoadRGB32 (&(s->ViewPort), ct);
#define COLOR_BLACK 8
#define COLOR_RED 9
#define COLOR_GREEN 10
#define COLOR_YELLOW 11
#define COLOR_BLUE 12
#define COLOR_PURPLE 13
#define COLOR_AQUA 14
#define COLOR_WHITE 15

	  {
	    static struct AreaInfo ai;
	    static UWORD aib[50];
	    static struct TmpRas tr;
	    static UBYTE __chip trb[(1280 / 8) * 710];

	    InitArea (&ai, aib, ((sizeof aib) * 2) / 5);
	    InitTmpRas (&tr, trb, sizeof trb);
	    rp->AreaInfo = &ai;
	    rp->TmpRas = &tr;
	  }

	  SetRast (rp, COLOR_WHITE);

/* try other values for XSIZE: less than 1024 works great,
   over 1024, will show what I believe to be a bug */
#ifndef XSIZE
#define XSIZE 1025
#endif

	  SetAPen (rp, COLOR_BLUE);
	  Move (rp, 0, 20);
	  Draw (rp, XSIZE, 20);
	  Draw (rp, XSIZE, 709);
	  Draw (rp, 0, 709);
	  Draw (rp, 0, 20);
	  rc = Flood (rp, 1, 1, 21);

	  Wait (SIGBREAKF_CTRL_C | (1 << w->UserPort->mp_SigBit));

	  CloseWindow (w);
	}
      else
	rc = 1;

      CloseScreen (s);
    }
  else
    rc = 1;
  return rc;
}
--
Loren J. Rittle (rittle@comm.mot.com)
Systems Technology Research (IL02/2240)
Motorola, Inc.
(708)576-7794