home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / magazine / pctech / hlsrc / hlwindow.c < prev    next >
C/C++ Source or Header  |  1988-09-09  |  3KB  |  129 lines

  1. /*+
  2.     Name:    hlwindow.c
  3.     Date:    07-Sep-1988
  4.     Author:    Kent J. Quirk
  5.         (c) Copyright 1988 Ziff Communications Co.
  6.     Abstract:    This tests speed of direct video access.
  7.     History:    09-Sep-88   kjq     Version 1.00
  8. -*/    
  9.  
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. #include <string.h>
  13. #include <dos.h>
  14. #include <graph.h>
  15. #include "hl.h"
  16. #include "hltimes.h"
  17. #include "winmenu.h"
  18.  
  19. void usage()
  20. {
  21.     printf("Usage:  HLWINDOW [-?] [-nNLINES]\n");
  22.     printf("This program opens seven windows in succession using\n");
  23.     printf("direct video writes to do its work.  In each window, it\n");
  24.     printf("uses the MSC _outtext() function to write NLINES lines\n");
  25.     printf("text to the screen.  It then closes all the windows one\n");
  26.     printf("by one, writing NLINES of text again before closing.\n");
  27.     printf("NLINES defaults to 50.\n");
  28.     exit(1);
  29. }
  30.  
  31. char *sayings[] = {
  32.     "To be, or not to be, that is the question.\n",
  33.     "To err is human; to really foul things up requires a computer.\n",
  34.     "Consistency is the hobgoblin of small minds.\n",
  35.     "Friends, Romans, and countrymen, lend me your ears.\n",
  36.     "Quoth the Raven, 'Nevermore.'\n",
  37.     "I think that I shall never see a billboard lovely as a tree.\n",
  38.     "For the snark was a boojum, you see.\n",
  39.     "A rolling stone gathers no moss.\n",
  40.     "Brevity is the soul of wit.\n",
  41.     "Call me Ishmael.\n",
  42.     "'Curiouser and curiouser,' said Alice.\n",
  43.     "A stitch in time saves nine.\n",
  44.     "It was the best of times, it was the worst of times.\n",
  45. };
  46.  
  47. TIME_REC timerec[] = {
  48.     {  0L, "Total: Window/Scrolling"     } ,
  49.     {  -1L, "HLWINDOW"       } ,
  50. };
  51.  
  52. #define hbound(a) (sizeof(a)/sizeof(a[0]))
  53. main(argc, argv)
  54. int argc;
  55. char *argv[];
  56. {
  57.     WINDOW *w[100];
  58.     WINDOW *base;
  59.     int i,j;
  60.     int nlines = 50;
  61.     struct rccoord cpos;
  62.     int program = -1;
  63.     char *filename = NULL;
  64.  
  65.     for (i=1; i<argc; i++)
  66.     {
  67.     if (argv[i][0] != '-')
  68.         usage();
  69.  
  70.     switch(tolower(argv[i][1])) {
  71.     case 'n':
  72.         nlines = atoi(argv[i]+2);
  73.         break;
  74.     case 'a':
  75.     case 'b':
  76.         break;          /* ignore batch switch */
  77.     case 'p':
  78.         program = atoi(argv[i]+2);
  79.         break;
  80.     case 'f':
  81.         filename = argv[i]+2;
  82.         break;
  83.     default:
  84.     case '?':
  85.         usage();
  86.         break;
  87.     }
  88.     }
  89.  
  90.     cpos = bios_getcur();
  91.     start_timer(0);
  92.     base = open_window(1, 1, 25, 80, 0xF);
  93.  
  94.     for (i=1; i<8; i++)
  95.     {
  96.     w[i] = open_window(2+i, 30-4*i, 24-i, 50+4*i,
  97.     (char)(((i) << 4) & 0x70) + (((3+i) & 0x0F) | 0x80));
  98.     activate_window(w[i]);
  99.     _settextposition(25,1);
  100.     for (j=0; j<nlines; j++)
  101.         _outtext(sayings[j % hbound(sayings)]);
  102.     deactivate_window(w[i]);
  103.     }
  104.  
  105.     for (i=7; i>0; i--)
  106.     {
  107.     activate_window(w[i]);
  108.     for (j=0; j<nlines; j++)
  109.         _outtext(sayings[j % hbound(sayings)]);
  110.     deactivate_window(w[i]);
  111.     close_window(w[i]);
  112.     }
  113.  
  114.     close_window(base);
  115.     stop_timer(0);
  116.     bios_setcur(cpos.row, cpos.col);
  117.     printf("Window/scrolling test took %s seconds.\n",
  118.     time_secs(timerec[0].ticks = get_timer(0)));
  119.  
  120.     if ((program != -1) && (filename != NULL))
  121.     {
  122.     opentime(filename);
  123.     savetime(program, 0, &timerec[0]);
  124.     savetime(program, 1, &timerec[1]);
  125.     closetime();
  126.     }
  127.     return(0);
  128. }
  129.