Example #1
0
//------------- Begin of function VgaBuf::bar_alpha --------------//
//
// Draw a bar with alpha-blendinig
//
// Syntax : bar( x1, y1, x2, y2, color )
//
// <int> x1,y1       - the top left vertex of the bar
// <int> x2,y2       - the bottom right vertex of the bar
// <int> logAlpha    - negative log alpha (right bit shift count, 0 to 5)
// <int> color index - the index of a 256 color palette
//
// logAlpha : 0=transparent ... 5=opaque colorCode
//
void VgaBuf::bar_alpha(int x1,int y1,int x2,int y2,int logAlpha, int colorCode)
{
	err_when( !buf_locked );

	if( logAlpha <= 0 )
	{
		err_when(logAlpha < 0);
		// if logAlpha == 0, no change
	}
	else if( logAlpha < 5 )
	{
		if( is_front )
			mouse.hide_area(x1,y1,x2,y2);
		IMGbarAlpha(cur_buf_ptr, cur_pitch, x1, y1, x2, y2, logAlpha, translate_color(colorCode) );
		if( is_front )
			mouse.show_area();
	}
	else	// logAlpha >= 5, equivalence to VgaBuf::bar
	{
		if( is_front )
			mouse.hide_area(x1,y1,x2,y2);
		IMGbar(cur_buf_ptr, cur_pitch, x1, y1, x2, y2, translate_color(colorCode) );
		if( is_front )
			mouse.show_area();
	}
}
Example #2
0
void
console_set_color(int32 foreground, int32 background)
{
	char buff[] = "\033b \033c ";
	buff[2] += (char)translate_color(foreground);
	buff[5] += (char)translate_color(background);
	sInput.WriteAt(NULL, 0LL, buff, 6);
}
Example #3
0
void
console_set_color(int32 foreground, int32 background)
{
	// Note: Toggling the cursor doesn't seem to help. We still get cursor
	// artifacts.
	of_interpret("toggle-cursor"
		" to foreground-color"
		" to background-color"
		" toggle-cursor",
		2, 0, translate_color(foreground), translate_color(background));
}
Example #4
0
BOOL Vga::init()
{
   //--------- Initialize DirectDraw object --------//

   if( !init_dd() )
      return FALSE;

   if( !set_mode(VGA_WIDTH, VGA_HEIGHT) )
      return FALSE;

   File palFile;
   palFile.file_open(DIR_RES"pal_std.res");

   BYTE palBuf[0x100][3];
   palFile.file_seek(8);     				// bypass the header info
   palFile.file_read(palBuf, sizeof(palBuf));
   palFile.file_close();

   // ------- palette description -------------//

   PalDesc palBufDesc( palBuf, 3, 0x100, 8 );

   //-------- create color remap table ---------//

   vga_color_table->generate_table_fast( MAX_BRIGHTNESS_ADJUST_DEGREE, palBufDesc, ColorTable::bright_func );
   default_remap_table = (short *) malloc(0x100 * 2);
   memcpy( default_remap_table, vga_color_table->get_table(0), 0x100 * 2 );

   default_blend_table = 0;
   transparent_code_w = translate_color(TRANSPARENT_CODE);
   return TRUE;
}
Example #5
0
//--------- Start of function Vga::load_pal ----------//
//
// Load the palette from a file and set it to the front buf.
//
BOOL Vga::load_pal(char* fileName) {
    char palBuf[256][3];
    File palFile;

    palFile.file_open(fileName);
    palFile.file_seek(8);                           // bypass the header info
    palFile.file_read(palBuf, 256*3);
    palFile.file_close();

    //--- Create a Direct Draw Palette and associate it with the front buffer ---//

    if( dd_pal == NULL ) {
	for(int i=0; i<256; i++) {
	    pal_entry_buf[i].peRed   = palBuf[i][0];
	    pal_entry_buf[i].peGreen = palBuf[i][1];
	    pal_entry_buf[i].peBlue  = palBuf[i][2];
	}

	HRESULT rc = dd_obj->CreatePalette( DDPCAPS_8BIT, pal_entry_buf, &dd_pal, NULL );

	if( rc != DD_OK )
	    return FALSE;
    }

    init_color_table();
    init_gray_remap_table();

    // set global variable
    transparent_code_w = translate_color(TRANSPARENT_CODE);

    return TRUE;
}
Example #6
0
//---------- Begin of function VgaBuf::line -------------//
//
// Draw a line
//
// <int> x1,y1,x2,y2 = the coordination of the line
// <int> lineColor   = color of the line
//
void VgaBuf::line(int x1,int y1,int x2,int y2,int lineColor)
{
	if( is_front )
		mouse.hide_area( x1,y1,x2,y2 );  // if the mouse cursor is in that area, hide it

	IMGline(cur_buf_ptr, cur_pitch, buf_width(), buf_height(), x1, y1, x2, y2, translate_color(lineColor));

	if( is_front )
		mouse.show_area();
}
Example #7
0
//------------- Begin of function VgaBuf::bar --------------//
//
// Draw a bar without bliting
//
// Syntax : bar( x1, y1, x2, y2, color )
//
// <int> x1,y1       - the top left vertex of the bar
// <int> x2,y2       - the bottom right vertex of the bar
// <int> color index - the index of a 256 color palette
//
void VgaBuf::bar(int x1,int y1,int x2,int y2,int colorCode)
{
	err_when( !buf_locked );

	if( is_front )
		mouse.hide_area(x1,y1,x2,y2);

	IMGbar(cur_buf_ptr, cur_pitch, x1, y1, x2, y2, translate_color(colorCode) );

	if( is_front )
		mouse.show_area();
}
Example #8
0
//---------- Begin of function VgaBuf::line -------------//
//
// Draw a line
//
// <int> x1,y1,x2,y2 = the coordination of the line
// <int> lineColor   = color of the line
//
void VgaBuf::line(int x1,int y1,int x2,int y2,int lineColor)
{
  int	dx = x2 - x1;
  int	dy = y2 - y1;
  short *bufPtr = buf_ptr(x1,y1);
  short color = translate_color(lineColor);
  int	d;
  int	inc_x = dx > 0 ? 1 : -1;
  int	inc_y = dy > 0 ? 1 : -1;
  int	lPitch = dy > 0 ? cur_pitch : -cur_pitch;
  if( dy == 0)
  {
    if( x1 <= x2)
    {
      // from left to right
      for(short x = x1; x <= x2; ++x, ++bufPtr)
        *bufPtr = color;
    }
    else
    {
      // from right to left
      for( short x = x1; x >= x2; --x, --bufPtr)
        *bufPtr = color;
    }
    return;
  }

  if( dx == 0)
  {
    if( y1 <= y2)
    {
      // from top to bottom
      for(short y = y1; y <= y2; ++y, bufPtr += lPitch)
        *bufPtr = color;
    }
    else
    {
      // from bottom to top
      for( short y = y1; y >= y2; --y, bufPtr -= lPitch)
        *bufPtr = color;
    }
    return;
  }

  if( abs(dy) <= abs(dx) )
  {
    // draw gentle line
    // use x as independent variable
    dx = abs(dx);
    dy = abs(dy);

    d = 2 * dy - dx;	
    int x = x1-inc_x;
    do
    {
      x += inc_x;
      *bufPtr = translate_color(lineColor);
      bufPtr += inc_x;
      if( d >= 0)
      {
        // y increase by 1
        bufPtr += lPitch;
        d += 2 * (dy - dx);
      }
      else
      {
        // y remain unchange;
        d += 2 * dy;
      }
    } while ( x != x2);
  }
  else
  {
    // draw steep line
    // use y as independent variable
    dx = abs(dx);
    dy = abs(dy);

    d = 2 * dx - dy;
    int y = y1 - inc_y;
    do
    {
      y += inc_y;
      *bufPtr = translate_color(lineColor);
      bufPtr += lPitch;
      if( d >= 0)
      {
        // x increase by 1
        bufPtr += inc_x;
        d += 2 * (dx - dy);
      }
      else
      {
        // x remain unchange;
        d += 2 * dx;
      }
    } while ( y != y2);
  }
}
Example #9
0
glm::vec3 Texture::getColour(glm::vec2 uv) const
{
	return translate_color(getpixel(pixelData, uv.x*(float)width, uv.y*(float)height));
}