home *** CD-ROM | disk | FTP | other *** search
- /***************************************************************************\
- *
- *
- * PROGRAM - DESQview Aware Test
- *
- * PURPOSE - A sample program to test the DVAWARE library
- *
- * GENERAL ALGORITHM - Use the DVAWARE library to make the TC CONIO library
- * DESQview aware. Using the CONIO library, display
- * three different windows with scrolling random text.
- * After several iterations, terminate with the time
- * taken.
- *
- * INPUT - Keystroke to terminate the program early.
- *
- * OUTPUT - The three windows of random text, and the total time
- * taken.
- *
- * SYSTEM - Borland's Turbo C++ v1.0 on an EPSON EQUITY III+
- * running MS-DOS v4.01 & DESQview v2.26. Should
- * operate under any MS/PC-DOS 2.x or greater &
- * DESQview 2.x or greater. Unknown if it will work
- * under any version of TC++ greater than 1.0.
- *
- * HISTORY:
- * 90-07-31 - Initiated Mark Potter
- *
- \***************************************************************************/
-
- #include <conio.h> // console I/O routines, inc window
- #include <stdlib.h> // needed for rand function
- #include <time.h> // timing functions.
-
- #include "dvaware.h" // desqview aware library
-
-
-
- /***************************************************************************\
- *
- * PROC win1 - goto the window in the upper left hand corner of the screen
- * and display a line of random text.
- *
- \***************************************************************************/
-
- void win1( // procedure
- void // no parameters
- ) {
- int col; // column working on
-
- window( 2, 2, 38, 12 ); // goto window
- gotoxy( 37, 11 ); // set cursor on bottom line
- textattr( (BLUE << 4) | WHITE ); // set window color
- for ( col=1; col<=37; col++ ) { // loop for a line of characters
- char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
- putch( c ); // put the character to the screen
- } // end loop
- }
-
-
- /***************************************************************************\
- *
- * PROC win2 - goto the window in the right side of the screen and display a
- * line of random text.
- *
- \***************************************************************************/
-
- void win2( // procedure
- void // no parameters
- ) {
- int col; // column working on
-
- window( 41, 2, 79, 24 ); // goto window
- gotoxy( 39, 23 ); // set cursor on bottom line
- textattr( (RED << 4) | YELLOW ); // set window color
- for ( col=1; col<=39; col++ ) { // loop for a line of characters
- char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
- putch( c ); // put the character to the screen
- } // end loop
- }
-
-
- /***************************************************************************\
- *
- * PROC win3 - goto the window in the lower left corner of the screen and
- * display a line of random text, scrolling the window down.
- *
- \***************************************************************************/
-
-
- void win3( // procedure
- void // no parameters
- ) {
- int col; // column working on
-
- window( 2, 14, 38, 24 ); // goto window
- gotoxy( 1, 1 ); // set cursor on TOP line
- textattr( (LIGHTGRAY << 4) | BLACK); // set window color
- insline(); // scroll the window down
- for ( col=1; col<=37; col++ ) { // loop for a line of characters
- char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
- putch( c ); // put the character to the screen
- } // end loop
- }
-
-
- /***************************************************************************\
- *
- * PROC cntrpt - Count Report - Report the iteration count to the screen.
- *
- \***************************************************************************/
-
- void cntrpt( // procedure
- int cnt // count to report
- ) {
- window( 70, 1, 80, 1 ); // small window on top line
- gotoxy( 1, 1 ); // ready the cursor
- normvideo(); // normal display attribute
- cprintf( "%5i", cnt ); // print the count
- }
-
-
-
- /***************************************************************************\
- *
- * PROC resetscreen - Reset the screen back to normal defaults.
- *
- \***************************************************************************/
-
- void resetscreen(
- void
- ) {
- window( 1, 1, 80, 25 ); // full screen window
- gotoxy( 1, 25 ); // cursor on bottom line
- normvideo(); // normal display attribute
- }
-
-
- /***************************************************************************\
- *****************************************************************************
- **
- ** Main line.
- **
- *****************************************************************************
- \***************************************************************************/
-
- int main( // return errorlevel
- void // ignoring parameters
- ) {
- int cnt; // loop counter
- time_t start; // timing start time
- time_t end; // finish time
-
- time( &start ); // get the starting time
-
- // Compile with different combinations of dv_conio() included and not, and
- // directvideo=0 and not. Then run under different settings of
- // Writes text directly to screen & Virtualize text/graphics (Y,N,T)
- // and compare the results.
-
- dv_conio(); // make tc's conio DV aware
- //directvideo = 0; // use BIOS instead of direct video
-
- clrscr(); // clear the screen
- for ( cnt=500; cnt; cnt-- ) { // repeat 500 times for timing
- win1(); // display a line in 1st window
- win2(); // display a line in 2nd window
- win3(); // display a line in 3rd window
- cntrpt( cnt ); // report count so far
- if ( kbhit() ) // if user hit the keyboard
- break; // break out of loop early
- else // otherwise no key hit
- ; // continue
- } // continue looping
- if ( kbhit() ) // if the user hit the keyboard
- getch(); // remove character from buffer
- else // otherwise looped the 500 times
- ; // continue
-
- resetscreen(); // restore screen defaults
-
- time( &end ); // get the finish time
- cprintf( "Elapsed time: %u sec.", // report the time elapsed
- end - start ); // the time elapsed
-
- return 0; // return w/ no error condition
- }
-
- // END DVA_TEST.C
-