Beispiel #1
0
/**
 * Plot an image at the given coordinates using tinct
 *
 * \param area              The sprite area containing the sprite
 * \param x                 Left edge of sprite
 * \param y                 Top edge of sprite
 * \param req_width         The requested width of the sprite
 * \param req_height        The requested height of the sprite
 * \param width             The actual width of the sprite
 * \param height            The actual height of the sprite
 * \param background_colour The background colour to blend to
 * \param repeatx           Repeat the image in the x direction
 * \param repeaty           Repeat the image in the y direction
 * \param alpha             Use the alpha channel
 * \param tinct_options	    The base option set to use
 * \return true on success, false otherwise
 */
bool image_redraw_tinct(osspriteop_id header, int x, int y,
		int req_width, int req_height, int width, int height,
		colour background_colour, bool repeatx, bool repeaty,
		bool alpha, unsigned int tinct_options)
{
	_kernel_oserror *error;

	/*	Set up our flagword
	*/
	tinct_options |= background_colour << tinct_BACKGROUND_SHIFT;
	if (print_active)
		tinct_options |= tinct_USE_OS_SPRITE_OP;
	if (repeatx)
		tinct_options |= tinct_FILL_HORIZONTALLY;
	if (repeaty)
		tinct_options |= tinct_FILL_VERTICALLY;

	if (alpha) {
		error = _swix(Tinct_PlotScaledAlpha, _INR(2,7),
				header, x, y - req_height,
				req_width, req_height, tinct_options);
	} else {
		error = _swix(Tinct_PlotScaled, _INR(2,7),
				header, x, y - req_height,
				req_width, req_height, tinct_options);
	}

	if (error) {
		LOG(("xtinct_plotscaled%s: 0x%x: %s", (alpha ? "alpha" : ""),
				error->errnum, error->errmess));
		return false;
	}

	return true;
}
Beispiel #2
0
void heap_release(char *base, char *block)
{
  _kernel_oserror *e;
  heapcb          *cb;
  int              errnum;
  int              change;
  unsigned int     actual_change;

  cb = getcb(base);
  if (cb == NULL)
    return; /* unknown heap */

  /* MemCheck_UnRegisterMiscBlock(block); */

  /* Release the block */
  _swi(OS_Heap, _INR(0,2), 3, base, block);

  /* Current SWI methods don't let us easily get at the returned R3, so we
   * use our own assembler veneer */
  e = xosheap_resize_r3(base, INT_MIN, &change);
  /* MemCheck_RegisterMiscBlock(e, sizeof(e->errnum)); */
  errnum = e->errnum;
  /* MemCheck_UnRegisterMiscBlock(e); */
  if (errnum != 0x187 /* Can't shrink heap any further */)
    _swi(OS_GenerateError, _IN(0), e);

  /* Shrink the dynamic area (note this needs to occur before the shrink of
   * the heap itself, since we need the actual size change) */
  _swi(OS_ChangeDynamicArea, _INR(0,1)|_OUT(1), cb->area, -change,
       &actual_change);

  /* Shrink the heap by the actual size change */
  _swi(OS_Heap, _INR(0,1)|_IN(3), 5, base, change - actual_change);
}
Beispiel #3
0
char *heap_create(const char *description, size_t size_limit)
{
  heapcb *cb;
  int     page_size;

  /* Get a new heapcb and link it into the start of the chain */
  cb = malloc(sizeof(heapcb));
  if (cb == NULL)
    return NULL; /* failed - unable to allocate space for control block */

  cb->next = first_cb;
  first_cb = cb;

  /* Create a dynamic area at least one page in size and set it up as a heap
   */
  _swi(OS_ReadMemMapInfo, _OUT(0), &page_size);

  if (EC(_swix(OS_DynamicArea, _INR(0,8)|_OUT(1)|_OUT(3), 0, -1, page_size,
               -1, 0x80, size_limit, NULL, -1, description, &cb->area,
               &cb->base)))
  {
    free(cb);
    return NULL;
  }

  /* page_size must be enough to hold the default heap structure */

  _swi(OS_Heap, _INR(0,1)|_IN(3), 0, cb->base, page_size);

  return cb->base;
}
Beispiel #4
0
char *heap_claim(char *base, size_t required_size)
{
  _kernel_oserror *e;
  int              largest;
  unsigned int     actual_change;
  void            *block;
  heapcb          *cb;

  if (required_size == 0)
    return NULL;

  cb = getcb(base);
  if (cb == NULL)
    return NULL; /* unknown heap */

  /* Repeatedly attempt to claim a block of the required size */
  while ((e = _swix(OS_Heap, _INR(0,1)|_IN(3)|_OUT(2), 2, base,
                    required_size, &block)) != NULL)
  {
    int errnum;

    /* MemCheck_RegisterMiscBlock(e, sizeof(e->errnum)); */
    errnum = e->errnum;
    /* MemCheck_UnRegisterMiscBlock(e); */
    if (errnum != 0x184 /* Heap Full */)
    {
#ifndef NDEBUG
      EC(e);
#endif
      return NULL; /* unknown error */
    }

    /* Read largest free space */
    _swi(OS_Heap, _INR(0,1)|_OUT(2), 1, base, &largest);

    /* Increase the dynamic area by at least the difference between what we
     * want and what we have spare */
    if (EC(_swix(OS_ChangeDynamicArea, _INR(0,1)|_OUT(1), cb->area,
                 required_size - largest, &actual_change)) != NULL)
      return NULL; /* (most likely) out of memory */

    /* Resize the heap itself */
    _swi(OS_Heap, _INR(0,1)|_IN(3), 5, base, actual_change);
  }

  /* MemCheck_RegisterMiscBlock(block, required_size); */

  return block;
}
Beispiel #5
0
_kernel_oserror *SWI_OS_File_5(const char *filename, int *objtype,
			       unsigned int *loadaddr,
			       unsigned int *execaddr,
			       int *length, int *attrib)
{ /* read file info */
  int _objtype,_length,_attrib;
  unsigned int _loadaddr,_execaddr;
  _kernel_oserror *err = _swix(OS_File,_INR(0,1)|_OUT(0)|_OUTR(2,5),5,
			       filename,
			       &_objtype,&_loadaddr,&_execaddr,&_length,
			       &_attrib);
  if (err)
    return err;
  if (objtype)
    *objtype = _objtype;
  if (loadaddr)
    *loadaddr = _loadaddr;
  if (execaddr)
    *execaddr = _execaddr;
  if (length)
    *length = _length;
  if (attrib)
    *attrib = _attrib;
  return NULL;
}
Beispiel #6
0
void heap_delete(char *base)
{
  heapcb *cb;
  heapcb *thiscb;

  cb = getcb(base);
  if (cb == NULL)
    return; /* unknown heap */

  /* Delete the dynamic area */
  EC(_swix(OS_DynamicArea, _INR(0,1), 1, cb->area));

  /* remove its heapcb from the chain */
  if (cb == first_cb)
  {
    /* start of chain */
    first_cb = first_cb->next;
  }
  else
  {
    /* elsewhere in chain */
    for (thiscb = first_cb; thiscb->next != cb; thiscb = thiscb->next)
      ;
    thiscb->next = cb->next;
  }

  free(cb);
}
Beispiel #7
0
void ro_gui_options_image_redraw(wimp_draw *redraw)
{
	osbool more;
	os_error *error;
	wimp_icon_state icon_state;
	osspriteop_header *bg = NULL, *fg = NULL;
	unsigned int bg_tinct = 0, fg_tinct = 0;

	/* get the icon location */
	icon_state.w = redraw->w;
	icon_state.i = IMAGE_CURRENT_DISPLAY;
	error = xwimp_get_icon_state(&icon_state);
	if (error) {
		LOG("xwimp_get_icon_state: 0x%x: %s",
				error->errnum, error->errmess);
		ro_warn_user("MenuError", error->errmess);
		return;
	}

	/* find the sprites */
	if (example_images) {
		ro_gui_options_image_read(redraw->w, &bg_tinct, &fg_tinct);
		fg_tinct |= 0xeeeeee00;
		xosspriteop_select_sprite(osspriteop_USER_AREA,
				example_images, (osspriteop_id)"img_bg", &bg);
		xosspriteop_select_sprite(osspriteop_USER_AREA,
				example_images, (osspriteop_id)"img_fg", &fg);
	}

	/* perform the redraw */
	more = wimp_redraw_window(redraw);
	while (more) {
		int origin_x, origin_y;
		origin_x = redraw->box.x0 - redraw->xscroll +
				icon_state.icon.extent.x0 + 2;
		origin_y = redraw->box.y1 - redraw->yscroll +
				icon_state.icon.extent.y0 + 2;
		if (bg)
			_swix(Tinct_Plot, _INR(2,4) | _IN(7),
					bg, origin_x, origin_y, bg_tinct);
		if (fg)
			_swix(Tinct_PlotAlpha, _INR(2,4) | _IN(7),
					fg, origin_x, origin_y, fg_tinct);
		more = wimp_get_rectangle(redraw);
	}
}
Beispiel #8
0
_kernel_oserror *SWI_OS_ReadVarVal(const char *var, char *buf, int len,
				   int *bytesused)
{ /* reads an OS varibale */
  int _bytesused;
  _kernel_oserror *err = _swix(OS_ReadVarVal,_INR(0,4)|_OUT(2),var,buf,len,
			       0,0,&_bytesused);
  if (err)
    return err;
  if (bytesused)
    *bytesused = _bytesused;
  return NULL;
}
Beispiel #9
0
bool OSystem_RISCOS::openUrl(const Common::String &url) {
	int flags;
	if (_swix(URI_Dispatch, _INR(0,2)|_OUT(0), 0, url.c_str(), 0, &flags) != NULL) {
		warning("openUrl() (RISCOS) failed to open URL");
		return false;
	}
	if ((flags & 1) == 1) {
		warning("openUrl() (RISCOS) failed to open URL");
		return false;
	}
	return true;
}
Beispiel #10
0
const char *mime_fromfiletype(int filetype)
{
  static char buffer[256];

  if (EC(_swix(0x50b00 /* MimeMap_Translate */,
              _INR(0,3),
               0,
               filetype,
               2,
               buffer)) != NULL)
    return "application/octet-stream";

  return buffer;
}
Beispiel #11
0
FILE *piechart_init(char *filename) {
  FILE *pieoutf;
  int xsize, ysize, b1, b2;

  if ((pieoutf = FOPENWB(filename)) == NULL) {
    warn('F', TRUE, "Failed to open pie chart file %s for writing: "
	 "ignoring it", filename);
    return(pieoutf);
  }
  debug('F', "Opening %s as pie chart file", filename);
#ifdef RISCOS
  _swix(OS_File, _INR(0,2), 18, filename, 0xb60);  /* set PNG filetype */
#endif

  xsize = normalchart?XSIZE:SHORTXSIZE;
  ysize = normalchart?YSIZE:SHORTYSIZE;
  im = gdImageCreate(xsize, ysize);
  /* The first colour allocated in a new image is the background colour. */
  white = gdImageColorAllocate(im, 255, 255, 255);           /* white */
  black = gdImageColorAllocate(im, 0, 0, 0);                 /* black */
  grey = gdImageColorAllocate(im, 128, 128, 128);            /* grey */
  lightgrey = gdImageColorAllocate(im, 217, 217, 217);       /* light grey */
  col = 0;
  /* Wedge colours. If these change, so must images/sq*. */
  colours[col++] = gdImageColorAllocate(im, 255, 0, 0);      /* red */
  colours[col++] = gdImageColorAllocate(im, 0, 0, 255);      /* mid blue */
  colours[col++] = gdImageColorAllocate(im, 0, 128, 0);      /* green */
  colours[col++] = gdImageColorAllocate(im, 255, 128, 0);    /* orange */
  colours[col++] = gdImageColorAllocate(im, 0, 0, 128);      /* navy blue */
  colours[col++] = gdImageColorAllocate(im, 0, 255, 0);      /* pale green */
  colours[col++] = gdImageColorAllocate(im, 255, 128, 128);  /* pink */
  colours[col++] = gdImageColorAllocate(im, 0, 255, 255);    /* cyan */
  colours[col++] = gdImageColorAllocate(im, 128, 0, 128);    /* purple */
  colours[col++] = gdImageColorAllocate(im, 255, 255, 0);    /* yellow */
  col = 0;
  totangle = 0.75;  /* starting at the top */
  boxesy = BOXESTOP;
  b1 = xsize - 1 - BORDER;
  b2 = ysize - 1 - BORDER;
  /* Plot outline of pie, and border of image */
  gdImageArc(im, XCENTRE, YCENTRE, DIAMETER + 2, DIAMETER + 2, 0, 360, black);
  gdImageRectangle(im, BORDER, BORDER, b1, b2, black);
  gdImageLine(im, xsize - 1, 0, b1, BORDER, black);
  gdImageLine(im, 0, ysize - 1, BORDER, b2, black);
  gdImageFill(im, 0, 0, lightgrey);
  gdImageFill(im, xsize - 1, ysize - 1, grey);
  gdImageLine(im, 0, 0, BORDER, BORDER, black);
  gdImageLine(im, xsize - 1, ysize - 1, b1, b2, black);
  return(pieoutf);
}
Beispiel #12
0
_kernel_oserror *SWI_OS_FSControl_37(const char *pathname, char *buffer,
				     int *size)
{ /* canonicalise path */
  return _swix(OS_FSControl,_INR(0,5)|_OUT(5),37,pathname,buffer,0,0,*size,
	       size);
}
Beispiel #13
0
_kernel_oserror *SWI_OS_FSControl_27(const char *filename, int actionmask)
{ /* wipe */
  return _swix(OS_FSControl,_INR(0,1)|_IN(3),27,filename,actionmask);
}
Beispiel #14
0
_kernel_oserror *SWI_OS_GBPB_9(const char *dirname, void *buf, int *number,
			       int *offset, int size, const char *match)
{ /* read dir */
  return  _swix(OS_GBPB,_INR(0,6)|_OUTR(3,4),9,dirname,buf,
		*number,*offset,size,match,number,offset);
}
Beispiel #15
0
_kernel_oserror *SWI_OS_File_1(const char *filename, unsigned int loadaddr,
			       unsigned int execaddr, int attrib)
{ /* write file attributes */
  return _swix(OS_File,_INR(0,3)|_IN(5),1,filename,loadaddr,execaddr,attrib);
}
Beispiel #16
0
_kernel_oserror *SWI_OS_File_6(const char *filename)
{ /* delete */
  return _swix(OS_File,_INR(0,1),6,filename);
}
Beispiel #17
0
_kernel_oserror *SWI_OS_File_7(const char *filename, int loadaddr,
			       int execaddr, int size)
{ /* create an empty file */
  return _swix(OS_File,_INR(0,5),7,filename,loadaddr,execaddr,0,size);
}
Beispiel #18
0
_kernel_oserror *SWI_OS_FSControl_26(const char *source, const char *dest,
				     int actionmask)
{ /* copy */
  return _swix(OS_FSControl,_INR(0,3),26,source,dest,actionmask);
}