Example #1
0
void clear_virtscreen(struct virtscreen *cur, int mode)
{
  switch (mode)
  {
    case 0: clear_region(cur,cur->ypos,cur->xpos,
			 cur->rows-1,cur->columns-1,cur->attrib);
            break;
    case 1: clear_region(cur,0,0,cur->ypos,cur->xpos,cur->attrib);
            break;
    default: clear_region(cur,0,0,cur->rows-1,cur->columns-1,cur->attrib);
             cur->xpos = cur->ypos = 0;
             break;
  }
}
Example #2
0
void SLsmg_erase_eos (void)
{
   if (Smg_Inited == 0) return;

   SLsmg_erase_eol ();
   clear_region (This_Row + 1, (int)Screen_Rows, 0x20);
}
Example #3
0
File: ugrid.c Project: SLieng/nvm
void ugrid_scroll(UGrid *grid, int count, int *clear_top, int *clear_bot)
{
  // Compute start/stop/step for the loop below
  int start, stop, step;
  if (count > 0) {
    start = grid->top;
    stop = grid->bot - count + 1;
    step = 1;
  } else {
    start = grid->bot;
    stop = grid->top - count - 1;
    step = -1;
  }

  int i;

  // Copy cell data
  for (i = start; i != stop; i += step) {
    UCell *target_row = grid->cells[i] + grid->left;
    UCell *source_row = grid->cells[i + count] + grid->left;
    memcpy(target_row, source_row,
        sizeof(UCell) * (size_t)(grid->right - grid->left + 1));
  }

  // clear cells in the emptied region,
  if (count > 0) {
    *clear_top = stop;
    *clear_bot = stop + count - 1;
  } else {
    *clear_bot = stop;
    *clear_top = stop + count + 1;
  }
  clear_region(grid, *clear_top, *clear_bot, grid->left, grid->right);
}
Example #4
0
/*
	Taking in a Map, renders a line on the game board.
	Last two parameters act as bit flags for the rendering:
	bDrawFlag	| bAND	| Result
	0			  1		  - Clear the whole line
	0			  0		  - Clear active bits
	1			  1		  - Draw active and clear inactive
	1			  0		  - Draw only active
*/
void render_Line( UINT16* fbBase16, 
					 UINT16 iMap, 
					 int iYPxlPos,
					 UINT8 bDrawFlag,
					 bool bAND )
				  
