[comp.sys.ibm.pc] MCGA videomode

i14@np1.hep.nl (Martin Los) (03/13/89)

Can anyone tell me how I can access the MCGA cards 256 color mode (PS/2 model
30) Please post a sample program (in pascal ,c or quickbasic) which places
256 different colored points on the screen (if this isn't too much trouble,per
haps you have to mess around with bitplanes or something.......)

Thanks in advance,
 Martin at i14@nikhefh.hep.nl

teittinen@cc.helsinki.fi (03/14/89)

In article <143@np1.hep.nl>, i14@np1.hep.nl (Martin Los) writes:
> Can anyone tell me how I can access the MCGA cards 256 color mode (PS/2 model
> 30) Please post a sample program (in pascal ,c or quickbasic) which places
> 256 different colored points on the screen 

OK, here comes two C-functions. One to write a pixel to screen and the
other to read the pixel value (This is typed without help of any
manual, so it has not been compiled, but it should work). Before you
use the functions below you should change the video mode to 0x13 which
is the 256 color mode. You can use interrupt 0x10, subfunction 0. If you
aren't familiar with it, ask somebody.

I hope this helps.

---cut here--------
/* This is source code for Turbo C or Microsoft C */
/* I don't remember what files you should #include, look up from manual */

/* This is pointer to the display memory area */
unsigned char far *DispMem = (unsigned char far *) 0xA0000000L;

/* This function plots a dot to the screen at (x,y) with color */
void putpixel(int x, int y, int color)
{
    /* First we check the parameters */
    if (x < 0 || x > 319 || y < 0 || y > 199 || color < 0 || color > 255)
        return;
    /* Put the pixel to screen */
    *(DispMem+320*y+x) = color;
}

/* This function returns the color of the pixel (-1 if out of screen) */
int getpixel(int x, int y)
{
    /* Check that the pixel is inside the screen area */
    if (x < 0 || x > 319 || y < 0 || y > 199)
        return(-1);
    /* Get the color of the pixel */
    return(*(DispMem+320*y+x));
}

---cut here--------

EARN: teittinen@finuh
Internet: teittinen@cc.helsinki.fi
Marko Teittinen, student of computer science