Category : C Source Code
Archive   : BIGTIME.ZIP
Filename : BIGTIME.C

 
Output of file : BIGTIME.C contained in archive : BIGTIME.ZIP

/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* Big Time */
/* */
/* Will display the time of day in a Big way. */
/* */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

/****************************** #define WN_DEBUG */
#include
#include
#include

/*--------------------------------------------------------------------*/
/* P R O T O T Y P I N G */
/*--------------------------------------------------------------------*/
void main ();
void BigTime ();
void DisplayNumber (char *Numbers[], int ArrayIndex, int SCol);
void TotalWindow (WINDOW *WindowName, int SRow, int ERow,
int SCol, int ECol, BORDERPTR BType,
int RMargin, int LMargin,
char *WindowTitle, int TitlePlacement);


/*--------------------------------------------------------------------*/
/* G L O B A L S */
/*--------------------------------------------------------------------*/
WINDOW wBigTime; /* window to display time in */


/*--------------------------------------------------------------------*/
/* main */
/* */
/* Will get the ball a mov'n */
/* */
/*--------------------------------------------------------------------*/

void main ()

{
init_wfc ();

cls ();
csr_hide (); /* hide cursor, save X, Y pos. */
BigTime ();
csr_show (); /* restore cursor position */
}


/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* BigTime */
/* */
/* Will display the time in a BIG way. */
/* */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

void BigTime ()

{
struct tm *TimeStruc; /* time structure */
int TimeHour, TimeMin, TimeSec; /* comparison values of TimeStr*/
long TimeSeconds; /* seconds for conversion to tm*/
int HTime; /* Temporary time hold var. */
int HourIndex1, HourIndex2 = 99; /* hours hold var. */
int MinIndex1 , MinIndex2 = 99; /* min. hold var. */
int SecIndex1 , SecIndex2 = 99; /* sec. hold var. */
int Index1, Index2; /* used as comparison holders */
char PmTime = 1; /* default time setting = PM */

static char *Numbers [100] = {
/* 0 */ "ÛÛÛÛÛÛÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ",
"ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛÛÛÛÛÛÛ",
/* 1 */ " ÜÛÛ ", " ÞÛÛÛÛ ", " ÛÛÛ ", " ÛÛÛ ", " ÛÛÛ ",
" ÛÛÛ ", " ÛÛÛ ", " ÛÛÛ ", " ÛÛÛ ", "ÛÛÛÛÛÛÛÛÛ",
/* 2 */ "ÛÛÛÛÛÛÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", "ÜÜÜÜÜÜÛÛÛ",
"ÛÛÛßßßßßß", "ÛÛÛ ", "ÛÛÛ ", "ÛÛÛ ", "ÛÛÛÛÛÛÛÛÛ",
/* 3 */ "ÛÛÛÛÛÛÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", "ÜÜÜÜÜÜÛÛÛ",
"ßßßßßßÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", "ÛÛÛÛÛÛÛÛÛ",
/* 4 */ "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛÜÜÜÛÛÛ",
"ßßßßßßÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ",
/* 5 */ "ÛÛÛÛÛÛÛÛÛ", "ÛÛÛ ", "ÛÛÛ ", "ÛÛÛ ", "ÛÛÛÜÜÜÜÜÜ",
"ßßßßßßÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", "ÛÛÛÛÛÛÛÛÛ",
/* 6 */ "ÛÛÛÛÛÛÛÛÛ", "ÛÛÛ ", "ÛÛÛ ", "ÛÛÛ ", "ÛÛÛÜÜÜÜÜÜ",
"ÛÛÛßßßÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛÛÛÛÛÛÛ",
/* 7 */ "ÛÛÛÛÛÛÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ",
" ÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ",
/* 8 */ "ÛÛÛÛÛÛÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛÜÜÜÛÛÛ",
"ÛÛÛßßßÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛÛÛÛÛÛÛ",
/* 9 */ "ÛÛÛÛÛÛÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛ ÛÛÛ", "ÛÛÛÜÜÜÛÛÛ",
"ßßßßßßÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ", " ÛÛÛ"};

char *FunctionName = "BigTime";
/*-----------------------------------------------------------------*/
INIT_MODULE (FunctionName); /* initialize DEBUG facility */

TotalWindow (&wBigTime, 5, 18, 1, 78, BDR_DLNP, 1, 1,
"µ Another DSB Marvel Æ", TOPCENTER);

sw_popup (ON, &wBigTime); /* make pop up window */
sw_cleor (OFF, &wBigTime); /* disable clear eol function */
set_wn (&wBigTime); /* display window on screen */

mv_cs (4, 24, &wBigTime); /* colons in the time 99 : 99 */
v_ch ('\xDB', &wBigTime);
mv_cs (7, 24, &wBigTime);
v_ch ('\xDB', &wBigTime);
mv_cs (7, 49, &wBigTime); /* Am / Pm - the M */
v_ch ('M', &wBigTime);

TimeHour = 99; /* initialize hold time vars. */
TimeMin = 99; /* to trigger printing */
TimeSec = 99;

/*-----------------------------------------------------------------*/
while (! kbhit ()) {
time (&TimeSeconds); /* get amount of time */
TimeStruc = localtime (&TimeSeconds);


/* T I M E -----------------------------------------------------*/
if (TimeStruc->tm_hour > 11 && TimeStruc->tm_hour < 24) {
HTime = TimeStruc->tm_hour - 12;
PmTime = 1;
} else {
HTime = TimeStruc->tm_hour;
PmTime = 0;
}
if (HTime == 0) HTime = 12; /* adjust for 12:__:__ times */

/* H O U R S ---------------------------------------------------*/

if (TimeHour != HTime) { /* hour change? */
TimeHour = HTime;

if (TimeHour >= 10) {
Index1 = 10; /* tens digit */
Index2 = (TimeHour % 10) * 10; /* remainder is ones digit */
} else {
Index1 = 0;
Index2 = TimeHour * 10;
}
if (HourIndex1 != Index1) { /* display tens digit */
HourIndex1 = Index1;
DisplayNumber (Numbers, HourIndex1, 2);
}
if (HourIndex2 != Index2) { /* display ones digit */
HourIndex2 = Index2;
DisplayNumber (Numbers, HourIndex2, 13);
}

/* A M / P M ----------------------------------------------*/

mv_cs (4, 49, &wBigTime); /* only redisplay AmPm on an */
if (PmTime) /* hour change */
v_ch ('P', &wBigTime);
else
v_ch ('A', &wBigTime);
}

/* M I N U T E S -----------------------------------------------*/

if (TimeMin != TimeStruc->tm_min) { /* min. change? */
TimeMin = TimeStruc->tm_min;

if (TimeMin >= 10) {
Index1 = (TimeMin / 10) * 10; /* dividend is tens */
Index2 = (TimeMin % 10) * 10; /* remainder is ones */
} else {
Index1 = 0;
Index2 = TimeMin * 10;
}
if (MinIndex1 != Index1) { /* display tens digit */
MinIndex1 = Index1;
DisplayNumber (Numbers, MinIndex1, 27);
}
if (MinIndex2 != Index2) { /* display ones digit */
MinIndex2 = Index2;
DisplayNumber (Numbers, MinIndex2, 38);
}
}

/* S E C O N D S -----------------------------------------------*/

if (TimeSec != TimeStruc->tm_sec) { /* sec. change? */
TimeSec = TimeStruc->tm_sec;

if (TimeSec >= 10) {
Index1 = (TimeSec / 10) * 10; /* dividend is tens */
Index2 = (TimeSec % 10) * 10; /* remainder is ones */
} else {
Index1 = 0;
Index2 = TimeSec * 10;
}
if (SecIndex1 != Index1) { /* display tens digit */
SecIndex1 = Index1;
DisplayNumber (Numbers, SecIndex1, 52);
}
if (SecIndex2 != Index2) { /* display ones digit */
SecIndex2 = Index2;
DisplayNumber (Numbers, SecIndex2, 63);
}
}
} /* end while */

getch (); /* empty kbhit key */
unset_wn (&wBigTime);

EXIT_MODULE (FunctionName);
}


