home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / SB_SHOW.C < prev    next >
C/C++ Source or Header  |  1990-05-14  |  6KB  |  163 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-90, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*              Routines for updating the screen within BinkleyTerm         */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*    For complete  details  of the licensing restrictions, please refer    */
  17. /*    to the License  agreement,  which  is published in its entirety in    */
  18. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.240.    */
  19. /*                                                                          */
  20. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  21. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  22. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  23. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  24. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  25. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  26. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  27. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  28. /*                                                                          */
  29. /*                                                                          */
  30. /* You can contact Bit Bucket Software Co. at any one of the following      */
  31. /* addresses:                                                               */
  32. /*                                                                          */
  33. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:132/491, 1:141/491  */
  34. /* P.O. Box 460398                AlterNet 7:491/0                          */
  35. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  36. /*                                Internet f491.n132.z1.fidonet.org         */
  37. /*                                                                          */
  38. /* Please feel free to contact us at any time to share your comments about  */
  39. /* our software and/or licensing policies.                                  */
  40. /*                                                                          */
  41. /*                                                                          */
  42. /*   This module is derived from code developed by Augie Hansen in his      */
  43. /*   book "Proficient C" published by Microsoft Press.  Mr. Hansen was      */
  44. /*   kind enough to give us verbal permission to use his routines, and      */
  45. /*   Bob, Vince and Alan (and all our full screen users) are grateful.      */
  46. /*   If you decide to use this code in some package you are doing, give     */
  47. /*   some thought to going out and buying the book. He deserves that.       */
  48. /*                                                                          */
  49. /*--------------------------------------------------------------------------*/
  50.  
  51.  
  52. #include <stdio.h>
  53. #include <dos.h>
  54.  
  55. #ifdef __TURBOC__
  56. #include <mem.h>
  57. #else
  58. #include <memory.h>
  59. #endif
  60.  
  61. #include "sbuf.h"
  62. #include "xfer.h"
  63. #include "com.h"
  64. #include "zmodem.h"
  65. #include "keybd.h"
  66. #include "sched.h"
  67. #include "externs.h"
  68. #include "prototyp.h"
  69. #include "vfossil.h"
  70.  
  71. extern BUFFER Sbuf;
  72. extern CELLP Scrnbuf;
  73. extern int cursor_col;
  74. extern int cursor_row;
  75.  
  76. void sb_show ()
  77. {
  78.    register int r;
  79.    unsigned int src_os;
  80.    unsigned int far *q;
  81.  
  82.    if (screen_blank && do_screen_blank)
  83.       {
  84.       for (r = 0; r < SB_ROWS; r++)
  85.          {
  86.          q = (unsigned int far *) blanks;
  87. #ifndef OS_2
  88.          (void) VioWrtCellStr (q, SB_COLS * 2, r, 0, 0);
  89. #else
  90.          (void) VioWrtCellStr ((PCH) q, (USHORT) (SB_COLS * 2), (USHORT) r, (USHORT) 0, (HVIO) 0L);
  91. #endif
  92.          }
  93.  
  94.       sb_dirty ();
  95.       return;
  96.       }
  97.  
  98.    /* Anything to do? */
  99.    if (!(Sbuf.flags & SB_DELTA))
  100.       {
  101.       return;
  102.       }
  103.  
  104.    src_os = 0;
  105.    for (r = 0; r < SB_ROWS; r++)
  106.       {
  107.       /* Copy only changed portions of lines */
  108.       if ((Sbuf.lcol[r] < SB_COLS) && (Sbuf.rcol[r] > 0))
  109.          {
  110.          q = (unsigned int far *) (Scrnbuf + src_os + Sbuf.lcol[r]);
  111. #ifndef OS_2
  112.          (void) VioWrtCellStr (q, (Sbuf.rcol[r] - Sbuf.lcol[r] + 1) * 2, r, Sbuf.lcol[r], 0);
  113. #else
  114.          (void) VioWrtCellStr ((PCH) q, (USHORT) ((Sbuf.rcol[r] - Sbuf.lcol[r] + 1) * 2), (USHORT) r, (USHORT) Sbuf.lcol[r], (HVIO) 0L);
  115. #endif
  116.          Sbuf.lcol[r] = SB_COLS;
  117.          Sbuf.rcol[r] = 0;
  118.          }
  119.       src_os += (unsigned) SB_COLS;
  120.       }
  121.  
  122.    /* the display now matches the buffer -- clear flag bit */
  123.    Sbuf.flags &= ~SB_DELTA;
  124.  
  125.    gotoxy (cursor_col, cursor_row);
  126.    return;
  127. }
  128.  
  129. /*
  130.  * Just cleans up the structure to say it is reality - I can use this when
  131.  * I write directly to the screen for single char writes.
  132.  */
  133.  
  134. void sb_clean ()
  135. {
  136.    int r;
  137.  
  138.    for (r = 0; r < SB_ROWS; r++)
  139.       {
  140.       Sbuf.lcol[r] = SB_COLS;
  141.       Sbuf.rcol[r] = 0;
  142.       }
  143.  
  144.    Sbuf.flags &= ~SB_DELTA;
  145. }
  146.  
  147. /*
  148.  * Make the entire buffer "dirty" so it will be updated.
  149.  */
  150.  
  151. void sb_dirty ()
  152. {
  153.    int r;
  154.  
  155.    for (r = 0; r < SB_ROWS; r++)
  156.       {
  157.       Sbuf.lcol[r] = 0;
  158.       Sbuf.rcol[r] = SB_COLS - 1;
  159.       }
  160.  
  161.    Sbuf.flags |= SB_DELTA;
  162. }
  163.