home *** CD-ROM | disk | FTP | other *** search
/ World of Shareware - Software Farm 2 / wosw_2.zip / wosw_2 / CPROG / DESQC21.ZIP / DESQDEMO.C < prev    next >
Text File  |  1989-07-06  |  5KB  |  137 lines

  1. /*==========================================================================*\
  2. | DESQDEMO.C                                               ver 2.1, 07-06-89 |
  3. |                                                                            |
  4. | Demo for DESQview interface routines                                       |
  5. |                                                                            |
  6. | It is assumed that you are an operator of DESQview and that you are        |
  7. | familiar with its operation.                                               |
  8. |                                                                            |
  9. |  TO TEST:                                                                  |
  10. |    1. Build the project file DESQDEMO.PRJ.                                 |
  11. |    2. Build the project file DESQLOOP.PRJ.                                 |
  12. |    3. Add these programs to DV with Direct video = "N".                    |
  13. |    4. Run DESQloop in one or more windows, say 1 and 2.                    |
  14. |    5. Run this program in another one, say 3.                              |
  15. |    6. Observe results.                                                     |
  16. |                                                                            |
  17. |  TO USE:                                                                   |
  18. |    1. Follow instruction provided by DESQview.                             |
  19. |    2. For high speed buffer writing to a DESQview window, use              |
  20. |       QWIKC21.ARC.                                                         |
  21. |                                                                            |
  22. |  by  James H. LeMay                                                        |
  23. |                                                                            |
  24. | converted to Turbo C by                                                    |
  25. |     Jordan Gallagher                                                       |
  26. | for Eagle Performance Software                                             |
  27. |     TC Products                                                            |
  28. |     P.O. Box 292786                                                        |
  29. |     Lewisville, TX  75029-2786                                             |
  30. |                                                                            |
  31. | Conversion to Turbo C by Jordan Gallagher / Wisdom Research                |
  32. \*==========================================================================*/
  33.  
  34. #include <stdio.h>
  35. #include <conio.h>
  36. #include <string.h>
  37. #include <dos.h>
  38. #include <process.h>
  39. #ifndef __TURBOC__
  40. #include <graph.h>
  41. #endif
  42.  
  43. #include "desqc21.h"
  44.  
  45. #define LO_CHAR(v) (v & 0x0f)
  46. #define HI_CHAR(v) (v >> 4)
  47. #define LO_INT(v) (v & 0xff)
  48. #define HI_INT(v) (v >> 8)
  49.  
  50. unsigned videoseg;
  51. int dv_version;
  52. char str[30];
  53. char _z;
  54.  
  55. #define tclock (*(long far *)(0x46CL+_z))
  56. #define videomode (*(long far *)(0x449L+_z))
  57.  
  58. /********************************| htoa |************************************\
  59. Converts a long to a string.  The target string contains the long in
  60. hexadecimal form, i.e. "21CF89A5".
  61. The parameter hcnt specifies the amount of characters the target
  62. string should contain.
  63. The return value is a pointer to the target string.
  64. \****************************************************************************/
  65. char *htoa( long val, char hcnt, char *string )
  66. {
  67.     if(hcnt > 4)
  68.         sprintf( string, "0x%*lX", hcnt, val );
  69.     else
  70.     if(hcnt > 2)
  71.         sprintf( string, "0x%0*X", hcnt, (int) val );
  72.     else
  73.     if(hcnt <= 2)
  74.         sprintf( string, "0x%0*hX", hcnt, (unsigned char) val );
  75.  
  76.     return(string);
  77. }
  78.  
  79.  
  80. void suspend(unsigned ms)
  81. {
  82.     long st=tclock;
  83.     while(tclock-st < 18*(ms/1000));
  84. }
  85.  
  86.  
  87. void main()
  88. {
  89. #ifdef __TURBOC__
  90.     directvideo=0;                /* use BIOS writes */
  91. #endif
  92.  
  93.     if(videomode == 7) {         /* set to mono or color segment */
  94.         videoseg=0xB000;
  95.     } else {
  96.         videoseg=0xB800;
  97.     }
  98.  
  99.     videoseg=dv_get_video_buffer( videoseg );
  100.     dv_version=dv_get_version();   /* Optional */
  101.  
  102. #ifdef __TURBOC__
  103.     clrscr();
  104. #else
  105.     _clearscreen(_GCLEARSCREEN);
  106. #endif
  107.  
  108.     if(!in_dv) {
  109.         printf( "DESQview not active\n" );
  110.     } else {
  111.         sprintf( str, "%4.2f", (float) (HI_INT(dv_version) +
  112.                  (float) LO_INT(dv_version) / 100 ) );
  113.         printf( "DESQview version = %s\n", str );
  114.         printf( "Video Segment = %s\n", htoa( (long) videoseg, 4, str ) );
  115.         printf( "First character in row 1 is = %c\n",
  116.                 *((unsigned char far *)(((unsigned long)videoseg)<<16)) );
  117.         printf( "All windows should now freeze for 3 seconds\n" );
  118. #ifdef __TURBOC__
  119.         delay(1000);
  120. #else
  121.         suspend(1000);
  122. #endif
  123.         dv_begin_critical();
  124. #ifdef __TURBOC__
  125.         delay(3000);
  126. #else
  127.         suspend(3000);
  128. #endif
  129.         dv_end_critical();
  130.         printf( "Now all windows will continue.\n" );
  131.         printf( "Test completed.  Scroll back to see row 1." );
  132.     }
  133.  
  134.     return;
  135. }
  136.  
  137.