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

  1. /*==========================================================================*\
  2. | DESQQWIK.C                                               ver 2.1, 07-06-89 |
  3. |                                                                            |
  4. | Demo for DESQview interface routines and the use of QWIKC                  |
  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 DESQQWIK.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.  
  40. #include "desqc21.h"
  41. #include "qwikc21.h"
  42.  
  43. #define LO_CHAR(v) (v & 0x0f)
  44. #define HI_CHAR(v) (v >> 4)
  45. #define LO_INT(v) (v & 0xff)
  46. #define HI_INT(v) (v >> 8)
  47.  
  48. int dv_version;
  49. char str[90];
  50.  
  51. #define tclock (*(long far *)(0x46CL+_z))
  52.  
  53. /********************************| htoa |************************************\
  54. Converts a long to a string.  The target string contains the long in
  55. hexadecimal form, i.e. "21CF89A5".
  56. The parameter hcnt specifies the amount of characters the target
  57. string should contain.
  58. The return value is a pointer to the target string.
  59. \****************************************************************************/
  60. char *htoa( long val, char hcnt, char *string )
  61. {
  62.     if(hcnt > 4)
  63.         sprintf( string, "0x%*lX", hcnt, val );
  64.     else
  65.     if(hcnt > 2)
  66.         sprintf( string, "0x%0*X", hcnt, (int) val );
  67.     else
  68.     if(hcnt <= 2)
  69.         sprintf( string, "0x%0*hX", hcnt, (unsigned char) val );
  70.  
  71.     return(string);
  72. }
  73.  
  74.  
  75. void clearscr(int attrib)
  76. {
  77.     qfill( 1, 1, crt_rows, crt_cols, attrib, ' ');
  78. }
  79.  
  80.  
  81. void suspend(unsigned ms)
  82. {
  83.     long st=tclock;
  84.     while(tclock-st < 18*(ms/1000));
  85. }
  86.  
  87.  
  88. void main()
  89. {
  90.     qinit();
  91.  
  92.     page0seg=dv_get_video_buffer(page0seg);   /* Base of video segment */
  93.     qscrseg=page0seg;                         /* Segment for QWIKC writing */
  94.     dv_version=dv_get_version();              /* Optional */
  95.  
  96.     if(!in_dv) {
  97.         clearscr(LIGHTGRAY);
  98.         qwrite( 1, 1, SAMEATTR, "DESQview not active" );
  99.         gotorc( 2, 1 );
  100.     } else {
  101.         /* QWIKC uses FAR pointers for the screen base.  DESQview only
  102.            changes the segment and is therefore paragraph aligned (meaning the
  103.            offset is always 0).  Since dv_get_video_buffer does not work with
  104.            the offset, DESQview assumes it to be zero for the screen base.
  105.         */
  106.  
  107.         qscrofs = 0;            /* Screen base offset */
  108.         qsnow = 0;
  109.         clearscr(SAMEATTR);
  110.         qwrite( 1, 1, SAMEATTR, "DESQview version = " );
  111.         sprintf( str, "%4.2f", (float) (HI_INT(dv_version) +
  112.                  (float) LO_INT(dv_version) / 100 ) );
  113.         qwriteeos( SAMEATTR, str );
  114.         qwrite( 2, 1, SAMEATTR, "Video Segment = " );
  115.         qwriteeos( SAMEATTR, htoa( (long) page0seg, 4, str ) );
  116.         qwrite( 3, 1, SAMEATTR, "First character in row 1 is = " );
  117.         sprintf( str, "%c",
  118.                  *((unsigned char far *)(((unsigned long)page0seg)<<16)) );
  119.         qwriteeos( SAMEATTR, str );
  120.         qwrite( 4, 1, SAMEATTR, "All windows should now freeze "
  121.                                 "for 3 seconds" );
  122.         gotorc( 5, 1 );
  123. #ifdef __TURBOC__
  124.         delay(1000);
  125. #else
  126.         suspend(1000);
  127. #endif
  128.         dv_begin_critical();
  129. #ifdef __TURBOC__
  130.         delay(3000);
  131. #else
  132.         suspend(3000);
  133. #endif
  134.         dv_end_critical();
  135.         qwrite( 5, 1, SAMEATTR, "Now all windows will continue." );
  136.         qwrite( 6, 1, SAMEATTR, "Test completed.  Scroll back "
  137.                                 "to see row 1." );
  138.         gotorc( 7, 1 );
  139.     }
  140.  
  141.     exit(0);
  142. }
  143.