home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / PROCWRKB.ZIP / BENCH1.ZIP / WIN / DOS / DS.C next >
Encoding:
C/C++ Source or Header  |  1990-08-16  |  3.3 KB  |  151 lines

  1. /* ==( dos/ds.c )== */
  2. /* ----------------------------------------------- */
  3. /* Pro-C - Copyright (C) 1988, 1989 Vestronix Inc. */
  4. /* Modification to this source is not supported    */
  5. /* by Vestronix Inc.                               */
  6. /*            All Rights Reserved                  */
  7. /* ----------------------------------------------- */
  8. /* Written   Geo  26-Aug-88                        */
  9. /* Modified  Geo   2-Aug-90  See comments below    */
  10. /* ----------------------------------------------- */
  11. /* %W%  (%H% %T%) */
  12.  
  13. /*
  14.  *  Modifications
  15.  *
  16.  *   2-Aug-90  Geo - Bios speedup on repeated chars
  17.  *   1-Nov-89  Geo - Clear to end of line speedup on blank lines
  18.  *  25-Dec-89  Geo - 1.32 Merge
  19.  *  18-Jan-90  Geo - Add mouse cursor
  20.  *
  21. */
  22.  
  23. # include <stdio.h>
  24. # include <bench.h>
  25.  
  26. # include "pregs.h"
  27.  
  28. /* Enable next define to eanble bios calls */
  29. /* # define USEBIOS */
  30.  
  31. extern char rowbuf[], newbuf[];
  32.  
  33. /*
  34.  * Blast form of subpoke
  35.  * Okay so why use a C version instead of asm ds
  36.  * easier to maintain, asm version was hardcoded
  37.  * for 80 cols, and fixed model size, no debug
  38.  * now we have the switched version (bios | direct)
  39. */
  40. void subpokel(row, col, len)
  41. int row, col, len;
  42. {
  43. char *nptr = newbuf, *optr = rowbuf;
  44.  
  45. # ifndef USEBIOS
  46.     extern char far *videoscreen;
  47.     short far *screen;
  48.  
  49.     row *= w_ncols<<1; /* 160 */
  50.     screen = (short far *)(videoscreen + row + (col<<1));
  51. # endif
  52.  
  53. # ifdef MOUSE
  54.     mouse_cursor(OFF);
  55. # endif
  56.  
  57.     /* Now output differences */
  58.     while (len--)
  59.     {
  60. # ifdef USEBIOS
  61.     int cnt = 1;
  62. # endif
  63.  
  64.         /*
  65.          * Optimising screen refresh by minimising n+1
  66.          * window refresh states
  67.          * Easiest way is to compare directly
  68.          * Char value changes faster than the attribute
  69.         */
  70. /*        if (*nptr != *optr || *(nptr+1) != *(optr+1))  */
  71.         if (*(short *)nptr != *(short *)optr)
  72.         {
  73.         unsigned char ch = *nptr;
  74.         unsigned char attr = *(nptr + 1);
  75.             
  76.             /* Convert logical boxes to physical */
  77.             if (attr & GRAPHIC)
  78.             {
  79.             extern char boxes[][BOXCHCNT];
  80.  
  81.                 /* ch = boxes[ch / BOXCHCNT][(ch - 1) % BOXCHCNT]; */
  82.                 ch = *(boxes[0] + ch - 1);
  83.             }
  84.  
  85. # ifdef USEBIOS
  86.                 { /* Start local block */
  87.  
  88.                     extern char _page;
  89.                     RegStorage;
  90.  
  91.                     /*
  92.                      * Take advantage of repeat parameter on
  93.                      * bios video call - really speeds up display
  94.                     */
  95.                     /* Loop looking for repeated chars */
  96.                     for ( ; cnt <= len; cnt++)
  97.                     {
  98.                         /* want a match with current target and repeated */
  99.                         if (*(short *)nptr != *(short *)(nptr+(cnt<<1)) ||
  100.                                 *(short *)nptr == *(short *)(optr+(cnt<<1)))
  101.                             break;
  102.                     }
  103.  
  104.                     /* Faster moveto(row, col); */
  105.                     Regs_bh = _page;
  106.                     Regs_dh = row;
  107.                     Regs_dl = col;
  108.                     Regs_ah = 0x02;
  109.                     Video();
  110.  
  111.                     /* Place character */
  112.                     Regs_bl = colour[attr & 15];
  113.                     Regs_bh = _page;
  114.                     Regs_cx = cnt;
  115.                     Regs_al = ch;
  116.                     Regs_ah = 0x09;
  117.                     Video();
  118.  
  119.                     if (cnt > 1)
  120.                     {
  121.                         /* Adjust counts */
  122.                         len -= cnt - 1;
  123.                         nptr += (cnt-1)<<1;
  124.                         optr += (cnt-1)<<1;
  125.                     }
  126.  
  127.                 } /* End local block */
  128. # else
  129.                 {
  130.                 /* will need get term to calculate base address + PAGE stuff */
  131.  
  132.                     *screen = ch + (colour[attr & 15]<<8);
  133.                 }
  134. # endif
  135.         }
  136.  
  137. # ifdef USEBIOS
  138.         col += cnt;
  139. # else
  140.         screen++;
  141. # endif
  142.         optr += 2;
  143.         nptr += 2;
  144.     }
  145.  
  146. # ifdef MOUSE
  147.     mouse_cursor(ON);
  148. # endif
  149. }
  150.  
  151.