home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / c / quikc21.zip / QWIKDEMO.C < prev    next >
Text File  |  1989-07-06  |  34KB  |  1,082 lines

  1. /*===========================================================================*\
  2. | QWIKDEMO.C                                                ver 2.1, 07-06-89 |
  3. |                                                                             |
  4. | Demo has been programmed best for color cards in 25-line mode.              |
  5. | Do not terminate this program manually.                                     |                                             |
  6. |                                                                             |
  7. |  Copyright (c) 1988,1989 by James H. LeMay, All rights reserved.            |
  8. |                                                                             |
  9. |  Conversion to C by Jordan Gallagher / Wisdom Research                      |
  10. \*===========================================================================*/
  11.  
  12. #include <stdio.h>
  13. #include <conio.h>
  14. #include <stdlib.h>
  15. #include <string.h>
  16. #include <time.h>
  17. #include <dos.h>
  18. #include <math.h>
  19.  
  20. #include "qwikc21.h"
  21.  
  22. char ch;
  23. char lastmode;
  24. char step, colmax;
  25. char blkrow, blkcol, v;
  26. char numstr[80];
  27. char coll[3], colr[3];
  28. char saved_block[4000], popup_block[4000];
  29. int  brdrattr, wndwattr;
  30. int  i, count, fgrnd, bgrnd;
  31. long rnum;
  32.  
  33. char strng[40]={ " Q Screen Utilities " };
  34. char strng2[40]={ " QWIKC Screen Utilities  " };
  35. char data[9][40]=
  36. { "1", "22", "333", " Q Screen Utilities ", "Odd  Length", "Even  Length",
  37.   "18 characters wide", "19 characters width", "Margin to Margin width" };
  38. char pc[14][80]=
  39. { "COMPUTERS:           ADAPTERS:",
  40.   "------------------   ----------",
  41.   "IBM PC               MDA",
  42.   "IBM XT               CGA",
  43.   "IBM AT               EGA",
  44.   "IBM PCjr             MCGA",
  45.   "IBM PC Convertible   VGA",
  46.   "IBM PS/2 Model 25    8514/A",
  47.   "IBM PS/2 Model 30    Hercules:",
  48.   "IBM PS/2 Model 50      HGC",
  49.   "IBM PS/2 Model 60      HGC Plus",
  50.   "IBM PS/2 Model 70      InColor",
  51.   "IBM PS/2 Model 80",
  52.   "IBM 3270 PC" };
  53. char other[12][80]=
  54. { "qscrollup  - Qwik scroll up",
  55.   "qscrolldown- Qwik scroll down",
  56.   "qscrtovscr - block to virtual screen",
  57.   "qvscrtoscr - virtual screen to block",
  58.   "qreadstr   - reads string from screen",
  59.   "qreadchar  - reads char   from screen",
  60.   "qreadattr  - reads attr   from screen",
  61.   "qviewpage  - view any video page",
  62.   "qwritepage - write to any video page",
  63.   "qwrite_sub - for arrays/partial strings",
  64.   "qfillc     - a self-centering qfill",
  65.   "qattrc     - a self-centering qattr" };
  66. char crsr[12][80]=
  67. { "gotorc        - absolute cursor position",
  68.   "wherer        - absolute cursor row",
  69.   "wherec        - absolute cursor column",
  70.   "setcursor     - sets cursor mode",
  71.   "getcursor     - gets cursor mode",
  72.   "modcursor     - modifies cursor mode",
  73.   "cursor_initial   - cursor at startup",
  74.   "cursor_underline - normal cursor",
  75.   "cursor_halfblock - for insert editing",
  76.   "cursor_block     - for the nearsighted",
  77.   "A total of 41 utilities",
  78.   "optimizing in just 2.7k bytes or less!" };
  79. char init[10][80]=
  80. { "∙ Detects dual monitor/adapters for all",
  81.   "  systems listed on the previous page",
  82.   "∙ Identifies each system by name",
  83.   "∙ Gets system ID and submodel ID",
  84.   "∙ Gets CPU ID",
  85.   "∙ Sets far pointer for virtual screens",
  86.   "∙ Determines need for wait-for-retrace",
  87.   "∙ Gets screen dimensions: rows by cols",
  88.   "∙ Determines the number of video pages",
  89.   "∙ Sets 4 standard cursor shapes" };
  90. char eoss[4][80]=
  91. { " ∙ qwriteeos     - just like qwrite     ",
  92.   " ∙ qwriteeos_sub - just like qwrite_sub ",
  93.   " ∙ qfilleos      - just like qfill      ",
  94.   " ∙ qattreos      - just like qattr      " };
  95.  
  96. int wait=400;
  97. struct border_t {
  98.     char TL[2];
  99.     char TH[2];
  100.     char TR[2];
  101.     char LV[2];
  102.     char RV[2];
  103.     char BL[2];
  104.     char BH[2];
  105.     char BR[2];
  106. } border = { "╔", "═", "╗", "║", "║", "╚", "═", "╝" };
  107.  
  108. char bwcolors[4]={ BLACK, LIGHTGRAY, WHITE, LIGHTGRAY_BG };
  109.  
  110. #ifndef __TURBOC__
  111. union REGS mr;
  112. #define disable _disable
  113. #define enable _enable
  114. #define random(num)     (rand() % (num))
  115. #define randomize()     srand((unsigned)time(NULL))
  116. #define textmode(m)     { mr.h.ah=0; mr.h.al=m; int86(0x10,&mr,&mr); }
  117. #endif
  118.  
  119. #ifdef __TURBOC__
  120. #define tclock() (*(long far *)0x46CL)
  121. #else
  122. #define tclock() (*(long far *)(0x46CL+_z))
  123. #endif
  124.  
  125.  
  126. /******************************| check_zenith |*****************************\
  127. Since Zenith doesn't have snow on any CGAs, turn off snow checking.
  128. \***************************************************************************/
  129. void check_zenith(void)
  130. {
  131.     char tmp[10];
  132.  
  133.     movedata( 0xF000u, 0x800Cu, (unsigned)(((char far *)tmp)+1),
  134.                                 (unsigned)((char far *)tmp),     8 );
  135.     if(qsnow && (strncmp( tmp, "ZDS CORP", 8 )) == 0) {
  136.         qsnow=0;
  137.         cardsnow=0;
  138.     }
  139. }
  140.  
  141.  
  142. /******************************| closedemo |********************************\
  143. Exits the demo.
  144. \***************************************************************************/
  145. void closedemo(void)
  146. {
  147.     if(qvideo_mode <= C40) {
  148. #ifdef __TURBOC__
  149.         delay( wait*6 );
  150. #else
  151.         suspend( wait*6 );
  152. #endif
  153.         textmode( lastmode );
  154.     }
  155.  
  156.     gotorc( 24, 1 );
  157.  
  158.     setcursor( cursor_initial );
  159. }
  160.  
  161.  
  162. /*********************************| qbox |**********************************\
  163. qbox is an application of QWIKC Screen Utilities.  It can make fast
  164. pop-up menus.  See WNDWxx.ARC for more applications.
  165. \***************************************************************************/
  166. void qbox( char row, char col, char rows, char cols, int wndwattr,
  167.            int brdrattr, struct border_t *b )
  168. {
  169.     if(rows >=2 && cols >=2) {
  170.         qwrite(   row,        col,                        brdrattr, b->TL );
  171.         qfilleos(                         1,      cols-2, brdrattr, b->TH[0] );
  172.         qwriteeos(                                        brdrattr, b->TR );
  173.         qfill(    row+1,      col,        rows-2, 1,      brdrattr, b->LV[0] );
  174.         qfill(    row+1,      col+cols-1, rows-2, 1,      brdrattr, b->RV[0] );
  175.         qwrite(   row+rows-1, col,                        brdrattr, b->BL );
  176.         qfilleos(                         1,      cols-2, brdrattr, b->BH[0] );
  177.         qwriteeos(                                        brdrattr, b->BR );
  178.         qfill(    row+1,      col+1,      rows-2, cols-2, wndwattr, ' '  );
  179.     }
  180. }
  181.  
  182.  
  183. /********************************| waitkey |********************************\
  184. Displays a prompt and awaits a keypress.
  185. \***************************************************************************/
  186. void waitkey(void)
  187. {
  188.     qwrite( 25, crt_cols-19, SAMEATTR, "press any key ..." );
  189.     if( (ch=getch()) == 0 ) ch=getch();
  190.     else if(ch==27) {
  191.         closedemo();
  192.         exit(0);
  193.     }
  194. }
  195.  
  196.  
  197. /*******************************| clearscr |********************************\
  198. Clears the screen using the specified attribute.
  199. \***************************************************************************/
  200. void clearscr( int attr )
  201. {
  202.     qfill( 1, 1, crt_rows, crt_cols, attr, ' ' );
  203. }
  204.  
  205.  
  206. /*******************************| scatter |*********************************\
  207. Displays random boxes on the screen.
  208. \***************************************************************************/
  209. void scatter( char maxrows, char leftcol, char rightcol,
  210.               char botrow, char toprow )
  211. {
  212.     int a;
  213.     char row, col, rows, cols;
  214.  
  215.     rows=random(maxrows)+1;
  216.  
  217.     if(qvideo_mode <= C40) {
  218.         cols = rows + (rows >> 2);
  219.     } else {
  220.         cols = (rows << 1) + (rows >> 1 );
  221.     }
  222.  
  223.     col = leftcol + random( rightcol - leftcol - cols + 2 );
  224.     row = toprow + random( botrow - toprow - rows + 2 );
  225.  
  226.     if(qvideo_mode == MONO) {
  227.         a=bwcolors[ random(4) ];
  228.     } else {
  229.         fgrnd=random(16);
  230.         bgrnd=random(8);
  231.         if(bgrnd == fgrnd) ++fgrnd;
  232.         a=fgrnd + (bgrnd << 4);
  233.     }
  234.  
  235.     qfill( row, col, rows, cols, a, 178 );
  236. }
  237.  
  238.  
  239. /*******************************| explode |*********************************\
  240. Makes the screen "explode" with boxes.
  241. \***************************************************************************/
  242. void explode(void)
  243. {
  244.     char toprow, botrow, maxrows, delta, leftcol, rightcol, center;
  245.     long start_time, elapsed_time;
  246.  
  247.     center = crt_cols >> 1;
  248.     randomize();
  249.  
  250.     disable();
  251.     start_time = tclock();
  252.     enable();
  253.  
  254.     for(step=1; step <= 12; step++) {
  255.         /* set boundaries */
  256.         toprow = 13-step;
  257.         botrow = 13+step;
  258.         maxrows = step;
  259.  
  260.         if(qvideo_mode <= C40) {                      /* Keep aspect 1:1 */
  261.             delta=( step*5/3 );
  262.         } else {
  263.             delta=( step*10/3 );
  264.         }
  265.  
  266.         leftcol=center-delta+1;
  267.         rightcol=center+delta;
  268.  
  269.         if(step < 12) {
  270.             for(count=1; count <= 40; count++)
  271.                 scatter(maxrows, leftcol, rightcol, botrow, toprow);
  272.         } else
  273.         do {
  274.             scatter(maxrows, leftcol, rightcol, botrow, toprow);
  275.             disable();
  276.             elapsed_time=tclock() - start_time;
  277.             enable();
  278.         } while( elapsed_time < 60 );      /* about 60/18.2 seconds */
  279.     }
  280. }
  281.  
  282.  
  283. /********************************| initdemo |********************************\
  284. Initialization for the QWIKC demo.
  285. If you set a mode, do it first before qinit()!
  286. Please!  Test a mode first to see if it is different than what you want;
  287. then change if necessary.  Otherwise, the screen jumps.
  288. \****************************************************************************/
  289. void initdemo(void)
  290. {
  291.     /* set up data */
  292.  
  293.     check_zenith();
  294.     setmultitask();
  295.     lastmode=qvideo_mode;
  296.  
  297.     if(qvideo_mode != MONO && !have_3270) {
  298.         clearscr( LIGHTGRAY+BLACK_BG );
  299.         qwritec( 11, 1, crt_cols, SAMEATTR, "(1) 40 column mode" );
  300.         qwritec( 12, 1, crt_cols, SAMEATTR, "(2) 80 column mode" );
  301.         qwritec( 14, 1, crt_cols, SAMEATTR, "Which mode (1,2)? " );
  302.         gotoeos();
  303.         while( !strchr( "12", (ch=getch()) ) );
  304.  
  305.         v=qvideo_mode;
  306.         switch(ch) {
  307.             case '1':
  308.                 switch(v) {
  309.                     case BW80: v=BW40; break;
  310.                     case C80: v=C40; break;
  311.                 } break;
  312.             case '2':
  313.                 switch(v) {
  314.                     case BW40: v=BW80; break;
  315.                     case C40: v=C80; break;
  316.                 } break;
  317.         }
  318.  
  319.         if(v != qvideo_mode) {
  320.             textmode( v );
  321.             qreinit();            /* call qreinit() after mode change! */
  322.             check_zenith();
  323.             setmultitask();
  324.         }
  325.     }
  326.  
  327.     modcursor( cursor_off );
  328. }
  329.  
  330.  
  331. /****************************| explode_screen |*****************************\
  332. Explodes the screen with boxes.
  333. \***************************************************************************/
  334. void explode_screen(void)
  335. {
  336.     int a;
  337.  
  338.     /* initial screen */
  339.     clearscr( WHITE+BLUE_BG );
  340.     qwritec( 11, 1, crt_cols, YELLOW+BLUE_BG, strng2 );
  341.     qwritec( 13, 1, crt_cols, SAMEATTR, "Your screen is about to explode." );
  342.     qwritec( 14, 1, crt_cols, SAMEATTR, "Hold on to your seat ..." );
  343. #ifdef __TURBOC__
  344.     delay( wait*5 );
  345. #else
  346.     suspend( wait*5 );
  347. #endif
  348.  
  349.     /* Explosion of Boxes */
  350.     clearscr( BLACK+LIGHTGRAY_BG );
  351.     explode();
  352.  
  353.     qfillc( 10, 1, crt_cols, 6, 34, RED_BG, ' ' );
  354.     qfillc( 11, 1, crt_cols, 4, 30, BROWN_BG, ' ' );
  355.  
  356.     a=YELLOW+RED_BG;
  357.     qwritec( 12, 1, crt_cols, a, strng2 );
  358.     qwritec( 13, 1, crt_cols, a, "       Version 2.1       " );
  359. }
  360.  
  361.  
  362. /*****************************| save_screen |*******************************\
  363. Saves the current screen.
  364. \***************************************************************************/
  365. void save_screen(void)
  366. {
  367.     int a, row, col;
  368.  
  369.     /* Save screen for Page Demo */
  370.     if(maxpage > 0) {
  371.         qstoretomem( 1, 1, 25, crt_cols, saved_block );
  372.         qwritepage(1);
  373.         qstoretoscr( 1, 1, 25, crt_cols, saved_block );
  374.         qwritepage(0);
  375.     }
  376.  
  377.     /* End of Save Screen */
  378. #ifdef __TURBOC__
  379.     delay( wait*4 );
  380. #else
  381.     suspend( wait*4 );
  382. #endif
  383.     a=WHITE+BLUE_BG;
  384.     qwritec( 6, 1, crt_cols, a, " qwrite will write with new attributes  " );
  385.     qwritec( 7, 1, crt_cols, a, " that you specify direct to the screen. " );
  386. #ifdef __TURBOC__
  387.     delay( wait*6 );
  388. #else
  389.     suspend( wait*6 );
  390. #endif
  391.     qwritec( 18, 1, crt_cols, SAMEATTR,
  392.     "qwrite will also use existing attributes" );
  393.     qwritec( 19, 1, crt_cols, SAMEATTR,
  394.     "   when you do not even know or care.   " );
  395.  
  396.     /* highlight the word "existing" */
  397.     qattrc( 18, 6, crt_cols+5, 1, 10, WHITE+RED_BG+BLINK );
  398. #ifdef __TURBOC__
  399.     delay( wait*10 );
  400. #else
  401.     suspend( wait*10 );
  402. #endif
  403.     qwritec( 21, 1, crt_cols, a, " Say Goodbye to this screen. " );
  404. #ifdef __TURBOC__
  405.     delay( wait*3 );
  406. #else
  407.     suspend( wait*3 );
  408. #endif
  409.  
  410.     /* Disintegrate Screen */
  411.     for(i=0; i < 5000; i++) {
  412.         row=random(25)+1;
  413.         col=random(crt_cols)+1;
  414.         qfill( row, col, 1, 1, BLACK, ' ' );
  415.     }
  416. }
  417.  
  418.  
  419. /*****************************| list_compats |******************************\
  420. Lists the computers and adapters, etc. that QWIKC is compatible with.
  421. \***************************************************************************/
  422. void list_compats(void)
  423. {
  424.     int row,col;
  425.  
  426.     /* Compatible computer and adapter list */
  427.     clearscr( LIGHTGRAY_BG );
  428.     qwritec( 4, 1, crt_cols, SAMEATTR,
  429.     "QWIKC Screen Utilities detects these IBM");
  430.     qwritec( 5, 1, crt_cols, SAMEATTR,
  431.     "or compatible computers and adapters:");
  432. #ifdef __TURBOC__
  433.     delay( wait*5 );
  434. #else
  435.     suspend( wait*5 );
  436. #endif
  437.     col=(crt_cols-30) >> 1;
  438.  
  439.     for(row=7; row <= 20; row++)
  440.         qwrite( row, col, SAMEATTR, pc[row-7] );
  441.  
  442.     qwritec( 23, 1, crt_cols, SAMEATTR, "Working text modes 0,1,2,3, or 7!" );
  443.  
  444.     waitkey();
  445. }
  446.  
  447.  
  448. /*****************************| list_detect |*******************************\
  449. Lists the auto-detection features of qinit().
  450. \***************************************************************************/
  451. void list_detect(void)
  452. {
  453.     int row,col;
  454.  
  455.     /* qinit() detection */
  456.     clearscr( LIGHTGRAY_BG );
  457.     qwritec( 4, 1, crt_cols, SAMEATTR, "To configure QWIKC, qinit() not only" );
  458.     qwritec( 5, 1, crt_cols, SAMEATTR, "detects computers/adapters, it:" );
  459. #ifdef __TURBOC__
  460.     delay( wait*5 );
  461. #else
  462.     suspend( wait*5 );
  463. #endif
  464.     col=(crt_cols-36) >> 1;
  465.     for(row=10; row <= 19; row++)
  466.         qwrite( row, col, SAMEATTR, init[row-10]);
  467.     waitkey();
  468. }
  469.  
  470.  
  471. /******************************| write_num |********************************\
  472. Shows how qwrite can be used with converted numbers.
  473. \***************************************************************************/
  474. void write_num(void)
  475. {
  476.     int row, col;
  477.  
  478.     clearscr( YELLOW+BLACK_BG );
  479.     qwritec( 2, 1,crt_cols, SAMEATTR,"qwrite with sprintf() will write");
  480.     qwritec( 3, 1, crt_cols, SAMEATTR, "number conversions faster:" );
  481. #ifdef __TURBOC__
  482.     delay( wait*7 );
  483. #else
  484.     suspend( wait*7 );
  485. #endif
  486.  
  487.     rnum=1234500000L;
  488.  
  489.     for(col=0; col <= crt_cols/20-1; col++) {
  490.         for(row=5; row <= 24; row++) {
  491.             ++rnum;
  492.             sprintf( numstr, "%ld", rnum );
  493.             qwrite( row, col*20+4, SAMEATTR, numstr );
  494.         }
  495.     }
  496.  
  497.     waitkey();
  498. }
  499.  
  500.  
  501. /******************************| centering |********************************\
  502. Demonstrates the auto-centering features of QWIKC.
  503. \***************************************************************************/
  504. void centering(void)
  505. {
  506.     int row;
  507.  
  508.     /* Centering demo */
  509.     clearscr( LIGHTGRAY_BG );
  510.     qwritec( 2, 1, crt_cols, SAMEATTR, "qwritec will automatically" );
  511.     qwritec( 3, 1, crt_cols, SAMEATTR, "center your data ..." );
  512.     qwritec( 4, 1, crt_cols, SAMEATTR, "(Odd breaks are shifted to the "
  513.                                        "left.)" );
  514. #ifdef __TURBOC__
  515.     delay( wait*6 );
  516. #else
  517.     suspend( wait*6 );
  518. #endif
  519.  
  520.     /* Set up columns for varying column modes */
  521.     coll[1]=1; colr[1]=crt_cols;
  522.  
  523.     if(crt_cols < 80) {
  524.         coll[0]=coll[1]; coll[2]=crt_cols/2;
  525.         colr[0]=colr[1]; colr[2]=crt_cols/2;
  526.     } else {
  527.         coll[0]=3; colr[0]=26;
  528.         coll[2]=crt_cols-14; colr[2]=crt_cols-14;
  529.     }
  530.  
  531.     qwritec( 7, coll[0], colr[0], SAMEATTR, "between margins ..." );
  532.     qbox( 8, ((coll[0]+colr[0]) >> 1) - 12, 15, 26, WHITE, LIGHTGRAY,
  533.           &border );
  534. #ifdef __TURBOC__
  535.     delay( wait*3 );
  536. #else
  537.     suspend( wait*3 );
  538. #endif
  539.  
  540.     for(row=11; row <= 19; row++)
  541.         qwritec( row, coll[0], colr[0], SAMEATTR, data[row-11] );
  542. #ifdef __TURBOC__
  543.     delay( wait*5 );
  544. #else
  545.     suspend( wait*5 );
  546. #endif
  547.  
  548.     qwritec( 7, coll[1], colr[1], SAMEATTR, "between two columns ..." );
  549.     qfillc( 9, coll[1], colr[1], 13, 24, YELLOW, ' ' );   /* Clear window */
  550.  
  551.     for(row=9; row <=21; row++)
  552.         qwritec( row, coll[1], colr[1], SAMEATTR, "><"); /* Show two columns */
  553. #ifdef __TURBOC__
  554.     delay( wait*3 );
  555. #else
  556.     suspend( wait*3 );
  557. #endif
  558.  
  559.     for(row=11; row <= 19; row++)
  560.         qwritec( row, coll[1], colr[1], LIGHTRED, data[row-11]);
  561. #ifdef __TURBOC__
  562.     delay( wait*5 );
  563. #else
  564.     suspend( wait*5 );
  565. #endif
  566.  
  567.     qwritec( 7, coll[2], colr[2], SAMEATTR, "or on a center line ..." );
  568.     /* Clear window */
  569.     qfillc( 8, coll[2], colr[2], 15, 27, BLACK+LIGHTGRAY_BG, ' ' );
  570.  
  571.     for(row=9; row <= 21; row++)        /* show center line */
  572.         qwritec( row, coll[2], colr[2], BLACK+LIGHTGRAY_BG, "|" );
  573. #ifdef __TURBOC__
  574.     delay( wait*3 );
  575. #else
  576.     suspend( wait*3 );
  577. #endif
  578.  
  579.     for(row=11; row <= 19; row++)
  580.         qwritec( row, coll[2], colr[2], SAMEATTR, data[row-11]);
  581.  
  582.     waitkey();
  583. }
  584.  
  585.  
  586. /*******************************| filling |*********************************\
  587. Demonstrates the screen filling and attributing utilities of QWIKC.
  588. \***************************************************************************/
  589. void filling(void)
  590. {
  591.     int row, col;
  592.  
  593.     /* qfill demo */
  594.     clearscr( WHITE+BLACK_BG );
  595.     qwritec( 2, 1, crt_cols, SAMEATTR, "qfill as well as qattr can fill" );
  596.     qwritec( 3, 1, crt_cols, SAMEATTR, "your screen in several ways." );
  597. #ifdef __TURBOC__
  598.     delay( wait*7 );
  599. #else
  600.     suspend( wait*7 );
  601. #endif
  602.  
  603.     qwritec( 7, 1, crt_cols, SAMEATTR, "by rows ..." );
  604. #ifdef __TURBOC__
  605.     delay( wait*3 );
  606. #else
  607.     suspend( wait*3 );
  608. #endif
  609.  
  610.     for(row=9; row <= 24; row++)
  611.         qfill( row, 2, 1, crt_cols-2, 9+row, row+56 );
  612. #ifdef __TURBOC__
  613.     delay( wait*5 );
  614. #else
  615.     suspend( wait*5 );
  616. #endif
  617.  
  618.     qfill( 7, 1, 19, crt_cols, WHITE, ' ' );       /* clear lines */
  619.     qwritec( 7, 1, crt_cols, SAMEATTR, "by columns ..." );
  620. #ifdef __TURBOC__
  621.     delay( wait*3 );
  622. #else
  623.     suspend( wait*3 );
  624. #endif
  625.  
  626.     for( col=2; col <= crt_cols-2; col++ )
  627.         qfill( 9, col, 16, 1, 16+col, col+63 );
  628. #ifdef __TURBOC__
  629.     delay( wait*5 );
  630. #else
  631.     suspend( wait*5 );
  632. #endif
  633.  
  634.     qfill( 7, 1, 19, crt_cols, WHITE, ' ' );       /* clear lines */
  635.     qwritec( 7, 1, crt_cols, SAMEATTR, "or by row-by-column blocks ..." );
  636. #ifdef __TURBOC__
  637.     delay( wait*3 );
  638. #else
  639.     suspend( wait*3 );
  640. #endif
  641.     qfill( 9, 2, 16, crt_cols-2, YELLOW+BLUE_BG, '!' );
  642. #ifdef __TURBOC__
  643.     delay( wait*5 );
  644. #else
  645.     suspend( wait*5 );
  646. #endif
  647. }
  648.  
  649.  
  650. /*******************************| qboxdemo |********************************\
  651. Demonstrates the application of the QWIKC utilities for making boxes on the
  652. screen.
  653. \***************************************************************************/
  654. void qboxdemo(void)
  655. {
  656.     int row, col;
  657.  
  658.     /* qbox demo */
  659.     clearscr( LIGHTGRAY_BG );
  660.     qwritec( 2, 1, crt_cols, SAMEATTR,
  661.     "qbox is an application function made " );
  662.     qwritec( 3, 1, crt_cols, SAMEATTR,
  663.     "from qwrite and qfill.  Together they" );
  664.     qwritec( 4, 1, crt_cols, SAMEATTR,
  665.     "can make windows with borders easy. " );
  666. #ifdef __TURBOC__
  667.     delay( wait*9 );
  668. #else
  669.     suspend( wait*9 );
  670. #endif
  671.     qwritec( 14, 1, crt_cols, SAMEATTR, "How about 100 of them? ... " );
  672. #ifdef __TURBOC__
  673.     delay( wait*4 );
  674. #else
  675.     suspend( wait*4 );
  676. #endif
  677.     colmax=crt_cols-21;
  678.  
  679.     for(i=0; i<100; i++) {
  680.         row=random( 10 )+6;
  681.         col=random( colmax )+2;
  682.  
  683.         if(qvideo_mode == MONO) {
  684.             brdrattr=bwcolors[random(4)];
  685.             wndwattr=bwcolors[random(4)];
  686.         } else {
  687.             brdrattr=random (128);
  688.             wndwattr=random (128);
  689.         }
  690.  
  691.         qbox( row, col, 10, 20, brdrattr, wndwattr, &border );
  692.     }
  693.  
  694. #ifdef __TURBOC__
  695.     delay( wait*10 );
  696. #else
  697.     suspend( wait*10 );
  698. #endif
  699. }
  700.  
  701.  
  702. /*******************************| popupdemo |*******************************\
  703. Demonstrates the use of QWIKC for pop-up menus.
  704. \***************************************************************************/
  705. void popupdemo(void)
  706. {
  707.     /* Block transfer and popup demo */
  708.     qfill( 1, 1, 25, crt_cols, YELLOW, '?' );         /* clear screen */
  709.     qfillc( 10, 1, crt_cols, 6, 40, BROWN_BG, ' ' );  /* clear block */
  710.     qwritec( 11, 1, crt_cols, SAMEATTR, "qstore will save and restore" );
  711.     qwritec( 12, 1, crt_cols, SAMEATTR,
  712.     "row-by-column blocks on your display." );
  713.     qwritec( 13, 1, crt_cols, SAMEATTR,
  714.     "It is so fast, I have to slow it down" );
  715.     qwritec( 14, 1, crt_cols, SAMEATTR, "so you can see it." );
  716. #ifdef __TURBOC__
  717.     delay( wait*11 );
  718. #else
  719.     suspend( wait*11 );
  720. #endif
  721.     blkrow=8;
  722.     blkcol=crt_cols/2-9;
  723.     qstoretomem( blkrow, blkcol, 10, 20, saved_block );
  724.  
  725.     /* make a pop up menu */
  726.     qbox( blkrow, blkcol, 10, 20, YELLOW+BLUE_BG, BROWN+BLUE_BG, &border );
  727.     qwritec( blkrow+4, blkcol, blkcol+20, SAMEATTR, "Pop up" );
  728.     qwritec( blkrow+5, blkcol, blkcol+20, SAMEATTR, "menu" );
  729.  
  730.     /* End of pop up menu */
  731.     qstoretomem( blkrow, blkcol, 10, 20, popup_block );
  732. #ifdef __TURBOC__
  733.     delay( wait*4 );
  734. #else
  735.     suspend( wait*4 );
  736. #endif
  737.     colmax = crt_cols-20;
  738.  
  739.     for(i=0; i < 30; i++) {
  740. #ifdef __TURBOC__
  741.         delay( wait/2 );
  742. #else
  743.         suspend( wait/2 );
  744. #endif
  745.         qstoretoscr( blkrow, blkcol, 10, 20, saved_block );
  746.         blkrow=random(15)+1;
  747.         blkcol=random(colmax)+1;
  748.         qstoretomem( blkrow, blkcol, 10, 20, saved_block );
  749.         qstoretoscr( blkrow, blkcol, 10, 20, popup_block );
  750.     }
  751. }
  752.  
  753.  
  754. /*******************************| pagedemo |********************************\
  755. Demonstrates the page-flipping features of QWIKC.
  756. \***************************************************************************/
  757. void pagedemo(void)
  758. {
  759.     int a;
  760.  
  761.     /* page demo */
  762.     if(maxpage > 0 && !inmultask) {
  763.         qviewpage(1);
  764.         qwritepage(1);
  765.         a=YELLOW+BLUE_BG;
  766.  
  767.         qfillc( 20, 1, crt_cols, 3, 35, a, ' ' );
  768.         qwritec( 20, 1, crt_cols, SAMEATTR, " Remember this page?  " );
  769.         qwritec( 21, 1, crt_cols, SAMEATTR, " It wasn't lost, but saved "
  770.                                             "using" );
  771.         qwritec( 22, 1, crt_cols, SAMEATTR, "qstores and placed on a new "
  772.                                             "page. " );
  773. #ifdef __TURBOC__
  774.         delay( wait*14 );
  775. #else
  776.         suspend( wait*14 );
  777. #endif
  778.         qwritepage(0);
  779.         qviewpage(0);
  780.     }
  781. }
  782.  
  783.  
  784. /*******************************| eosmarker |*******************************\
  785. Demonstrates the use of the QWIKC utilities' EOS marker.
  786. \***************************************************************************/
  787. void eosmarker(void)
  788. {
  789.     int col;
  790.  
  791.     /* EOS marker */
  792.     clearscr( LIGHTGREEN+BLACK_BG );
  793.     qwritec( 3, 1, crt_cols, WHITE, "EOS marker:" );
  794.     col=eosc();
  795.     sprintf( numstr, "%c%c%cright here", 7, 0, 24 );
  796.     qwriteeos( BLINK+YELLOW, numstr );
  797.     qwrite( 4, col, YELLOW, &numstr[2] );
  798.     qwritec( 7, 1, crt_cols, SAMEATTR,
  799.              "The printf function locates your next" );
  800.     qwritec( 8, 1, crt_cols, SAMEATTR,
  801.              "string by placing the cursor at the end " );
  802.     qwritec( 9, 1, crt_cols, SAMEATTR,
  803.              "of the string.  QWIKC functions can do  " );
  804.     qwritec( 10, 1, crt_cols, SAMEATTR,
  805.              "the same thing, but without moving the  " );
  806.     qwritec( 11, 1, crt_cols, SAMEATTR,
  807.              "cursor!  It's done with an offset called" );
  808.     qwritec( 12, 1, crt_cols, SAMEATTR,
  809.              "qeosofs.  It's updated after every QWIKC" );
  810.     qwritec( 13, 1, crt_cols, SAMEATTR,
  811.              "function.                               " );
  812.     qwritec( 16, 1, crt_cols, SAMEATTR,
  813.              "Now you can have the convenience of a" );
  814.     qwritec( 17, 1, crt_cols, SAMEATTR,
  815.              "printf but the speed of QWIKC!  Check   " );
  816.     qwritec( 18, 1, crt_cols, SAMEATTR,
  817.              "out the following q*eos functions.      " );
  818.     waitkey();
  819. }
  820.  
  821.  
  822. /*******************************| qeosdemo |********************************\
  823. Demonstrates the QWIKC EOS functions.
  824. \***************************************************************************/
  825. void qeosdemo(void)
  826. {
  827.     int row, col;
  828.  
  829.     /* QWIKC EOS utilities demo */
  830.     clearscr( BLACK+LIGHTGRAY_BG );
  831.     qwritec( 3, 1, crt_cols, SAMEATTR, "The q*eos functions:" );
  832.  
  833.     for(row=5; row <= 8; row++)
  834.         qwritec( row, 1, crt_cols, YELLOW+BLACK_BG, eoss[row-5] );
  835.     qwritec( 10, 1, crt_cols, SAMEATTR, "Take advantage of the EOS marker "
  836.                                         "to" );
  837.     qwritec( 11, 1, crt_cols, SAMEATTR, "chain the next string - with an "
  838.                                         "   " );
  839.     qwritec( 12, 1, crt_cols, SAMEATTR, "optional change of attribute! "
  840.                                         "     " );
  841. #ifdef __TURBOC__
  842.     delay( wait*5 );
  843. #else
  844.     suspend( wait*5 );
  845. #endif
  846.  
  847.     col=(crt_cols-38) >> 1;
  848.     qwrite( 14, col, BLACK+BROWN_BG, " Yellow " );
  849.  
  850.     for(count=1; count <= 2; count++) {
  851. #ifdef __TURBOC__
  852.         delay( wait );
  853. #else
  854.         suspend( wait );
  855. #endif
  856.         qwriteeos( WHITE+BLUE_BG, "  Blue  " );
  857. #ifdef __TURBOC__
  858.         delay( wait );
  859. #else
  860.         suspend( wait );
  861. #endif
  862.         qwriteeos( BLACK+BROWN_BG, " Yellow " );
  863.     }
  864.  
  865. #ifdef __TURBOC__
  866.     delay(wait);
  867. #else
  868.     suspend( wait);
  869. #endif
  870.     qwritec( 16, 1, crt_cols, SAMEATTR, "Starts where the last QWIKC" );
  871.     qwritec( 17, 1, crt_cols, SAMEATTR, "function left off!" );
  872.     qwritec( 18, 1, crt_cols, SAMEATTR, "Like printf ... but at QWIKC "
  873.                                         "speeds!" );
  874. #ifdef __TURBOC__
  875.     delay( wait*2 );
  876. #else
  877.     suspend( wait*2 );
  878. #endif
  879.  
  880.     qwrite( 21, col, BLACK+BROWN_BG, " Yellow " );
  881.     for(count=1; count <= 2; count++) {
  882.         qwriteeos( WHITE+BLUE_BG, "  Blue  " );
  883.         qwriteeos( BLACK+BROWN_BG, " Yellow " );
  884.     }
  885.  
  886.     waitkey();
  887. }
  888.  
  889.  
  890. /*******************************| usingeos |********************************\
  891. Demonstrates the use of the EOS marker.
  892. \***************************************************************************/
  893. void usingeos(void)
  894. {
  895.     int col;
  896.  
  897.     /* Using EOS marker */
  898.     clearscr( BLACK+LIGHTGRAY_BG );
  899.     col=((crt_cols-40) >> 1)+1;
  900.     qwritec( 2, 1, crt_cols, WHITE, " Using the EOS marker: " );
  901.     qwrite(  4, col, SAMEATTR, "Now you have two marker utilities -" );
  902.     qwrite(  5, col, SAMEATTR, "(1) EOS, and (2) the cursor.  Both can" );
  903.     qwrite(  6, col, SAMEATTR, "be used interchangeably:" );
  904.     qwrite(  8, col, SAMEATTR, "gotoeos   - cursor to end-of-string" );
  905.     qwrite(  9, col, SAMEATTR, "eosr      - end-of-string row" );
  906.     qwrite( 10, col, SAMEATTR, "eosc      - end-of-string column" );
  907.     qwrite( 12, col, SAMEATTR, "You can also manually alter EOS with the" );
  908.     qwrite( 13, col, SAMEATTR, "following functions:" );
  909.     qwrite( 15, col, SAMEATTR, "eostorc     - Sets EOS to a given row" );
  910.     qwrite( 16, col, SAMEATTR, "              and column." );
  911.     qwrite( 17, col, SAMEATTR, "eostorcrel  - Relatively shifts EOS by" );
  912.     qwrite( 18, col, SAMEATTR, "              row and column." );
  913.     qwrite( 19, col, SAMEATTR, "eostocursor - Matches EOS to the cursor" );
  914.     qwrite( 20, col, SAMEATTR, "              position." );
  915.     qwrite( 21, col, SAMEATTR, "eosln       - Sets EOS to next row" );
  916.     qwrite( 22, col, SAMEATTR, "qeosln      - Like eosln, but scrolls up" );
  917.     qwrite( 23, col, SAMEATTR, "              if on last row." );
  918.  
  919.     waitkey();
  920. }
  921.  
  922.  
  923. /*******************************| moreutils |*******************************\
  924. Displays information about the other screen functions.
  925. \***************************************************************************/
  926. void moreutils(void)
  927. {
  928.     int row, col;
  929.  
  930.     /* Other Screen Utilities demo */
  931.     clearscr( BLACK+LIGHTGRAY_BG );
  932.     qwritec( 3, 1, crt_cols, SAMEATTR, "Here are more powerful" );
  933.     qwritec( 4, 1, crt_cols, SAMEATTR, "QWIKC Screen Utilities" );
  934.     qwritec( 5, 1, crt_cols, SAMEATTR, "(for standard and virtual):" );
  935. #ifdef __TURBOC__
  936.     delay( wait*5 );
  937. #else
  938.     suspend( wait*5 );
  939. #endif
  940.     col=(crt_cols-38) >> 1;
  941.  
  942.     for(row=8; row <= 19; row++)
  943.         qwrite( row, col, SAMEATTR, other[row-8]);
  944.     waitkey();
  945. }
  946.  
  947.  
  948. /*****************************| cursorutils |*******************************\
  949. Displays information about the cursor manipulation functions.
  950. \***************************************************************************/
  951. void cursorutils(void)
  952. {
  953.     int row, col;
  954.  
  955.     /* cursor utilities demo */
  956.     clearscr( BLACK+BROWN_BG );
  957.     qwritec( 1, 1, crt_cols, SAMEATTR, "And of course there is a complete" );
  958.     qwritec( 2, 1, crt_cols, SAMEATTR, "set of CURSOR location and mode  " );
  959.     qwritec( 3, 1, crt_cols, SAMEATTR, "routines for all video pages and " );
  960.     qwritec( 4, 1, crt_cols, SAMEATTR, "video cards:                     " );
  961. #ifdef __TURBOC__
  962.     delay( wait*5 );
  963. #else
  964.     suspend( wait*5 );
  965. #endif
  966.     col=(crt_cols-38) >> 1;
  967.  
  968.     for(row=6; row <= 11; row++)
  969.         qwrite( row, col, SAMEATTR, crsr[row-6] );
  970.  
  971.     qwritec( 13, 1, crt_cols, SAMEATTR, "For universal cursor sizes, four" );
  972.     qwritec( 14, 1, crt_cols, SAMEATTR, "standard shapes are initialized " );
  973.     qwritec( 15, 1, crt_cols, SAMEATTR, "by detecting each video card:   " );
  974.  
  975.     for(row=17; row <= 20; row++)
  976.         qwrite( row, col, SAMEATTR, crsr[row-11] );
  977.     for(row=22; row <= 23; row++)
  978.         qwritec( row, 1, crt_cols, SAMEATTR, crsr[row-12] );
  979.     waitkey();
  980. }
  981.  
  982.  
  983. /******************************| attrdemo |*********************************\
  984. Demonstrates the attribute-changing features of QWIKC.
  985. \***************************************************************************/
  986. void attrdemo(void)
  987. {
  988.     int a, row, col, cols;
  989.  
  990.     /* Attribute demo */
  991.     clearscr( GREEN+GREEN_BG );
  992.     a=WHITE+GREEN_BG;
  993.     qwritec( 2, 1, crt_cols, a, "QWIKC Screen Utilities are hiding data" );
  994.     qwritec( 3, 1, crt_cols, a, "on your screen ..." );
  995.     cols=crt_cols/20;
  996.  
  997.     if(qvideo_mode == MONO)
  998.          a=BLACK+BLACK_BG;
  999.     else a=GREEN+GREEN_BG;
  1000.  
  1001.     for(col=0; col < cols; col++)
  1002.         for(row=5; row <= 20; row++)
  1003.             qwrite( row, 20*col+1, a, strng );
  1004.  
  1005. #ifdef __TURBOC__
  1006.     delay( wait*8 );
  1007. #else
  1008.     suspend( wait*8 );
  1009. #endif
  1010.     qfill( 2, 1, 2, crt_cols, SAMEATTR, ' ' );        /* clear lines */
  1011.     a=WHITE+GREEN_BG;
  1012.     qwritec( 2, 1, crt_cols, a, "qattr can show them -" );
  1013.     qwritec( 3, 1, crt_cols, a, "by merely changing the attribute!" );
  1014. #ifdef __TURBOC__
  1015.     delay( wait*6 );
  1016. #else
  1017.     suspend( wait*6 );
  1018. #endif
  1019.  
  1020.     a=BLACK+GREEN_BG;
  1021.     qattr( 5, 1, 16, crt_cols, a );                   /* reveal data */
  1022. #ifdef __TURBOC__
  1023.     delay( wait*5 );
  1024. #else
  1025.     suspend( wait*5 );
  1026. #endif
  1027.  
  1028.     qfill( 2, 1, 2, crt_cols, SAMEATTR, ' ' );        /* clear lines */
  1029.     a=YELLOW+GREEN_BG;
  1030.     qwritec( 2, 1, crt_cols, a, "Or even just emphasize what's seen ..." );
  1031.  
  1032.     for(i=0; i < 500; i++) {
  1033.         row=random( 16 ) + 5;
  1034.         col=random( cols )*20+1;
  1035.         qattr( row, col, 1, 20, 46 );
  1036. #ifdef __TURBOC__
  1037.         delay( 3 );
  1038. #else
  1039.         suspend( 3 );
  1040. #endif
  1041.         qattr( row, col, 1, 20, 32 );
  1042.     }
  1043.  
  1044.     for(i=1; i <= cols; i++)
  1045.         qattr( 5*i, (i-1)*20+1, 1, 20, YELLOW+GREEN_BG+BLINK );
  1046.     qattr( 21, 1, 5, crt_cols, a );
  1047.     qwritec( 22, 1, crt_cols, a, " (c) 1988-1989 James H. LeMay " );
  1048.     qwritec( 23, 1, crt_cols, a, "Conversion to C by" );
  1049.     qwritec( 24, 1, crt_cols, a, "Jordan Gallagher/Wisdom Research" );
  1050. }
  1051.  
  1052.  
  1053. /*********************************| main |***********************************\
  1054. The main block.
  1055. \****************************************************************************/
  1056. main()
  1057. {
  1058.     qinit();
  1059.     initdemo();
  1060.  
  1061.     explode_screen();
  1062.     save_screen();
  1063.     list_compats();
  1064.     list_detect();
  1065.     write_num();
  1066.     centering();
  1067.     filling();
  1068.     qboxdemo();
  1069.     popupdemo();
  1070.     if(maxpage>0 && !inmultask)
  1071.         pagedemo();
  1072.     eosmarker();
  1073.     qeosdemo();
  1074.     usingeos();
  1075.     moreutils();
  1076.     cursorutils();
  1077.     attrdemo();
  1078.     closedemo();
  1079.  
  1080.     return;
  1081. }
  1082.