Category : C Source Code
Archive   : MSC_COLR.ZIP
Filename : COLOR.C

 
Output of file : COLOR.C contained in archive : MSC_COLR.ZIP
#include
#include
#include
#include

void clreol()
{
int count;
short old_wrap;
struct rccoord cp;
struct videoconfig vc;

_getvideoconfig(&vc);
old_wrap = _wrapon(_GWRAPOFF);
cp = _gettextposition();
for (count = 0; count < ((vc.numtextcols - cp.col) + 1); count++)
_outtext(" ");
_settextposition(cp.row,cp.col);
_wrapon(old_wrap);
}

void bell()
{
char timerport = 0x43;
char pitchport = 0x42;
char speakerport = 0x61;
char timerswitch = 0xb6;
char low_val = 0x00;
char high_val = 0x09;
char speakerbyte;
int count;

outp(timerport, timerswitch);
outp(pitchport, low_val);
outp(pitchport, high_val);
speakerbyte = inp(speakerport);
speakerbyte &= 0xfc;
speakerbyte |= 0x03;
outp(speakerport, speakerbyte);
for (count = 0; count < 8000; count++);
speakerbyte = inp(speakerport);
speakerbyte &= 0xfc;
outp(speakerport, speakerbyte);
}

void col_gchar(char_in)
char *char_in;
{
char string_hold[2];

get_any_type(string_hold, 1, 'S');
*char_in = string_hold[0];
}

void col_gdouble(double_in, max_length)
double *double_in;
int max_length;
{
char type_get = 'F';
char string_hold[50];

get_any_type(string_hold, max_length, type_get);
*double_in = atof(string_hold);
}

void col_gfloat(float_in, max_length)
float *float_in;
int max_length;
{
char type_get = 'F';
char string_hold[50];
int good_float;
double double_in;
int count;
struct rccoord cp;

cp = _gettextposition();
do
{
good_float = 0;
get_any_type(string_hold, max_length, type_get);
double_in = atof(string_hold);
if (double_in > 3.4e-38 || double_in < 3.4e+38)
{
*float_in = double_in;
good_float = 1;
}
else
{
bell();
_settextposition(cp.row,cp.col);
for (count = 0; count < max_length; count++)
col_pchar(' ');
}
}
while (!good_float);
}

void col_gint(int_in, max_length)
int *int_in;
int max_length;
{
char type_get = 'I';
char string_hold[50];
int good_int;
double double_in;
int count;
struct rccoord cp;

cp = _gettextposition();
do
{

_settextposition(cp.row, cp.col);
good_int = 0;
get_any_type(string_hold, max_length, type_get);
double_in = atof(string_hold);
if (double_in > -32769 && double_in < 32768)
{
*int_in = double_in;
good_int = 1;
}
else
{
bell();
_settextposition(cp.row, cp.col);
for (count = 0; count < max_length; count++)
col_pchar(' ');
}
}
while (!good_int);
}

void col_glong(long_in, max_length)
long *long_in;
int max_length;
{
char type_get = 'I';
char string_hold[50];
int good_long;
double double_in;
int count;
struct rccoord cp;

cp = _gettextposition();
do
{
_settextposition(cp.row,cp.col);
good_long = 0;
get_any_type(string_hold, max_length, type_get);
double_in = atof(string_hold);
if (double_in > -2.147483649e+9 && double_in < 2.147483648e+9)
{
*long_in = double_in;
good_long = 1;
}
else
{
bell();
_settextposition(cp.row,cp.col);
for (count = 0; count < max_length; count++)
col_pchar(' ');
}
}
while (!good_long);
}

void col_gstring(string_in, max_string)
char string_in[];
int max_string;
{
char type_get = 'S';

get_any_type(string_in, max_string, type_get);
}


void col_gunlong(unlong_in, max_length)
unsigned long *unlong_in;
int max_length;
{
char type_get = 'U';
char string_hold[50];
int good_unlong;
double double_in;
int count;
struct rccoord cp;

cp = _gettextposition();
do
{
_settextposition(cp.row,cp.col);
good_unlong = 0;
get_any_type(string_hold, max_length, type_get);
double_in = atof(string_hold);
if (double_in < 4.294967295e+9)
{
*unlong_in = double_in;
good_unlong = 1;
}
else
{
bell();
_settextposition(cp.row,cp.col);
for (count = 0; count < max_length; count++)
col_pchar(' ');
}
}
while (!good_unlong);
}

void col_gunsigned(unsigned_in, max_length)
unsigned *unsigned_in;
int max_length;
{
char type_get = 'U';
char string_hold[50];
int good_unsigned;
double double_in;
int count;
struct rccoord cp;

cp =_gettextposition();
do
{
_settextposition(cp.row,cp.col);
good_unsigned = 0;
get_any_type(string_hold, max_length, type_get);
double_in = atof(string_hold);
if (double_in < 65536)
{
*unsigned_in = double_in;
good_unsigned = 1;
}
else
{
bell();
_settextposition(cp.row,cp.col);
for (count = 0; count < max_length; count++)
col_pchar(' ');
}
}
while (!good_unsigned);
}

