home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 2 BBS / 02-BBS.zip / BTMTSRC3.ZIP / SB_SAVE.C < prev    next >
C/C++ Source or Header  |  1990-07-05  |  6KB  |  146 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. #include <alloc.h>
  58. #else
  59. #include <memory.h>
  60. #include <malloc.h>
  61. #endif
  62.  
  63. #include "sbuf.h"
  64. #include "xfer.h"
  65. #include "com.h"
  66. #include "zmodem.h"
  67. #include "keybd.h"
  68. #include "sched.h"
  69. #include "externs.h"
  70. #include "prototyp.h"
  71. #include "vfossil.h"
  72.  
  73. extern BUFFER Sbuf;
  74. extern CELLP Scrnbuf;
  75. extern REGIONP sb_new ();
  76.  
  77. char *pop_malloc (unsigned);
  78. void pop_free (char *);
  79.  
  80. SAVEP sb_save (top, left, height, width)
  81. int top;
  82. int left;
  83. int height;
  84. int width;
  85. {
  86.    SAVEP new;
  87.    CELLP c;
  88.    int i, j;
  89.  
  90.    new = (SAVEP) malloc (sizeof (SAVE));
  91.    c = new->save_cells = (CELLP) pop_malloc (sizeof (CELL) * height * width);
  92.    new->region = sb_new (top, left, height, width);
  93.    new->save_row = top;
  94.    new->save_col = left;
  95.    new->save_ht  = height;
  96.    new->save_wid = width;
  97.  
  98.    j = top * SB_COLS + left;
  99.    for (i = 0; i < height; i++)
  100.       {
  101.       memcpy (&c[i * width], &Scrnbuf[j], width * sizeof (CELL));
  102.       j += SB_COLS;
  103.       }
  104.  
  105.    return (new);
  106. }
  107.  
  108. void sb_restore (save)
  109. SAVEP save;
  110. {
  111.    int i, j, r;
  112.  
  113.    j = save->save_row * SB_COLS + save->save_col;
  114.    for (r = save->save_row, i = 0; i < save->save_ht; r++, i++)
  115.       {
  116.       memcpy (&Scrnbuf[j], &(save->save_cells[i * save->save_wid]), save->save_wid * sizeof (CELL));
  117.       j += SB_COLS;
  118.       if (save->save_col < Sbuf.lcol[r])
  119.          Sbuf.lcol[r] = save->save_col;
  120.       if (save->save_col + save->save_wid > Sbuf.rcol[r])
  121.          Sbuf.rcol[r] = save->save_col + save->save_wid;
  122.       }
  123.  
  124.    Sbuf.flags |= SB_DELTA;
  125.  
  126.    pop_free ((char *) (save->save_cells));
  127.    free (save->region);
  128.    free (save);
  129. }
  130.  
  131. char *pop_malloc (s)
  132. unsigned int s;
  133. {
  134.     char *p;
  135.  
  136.     p = popbuf;
  137.     popbuf += s;
  138.     return (p);
  139. }
  140.  
  141. void pop_free (s)
  142. char *s;
  143. {
  144.     popbuf = s;
  145. }
  146.