Category : Miscellaneous Language Source Code
Archive   : ATIDRIV.ZIP
Filename : COLORTST.C

 
Output of file : COLORTST.C contained in archive : ATIDRIV.ZIP
/* Demo of using BGI driver in BGI format. */

/*----------------------------------------------*/
/* COLORTST.C Color test program */
/* */
/* By: Thomas Design August 3, 1989 */
/*----------------------------------------------*/

#include
#include
#include
#include "ATI256.H" /* pick up the main BGI defines */
#include "ATIDET.H" /* pick up autodetect */
#include "VGAEXTRA.H" /* use for palette control & flashmodes */

int g_driver, g_mode, g_error;

/*----------------- Array for RGB color info ------------------------*/

DACarray Palette_Array; /* create array to hold DAC values */

/*----------------- RGB colors from HSV model ---------------------------*/
/* hue = pure color of the light
sat = how much white light is mixed in
value = max component of RGB */

void hsv2rgb(float h,float s,float v,RGB *Color)
{
float h1,f,a[7];
int i;
h1 = h / 60;
i = h1;
f = h1 - i;
a[1] = v;
a[2] = v;
a[3] = v * (1 - (s*f));
a[4] = v * (1 - s);
a[5] = a[4];
a[6] = v * (1-(s*(1-f)));
if (i>4) i = i - 4; else i = i + 2;
Color->Red = a[i];
if (i>4) i = i - 4; else i = i + 2;
Color->Green = a[i];
if (i>4) i = i - 4; else i = i + 2;
Color->Blue = a[i];
}

/*----------------- Draw all 256 colors on screen ------------------------*/
void Palette_List()
{
int x,y,xw,yh,xinc,yinc,count;
int x1,y1,x2,y2;
char holdstr[20];
settextjustify(CENTER_TEXT,CENTER_TEXT);
xw = (getmaxx() / 16) - 5;
yh = (getmaxy() / 16) - 5;
xinc = xw + 5;
yinc = yh + 5;
x1 = 0;
y1 = 0;
x2 = xw;
y2 = yh;
count = 0;
setcolor(255);
for (x=0;x<256;x++) {
setfillstyle(SOLID_FILL,x);
bar(x1,y1,x2,y2);
outtextxy((x2-x1)/2+x1,(y2-y1)/2+y1,itoa(x,&holdstr,10));
line(x1,y1,x2,y1);
line(x2,y1,x2,y2);
line(x2,y2,x1,y2);
line(x1,y2,x1,y1);
x1 = x1 + xinc;
x2 = x2 + xinc;
count = ++count;
if (count == 16) {
x1 = 0;
y1 = y1 + yinc;
x2 = xw;
y2 = y2 + yinc;
count = 0;
}
}
}

/*----------------- Main Program -----------------------------------------*/
void main()
{
int x,y;
RGB ColorValue;
int count;
float hue,sat,val;
installuserdriver("ATI256",DetectATI256); /* install my BGI driver */
g_driver = DETECT;
initgraph(&g_driver,&g_mode,"");
g_error = graphresult();
if (g_error != 0) {
printf("%s \n",grapherrormsg(g_error));
exit(1);
}
hue = 0;
sat = 1.0;
val = 63.0;
for (x=1; x<128; x++) {
hsv2rgb(hue,sat,val,&ColorValue);
Palette_Array[x][red] = ColorValue.Red;
Palette_Array[x][grn] = ColorValue.Green;
Palette_Array[x][blu] = ColorValue.Blue;
hue = hue + 3.0;
}
hue = 0;
sat = 1.0;
val = 43.0;
for (x=128; x<256; x++) {
hsv2rgb(hue,sat,val,&ColorValue);
Palette_Array[x][red] = ColorValue.Red;
Palette_Array[x][grn] = ColorValue.Green;
Palette_Array[x][blu] = ColorValue.Blue;
hue = hue + 2.80;
}
Palette_Array[0][red] = 1; /* Set first DAC register to black */
Palette_Array[0][grn] = 2;
Palette_Array[0][blu] = 3;
Palette_Array[253][red] = 0x1f; /* Set last DAC register to white */
Palette_Array[253][grn] = 0x1f;
Palette_Array[253][blu] = 0x1f;
Palette_Array[254][red] = 0x2f; /* Set last DAC register to white */
Palette_Array[254][grn] = 0x2f;
Palette_Array[254][blu] = 0x2f;
Palette_Array[255][red] = 0x3f; /* Set last DAC register to white */
Palette_Array[255][grn] = 0x3f;
Palette_Array[255][blu] = 0x3f;
/* flashmodeon(); put vram into hyperdrive... */
dacpalette(Palette_Array); /* load DAC registers with new colors */
Palette_List(); /* display the 256 colors */
/* flashmodeoff(); slow down to reality..(wait states) */
getch();
restorecrtmode();
}


  3 Responses to “Category : Miscellaneous Language Source Code
Archive   : ATIDRIV.ZIP
Filename : COLORTST.C

  1. Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!

  2. This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.

  3. But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/