Example #1
0
void ScratchRast_Del(struct RastPort *This)
{
int loop;

if(This)
	{
	if(This->BitMap)
		{
		if(This->BitMap->Planes[7])
			{
			FreeRaster(This->BitMap->Planes[7], (int)This->RP_User, This->BitMap->Rows);
			This->BitMap->Planes[7] = NULL;
			} /* if */
		for(loop = 0; loop < This->BitMap->Depth; loop++)
			{
			if(This->BitMap->Planes[loop])
				{
				FreeRaster(This->BitMap->Planes[loop], (int)This->RP_User, This->BitMap->Rows);
				} /* if */
			} /* for */
		FreeMem(This->BitMap, sizeof(struct BitMap));
		} /* if */
	FreeMem(This, sizeof(struct RastPort));
	} /* if */

} /* ScratchRast_Del() */
Example #2
0
void ami_mouse_pointers_free(void)
{
	int i;

	for(i=0;i<=AMI_LASTPOINTER;i++)
	{
		if(mouseptrbm[i])
		{
			FreeRaster(mouseptrbm[i]->Planes[0],32,32);
			FreeRaster(mouseptrbm[i]->Planes[1],32,32);
			FreeVec(mouseptrbm[i]);
		}
	}
}
Example #3
0
struct RastPort *ScratchRast_New(int Width, int Height, char Planes)
{
struct RastPort *This;
int loop;

/* Planes must be < 8, since we steal the topmost entry for our Mask */

if(Planes > 7)
	return(NULL); /* Zo zorry. */

Width = ROUNDUP(Width,32);

if(This=AllocMem(sizeof(struct RastPort), MEMF_CLEAR))
	{
	InitRastPort(This);
	This->RP_User=(void *)Width; /* cope with it. */
	if(This->BitMap = AllocMem(sizeof(struct BitMap), MEMF_CLEAR))
		{
		InitBitMap(This->BitMap, Planes, Width, Height);
		for(loop = 0; loop < Planes; loop++)
			{
			if(!(This->BitMap->Planes[loop] = AllocRaster(Width, Height)))
				{
				break;
				} /* if */
			} /* for */
		if(loop == Planes)
			{
			This->BitMap->Planes[7] = AllocRaster(Width, Height);
			} /* if */
		if(loop != Planes) /* aborted early */
			{
			for(loop = 0; loop < Planes; loop++)
				{
				if(This->BitMap->Planes[loop])
					{
					FreeRaster(This->BitMap->Planes[loop], Width, Height);
					This->BitMap->Planes[loop] = NULL;
					} /* if */
				} /* for */
			} /* if */
		else /* Success! Rice */
			{
			return(This);
			} /* else */
		FreeMem(This->BitMap, sizeof(struct BitMap));
		} /* if */
	FreeMem(This, sizeof(struct RastPort));
	} /* if */

return(NULL);
} /* ScratchRast_New() */
Example #4
0
/* Resamples N input maps into 1 output map.
 * For every pixel in the output map all input maps are scanned.
 * The output value of the pixel is determined according to the
 * cells of the input maps at the pixel location. With an optional
 * percentage a minimum coverage area for a non MV can be given.
 * Returns 0 if no error occurs, 1 otherwise.
 */ 
int SampleCont(
	MAP *out,		/* write-only output map */
 	MAP **in,		/* read-only list input maps */
 	double percentage,	/* min. percentage for non-MV */
 	size_t nrMaps,		/* number of input maps */
 	size_t nrRows,		/* number of rows */
 	size_t nrCols,		/* number of columns */
 	BOOL aligned,		/* maps are aligned */
 	REAL8 angle)		/* angle of output map */
 {		
	double r, c;
	size_t nrCoverCells = (size_t)ceil((percentage / 100) * rasterSize
					* rasterSize);
	InitCache(out, in, nrMaps);
	for(r = 0; r < nrRows; r++) 	
	{

		if(nrMaps > 1 && percentage > 0)
	 		raster = NewRaster(nrCoverCells, rasterSize);

	 	/* Print progress information if wanted */
	 	AppRowProgress((int) r);

	 	for(c = 0; c < nrCols; c++) 	
	 	{   /* For every output cell */
		    if(CalcPixel(out, in, nrCoverCells, nrMaps, r, c, aligned, angle)) 
			return 1;	/* allocation failed */
	 	}
	}

	AppEndRowProgress();
	if(nrMaps > 1 && percentage > 0)
		FreeRaster(raster);
	FreeCache(nrMaps);
	return 0;			/* successfully terminated */
 }
