chiark / gitweb /
*** empty log message ***
[sympathy.git] / src / crt.c
index 24c0f02128b1baf4b0c43bbd1eea65531a1a157c..5f5656b2ccf33c46d4eedc8e0260e18b56728451 100644 (file)
--- a/src/crt.c
+++ b/src/crt.c
@@ -10,6 +10,33 @@ static char rcsid[] = "$Id$";
 
 /*
  * $Log$
+ * Revision 1.10  2008/02/22 17:07:00  james
+ * *** empty log message ***
+ *
+ * Revision 1.9  2008/02/07 13:22:51  james
+ * *** empty log message ***
+ *
+ * Revision 1.8  2008/02/07 13:19:48  james
+ * *** empty log message ***
+ *
+ * Revision 1.7  2008/02/07 12:41:06  james
+ * *** empty log message ***
+ *
+ * Revision 1.6  2008/02/07 12:16:04  james
+ * *** empty log message ***
+ *
+ * Revision 1.5  2008/02/06 11:30:37  james
+ * *** empty log message ***
+ *
+ * Revision 1.4  2008/02/05 01:11:46  james
+ * *** empty log message ***
+ *
+ * Revision 1.3  2008/02/04 20:23:55  james
+ * *** empty log message ***
+ *
+ * Revision 1.2  2008/02/04 02:05:06  james
+ * *** empty log message ***
+ *
  * Revision 1.1  2008/02/03 23:31:25  james
  * *** empty log message ***
  *
@@ -17,35 +44,127 @@ static char rcsid[] = "$Id$";
 
 #include "project.h"
 
-void crt_cls(CRT *c)
+void
+crt_erase (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
 {
-int i;
+  CRT_CA *ps = &c->screen[CRT_ADDR_POS (&s)];
+  CRT_CA *pe = &c->screen[CRT_ADDR_POS (&e)];
+
+  while (ps <= pe)
+    {
+      ps->chr = ' ';
+      if (ea)
+        {
+          ps->attr = CRT_ATTR_NORMAL;
+          ps->color = color;
+        }
+      ps++;
+    }
 
-for (i=0;i<CRT_CELS;++i) {
-       c->screen[i].chr=' ';
-       c->screen[i].chr=CRT_ATTR_NORMAL;
 }
+
+void
+crt_cls (CRT * c)
+{
+  CRT_Pos s = { 0, 0 };
+  CRT_Pos e = { CRT_COLS - 1, CRT_ROWS - 1 };
+  int i;
+
+  crt_erase (c, s, e, 1, CRT_COLOR_NORMAL);
+  c->sh.dir = 0;
 }
 
-void crt_reset(CRT *c)
+void
+crt_scroll_up (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
 {
-crt_cls(c);
+  int l, n;
+  int p;
+
+
+  s.x = 0;
+  e.x = CRT_COLS - 1;
+
+  c->sh.s = s;
+  c->sh.e = e;
+  c->sh.dir = -1;
+
+  l = e.x - s.x;
+  l++;
+  l *= sizeof (CRT_CA);
+
+  n = e.y - s.y;
+
+
+  p = CRT_ADDR_POS (&s);
+
+  while (n--)
+    {
+      memcpy (&c->screen[p], &c->screen[p + CRT_COLS], l);
+      p += CRT_COLS;
+    }
+
+  s.y = e.y;
+  crt_erase (c, s, e, ea,color);
 
-crt->pos.x=0;
-crt->pos.y=0;
-crt->hide_cursor=1;
 }
 
-void crt_insert(CRT *c,CRT_CA ca)
+void
+crt_scroll_down (CRT * c, CRT_Pos s, CRT_Pos e, int ea,int color)
 {
-if (c->pos.x<0) c->pos.x=0;
-if (c->pos.x>=CRT_COLS) c->pos.x=CRT_COLS-1;
-if (c->pos.y<0) c->pos.y=0;
-if (c->pos.y>=CRT_ROWS) c->pos.y=CRT_ROWS-1;
+  int l, n;
+  int p;
+
+  s.x = 0;
+  e.x = CRT_COLS - 1;
+
+  c->sh.s = s;
+  c->sh.e = e;
+  c->sh.dir = 1;
 
-crt->screen[CRT_ADDR(c->pos.y,c->pos.x)]=ca;
+  l = e.x - s.x;
+  l++;
+  l *= sizeof (CRT_CA);
 
+  n = e.y - s.y;
+  n++;
 
+  p = CRT_ADDR_POS (&e);
 
+  while (n--)
+    {
+      memcpy (&c->screen[p], &c->screen[p - CRT_COLS], l);
+      p -= CRT_COLS;
+    }
+
+  e.y = s.y;
+  crt_erase (c, s, e, ea,color);
+
+}
+
+void
+crt_reset (CRT * c)
+{
+  crt_cls (c);
+
+  c->pos.x = 0;
+  c->pos.y = 0;
+  c->hide_cursor = 1;
+  c->sh.dir = 0;
 }
 
+void
+crt_insert (CRT * c, CRT_CA ca)
+{
+  if (c->pos.x < 0)
+    c->pos.x = 0;
+  if (c->pos.x >= CRT_COLS)
+    c->pos.x = CRT_COLS - 1;
+  if (c->pos.y < 0)
+    c->pos.y = 0;
+  if (c->pos.y >= CRT_ROWS)
+    c->pos.y = CRT_ROWS - 1;
+
+  c->screen[CRT_ADDR (c->pos.y, c->pos.x)] = ca;
+
+  c->sh.dir = 0;
+}