Exemple #1
0
void LoadPalette(void)
/* Apre il file 256color.pal e carica i valori RGB usati per la palette */
/* assegnandoli a valori compresi tra 0 e 255 tramite la funzione       */
/* gl_setpalettecolor(int num_color, int r, int g, int b);              */
{
  int i;
  FILE *file_pointer;
  file_pointer = fopen(PALETTE_FILE, "rb");
  if(file_pointer == NULL) { 
    printf(" Si e' verificato un errore durante l'apertura del file :\n");
    printf(" 256color.pal\n");
    exit(0);
  }
  for(i=0;i<NUM_COLOR;i++) {
    fseek(file_pointer, i*sizeof(struct color), SEEK_SET);
    fread(&Color, sizeof(struct color), 1, file_pointer);
    gl_setpalettecolor(i, Color.r, Color.g, Color.b);
  }
}
Exemple #2
0
bool screen_init (void)
{
#ifdef LINUXFB
  use_fb = 1;
  if (fb_init ()) 
  {
    use_fb = 0;
    return false;
  }
#endif

#ifdef VGALIB
  use_fb = 0;
  vga_init ();
  vga_setmode(DEFAULT_VGA_MODE);
  gl_setcontextvga(DEFAULT_VGA_MODE);
  physical_screen = gl_allocatecontext();
  gl_getcontext(physical_screen);

  gl_setcontextvgavirtual(DEFAULT_VGA_MODE);
  virtual_screen = gl_allocatecontext();
  gl_getcontext(virtual_screen);

  gl_setcontext(virtual_screen);
  //vga_ext_set(VGA_EXT_SET,  VGA_CLUT8);

// color table:
// http://en.wikipedia.org/wiki/ANSI_escape_code#Colors 

  gl_setpalettecolor(BLUE, 0, 0, 63); // blue
  gl_setpalettecolor(BLACK, 0, 0, 0); // black
  gl_setpalettecolor(GREEN, 0, 63, 0); 
  gl_setpalettecolor(RED, 63, 0, 0); 
  gl_setpalettecolor(BROWN, 170/4, 85/4, 0);
  gl_setpalettecolor(MAGENTA, 170/4, 0, 170/4);
  gl_setpalettecolor(CYAN, 0, 170/4, 170/4); 
  gl_setpalettecolor(GRAY, 48, 48, 48);

  gl_setpalettecolor(LIGHTBLACK, 85/4, 85/4, 85/4); 
  gl_setpalettecolor(LIGHTBLUE, 85/4, 85/4, 255/4); 
  gl_setpalettecolor(LIGHTGREEN, 85/4, 255/4, 85/4); 
  gl_setpalettecolor(LIGHTCYAN, 85/4, 255/4, 255/4); 
  gl_setpalettecolor(LIGHTRED, 25/45/4, 85/4, 85/4); 
  gl_setpalettecolor(LIGHTMAGENTA, 255/4, 85/4, 255/4); 
  gl_setpalettecolor(LIGHTBROWN, 255/4, 255/4, 85/4); 

#endif

  active_console = 1;
  return true;
}
/* ---------------------------------------------------------------------- *
 * Public Functions
 * ---------------------------------------------------------------------- */
