Category : Utilities for DOS and Windows Machines
Archive   : CDNTIMER.ZIP
Filename : CDNTIMER.CPP

 
Output of file : CDNTIMER.CPP contained in archive : CDNTIMER.ZIP
/****************************** BOARD GAME TIMER****************************
Full-featured "turn timer" Digital displays of time
for board games.
Also usable as cooking
darkroom timer, etc.
Low-time warning (optional)
Flashing "tick" indicator (optional)
****************************************************************************/


#include
#include
#include
#include
#include
#include
#include "oscr.hpp"
#include "bt.hpp"

void main()
{
randomize();
opening_screen();
play();
}

void CountdownTimer::clock_on()
{
time_t prev_sec;
int ch;

text_color = LIGHTRED;

settextstyle( TRIPLEX_FONT, HORIZ_DIR, 1 );
settextjustify( LEFT_TEXT, TOP_TEXT );

startn_t = time ( NULL ); //Click on stopwatch.
setcolor( BKGRND_COLOR );
outtextxy( NAME_POS, 100, "Press a key to reset timer" );
setcolor( LIGHTBLUE );
outtextxy( NAME_POS, 100, "Press a key to stop timer" );


settextstyle( TRIPLEX_FONT, HORIZ_DIR, 5 );
display_time(); //Otherwise initial time not displayed...

while( !( ch = kbhit() ) )
{
prev_sec = seconds;
interval_t = time( NULL ) - start_t;
running_t = total_seconds - interval_t;
convert( running_t );

if( seconds - prev_sec )
{
display_time();

if( !seconds )
if( minutes == warning )
if( !hours )
if( time_warning_flag )
blatt();

if( visual_ticking_flag ) // Show blinking box ticks?
{
setfillstyle( random ( PATTERNS ), random ( COLORS ) );
setcolor ( random ( COLORS ) );
setlinestyle( SOLID_LINE, 0xFFF, NORM_WIDTH );
bar( X_C - RADIUS, Y_C - RADIUS,
X_C + RADIUS, Y_C + RADIUS );
}
}

if( timeout() )
{
exit_();
reset_timer();

settextstyle( TRIPLEX_FONT, HORIZ_DIR, 5 );
display_time();
return; /*Move counter increments*/
}

}

ch = getch();
if( ch == ESC )
exit__(); // Quit.

running_flag = OFF; // Reset each time.
setcolor( BKGRND_COLOR );
settextstyle( TRIPLEX_FONT, HORIZ_DIR, 1 );
outtextxy( NAME_POS, 100, "Press a key to stop timer" );
setcolor( CYAN );
outtextxy( NAME_POS, 100, "Press a key to reset timer" );
ch = getch();
if( ch == ESC )
exit__(); // Quit.

reset_timer();

return;

}

void CountdownTimer::display_moves()
{
char buf[ 5 ];
static char ebuf[ 5 ];

if( moves > 1 )
{
setcolor( WHITE );
settextstyle( TRIPLEX_FONT, HORIZ_DIR, 1 );
settextjustify( CENTER_TEXT, TOP_TEXT );
outtextxy( MOVES_X, MOVES_Y, ebuf );
}

sprintf( buf, "%003d", moves );
sprintf( ebuf, buf );
setcolor( GREEN );
settextstyle( TRIPLEX_FONT, HORIZ_DIR, 1 );
settextjustify( CENTER_TEXT, TOP_TEXT );
outtextxy( MOVES_X, MOVES_Y, buf );

return;
}

void graphics_setup( int background_color )
{
int grdriver = VGA,
grmode = VGAHI;

registerfarbgidriver( EGAVGA_driver_far );
registerfarbgifont( gothic_font_far );
registerfarbgifont( triplex_font_far );
initgraph( &grdriver, &grmode, "" );
setbkcolor( background_color );

}

void exit__()
{
closegraph();
exit( QUIT );
}

/***************Routine to erase old numbers*************/
void CountdownTimer::erase_numbers()
{
setcolor ( WHITE );

if( seconds == 59 )
outtextxy( BLK_TIME, Y_TIMEPOS, line_clear );
else
if( seconds == 9 || seconds == 19 || seconds == 29
|| seconds == 39 || seconds == 49 )
outtextxy( BLK_TIME + POS1_OFFSET, Y_TIMEPOS,
line_clear + 6 );
else
outtextxy( BLK_TIME + POS_OFFSET, Y_TIMEPOS,
line_clear + 7 );

return;

}


