示例#1
0
int vga_setpalvec(int start, int num, int *pal)
{
    int i;

    DTP((stderr,"setpalvec %i %i %x\n",start,num,pal));

    if ((__svgalib_driverspecs->emul && __svgalib_driverspecs->emul->setpalette) ||
	(__svgalib_outpal!=__svgalib_vga_outpal)) {
        for (i = start; i < start + num; ++i) {
	    vga_setpalette(i, pal[0], pal[1], pal[2]);
	    pal += 3;
        }
    } else {
        unsigned char string[768];

        if ( num > 256 )
            return 0;

        for (i = 0; i < num * 3; i++)
            string[i] = pal[i];

        port_out ( start, 0x3c8 );
#if 0
        port_rep_outb( string, num * 3, 0x3c9 );
#else
        for(i=0;i<num*3;i++)port_out(string[i],0x3c9);
#endif
    }

    return num;
}
示例#2
0
static int
svgadisplay_allocate_colours( int numColours )
{
  static const libspectrum_byte colour_palette[] = {
  0,0,0,
  0,0,192,
  192,0,0,
  192,0,192,
  0,192,0,
  0,192,192,
  192,192,0,
  192,192,192,
  0,0,0,
  0,0,255,
  255,0,0,
  255,0,255,
  0,255,0,
  0,255,255,
  255,255,0,
  255,255,255
  };

  int i;

  for(i=0;i<numColours;i++) {
    float grey = 0.299 * colour_palette[i*3]
               + 0.587 * colour_palette[i*3+1]
               + 0.114 * colour_palette[i*3+2] + 0.5;
    vga_setpalette(i+16, grey / 4, grey / 4, grey / 4);
    vga_setpalette(i,colour_palette[i*3]>>2,colour_palette[i*3+1]>>2,
		   colour_palette[i*3+2]>>2);
  }

  return 0;
}
示例#3
0
文件: palette.c 项目: raphot/openbor
// Set gamma/brightness corrected palette.
// Valid values range between -255 and 255, where 0 is normal.
void palette_set_corrected(unsigned char *pal, int gr, int gg, int gb, int br, int bg, int bb){
	unsigned char pal2[768];
	int i;

	if(gr<-255) gr = -255;
	else if(gr>255) gr = 255;
	if(gg<-255) gg = -255;
	else if(gg>255) gg = 255;
	if(gb<-255) gb = -255;
	else if(gb>255) gb = 255;

	if(br<-255) br = -255;
	else if(br>255) br = 255;
	if(bg<-255) bg = -255;
	else if(bg>255) bg = 255;
	if(bb<-255) bb = -255;
	else if(bb>255) bb = 255;

	for(i=0; i<256; i++){
		pal2[i*3] =   gbcorrect(pal[i*3],   gr, br);
		pal2[i*3+1] = gbcorrect(pal[i*3+1], gg, bg);
		pal2[i*3+2] = gbcorrect(pal[i*3+2], gb, bb);
	}
	vga_setpalette(pal2);
}
示例#4
0
文件: svga.c 项目: Pa0l0ne/Amiga360
static void restore_vga_colors (void)
{
    int i;
    if (gfxvidinfo.pixbytes != 1)
	return;
    for (i = 0; i < 256; i++)
	vga_setpalette (i, palette_entries[i][0], palette_entries[i][1], palette_entries[i][2]);
}
示例#5
0
void VL_SetPalette(const byte *palette)
{
	myint i;
	
	VL_WaitVBL(1);
	
	for (i = 0; i < 256; i++)
		vga_setpalette(i, palette[i*3+0], palette[i*3+1], palette[i*3+2]);
}
示例#6
0
文件: my_vgax.hpp 项目: shaos/rw1o
 void SetHardPalette(void)
 {   int lr,lg,lb;
     for(int i=0; i<256; i++)
     {   lr = d[i][0];
         lg = d[i][1];
         lb = d[i][2];
         vga_setpalette(i,lr,lg,lb);
     }
 };
