home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / DESQVIEW / TECH / DVA_TCPP.ZIP / DVA_TEST.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-06  |  7.8 KB  |  183 lines

  1. /***************************************************************************\
  2. *
  3. *
  4. *   PROGRAM           - DESQview Aware Test
  5. *
  6. *   PURPOSE           - A sample program to test the DVAWARE library
  7. *
  8. *   GENERAL ALGORITHM - Use the DVAWARE library to make the TC CONIO library
  9. *                       DESQview aware.  Using the CONIO library, display
  10. *                       three different windows with scrolling random text.
  11. *                       After several iterations, terminate with the time
  12. *                       taken.
  13. *
  14. *   INPUT             - Keystroke to terminate the program early.
  15. *
  16. *   OUTPUT            - The three windows of random text, and the total time
  17. *                       taken.
  18. *
  19. *   SYSTEM            - Borland's Turbo C++ v1.0 on an EPSON EQUITY III+
  20. *                       running MS-DOS v4.01 & DESQview v2.26.  Should
  21. *                       operate under any MS/PC-DOS 2.x or greater &
  22. *                       DESQview 2.x or greater.  Unknown if it will work
  23. *                       under any version of TC++ greater than 1.0.
  24. *
  25. *   HISTORY:
  26. *      90-07-31       - Initiated Mark Potter
  27. *
  28. \***************************************************************************/
  29.  
  30. #include <conio.h>                      // console I/O routines, inc window
  31. #include <stdlib.h>                     // needed for rand function
  32. #include <time.h>                       // timing functions.
  33.  
  34. //#define DVAWARE_INLINE                // uncomment to make DVAWARE inline 
  35.                                            // functions
  36. #include "dvaware.h"                    // desqview aware library
  37.  
  38.  
  39.  
  40. /***************************************************************************\
  41. *
  42. *  PROC win1 - goto the window in the upper left hand corner of the screen
  43. *              and display a line of random text.
  44. *
  45. \***************************************************************************/
  46.  
  47. void win1(                              // procedure
  48.    void                                 // no parameters
  49. ) {
  50.    window( 2, 2, 38, 12 );              // goto window
  51.    gotoxy( 37, 11 );                    // set cursor on bottom line
  52.    textattr( (BLUE << 4) | WHITE );     // set window color
  53.    for ( int col=1; col<=37; col++ ) {  // loop for a line of characters
  54.       char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
  55.       putch( c );                          // put the character to the screen
  56.    }                                    // end loop
  57. }
  58.  
  59.  
  60. /***************************************************************************\
  61. *
  62. *  PROC win2 - goto the window in the right side of the screen and display a
  63. *              line of random text.
  64. *
  65. \***************************************************************************/
  66.  
  67. void win2(                              // procedure
  68.    void                                 // no parameters
  69. ) {
  70.    window( 41, 2, 79, 24 );             // goto window
  71.    gotoxy( 39, 23 );                    // set cursor on bottom line
  72.    textattr( (RED << 4) | YELLOW );     // set window color
  73.    for ( int col=1; col<=39; col++ ) {  // loop for a line of characters
  74.       char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
  75.       putch( c );                          // put the character to the screen
  76.    }                                    // end loop
  77. }
  78.  
  79.  
  80. /***************************************************************************\
  81. *
  82. *  PROC win3 - goto the window in the lower left corner of the screen and
  83. *              display a line of random text, scrolling the window down.
  84. *
  85. \***************************************************************************/
  86.  
  87.  
  88. void win3(                              // procedure
  89.    void                                 // no parameters
  90. ) {
  91.    window( 2, 14, 38, 24 );             // goto window
  92.    gotoxy( 1, 1 );                      // set cursor on TOP line
  93.    textattr( (LIGHTGRAY << 4) | BLACK); // set window color
  94.    insline();                           // scroll the window down
  95.    for ( int col=1; col<=37; col++ ) {  // loop for a line of characters
  96.       char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
  97.       putch( c );                          // put the character to the screen
  98.    }                                    // end loop
  99. }
  100.  
  101.  
  102. /***************************************************************************\
  103. *
  104. *  PROC cntrpt - Count Report - Report the iteration count to the screen.
  105. *
  106. \***************************************************************************/
  107.  
  108. void cntrpt(                            // procedure
  109.    int cnt                              // count to report
  110. ) {
  111.    window( 70, 1, 80, 1 );              // small window on top line
  112.    gotoxy( 1, 1 );                      // ready the cursor
  113.    normvideo();                         // normal display attribute
  114.    cprintf( "%5i", cnt );               // print the count
  115. }
  116.  
  117.  
  118.  
  119. /***************************************************************************\
  120. *
  121. *  PROC resetscreen - Reset the screen back to normal defaults.
  122. *
  123. \***************************************************************************/
  124.  
  125. void resetscreen(
  126.    void
  127. ) {
  128.    window( 1, 1, 80, 25 );              // full screen window
  129.    gotoxy( 1, 25 );                     // cursor on bottom line
  130.    normvideo();                         // normal display attribute
  131. }
  132.  
  133.  
  134. /***************************************************************************\
  135. *****************************************************************************
  136. **
  137. **  Main line.
  138. **
  139. *****************************************************************************
  140. \***************************************************************************/
  141.  
  142. int main(                               // return errorlevel
  143.    void                                 // ignoring parameters
  144. ) {
  145.    time_t start;                        // timing start time
  146.    time( &start );                      // get the starting time
  147.  
  148.    // Compile with different combinations of dv_conio() included and not, and
  149.    // directvideo=0 and not.  Then run under different settings of
  150.    // Writes text directly to screen & Virtualize text/graphics (Y,N,T)
  151.    // and compare the results.
  152.  
  153.    dv_conio();                          // make tc's conio DV aware
  154.    //directvideo = 0;                   // use BIOS instead of direct video
  155.  
  156.    clrscr();                            // clear the screen
  157.    for ( int cnt=500; cnt; cnt-- ) {    // repeat 500 times for timing
  158.       win1();                              // display a line in 1st window
  159.       win2();                              // display a line in 2nd window
  160.       win3();                              // display a line in 3rd window
  161.       cntrpt( cnt );                       // report count so far
  162.       if ( kbhit() )                       // if user hit the keyboard
  163.          break;                               // break out of loop early
  164.       else                                 // otherwise no key hit
  165.          ;                                    // continue
  166.    }                                    // continue looping
  167.    if ( kbhit() )                       // if the user hit the keyboard
  168.       getch();                             // remove character from buffer
  169.    else                                 // otherwise looped the 500 times
  170.       ;                                    // continue
  171.  
  172.    resetscreen();                       // restore screen defaults
  173.  
  174.    time_t end;                          // the finish time
  175.    time( &end );                        // get the finish time
  176.    cprintf( "Elapsed time: %u sec.",    // report the time elapsed
  177.             end - start );                 // the time elapsed
  178.  
  179.    return 0;                            // return w/ no error condition
  180. }
  181.  
  182. // END DVA_TEST.CPP
  183.