main(int argc, char *argv[])
{
    unsigned char str[256];
    int i;
    int j;
    struct RastPort rp;
    unsigned char *pp;
    struct BitMap bm = {
	256, 	/* bytes per row */
	8,	/* rows */
	0,	/* flags */
	1,	/* depth */
	0,	/* pad */
	0 	/* planes */
	};
    struct TextAttr ta;
    struct TextFont *tf;
    struct FontRequester *fr;
    struct TagItem frtags[] = {
	ASL_Hail, (ULONG)"NetBSD font choices",
	ASL_Width, 640,
	ASL_Height, 400,
	ASL_LeftEdge, 10,
	ASL_TopEdge, 10,
	ASL_OKText, (ULONG)"Dump",
	ASL_CancelText, (ULONG)"Cancel",
	ASL_FontName, (ULONG)"topaz.font",
	ASL_FontHeight, 8L,
	ASL_FontStyles, FS_NORMAL,
	ASL_FuncFlags, FONF_STYLES | FONF_FIXEDWIDTH,
	TAG_DONE
	    };

    /* Let the user pick a font to dump */
    if (fr = (struct FontRequester *)
	AllocAslRequest(ASL_FontRequest, frtags)) {
	if (!AslRequest(fr, NULL)) {
	    FreeAslRequest(fr);
	    fprintf(stderr, "User requested exit\n");
	    exit (0);
	}
	ta.ta_Name = (STRPTR)malloc(strlen(fr->fo_Attr.ta_Name));
	strcpy(ta.ta_Name, fr->fo_Attr.ta_Name);
	ta.ta_YSize = fr->fo_Attr.ta_YSize;
	ta.ta_Style = fr->fo_Attr.ta_Style;
	ta.ta_Flags = fr->fo_Attr.ta_Flags;
	FreeAslRequest(fr);
    } else {
	fprintf(stderr, "Can't allocate Font Requestor\n");
	exit (1);
    }

    /* Open the selected font */
    tf = (struct TextFont *)OpenDiskFont (&ta);
    if (! tf) {
	fprintf (stderr, "Can't open font: %s\n", ta.ta_Name);
	exit (1);
    }
#ifdef DEBUG
    fprintf(stderr, "Information on selected font:\n");
    fprintf(stderr, "Name=%s\n", ta.ta_Name);
    fprintf(stderr, "Height=%d tf_Style=%x tf_Flags=%x Width=%d Baseline=%d\n",
	    tf->tf_YSize, tf->tf_Style, tf->tf_Flags, tf->tf_XSize, tf->tf_Baseline);
#endif

    /* Check for NetBSD restrictions */
    if (tf->tf_Flags & FPF_PROPORTIONAL) {
	fprintf(stderr, "NetBSD does not support proportional fonts\n");
	exit (1);
    }
    if (tf->tf_XSize > NetBSDwidth) {
	fprintf(stderr, "NetBSD does not support fonts wider than %d pixels\n", NetBSDwidth);
	exit (1);
    }

    /* Allocate area to render font in */
    InitBitMap(&bm, 1, 256 * NetBSDwidth, tf->tf_YSize);
    InitRastPort (&rp);
    rp.BitMap = &bm;
    bm.Planes[0] = pp = AllocRaster (256 * NetBSDwidth, tf->tf_YSize);
    if (!pp) {
	fprintf (stderr, "Can't allocate raster!\n");
	exit (1);
    }

    /* Initialize string to be rendered */
    for (i = 32; i < 256; i++) {
	str[i - 32] = i;
    }

    /* Render string with selected font */
    SetFont (&rp, tf);
    SetSoftStyle(&rp, ta.ta_Style ^ tf->tf_Style,
		 FSF_BOLD | FSF_UNDERLINED | FSF_ITALIC);
    Move (&rp, 0, tf->tf_Baseline);
    ClearEOL(&rp);
    if (tf->tf_XSize != NetBSDwidth) {
	/* right-justify char in cell */
	Move (&rp, NetBSDwidth - tf->tf_XSize, tf->tf_Baseline);
	/* Narrow font, put each character in space of normal font */
	for (i = 0; i < (256 - 32); i++) {
	    Text (&rp, &str[i], 1);
	    Move (&rp, rp.cp_x + (NetBSDwidth - tf->tf_XSize), rp.cp_y);
	}
    } else {
	Text (&rp, str, 256 - 32);
    }

    /* Dump them.. */
    printf ("/* Generated automatically by fontdumper.c. *DONT* distribute\n");
    printf ("   this file, it may contain information Copyright by Commodore!\n");
    printf ("\n");
    printf ("   Font: %s/%d\n", ta.ta_Name, tf->tf_YSize);
    printf (" */\n\n");

    printf ("unsigned char kernel_font_width  = %d;\n", tf->tf_XSize);
    printf ("unsigned char kernel_font_height = %d;\n", tf->tf_YSize);
    printf ("unsigned char kernel_font_baseline = %d;\n", tf->tf_Baseline);
    printf ("short         kernel_font_boldsmear = %d;\n", tf->tf_BoldSmear);
    printf ("unsigned char kernel_font_lo = 32;\n");
    printf ("unsigned char kernel_font_hi = 255;\n\n");

    printf ("unsigned char kernel_cursor[] = {\n");
    for (j = 0; j < (tf->tf_YSize -1); j++) {
	printf ("0xff, ");
    }
    printf ("0xff };\n\n");

    printf ("unsigned char kernel_font[] = {\n");
    for (i = 0; i < 256 - 32; i++) {
	printf ("/* %c */", i + 32);
	for (j = 0; j < tf->tf_YSize; j++) {
	    printf (" 0x%02x,", pp[i+j*256]);
	    }
	printf ("\n");
    }
    printf ("};\n");

    CloseFont (tf);
    FreeRaster (pp, 256 * NetBSDwidth, tf->tf_YSize);
    return (0);
}
Example #6
0
main()
{
  unsigned char str[256], *pp;
  int i;
  struct TextAttr ta = { "topaz.font", 8, FS_NORMAL, FPF_ROMFONT };
  struct RastPort rp;
  struct BitMap bm = { 256, 	/* bytes per row */
		         8,	/* rows */
			 0,	/* flags */
			 1,	/* depth */
			 0,	/* pad */
			 0 };	/* planes */
  struct TextFont *tf;

  InitRastPort (& rp);
  rp.BitMap = &bm;
  bm.Planes[0] = pp = AllocRaster (256 * 8, 8);

  if (!pp)
    {
      fprintf (stderr, "Can't allocate raster!\n");
      exit (1);
    }
  bzero (pp, 256 * 8);
  
  tf = OpenFont (& ta);
  if (! tf)
    {
      fprintf (stderr, "can't open topaz font.\n");
      exit (1);
    }

  SetFont (&rp, tf);

  /* initialize string to be printed */
  for (i = 32; i < 256; i++) str[i - 32] = i;

  Move (&rp, 0, 6);
  
  Text (&rp, str, 256 - 32);
  {
    int bin = open ("bitmap", 1);
    if (bin >= 0)
      {
        write (bin, pp, 256*8);
        close (bin);
      }
  }
  
  /* dump them.. */
  printf ("/* generated automatically by dumpfont.c. *DONT* distribute\n");
  printf ("   this file, it contains information Copyright by Commodore!\n");
  printf ("\n");
  printf ("   This is the (new) topaz80 system font: */\n\n");
  
  printf ("unsigned char kernel_font_width  = 8;\n");
  printf ("unsigned char kernel_font_height = 8;\n");
  printf ("unsigned char kernel_font_lo = 32;\n");
  printf ("unsigned char kernel_font_hi = 255;\n\n");
  
  printf ("unsigned char kernel_cursor[] = {\n");
  printf ("  0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff };\n\n");
  printf ("unsigned char kernel_font[] = {\n");
  
  for (i = 0; i < 256 - 32; i++)
    {
      printf ("/* %c */ ", i + 32);
      printf ("0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x, 0x%02x,\n",
      	      pp[i+0*256], pp[i+1*256], pp[i+2*256], pp[i+3*256],
      	      pp[i+4*256], pp[i+5*256], pp[i+6*256], pp[i+7*256]);
    }
  printf ("};\n");
  
  CloseFont (tf);
  FreeRaster (pp, 256 * 8, 8);
}