home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
OS/2 Shareware BBS: 2 BBS
/
02-BBS.zip
/
BTMTSRC3.ZIP
/
SB_SAVE.C
< prev
next >
Wrap
C/C++ Source or Header
|
1990-07-05
|
6KB
|
146 lines
/*--------------------------------------------------------------------------*/
/* */
/* */
/* ------------ Bit-Bucket Software, Co. */
/* \ 10001101 / Writers and Distributors of */
/* \ 011110 / Freely Available<tm> Software. */
/* \ 1011 / */
/* ------ */
/* */
/* (C) Copyright 1987-90, Bit Bucket Software Co., a Delaware Corporation. */
/* */
/* */
/* Routines for updating the screen within BinkleyTerm */
/* */
/* */
/* For complete details of the licensing restrictions, please refer */
/* to the License agreement, which is published in its entirety in */
/* the MAKEFILE and BT.C, and also contained in the file LICENSE.240. */
/* */
/* USE OF THIS FILE IS SUBJECT TO THE RESTRICTIONS CONTAINED IN THE */
/* BINKLEYTERM LICENSING AGREEMENT. IF YOU DO NOT FIND THE TEXT OF */
/* THIS AGREEMENT IN ANY OF THE AFOREMENTIONED FILES, OR IF YOU DO */
/* NOT HAVE THESE FILES, YOU SHOULD IMMEDIATELY CONTACT BIT BUCKET */
/* SOFTWARE CO. AT ONE OF THE ADDRESSES LISTED BELOW. IN NO EVENT */
/* SHOULD YOU PROCEED TO USE THIS FILE WITHOUT HAVING ACCEPTED THE */
/* TERMS OF THE BINKLEYTERM LICENSING AGREEMENT, OR SUCH OTHER */
/* AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO. */
/* */
/* */
/* You can contact Bit Bucket Software Co. at any one of the following */
/* addresses: */
/* */
/* Bit Bucket Software Co. FidoNet 1:104/501, 1:132/491, 1:141/491 */
/* P.O. Box 460398 AlterNet 7:491/0 */
/* Aurora, CO 80046 BBS-Net 86:2030/1 */
/* Internet f491.n132.z1.fidonet.org */
/* */
/* Please feel free to contact us at any time to share your comments about */
/* our software and/or licensing policies. */
/* */
/* */
/* This module is derived from code developed by Augie Hansen in his */
/* book "Proficient C" published by Microsoft Press. Mr. Hansen was */
/* kind enough to give us verbal permission to use his routines, and */
/* Bob, Vince and Alan (and all our full screen users) are grateful. */
/* If you decide to use this code in some package you are doing, give */
/* some thought to going out and buying the book. He deserves that. */
/* */
/*--------------------------------------------------------------------------*/
#include <stdio.h>
#include <dos.h>
#ifdef __TURBOC__
#include <mem.h>
#include <alloc.h>
#else
#include <memory.h>
#include <malloc.h>
#endif
#include "sbuf.h"
#include "xfer.h"
#include "com.h"
#include "zmodem.h"
#include "keybd.h"
#include "sched.h"
#include "externs.h"
#include "prototyp.h"
#include "vfossil.h"
extern BUFFER Sbuf;
extern CELLP Scrnbuf;
extern REGIONP sb_new ();
char *pop_malloc (unsigned);
void pop_free (char *);
SAVEP sb_save (top, left, height, width)
int top;
int left;
int height;
int width;
{
SAVEP new;
CELLP c;
int i, j;
new = (SAVEP) malloc (sizeof (SAVE));
c = new->save_cells = (CELLP) pop_malloc (sizeof (CELL) * height * width);
new->region = sb_new (top, left, height, width);
new->save_row = top;
new->save_col = left;
new->save_ht = height;
new->save_wid = width;
j = top * SB_COLS + left;
for (i = 0; i < height; i++)
{
memcpy (&c[i * width], &Scrnbuf[j], width * sizeof (CELL));
j += SB_COLS;
}
return (new);
}
void sb_restore (save)
SAVEP save;
{
int i, j, r;
j = save->save_row * SB_COLS + save->save_col;
for (r = save->save_row, i = 0; i < save->save_ht; r++, i++)
{
memcpy (&Scrnbuf[j], &(save->save_cells[i * save->save_wid]), save->save_wid * sizeof (CELL));
j += SB_COLS;
if (save->save_col < Sbuf.lcol[r])
Sbuf.lcol[r] = save->save_col;
if (save->save_col + save->save_wid > Sbuf.rcol[r])
Sbuf.rcol[r] = save->save_col + save->save_wid;
}
Sbuf.flags |= SB_DELTA;
pop_free ((char *) (save->save_cells));
free (save->region);
free (save);
}
char *pop_malloc (s)
unsigned int s;
{
char *p;
p = popbuf;
popbuf += s;
return (p);
}
void pop_free (s)
char *s;
{
popbuf = s;
}