{
	UINT16 i, iXPxlPos = (BOARD_DRAW_END_X - MINO_SIZE);
	UINT16 iYPxlEndPos;
	UINT8 bActiveBit;
	
	if( iYPxlPos >= 0 && iYPxlPos < SCREEN_HEIGHT )
	{
		iYPxlEndPos = iYPxlPos + MINO_SIZE;
		for( i = 0; i < BOARD_WIDTH; i++ )
		{		
			bActiveBit = (iMap & (TETRI_MAP_BASE - 1));
			
			if( bDrawFlag && bActiveBit ) 
				draw_bitmap_16( fbBase16,
								iXPxlPos,
								iYPxlPos,
								iMinoBitmap,
								BMP_HEIGHT );
			else if( bAND || bActiveBit)
				clear_region( fbBase16,
							  iXPxlPos,
							  iXPxlPos + MINO_SIZE,
							  iYPxlPos,
							  iYPxlEndPos );
			iMap >>= 1;
			iXPxlPos -= MINO_SIZE;
		}	
	}
Example #5
0
void clear_to_eol(struct virtscreen *cur, int mode)
{
  switch(mode)
    {
      case 0: 
          clear_region(cur,cur->ypos,cur->xpos,cur->ypos,
                       cur->columns-1,cur->attrib);
          break;
      case 1:
	  clear_region(cur,cur->ypos,0,cur->ypos,cur->xpos,
                       cur->attrib);
          break;
      default:
          clear_region(cur,cur->ypos,0,cur->ypos,cur->columns-1,
                       cur->attrib);
	}
}
/**
 * gimp_projection_initialize:
 * @proj: A #GimpProjection.
 * @x:
 * @y:
 * @w:
 * @h:
 *
 * This function determines whether a visible layer with combine mode
 * Normal provides complete coverage over the specified area.  If not,
 * the projection is initialized to transparent black.
 */
static void
gimp_projection_initialize (GimpProjection *proj,
                            gint            x,
                            gint            y,
                            gint            w,
                            gint            h)
{
    GList    *list;
    gint      proj_off_x;
    gint      proj_off_y;
    gboolean  coverage = FALSE;

    gimp_projectable_get_offset (proj->projectable, &proj_off_x, &proj_off_y);

    for (list = gimp_projectable_get_layers (proj->projectable);
            list;
            list = g_list_next (list))
    {
        GimpLayer    *layer    = list->data;
        GimpDrawable *drawable = GIMP_DRAWABLE (layer);
        GimpItem     *item     = GIMP_ITEM (layer);
        gint          off_x, off_y;

        gimp_item_get_offset (item, &off_x, &off_y);

        /*  subtract the projectable's offsets because the list of
         *  update areas is in tile-pyramid coordinates, but our
         *  external API is always in terms of image coordinates.
         */
        off_x -= proj_off_x;
        off_y -= proj_off_y;

        if (gimp_item_get_visible (item)                          &&
                ! gimp_drawable_has_alpha (drawable)                  &&
                ! gimp_layer_get_mask (layer)                         &&
                gimp_layer_get_mode (layer) == GIMP_NORMAL_MODE       &&
                gimp_layer_get_opacity (layer) == GIMP_OPACITY_OPAQUE &&
                off_x <= x                                            &&
                off_y <= y                                            &&
                (off_x + gimp_item_get_width  (item)) >= (x + w)      &&
                (off_y + gimp_item_get_height (item)) >= (y + h))
        {
            coverage = TRUE;
            break;
        }
    }

    if (! coverage)
    {
        PixelRegion region;

        pixel_region_init (&region,
                           gimp_pickable_get_tiles (GIMP_PICKABLE (proj)),
                           x, y, w, h, TRUE);
        clear_region (&region);
    }
}
Example #7
0
void SLsmg_cls (void)
{
   int tac;
   if (Smg_Inited == 0) return;

   tac = This_Alt_Char; This_Alt_Char = 0;
   SLsmg_set_color (0);
   clear_region (0, (int)Screen_Rows, 0x20);
   This_Alt_Char = tac;
   SLsmg_set_color (0);
   Cls_Flag = 1;
}
Example #8
0
/*
	Draws the FPS in the top left corner of the screen
	or clears it based on the FPS render flags.
*/
void render_FPS( UINT8* fbBase8, int iValue )
{
	if( sMainState[ iCurrState ].bRenderFPS )
	{
		render_Value( fbBase8, iValue, 0, 0 );
		sMainState[ iCurrState ].bRenderFPS = false;
	}
	else if( sMainState[ iCurrState ].bClearFPS )
	{
		clear_region( (UINT16*)fbBase8, 0, TEXT_WIDTH << 1, 0, TEXT_HEIGHT );
		sMainState[ iCurrState ].bClearFPS = false;
	}
}
Example #9
0
void clear_whole_screen(void) {
    struct rccoord start = { 0, 0 };
    DWORD dwConSize;
    CONSOLE_SCREEN_BUFFER_INFO record;

    // get buffer size
    GetConsoleScreenBufferInfo(STDCONSOLE, &record);
    dwConSize = record.dwSize.X * record.dwSize.Y;

    clear_region(start, dwConSize);

    // home cursor
    SetConsoleCursorPosition(STDCONSOLE, rccoord_to_COORD(start));
    return;
}
Example #10
0
int init_virtscreen(struct virtscreen *cur, int rows, int columns)
{

  cur->num_bytes = ((sizeof(unsigned short) * rows * columns));

  if (!(cur->data=malloc(cur->num_bytes)))
    return (-1);

  cur->data_off_scr = cur->data;

  cur->bottom_scroll = cur->rows = rows;
  cur->columns = columns;
  cur->cur_ansi_number = cur->top_scroll = 0;
  cur->ansi_elements = cur->ansi_reading_number = 0;
  cur->next_char_send = std_interpret_char;
  cur->old_attrib = cur->attrib = 0x07;
  cur->next_char_send = std_interpret_char;
  clear_region(cur,0,0,rows-1,columns-1,cur->attrib);
  cur->old_xpos = cur->old_ypos = 0;

  return (0);
}
Example #11
0
DiplomacyRegion::~DiplomacyRegion() {
    clear_region();
}
Example #12
0
static GimpLayer *
gimp_image_merge_layers (GimpImage     *image,
                         GSList        *merge_list,
                         GimpContext   *context,
                         GimpMergeType  merge_type,
                         const gchar   *undo_desc)
{
  GList           *list;
  GSList          *reverse_list = NULL;
  PixelRegion      src1PR, src2PR, maskPR;
  PixelRegion     *mask;
  GimpLayer       *merge_layer;
  GimpLayer       *layer;
  GimpLayer       *bottom_layer;
  GimpImageType    type;
  gint             count;
  gint             x1, y1, x2, y2;
  gint             x3, y3, x4, y4;
  CombinationMode  operation;
  gint             position;
  gboolean         active[MAX_CHANNELS] = { TRUE, TRUE, TRUE, TRUE };
  gint             off_x, off_y;
  gchar           *name;

  g_return_val_if_fail (GIMP_IS_IMAGE (image), NULL);
  g_return_val_if_fail (GIMP_IS_CONTEXT (context), NULL);

  layer        = NULL;
  type         = GIMP_RGBA_IMAGE;
  x1 = y1      = 0;
  x2 = y2      = 0;
  bottom_layer = NULL;

  /*  Get the layer extents  */
  count = 0;
  while (merge_list)
    {
      layer = merge_list->data;

      gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);

      switch (merge_type)
        {
        case GIMP_EXPAND_AS_NECESSARY:
        case GIMP_CLIP_TO_IMAGE:
          if (! count)
            {
              x1 = off_x;
              y1 = off_y;
              x2 = off_x + gimp_item_width  (GIMP_ITEM (layer));
              y2 = off_y + gimp_item_height (GIMP_ITEM (layer));
            }
          else
            {
              if (off_x < x1)
                x1 = off_x;
              if (off_y < y1)
                y1 = off_y;
              if ((off_x + gimp_item_width (GIMP_ITEM (layer))) > x2)
                x2 = (off_x + gimp_item_width (GIMP_ITEM (layer)));
              if ((off_y + gimp_item_height (GIMP_ITEM (layer))) > y2)
                y2 = (off_y + gimp_item_height (GIMP_ITEM (layer)));
            }

          if (merge_type == GIMP_CLIP_TO_IMAGE)
            {
              x1 = CLAMP (x1, 0, gimp_image_get_width  (image));
              y1 = CLAMP (y1, 0, gimp_image_get_height (image));
              x2 = CLAMP (x2, 0, gimp_image_get_width  (image));
              y2 = CLAMP (y2, 0, gimp_image_get_height (image));
            }
          break;

        case GIMP_CLIP_TO_BOTTOM_LAYER:
          if (merge_list->next == NULL)
            {
              x1 = off_x;
              y1 = off_y;
              x2 = off_x + gimp_item_width (GIMP_ITEM (layer));
              y2 = off_y + gimp_item_height (GIMP_ITEM (layer));
            }
          break;

        case GIMP_FLATTEN_IMAGE:
          if (merge_list->next == NULL)
            {
              x1 = 0;
              y1 = 0;
              x2 = gimp_image_get_width  (image);
              y2 = gimp_image_get_height (image);
            }
          break;
        }

      count ++;
      reverse_list = g_slist_prepend (reverse_list, layer);
      merge_list = g_slist_next (merge_list);
    }

  if ((x2 - x1) == 0 || (y2 - y1) == 0)
    return NULL;

  /*  Start a merge undo group. */

  gimp_image_undo_group_start (image, GIMP_UNDO_GROUP_IMAGE_LAYERS_MERGE,
                               undo_desc);

  name = g_strdup (gimp_object_get_name (GIMP_OBJECT (layer)));

  if (merge_type == GIMP_FLATTEN_IMAGE ||
      gimp_drawable_type (GIMP_DRAWABLE (layer)) == GIMP_INDEXED_IMAGE)
    {
      guchar bg[4] = { 0, 0, 0, 0 };

      type = GIMP_IMAGE_TYPE_FROM_BASE_TYPE (gimp_image_base_type (image));

      merge_layer = gimp_layer_new (image, (x2 - x1), (y2 - y1),
                                    type,
                                    gimp_object_get_name (GIMP_OBJECT (layer)),
                                    GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);
      if (! merge_layer)
        {
          g_warning ("%s: could not allocate merge layer.", G_STRFUNC);
          return NULL;
        }

      GIMP_ITEM (merge_layer)->offset_x = x1;
      GIMP_ITEM (merge_layer)->offset_y = y1;

      /*  get the background for compositing  */
      gimp_image_get_background (image, context,
                                 gimp_drawable_type (GIMP_DRAWABLE (merge_layer)),
                                 bg);

      /*  init the pixel region  */
      pixel_region_init (&src1PR,
                         gimp_drawable_get_tiles (GIMP_DRAWABLE (merge_layer)),
                         0, 0, (x2 - x1), (y2 - y1),
                         TRUE);

      /*  set the region to the background color  */
      color_region (&src1PR, bg);

      position = 0;
    }
  else
    {
      /*  The final merged layer inherits the name of the bottom most layer
       *  and the resulting layer has an alpha channel whether or not the
       *  original did. Opacity is set to 100% and the MODE is set to normal.
       */

      merge_layer =
        gimp_layer_new (image, (x2 - x1), (y2 - y1),
                        gimp_drawable_type_with_alpha (GIMP_DRAWABLE (layer)),
                        "merged layer",
                        GIMP_OPACITY_OPAQUE, GIMP_NORMAL_MODE);

      if (!merge_layer)
        {
          g_warning ("%s: could not allocate merge layer", G_STRFUNC);
          return NULL;
        }

      GIMP_ITEM (merge_layer)->offset_x = x1;
      GIMP_ITEM (merge_layer)->offset_y = y1;

      /*  clear the layer  */
      pixel_region_init (&src1PR,
                         gimp_drawable_get_tiles (GIMP_DRAWABLE (merge_layer)),
                         0, 0,
                         (x2 - x1), (y2 - y1),
                         TRUE);
      clear_region (&src1PR);

      /*  Find the index in the layer list of the bottom layer--we need this
       *  in order to add the final, merged layer to the layer list correctly
       */
      layer = reverse_list->data;
      position =
        gimp_container_num_children (image->layers) -
        gimp_container_get_child_index (image->layers, GIMP_OBJECT (layer));
    }

  bottom_layer = layer;

  /* Copy the tattoo and parasites of the bottom layer to the new layer */
  gimp_item_set_tattoo (GIMP_ITEM (merge_layer),
                        gimp_item_get_tattoo (GIMP_ITEM (bottom_layer)));

  g_object_unref (GIMP_ITEM (merge_layer)->parasites);
  GIMP_ITEM (merge_layer)->parasites =
    gimp_parasite_list_copy (GIMP_ITEM (bottom_layer)->parasites);

  while (reverse_list)
    {
      GimpLayerModeEffects  mode;

      layer = reverse_list->data;

      /*  determine what sort of operation is being attempted and
       *  if it's actually legal...
       */
      operation = gimp_image_merge_layers_get_operation (merge_layer, layer);

      if (operation == -1)
        {
          gimp_layer_add_alpha (layer);

          /*  try again ...  */
          operation = gimp_image_merge_layers_get_operation (merge_layer,
                                                             layer);
        }

      if (operation == -1)
        {
          g_warning ("%s: attempting to merge incompatible layers.", G_STRFUNC);
          return NULL;
        }

      gimp_item_offsets (GIMP_ITEM (layer), &off_x, &off_y);

      x3 = CLAMP (off_x, x1, x2);
      y3 = CLAMP (off_y, y1, y2);
      x4 = CLAMP (off_x + gimp_item_width  (GIMP_ITEM (layer)), x1, x2);
      y4 = CLAMP (off_y + gimp_item_height (GIMP_ITEM (layer)), y1, y2);

      /* configure the pixel regions  */
      pixel_region_init (&src1PR,
                         gimp_drawable_get_tiles (GIMP_DRAWABLE (merge_layer)),
                         (x3 - x1), (y3 - y1), (x4 - x3), (y4 - y3),
                         TRUE);
      pixel_region_init (&src2PR,
                         gimp_drawable_get_tiles (GIMP_DRAWABLE (layer)),
                         (x3 - off_x), (y3 - off_y),
                         (x4 - x3), (y4 - y3),
                         FALSE);

      if (gimp_layer_get_mask (layer) &&
          gimp_layer_mask_get_apply (layer->mask))
        {
          TileManager *tiles;

          tiles = gimp_drawable_get_tiles (GIMP_DRAWABLE (layer->mask));

          pixel_region_init (&maskPR, tiles,
                             (x3 - off_x), (y3 - off_y), (x4 - x3), (y4 - y3),
                             FALSE);
          mask = &maskPR;
        }
      else
        {
          mask = NULL;
        }

      /* DISSOLVE_MODE is special since it is the only mode that does not
       *  work on the projection with the lower layer, but only locally on
       *  the layers alpha channel.
       */
      mode = gimp_layer_get_mode (layer);
      if (layer == bottom_layer && mode != GIMP_DISSOLVE_MODE)
        mode = GIMP_NORMAL_MODE;

      combine_regions (&src1PR, &src2PR, &src1PR, mask, NULL,
                       gimp_layer_get_opacity (layer) * 255.999,
                       mode,
                       active,
                       operation);

      gimp_image_remove_layer (image, layer);

      reverse_list = g_slist_next (reverse_list);
    }

  g_slist_free (reverse_list);

  /*  if the type is flatten, remove all the remaining layers  */
  if (merge_type == GIMP_FLATTEN_IMAGE)
    {
      list = GIMP_LIST (image->layers)->list;
      while (list)
        {
          layer = list->data;

          list = g_list_next (list);
          gimp_image_remove_layer (image, layer);
        }

      gimp_image_add_layer (image, merge_layer, position);
    }
  else
    {
      /*  Add the layer to the image  */
      gimp_image_add_layer (image, merge_layer,
         gimp_container_num_children (image->layers) - position + 1);
    }

  /* set the name after the original layers have been removed so we
   * don't end up with #2 appended to the name
   */
  gimp_object_take_name (GIMP_OBJECT (merge_layer), name);

  gimp_item_set_visible (GIMP_ITEM (merge_layer), TRUE, TRUE);

  /*  End the merge undo group  */
  gimp_image_undo_group_end (image);

  gimp_drawable_update (GIMP_DRAWABLE (merge_layer),
                        0, 0,
                        gimp_item_width  (GIMP_ITEM (merge_layer)),
                        gimp_item_height (GIMP_ITEM (merge_layer)));

  return merge_layer;
}
Example #13
0
File: ugrid.c Project: ZyX-I/neovim
void ugrid_clear(UGrid *grid)
{
  clear_region(grid, 0, grid->height-1, 0, grid->width-1,
               HLATTRS_INIT);
}
Example #14
0
File: ugrid.c Project: ZyX-I/neovim
void ugrid_clear_chunk(UGrid *grid, int row, int col, int endcol, HlAttrs attrs)
{
  clear_region(grid, row, row, col, endcol-1, attrs);
}
Example #15
0
File: ugrid.c Project: SLieng/nvm
void ugrid_clear(UGrid *grid)
{
  clear_region(grid, grid->top, grid->bot, grid->left, grid->right);
}
Example #16
0
void ugrid_clear_chunk(UGrid *grid, int row, int col, int endcol, sattr_T attr)
{
  clear_region(grid, row, row, col, endcol-1, attr);
}
Example #17
0
void ugrid_clear(UGrid *grid)
{
  clear_region(grid, 0, grid->height-1, 0, grid->width-1, 0);
}
Example #18
0
DiplomacyRegion::DiplomacyRegion(char *name, DiplomacyGame *gamep) {
    clear_region();
    names.push_back(strdup(name));
    game = gamep;
}
Example #19
0
File: ugrid.c Project: SLieng/nvm
void ugrid_eol_clear(UGrid *grid)
{
  clear_region(grid, grid->row, grid->row, grid->col, grid->right);
}