int main()
{ 
    ret = init_vga(G320x200x256, VGA, PCI_DEVICE_ID_S3_TRIO64V2);            
    
    int i;
    for(i=0;i<64;i++){
        vga_setpalette(i, i, i, i);
    }
    
    for(i=0;i<64;i++){
        vga_setpalette(i+64, i, 0, 0);
    }
    
    for(i=0;i<64;i++){
        vga_setpalette(i+64+64, 0, i, 0);
    }
   
    buffer = (unsigned char *)malloc(VGA_WIDTH*VGA_HEIGHT);//virtual canvas
    memset(buffer, 0, VGA_WIDTH*VGA_HEIGHT);    
            
    set_raw_mode();

    unsigned int seed = (unsigned) time(NULL);
    srand(seed);
    /*srand(seed);rand();*/

    float period = 1.0/60.0;
    //period_ts = double_to_timespec(period);  //old versions of MaRTE OS
    double_to_timespec(period,&period_ts); //new versions of MaRTE OS
    
    while(1){
        
        DrawObjects();
        //flip
        vga_drawscansegment(buffer,0,0,VGA_WIDTH*VGA_HEIGHT); 
        nanosleep(&period_ts, NULL);

    }
    
    
    while(getchar()==-1);

    return 0;
}
示例#8
0
文件: svga.c 项目: Pa0l0ne/Amiga360
void DX_SetPalette(int start, int count)
{
    if (!screen_is_picasso || picasso_vidinfo.pixbytes != 1)
	return;

    while (count-- > 0) {
	vga_setpalette(start, picasso96_state.CLUT[start].Red * 63 / 255,
		       picasso96_state.CLUT[start].Green * 63 / 255,
		       picasso96_state.CLUT[start].Blue * 63 / 255);
	start++;
    }
}
示例#9
0
文件: svga.c 项目: Pa0l0ne/Amiga360
static int get_color (int r, int g, int b, xcolnr *cnp)
{
    if (colors_allocated == 256)
	return -1;
    *cnp = colors_allocated;
    palette_entries[colors_allocated][0] = doMask (r, 6, 0);
    palette_entries[colors_allocated][1] = doMask (g, 6, 0);
    palette_entries[colors_allocated][2] = doMask (b, 6, 0);
    vga_setpalette(colors_allocated, doMask (r, 6, 0), doMask (g, 6, 0), doMask (b, 6, 0));
    colors_allocated++;
    return 1;
}
示例#10
0
static int init_vidmode ()
{
	int err, i;

	fprintf (stderr, "svgalib: SVGAlib support by XoXus\n");

	err = vga_init ();
	if (err) {
		fprintf (stderr, "svgalib: can't initialize svgalib\n");
		return err_Unk;
	}
	err = vga_hasmode (G320x200x256);
	if (err == 0) {
		fprintf (stderr,
			"svgalib: video mode unavailable (320x200x256)\n");
		return err_Unk;
	}

	vga_setmode (G320x200x256);
	svgalib_framebuffer = vga_getgraphmem ();

	/* Set up EGA colors */
	for (i = 0; i < 32; i++) {
		vga_setpalette (i, palette[i * 3],
			palette[i * 3 + 1], palette[i * 3 + 2]);
	}

	/* Allocate framebuffer */
	video_buffer = (UINT8 *) malloc (320 * 200);
	if (!video_buffer) {
		fprintf (stderr, "svgalib: can't alloc framebuffer\n");
		deinit_vidmode ();
		return err_Unk;
	}

	/* XoXus: This is a semantics issue, but the keyboard init
	 *		probably shouldn't be done in 'init_vidmode'
	 */
	err = svgalib_key_init ();
	if (err != err_OK) {
		deinit_vidmode ();
		return err_Unk;
	}

	return err_OK;
}
示例#11
0
// Set gamma/brightness corrected palette.
// Valid values range between -255 and 255, where 0 is normal.
void palette_set_corrected(unsigned char *pal, int gr, int gg, int gb, int br, int bg, int bb) {
	unsigned char pal2[768];
	int i;

	int_min_max(&gr, -255, 255);
	int_min_max(&gg, -255, 255);
	int_min_max(&gb, -255, 255);
	int_min_max(&br, -255, 255);
	int_min_max(&bg, -255, 255);
	int_min_max(&bb, -255, 255);

	for(i = 0; i < 256; i++) {
		pal2[i * 3] = gbcorrect(pal[i * 3], gr, br);
		pal2[i * 3 + 1] = gbcorrect(pal[i * 3 + 1], gg, bg);
		pal2[i * 3 + 2] = gbcorrect(pal[i * 3 + 2], gb, bb);
	}
	vga_setpalette(pal2);
}
示例#12
0
void SvgalibScreen::initColorMap()
{
    const int numColors = vga_getcolors();
    if (numColors == 2 || numColors > 256) {
        screencols = 0;
        return; // not a palette based mode
    }

    if (numColors == 16) {
        if (grayscale) {
            for (int i = 0; i < 256; ++i) {
                const int c = i * 16 / 256;
                vga_setpalette(i, c, c, c);
            }
            screencols = 256; // XXX: takes advantage of optimization in alloc()
        } else { // read in EGA palette
            int r, g, b;
            for (int i = 0; i < 16; ++i) {
                vga_getpalette(i, &r, &g, &b);
                screenclut[i] = qRgb(r, g, b);
            }
            screencols = 16;
        }

        return;
    }

    Q_ASSERT(numColors == 256);

    if (grayscale) {
        for (int i = 0; i < 256; ++i) {
            const int c = i * 64 / 256;
            vga_setpalette(i, c, c, c);
        }
    } else {
        int i = 0;

#if 0
        // read in EGA palette
        while (i < 16) {
            int r, g, b;
            vga_getpalette(i, &r, &g, &b);
            screenclut[i] = qRgb(r, g, b);
            ++i;
        }
        screencols = 16;
#endif

        // 6 * 6 * 6 color cube
        for (int r = 0; r < 6; ++r) {
            for (int g = 0; g < 6; ++g) {
                for (int b = 0; b < 6; ++b) {
                    vga_setpalette(i, r * 64/6, g * 64/6, b * 64/6);
                    screenclut[i] = qRgb(r * 256/6, g * 256/6, b * 256/6);
                    ++i;
                }
            }
        }
        screencols = i;

        while (i < 256) {
            screenclut[i] = qRgb(0, 0, 0);
            ++i;
        }
    }
}
示例#13
0
static void testmode(int mode)
{
    int xmax, ymax, i, x, y, yw, ys, c;
    vga_modeinfo *modeinfo;

    vga_setmode(mode);

    modeinfo = vga_getmodeinfo(mode);

    printf("Width: %d  Height: %d  Colors: %d\n",
           modeinfo->width,
           modeinfo->height,
           modeinfo->colors);
    printf("DisplayStartRange: %xh  Maxpixels: %d  Blit: %s\n",
           modeinfo->startaddressrange,
           modeinfo->maxpixels,
           modeinfo->haveblit ? "YES" : "NO");

#ifdef TEST_MODEX
    if (modeinfo->colors == 256)
        printf("Switching to ModeX ... %s\n",
               (vga_setmodeX()? "done" : "failed"));
#endif

    vga_screenoff();

    xmax = vga_getxdim() - 1;
    ymax = vga_getydim() - 1;

    vga_setcolor(vga_white());
    vga_drawline(0, 0, xmax, 0);
    vga_drawline(xmax, 0, xmax, ymax);
    vga_drawline(xmax, ymax, 0, ymax);
    vga_drawline(0, ymax, 0, 0);

    /* Draw crosses */
    for (i = 0; i <= 15; i++) {
        vga_setegacolor(i);
        vga_drawline(10 + i * 5, 10, 89 + i * 5, 89);
    }
    for (i = 0; i <= 15; i++) {
        vga_setegacolor(i);
        vga_drawline(89 + i * 5, 10, 10 + i * 5, 89);
    }

    vga_screenon();

    ys = 100;
    yw = (ymax - 100) / 4;
    switch (vga_getcolors()) {
    case 256:
        /* Draw horizontal color bands using palette */
        for (i = 0; i < 60; ++i) {
            c = (i * 64) / 60;
            vga_setpalette(i + 16, c, c, c);
            vga_setpalette(i + 16 + 60, c, 0, 0);
            vga_setpalette(i + 16 + (2 * 60), 0, c, 0);
            vga_setpalette(i + 16 + (3 * 60), 0, 0, c);
        }
        line[0] = line[xmax] = 15;
        line[1] = line[xmax - 1] = 0;
        for (x = 2; x < xmax - 1; ++x)
            line[x] = (((x - 2) * 60) / (xmax - 3)) + 16;
        for (y = ys; y < ys + yw; ++y)	/* gray */
            vga_drawscanline(y, line);
        for (x = 2; x < xmax - 1; ++x)
            line[x] += 60;
        ys += yw;
        for (y = ys; y < ys + yw; ++y)	/* red */
            vga_drawscanline(y, line);
        for (x = 2; x < xmax - 1; ++x)
            line[x] += 60;
        ys += yw;
        for (y = ys; y < ys + yw; ++y)	/* green */
            vga_drawscanline(y, line);
        for (x = 2; x < xmax - 1; ++x)
            line[x] += 60;
        ys += yw;
        for (y = ys; y < ys + yw; ++y)	/* blue */
            vga_drawscanline(y, line);
        break;

    case 1 << 15:
    case 1 << 16:
    case 1 << 24:
        /* Draw horizontal color bands in RGB */
        for (x = 2; x < xmax - 1; ++x) {
            c = ((x - 2) * 255) / (xmax - 4);
            y = ys;
            vga_setrgbcolor(c, c, c);
            vga_drawline(x, y, x, y + yw - 1);
            y += yw;
            vga_setrgbcolor(c, 0, 0);
            vga_drawline(x, y, x, y + yw - 1);
            y += yw;
            vga_setrgbcolor(0, c, 0);
            vga_drawline(x, y, x, y + yw - 1);
            y += yw;
            vga_setrgbcolor(0, 0, c);
            vga_drawline(x, y, x, y + yw - 1);
        }
        drawSquares(xmax, ymax);
        break;
    default:
        /* Draw vertical color bars */
        if (vga_getcolors() == 16) {
            for (i = 0; i < xmax - 1; i++)
                line[i] = (i + 2) % 16;
            line[0] = line[xmax] = 15;
            line[1] = line[xmax - 1] = 0;
        }
        if (vga_getcolors() == 2) {
            for (i = 0; i <= xmax; i++)
                line[i] = 0x11;
            line[0] = 0x91;
        }
        for (i = 100; i < ymax - 1; i++)
            vga_drawscanline(i, line);
        break;

    }

    if (getchar() == 'd')
        vga_dumpregs();

}