void col_pchar(char_in)
int char_in;
{
char string_hold[2];

string_hold[0] = char_in;
string_hold[1] = '\00';
_outtext(string_hold);
}

void col_pdouble(pass_double, ndec)
double pass_double;
int ndec;
{
int decptr;
int signptr;
char *buffer;
char d_string[51];
int string_count = 0;
int buffer_count = 0;
int count;

buffer = fcvt(pass_double, ndec, &decptr, &signptr);
if (signptr != 0)
{
d_string[string_count] = '-';
string_count++;
}
if (decptr <= 0)
{
d_string[string_count] = '.';
string_count++;
decptr *= -1;
for (count = 0; count < decptr; count++)
{
d_string[string_count] = '0';
string_count++;
}
}
else
{
for (count = 0; count < decptr; count++)
{
d_string[string_count] = *(buffer + buffer_count);
string_count++;
buffer_count++;
}
d_string[string_count] = '.';
string_count++;
}
while (buffer[buffer_count] != 0x00)
{
d_string[string_count] = buffer[buffer_count];
string_count++;
buffer_count++;
}
d_string[string_count] = 0x00;
col_pstring(d_string);
}

void col_pfloat(float_in, ndec)
float float_in;
int ndec;
{
double pass_double;

pass_double = float_in;
col_pdouble(pass_double, ndec);
}

void col_pint(int_in)
int int_in;
{
char print_int[17];
int rad = 10;

itoa(int_in, print_int, rad);
col_pstring(print_int);
}

void col_plong(long_in)
long long_in;
{
char print_long[33];
int rad = 10;

ltoa(long_in, print_long, rad);
col_pstring(print_long);
}

void col_pstring(instring)
char instring[];
{
int count;

for (count = 0; count < (strlen(instring)); count++)
col_pchar(instring[count]);
}

void col_punlong(unlong_in)
unsigned long unlong_in;
{
char print_long[33];
int rad = 10;

ultoa(unlong_in, print_long, rad);
col_pstring(print_long);
}

void col_punsigned(unsigned_in)
unsigned unsigned_in;
{
unsigned long pass_unlong;

pass_unlong = unsigned_in;
col_punlong(pass_unlong);
}

void get_any_type(string_in, max_string, type_get)
char string_in[];
int max_string;
char type_get;
{
char char_in = ' ';
long count = 0;
char hold_color;
int good_char = 0;
struct rccoord cp;
struct videoconfig vc;

string_in[0] = '\00';
if (max_string > 0)
do
{

if (type_get == 'S')
do
{
good_char = 0;
char_in = getch();
if (char_in == '\000')
{
char_in = getch();
char_in = '\000';
}
if (char_in == '\010' || char_in == '\015' ||
(char_in > '\037' && char_in < '\177'))
good_char = 1;
else
bell();
}
while (!good_char);

if (type_get == 'I')
do
{
good_char = 0;
char_in = getch();
if (char_in == '\000')
{
char_in = getch();
char_in = '\000';
}
if (char_in == '\010' || char_in == '\015' ||
char_in == '\053' || char_in == '\055' ||
(char_in > '\057' && char_in < '\072'))
good_char = 1;
else
bell();
}
while (!good_char);

if (type_get == 'U')
do
{
good_char = 0;
char_in = getch();
if (char_in == '\000')
{
char_in = getch();
char_in = '\000';
}
if (char_in == '\010' || char_in == '\015' ||
(char_in > '\057' && char_in < '\072'))
good_char = 1;
else
bell();
}
while (!good_char);

if (type_get == 'F')
do
{
good_char = 0;
char_in = getch();
if (char_in == '\000')
{
char_in = getch();
char_in = '\000';
}
if (char_in == '\010' || char_in == '\015' ||
char_in == '\053' || char_in == '\055' ||
char_in == '\056' ||
(char_in > '\057' && char_in < '\072'))
good_char = 1;
else
bell();
}
while (!good_char);

if (char_in == '\015')
string_in[count] = '\00';

if (char_in == '\010')
if (count > 0)
{
count--;
string_in[count] = '\00';
_getvideoconfig(&vc);
cp = _gettextposition();
if (cp.col > 1)
{
cp.col -= 1;
_settextposition(cp.row,cp.col);
col_pchar(' ');
_settextposition(cp.row,cp.col);
}
else
{
if (cp.row > 1)
{
cp.row -= 1;
cp.col = vc.numtextcols;
_settextposition(cp.row,cp.col);
col_pchar(' ');
_settextposition(cp.row,cp.col);
}
else
{
bell();
}
}
}
else
bell();

if (char_in != '\010' && char_in != '\015')
{
if (strlen(string_in) < max_string)
{
cp = _gettextposition();
string_in[count] = char_in;
count++;
col_pchar(char_in);
string_in[count] = '\00';
}
else
{
bell();
}
}
}
while (char_in != '\015');
}


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