home *** CD-ROM | disk | FTP | other *** search
/ ProfitPress Mega CDROM2 …eeware (MSDOS)(1992)(Eng) / ProfitPress-MegaCDROM2.B6I / DESQVIEW / TECH / DVA_TCPP.ZIP / DVA_TEST.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-08-06  |  7.9 KB  |  190 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. #include "dvaware.h"                    // desqview aware library
  35.  
  36.  
  37.  
  38. /***************************************************************************\
  39. *
  40. *  PROC win1 - goto the window in the upper left hand corner of the screen
  41. *              and display a line of random text.
  42. *
  43. \***************************************************************************/
  44.  
  45. void win1(                              // procedure
  46.    void                                 // no parameters
  47. ) {
  48.    int col;                             // column working on
  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 ( 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.    int col;                             // column working on
  71.  
  72.    window( 41, 2, 79, 24 );             // goto window
  73.    gotoxy( 39, 23 );                    // set cursor on bottom line
  74.    textattr( (RED << 4) | YELLOW );     // set window color
  75.    for ( col=1; col<=39; col++ ) {      // loop for a line of characters
  76.       char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
  77.       putch( c );                          // put the character to the screen
  78.    }                                    // end loop
  79. }
  80.  
  81.  
  82. /***************************************************************************\
  83. *
  84. *  PROC win3 - goto the window in the lower left corner of the screen and
  85. *              display a line of random text, scrolling the window down.
  86. *
  87. \***************************************************************************/
  88.  
  89.  
  90. void win3(                              // procedure
  91.    void                                 // no parameters
  92. ) {
  93.    int col;                             // column working on
  94.  
  95.    window( 2, 14, 38, 24 );             // goto window
  96.    gotoxy( 1, 1 );                      // set cursor on TOP line
  97.    textattr( (LIGHTGRAY << 4) | BLACK); // set window color
  98.    insline();                           // scroll the window down
  99.    for ( col=1; col<=37; col++ ) {      // loop for a line of characters
  100.       char c = (rand() % ('~'-' ')) + ' '; // get a random printable character
  101.       putch( c );                          // put the character to the screen
  102.    }                                    // end loop
  103. }
  104.  
  105.  
  106. /***************************************************************************\
  107. *
  108. *  PROC cntrpt - Count Report - Report the iteration count to the screen.
  109. *
  110. \***************************************************************************/
  111.  
  112. void cntrpt(                            // procedure
  113.    int cnt                              // count to report
  114. ) {
  115.    window( 70, 1, 80, 1 );              // small window on top line
  116.    gotoxy( 1, 1 );                      // ready the cursor
  117.    normvideo();                         // normal display attribute
  118.    cprintf( "%5i", cnt );               // print the count
  119. }
  120.  
  121.  
  122.  
  123. /***************************************************************************\
  124. *
  125. *  PROC resetscreen - Reset the screen back to normal defaults.
  126. *
  127. \***************************************************************************/
  128.  
  129. void resetscreen(
  130.    void
  131. ) {
  132.    window( 1, 1, 80, 25 );              // full screen window
  133.    gotoxy( 1, 25 );                     // cursor on bottom line
  134.    normvideo();                         // normal display attribute
  135. }
  136.  
  137.  
  138. /***************************************************************************\
  139. *****************************************************************************
  140. **
  141. **  Main line.
  142. **
  143. *****************************************************************************
  144. \***************************************************************************/
  145.  
  146. int main(                               // return errorlevel
  147.    void                                 // ignoring parameters
  148. ) {
  149.    int    cnt;                          // loop counter
  150.    time_t start;                        // timing start time
  151.    time_t end;                          // finish time
  152.  
  153.    time( &start );                      // get the starting time
  154.  
  155.    // Compile with different combinations of dv_conio() included and not, and
  156.    // directvideo=0 and not.  Then run under different settings of
  157.    // Writes text directly to screen & Virtualize text/graphics (Y,N,T)
  158.    // and compare the results.
  159.  
  160.    dv_conio();                          // make tc's conio DV aware
  161.    //directvideo = 0;                   // use BIOS instead of direct video
  162.  
  163.    clrscr();                            // clear the screen
  164.    for ( cnt=500; cnt; cnt-- ) {        // repeat 500 times for timing
  165.       win1();                              // display a line in 1st window
  166.       win2();                              // display a line in 2nd window
  167.       win3();                              // display a line in 3rd window
  168.       cntrpt( cnt );                       // report count so far
  169.       if ( kbhit() )                       // if user hit the keyboard
  170.          break;                               // break out of loop early
  171.       else                                 // otherwise no key hit
  172.          ;                                    // continue
  173.    }                                    // continue looping
  174.    if ( kbhit() )                       // if the user hit the keyboard
  175.       getch();                             // remove character from buffer
  176.    else                                 // otherwise looped the 500 times
  177.       ;                                    // continue
  178.  
  179.    resetscreen();                       // restore screen defaults
  180.  
  181.    time( &end );                        // get the finish time
  182.    cprintf( "Elapsed time: %u sec.",    // report the time elapsed
  183.             end - start );                 // the time elapsed
  184.  
  185.    return 0;                            // return w/ no error condition
  186. }
  187.  
  188. // END DVA_TEST.C
  189. 
  190.