void
load_start_image (void)
{
#ifdef LC_X11
  XColor pal[256];
  XEvent xev;
#endif
  long x, y, l, r, g, b;
  gzFile fp;

  fp = gzopen( opening_pic, "r" );
  if (fp == NULL) {
      return;
  }

  for (x = 0; x < 7; x++)
    l = gzgetc (fp);
  l &= 0xff;
  if (l == 0)
    l = 256;
  for (x = 0; x < l; x++)
    {
      r = gzgetc (fp);
      g = gzgetc (fp);
      b = gzgetc (fp);
#ifdef LC_X11
      pal[x].red = r;
      pal[x].green = g;
      pal[x].blue = b;
      pal[x].flags = DoRed | DoGreen | DoBlue;
#elif defined LC_SVGA
      gl_setpalettecolor (x, r, g, b);
#endif
    }
  /* use last 4 colours for text */
#ifdef LC_X11
  pal[SI_BLACK].red = 0;
  pal[SI_BLACK].green = 0;
  pal[SI_BLACK].blue = 0;
  pal[SI_BLACK].flags = DoRed | DoGreen | DoBlue;
  pal[SI_RED].red = 60;
  pal[SI_RED].green = 0;
  pal[SI_RED].blue = 0;
  pal[SI_RED].flags = DoRed | DoGreen | DoBlue;
  pal[SI_GREEN].red = 0;
  pal[SI_GREEN].green = 60;
  pal[SI_GREEN].blue = 0;
  pal[SI_GREEN].flags = DoRed | DoGreen | DoBlue;
  pal[SI_YELLOW].red = 60;
  pal[SI_YELLOW].green = 60;
  pal[SI_YELLOW].blue = 0;
  pal[SI_YELLOW].flags = DoRed | DoGreen | DoBlue;
  open_setcustompalette (pal);
  suppress_next_expose = 1;
  do
    {
      while (XPending (display.dpy) == 0);
      XNextEvent (display.dpy, &xev);
      HandleEvent (&xev);
    }
  while (xev.type != MapNotify);

#elif defined LC_SVGA
  gl_setpalettecolor (SI_BLACK, 0, 0, 0);
  gl_setpalettecolor (SI_RED, 60, 0, 0);
  gl_setpalettecolor (SI_GREEN, 0, 60, 0);
  gl_setpalettecolor (SI_YELLOW, 60, 60, 0);
#endif
#if defined (WIN32)
  UpdatePalette ();
#endif
  for (y = 0; y < 480; y++)
    for (x = 0; x < 640; x++)
      {
	l = gzgetc (fp);
	/*
	   //      printf("l=%d x=%d y=%d ",l,x,y);
	   // octree doesn't seem to want to generate images with 252 colours!
	   // So the next best thing (well the easyest) is to just map the pixels
	   // coloured as the last 4 colours to the 4 before that.
	   // If it looks OK, leave it.
	 */
	if (l == SI_BLACK)
	  l = SI_BLACK - 4;
	if (l == SI_RED)
	  l = SI_RED - 4;
	if (l == SI_GREEN)
	  l = SI_GREEN - 4;
	if (l == SI_YELLOW)
	  l = SI_YELLOW - 4;
	Fgl_setpixel (x, y, l);
      }

  gzclose(fp);

#if defined (WIN32)
  RefreshScreen ();
#endif
  start_image_text ();
}
Exemple #4
0
void Graphic::init_graph_mode()
{
#ifdef SVGALIB
  vga_init();
  int vga_mode=G640x480x16M;
  vga_setmode(vga_mode);
  gl_setcontextvga(vga_mode);
#endif

#if 0
  gl_setpalettecolor(BLUE, 0, 0, 63); // blue
  gl_setpalettecolor(BLACK, 0, 0, 0); // black
  gl_setpalettecolor(GREEN, 0, 63, 0);
  gl_setpalettecolor(RED, 63, 0, 0);
  gl_setpalettecolor(BROWN, 170/4, 85/4, 0);
  gl_setpalettecolor(MAGENTA, 170/4, 0, 170/4);
  gl_setpalettecolor(CYAN, 0, 170/4, 170/4);
  gl_setpalettecolor(GRAY, 48, 48, 48);

  gl_setpalettecolor(LIGHTBLACK, 85/4, 85/4, 85/4);
  gl_setpalettecolor(LIGHTBLUE, 85/4, 85/4, 255/4);
  gl_setpalettecolor(LIGHTGREEN, 85/4, 255/4, 85/4);
  gl_setpalettecolor(LIGHTCYAN, 85/4, 255/4, 255/4);
  gl_setpalettecolor(LIGHTRED, 25/45/4, 85/4, 85/4);
  gl_setpalettecolor(LIGHTMAGENTA, 255/4, 85/4, 255/4);
  gl_setpalettecolor(LIGHTBROWN, 255/4, 255/4, 85/4);
#endif
}
Exemple #5
0
void SetPaletteColor(unsigned char color,
                     unsigned char red,
                     unsigned char green,
                     unsigned char blue) {
  gl_setpalettecolor(color, red, green, blue);
}