void play()
{
int hrs,
min;
char inputstr[ MAXLEN ],
inp;

clrscr();

textcolor ( RED );
cprintf( "\n MINUTES: " );
gets( inputstr );
min = atoi( inputstr );
CountdownTimer t1( min );

textcolor( CYAN );
cprintf( "\n\n Enable flashing clock ticks? " );
inp = getche();
if( inp == 'y' || inp == 'Y' )
t1.visual_ticking_flag = ON;
else
t1.visual_ticking_flag = OFF;

cprintf( "\n Enable time warning? " );
inp = getche();
if( inp == 'y' || inp == 'Y' )
{
t1.time_warning_flag = ON;
cprintf( " At how many minutes? " );
gets( inputstr );
t1.warning = atoi( inputstr );
}
else
t1.time_warning_flag = OFF;

textcolor( YELLOW | BLINK );
_setcursortype( _NOCURSOR );
printf( "\n\n\n\n\n\n\n\n\n\n\n\n" );
cprintf( " PRESS A KEY TO BEGIN" );
while ( !getch() );

graphics_setup( WHITE );

settextjustify( CENTER_TEXT, CENTER_TEXT );
settextstyle( GOTHIC_FONT, HORIZ_DIR, 4 );
setcolor( LIGHTMAGENTA );
outtextxy( TOPX, TOPY - 30, title_msg ); /*******************/

settextstyle( TRIPLEX_FONT, HORIZ_DIR, 1 );
setcolor( LIGHTGREEN );
outtextxy( TOPX, TOPY + 20, esc_msg );


t1.initialize_clock();
t1.moves++;
t1.display_moves();
t1.clock_on();

while ( PLAY ) //Forever, until keypress
{
t1.moves++;
t1.display_moves();
t1.clock_on();
}

} // End play()


void opening_screen()
{
char topline[] = "Countdown Timer",
by_line[] = "by",
name_line[] = "M\\Cooper",
endline[] = "PRESS A KEY";

graphics_setup( LIGHTCYAN );
settextstyle( GOTHIC_FONT, HORIZ_DIR, HEADLINE_SIZE );
settextjustify( CENTER_TEXT, CENTER_TEXT );
setcolor( LIGHTRED );
outtextxy( TOPX, TOPY, topline );

settextstyle( TRIPLEX_FONT, HORIZ_DIR, BY_LINE_SIZE );
setcolor( BLUE );
outtextxy( BY_LINE_X, BY_LINE_Y, by_line );

setfillstyle( BAR_PATTERN, BAR_COLOR );
bar3d( BAR_LEFT, BAR_TOP, BAR_RIGHT, BAR_BOTTOM, BAR_DEPTH, BAR_TOPFLAG );

setfillstyle( PIE_PATTERN, PIE_COLOR );
pieslice( PIE1_X, PIE_Y, PIE_STARTANGLE, PIE_ENDANGLE, PIE_RADIUS );
// pieslice( PIE2_X, PIE_Y, PIE_STARTANGLE, PIE_ENDANGLE, PIE_RADIUS );
circle( PIE1_X, PIE_Y, CIRC_RAD );
// circle( PIE2_X, PIE_Y, CIRC_RAD );
setlinestyle( SOLID_LINE, 0xFFFF, THICK_WIDTH );
setcolor( LIGHTRED );
line( LINE1_X, LINE_Y1, LINE1_X, LINE_Y2 );
// line( LINE2_X, LINE_Y1, LINE2_X, LINE2_Y2 );
setfillstyle( PIE_PATTERN, WHITE );
bar( B1_LEFT, B1_TOP, B1_RIGHT, B_BOTTOM );
// bar( B2_LEFT, B2_TOP, B2_RIGHT, B_BOTTOM );


settextstyle( TRIPLEX_FONT, HORIZ_DIR, NAME_LINE_SIZE );
setcolor( BLUE );
outtextxy( NAME_LINE_X, NAME_LINE_Y, name_line );

sleep( DELAY );

settextstyle( TRIPLEX_FONT, HORIZ_DIR, ENDLINE_SIZE );
setcolor( RED );
outtextxy( ENDLINE_X, ENDLINE_Y, endline );

getch();
closegraph();

return;
}


void CountdownTimer::erase()
{
display_time();
setcolor( WHITE );
outtextxy( BLK_TIME, Y_TIMEPOS, line_clear ); /* Erase time display */

}

void CountdownTimer::reset_timer()
{
settextstyle( TRIPLEX_FONT, HORIZ_DIR, 5 );
erase();
convert ( total_seconds_mem ); /***RESET TIME*****/
initialize_clock();

return;

}

  3 Responses to “Category : Utilities for DOS and Windows Machines
Archive   : CDNTIMER.ZIP
Filename : CDNTIMER.CPP

  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/