Category : C Source Code
Archive   : TWKTC.ZIP
Filename : SIMPLE.C

 
Output of file : SIMPLE.C contained in archive : TWKTC.ZIP
#include
#include
#include
#include
#include "TWK256.h" /* pick up the defines for the driver */
#include "TWKDET.H"
#include "VGAEXTRA.H"

struct PTS {
int x, y;
}; /* Structure to hold vertex points */

int g_driver,g_mode,g_error;
int x,y,count;
int SelectedMode;
int StartX,StartY,r;
DACarray Palette_Array; /* create array to hold DAC values */
RGB ColorValue;
int count;

/*------------------- get command line options ---------*/
void get_options(char Option)
{
switch (Option) {
case '0' : SelectedMode = 0; break;
case '1' : SelectedMode = 1; break;
case '2' : SelectedMode = 2; break;
case '3' : SelectedMode = 3; break;
case '4' : SelectedMode = 4; break;
case '5' : SelectedMode = 5; break;
case '6' : SelectedMode = 6; break;
case '7' : SelectedMode = 7; break;
default : printf("\nInvalid option: %c\n",Option); exit(4); break;
}
}


/*--------------- Hue Saturation and Value to 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];
}

void Load_Palette(void)
{
float hue,sat,val,x;
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;
dacpalette(Palette_Array); /* load DAC registers with new colors */
}


/*----------------- Main Program -----------------------------------------*/
void main(argc,argv)
int argc;
char *argv[];
{
if ((argc < 2) || (argc > 2)) {
printf("Options are:\n");
printf("\t Simple 0 (320x200)\n");
printf("\t 1 (320x240)\n");
printf("\t 2 (320x400)\n");
printf("\t 3 (360x480)\n");
printf("\t 4 (320x480)\n");
printf("\t 5 (376x564)\n");
printf("\t 6 (400x564)\n");
printf("\t 7 (400x600)\n");

exit(1);
}
if (argc == 2) get_options(argv[1][0]);
installuserdriver("TWK256",DetectTWK256);
g_driver = DETECT;
initgraph(&g_driver,&g_mode,"");
setgraphmode(SelectedMode);
g_error = graphresult();
if (g_error != 0) {
printf("%s \n",grapherrormsg(g_error));
exit(1);
}
Load_Palette();
x = getmaxx();
y = getmaxy();
line(0,0,x,0);
line(x,0,x,y);
line(x,y,0,y);
line(0,y,0,0);
line(0,0,getmaxx(),getmaxy());
outtextxy(getmaxx()/2,getmaxy()/2,"Page 1");
setactivepage(1);
outtextxy(getmaxx()/2,getmaxy()/2,"Page 2");
getch();
setvisualpage(1);
getch();
setvisualpage(0);
getch();
restorecrtmode();
}


  3 Responses to “Category : C Source Code
Archive   : TWKTC.ZIP
Filename : SIMPLE.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/