home *** CD-ROM | disk | FTP | other *** search
/ Mega CD-ROM 1 / megacd_rom_1.zip / megacd_rom_1 / DESQVIEW / DESQC20.ZIP / DESQQWIK.C < prev    next >
Text File  |  1988-12-03  |  5KB  |  125 lines

  1. /*==========================================================================*\
  2.  | DESQQWIK.C                                             ver 2.0, 12-03-88 |
  3.  |                                                                          |
  4.  | Demo for DESQview interface routines and the use 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.  |       QWIKC20.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 "desqc20.h"
  41. #include "qwikc20.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. /********************************| htoa |************************************\
  52. Converts a long to a string.  The target string contains the long in
  53. hexadecimal form, i.e. "21CF89A5".
  54. The parameter hcnt specifies the amount of characters the target
  55. string should contain.
  56. The return value is a pointer to the target string.
  57. \****************************************************************************/
  58. char *htoa( long val, char hcnt, char *string )
  59. {
  60.     if(hcnt > 4)
  61.         sprintf( string, "0x%*lX", hcnt, val );
  62.     else
  63.     if(hcnt > 2)
  64.         sprintf( string, "0x%0*X", hcnt, (int) val );
  65.     else
  66.     if(hcnt <= 2)
  67.         sprintf( string, "0x%0*hX", hcnt, (unsigned char) val );
  68.  
  69.     return(string);
  70. }
  71.  
  72.  
  73. void clearscr(int attrib)
  74. {
  75.     qfill( 1, 1, crt_rows, crt_cols, attrib, ' ');
  76. }
  77.  
  78.  
  79. void main()
  80. {
  81.     qinit();
  82.  
  83.     page0seg=dv_get_video_buffer(page0seg);   /* Base of video segment */
  84.     qscrseg=page0seg;                         /* Segment for QWIKC writing */
  85.     dv_version=dv_get_version();              /* Optional */
  86.  
  87.     if(!in_dv) {
  88.         clearscr(LIGHTGRAY);
  89.         qwrite( 1, 1, SAMEATTR, "DESQview not active" );
  90.         gotorc( 2, 1 );
  91.     } else {
  92.         /* QWIKC uses FAR pointers for the screen base.  DESQview only
  93.            changes the segment and is therefore paragraph aligned (meaning the
  94.            offset is always 0).  Since dv_get_video_buffer does not work with
  95.            the offset, DESQview assumes it to be zero for the screen base.
  96.         */
  97.  
  98.         qscrofs = 0;            /* Screen base offset */
  99.         qsnow = 0;
  100.         clearscr(SAMEATTR);
  101.         qwrite( 1, 1, SAMEATTR, "DESQview version = " );
  102.         sprintf( str, "%4.2f", (float) (HI_INT(dv_version) +
  103.                  (float) LO_INT(dv_version) / 100 ) );
  104.         qwriteeos( SAMEATTR, str );
  105.         qwrite( 2, 1, SAMEATTR, "Video Segment = " );
  106.         qwriteeos( SAMEATTR, htoa( page0seg, 4, str ) );
  107.         qwrite( 3, 1, SAMEATTR, "First character in row 1 is = " );
  108.         sprintf( str, "%c", peekb( page0seg, 0 ) );
  109.         qwriteeos( SAMEATTR, str );
  110.         qwrite( 4, 1, SAMEATTR, "All windows should now freeze "
  111.                                 "for 3 seconds" );
  112.         gotorc( 5, 1 );
  113.         delay(1000);
  114.         dv_begin_critical();
  115.         delay(3000);
  116.         dv_end_critical();
  117.         qwrite( 5, 1, SAMEATTR, "Now all windows will continue." );
  118.         qwrite( 6, 1, SAMEATTR, "Test completed.  Scroll back "
  119.                                 "to see row 1." );
  120.         gotorc( 7, 1 );
  121.     }
  122.  
  123.     exit(0);
  124. }
  125.