/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* DisplayNumber */
/* */
/* Will display the given number from Numbers array into wBigTime */
/* starting at WindowCol. 10 strings will be displayed vertically. */
/* */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

void DisplayNumber (char *Numbers[], int ArrayIndex, int SCol)

{
int SRow;
char *FunctionName = "DisplayNumber";
/*-----------------------------------------------------------------*/
INIT_MODULE (FunctionName); /* initialize DEBUG facility */

for (SRow = 1; SRow <= 10; SRow++) {
mv_cs (SRow, SCol, &wBigTime);
v_st (Numbers [ArrayIndex++], &wBigTime);
}

EXIT_MODULE (FunctionName);
}


/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/
/* TotalWindow */
/* Accepts all the necessary attributes of a window as to create */
/* it fresh without all the different calls to other functions. */
/* */
/* *WindowName, SRow, ERow, SCol, ECol, BType, */
/* RMargin, LMargin, *WindowTitle, TitlePlacement */
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------*/

void TotalWindow (WINDOW *WindowName, int SRow, int ERow,
int SCol, int ECol, BORDERPTR BType,
int RMargin, int LMargin,
char *WindowTitle, int TitlePlacement)

{
char *FunctionName = "TotalWindow";
/*-----------------------------------------------------------------*/
INIT_MODULE (FunctionName); /* initialize DEBUG facility */

def_wn (WindowName, SRow, ERow, SCol, ECol, RMargin, LMargin, BType);
sw_namelocation (TitlePlacement, WindowName);
sw_name (WindowTitle, WindowName);

EXIT_MODULE (FunctionName);
}