BSD 4_3_Tahoe development
authorCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 1 Dec 1986 09:28:10 +0000 (01:28 -0800)
committerCSRG <csrg@ucbvax.Berkeley.EDU>
Mon, 1 Dec 1986 09:28:10 +0000 (01:28 -0800)
Work on file usr/src/new/X/libvs100/Makefile
Work on file usr/src/new/X/libvs100/bitpix.c
Work on file usr/src/new/X/libvs100/copy.c
Work on file usr/src/new/X/libvs100/cursor.c
Work on file usr/src/new/X/libvs100/dl.c
Work on file usr/src/new/X/libvs100/draw.c
Work on file usr/src/new/X/libvs100/fill.c
Work on file usr/src/new/X/libvs100/font.c
Work on file usr/src/new/X/libvs100/maps.c
Work on file usr/src/new/X/libvs100/mem.h
Work on file usr/src/new/X/libvs100/move.c
Work on file usr/src/new/X/libvs100/packet.c
Work on file usr/src/new/X/libvs100/packet.h
Work on file usr/src/new/X/libvs100/param.h
Work on file usr/src/new/X/libvs100/put.c
Work on file usr/src/new/X/libvs100/reason.h
Work on file usr/src/new/X/libvs100/report.c
Work on file usr/src/new/X/libvs100/text.c
Work on file usr/src/new/X/libvs100/tile.c
Work on file usr/src/new/X/libvs100/util.c
Work on file usr/src/new/X/libvs100/vs100.h
Work on file usr/src/new/X/libvs100/vsalloc.c
Work on file usr/src/new/X/libvs100/vsioctl.h
Work on file usr/src/new/X/libvs100/vssite.h

Synthesized-from: CSRG/cd2/4.3tahoe

24 files changed:
usr/src/new/X/libvs100/Makefile [new file with mode: 0644]
usr/src/new/X/libvs100/bitpix.c [new file with mode: 0644]
usr/src/new/X/libvs100/copy.c [new file with mode: 0644]
usr/src/new/X/libvs100/cursor.c [new file with mode: 0644]
usr/src/new/X/libvs100/dl.c [new file with mode: 0644]
usr/src/new/X/libvs100/draw.c [new file with mode: 0644]
usr/src/new/X/libvs100/fill.c [new file with mode: 0644]
usr/src/new/X/libvs100/font.c [new file with mode: 0644]
usr/src/new/X/libvs100/maps.c [new file with mode: 0644]
usr/src/new/X/libvs100/mem.h [new file with mode: 0644]
usr/src/new/X/libvs100/move.c [new file with mode: 0644]
usr/src/new/X/libvs100/packet.c [new file with mode: 0644]
usr/src/new/X/libvs100/packet.h [new file with mode: 0644]
usr/src/new/X/libvs100/param.h [new file with mode: 0644]
usr/src/new/X/libvs100/put.c [new file with mode: 0644]
usr/src/new/X/libvs100/reason.h [new file with mode: 0644]
usr/src/new/X/libvs100/report.c [new file with mode: 0644]
usr/src/new/X/libvs100/text.c [new file with mode: 0644]
usr/src/new/X/libvs100/tile.c [new file with mode: 0644]
usr/src/new/X/libvs100/util.c [new file with mode: 0644]
usr/src/new/X/libvs100/vs100.h [new file with mode: 0644]
usr/src/new/X/libvs100/vsalloc.c [new file with mode: 0644]
usr/src/new/X/libvs100/vsioctl.h [new file with mode: 0644]
usr/src/new/X/libvs100/vssite.h [new file with mode: 0644]

diff --git a/usr/src/new/X/libvs100/Makefile b/usr/src/new/X/libvs100/Makefile
new file mode 100644 (file)
index 0000000..4227f94
--- /dev/null
@@ -0,0 +1,31 @@
+#
+# Copyright 1985, Massachusetts Institute of Technology
+#
+# Makefile for Vs100 X library.
+#
+
+
+INCLUDES= -I../include
+CFLAGS= -O ${INCLUDES}
+
+OBJS= bitpix.o copy.o cursor.o dl.o draw.o fill.o font.o maps.o \
+          move.o packet.o put.o report.o text.o tile.o util.o vsalloc.o
+
+all: libvs100.a
+
+site:
+       rm -f dl.o font.o
+
+# as this library is private to X, we should do nothing on install.
+
+install: all
+
+lint:
+       lint -Cvs100 *.c
+
+libvs100.a: $(OBJS)
+       ar r libvs100.a $(OBJS)
+       @ranlib libvs100.a
+
+clean:
+       rm -f ERRS *.o libvs100.a *~
diff --git a/usr/src/new/X/libvs100/bitpix.c b/usr/src/new/X/libvs100/bitpix.c
new file mode 100644 (file)
index 0000000..60dd4e7
--- /dev/null
@@ -0,0 +1,322 @@
+/* $Header: bitpix.c,v 10.3 86/02/01 15:46:25 tony Rel $ */
+/* Routines to cache bitmaps and pixmaps in the frame buffer memory:
+ *
+ *     StoreBitmap     Creates a bitmap
+ *     FreeBitmap      Frees the storage taken by a bitmap
+ *     CharBitmap      Creates a bitmap from a font character
+ *     StorePixmap     Creates a pixmap
+ *     FreePixmap      Frees the storage taken by a pixmap
+ *     MakePixmap      Create a pixmap from a bitmap
+ *     PixmapSave      Save a region of the screen
+ *     PixmapGet       Read a region of the screen
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+#include <errno.h>
+
+extern int errno;
+extern BitMap screen;
+extern int VSReloc;
+
+char *Xalloc(), *AllocateSpace();
+VSArea *VSAlloc();
+PIXMAP *MakePixmap();
+
+BITMAP *StoreBitmap (width, height, data)
+       int width, height;
+       char *data;
+{
+       register BITMAP *bm;
+       int size;
+
+       bm = (BITMAP *) Xalloc (sizeof (BITMAP));
+       bm->width = width;
+       bm->height = height;
+       bm->refcnt = 1;
+
+       size = BitmapSize(width, height);
+       if ((bm->data = (caddr_t) VSAlloc (size, BITMAP_TYPE)) == NULL) {
+           free ((caddr_t) bm);
+           return (NULL);
+       }
+       if (MoveBufferDown (data, BDATA(bm)->vsPtr, size)) {
+           FreeBitmap (bm);
+           return (NULL);
+       }
+       return (bm);
+}
+
+FreeBitmap (bitmap)
+       register BITMAP *bitmap;
+{
+       VSFree (BDATA(bitmap));
+       free ((caddr_t) bitmap);
+}
+
+BITMAP *CharBitmap (c, font)
+       unsigned c;
+       register FONT *font;
+{
+       int width;
+       register BITMAP *bm;
+
+       if (c < font->first || c > font->last) {
+           errno = EINVAL;
+           return (NULL);
+       }
+       if (font->fixed)
+           width = font->avg_width;
+       else
+           width = FDATA(font)->widths[c - font->first];
+       if (width == 0) {
+           errno = EINVAL;
+           return (NULL);
+       }
+       bm = (BITMAP *) Xalloc (sizeof (BITMAP));
+       bm->width = width;
+       bm->height = font->height;
+       bm->refcnt = 1;
+       if ((bm->data = (caddr_t) VSAlloc (BitmapSize(width, bm->height),
+                                          BITMAP_TYPE)) == NULL) {
+           free ((caddr_t) bm);
+           errno = ENOMEM;
+           return (NULL);
+       }
+
+       CopyText ((caddr_t) &c, 1, font, bm);
+       return (bm);
+}
+
+/*ARGSUSED*/
+PIXMAP *StorePixmap (width, height, format, data)
+       int width, height, format;
+       char *data;
+{
+       register BITMAP *bm;
+       register PIXMAP *pm;
+
+       bm = (BITMAP *) StoreBitmap (width, height, data);
+       if (bm == NULL)
+           return (NULL);
+       bm->refcnt = 0;
+       if (pm = MakePixmap (bm, 1, 0))
+           return (pm);
+       FreeBitmap (bm);
+       return (NULL);
+}
+
+FreePixmap (pixmap)
+       register PIXMAP *pixmap;
+{
+#ifdef HTCROCK
+       register TilePriv *tp;
+#endif
+       register BITMAP *bm;
+
+       if (pixmap->kind) {
+#ifdef HTCROCK
+           if (pixmap->kind & 2) {
+               tp = TDATA(pixmap);
+               bm = tp->bitmap;
+               free ((caddr_t) tp);
+           } else
+#endif
+           bm = PDATA(pixmap);
+           if (--bm->refcnt == 0)
+               FreeBitmap (bm);
+       }
+       free ((caddr_t) pixmap);
+}
+
+PIXMAP constpix0 = {1, 1, 1, 1, 0, (caddr_t) 0};
+PIXMAP constpix1 = {1, 1, 1, 1, 0, (caddr_t) 1};
+
+PIXMAP *MakePixmap (xymask, fore, back)
+       register BITMAP *xymask;
+       int fore, back;
+{
+#ifdef HTCROCK
+       register TilePriv *tp;
+#endif
+       register PIXMAP *pm;
+
+       if (xymask == NULL || !((fore ^ back) & 1)) {
+           if (fore & 1)
+               pm = &constpix1;
+           else
+               pm = &constpix0;
+           pm->refcnt++;
+           return (pm);
+       }
+
+       pm = (PIXMAP *) Xalloc (sizeof (PIXMAP));
+       pm->width = xymask->width;
+       pm->height = xymask->height;
+       pm->refcnt = 1;
+       xymask->refcnt++;
+       if (xymask->width == 16 && xymask->height == 16) {
+           pm->tile = 1;
+           pm->kind = 2;
+#ifdef HTCROCK
+           tp = (TilePriv *) Xalloc (sizeof (TilePriv));
+           tp->bitmap = xymask;
+           pm->data = (caddr_t) tp;
+           if (MoveBufferUp (BDATA(xymask)->vsPtr, (char *) tp->data, 32)) {
+               FreePixmap (pm);
+               return (NULL);
+           }
+#else
+           pm->data = (caddr_t) xymask;
+#endif
+       } else {
+           pm->tile = 0;
+           pm->kind = 1;
+           pm->data = (caddr_t) xymask;
+       }
+       if (back & 1)
+           pm->kind |= 0x10;
+       return (pm);
+}
+
+PIXMAP *PixmapSave (srcx, srcy, width, height)
+       int srcx, srcy, width, height;
+{
+       register BITMAP *bm;
+       PIXMAP *pm;
+       register CopyAreaPacket *cap;
+#define        h ((PacketHeader *) cap->cap_head)
+#define src ((SubBitmap *) cap->cap_source.image)
+#define dst ((SubBitmap *) cap->cap_destImage)
+#define        size ((Extent *) cap->cap_maskSize)
+
+       bm = (BITMAP *) Xalloc (sizeof (BITMAP));
+       bm->width = width;
+       bm->height = height;
+       bm->refcnt = 0;
+
+       if ((bm->data = (caddr_t) VSAlloc (BitmapSize(width, height),
+                                          BITMAP_TYPE)) == NULL) {
+           free ((caddr_t) bm);
+           return (NULL);
+       }
+
+       cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket));
+       if (cap == NULL) {
+           FreeBitmap (bm);
+           return (NULL);
+       }
+
+       h->ph_copyMod.m_mask = 0;
+       h->ph_copyMod.m_map = 0;
+       h->ph_copyMod.m_clipping = 0;
+       h->ph_copyMod.m_source = 1;
+       h->ph_opcode = COPY_AREA;
+       *(long *) h->ph_next = NULL;
+
+       *(BitMap *) src->sb_base = screen;
+       src->sb_x = srcx;
+       src->sb_y = srcy;
+       size->e_height = height;
+       size->e_width = width;
+
+       *(caddr_t *)dst->sb_address = BDATA(bm)->vsPtr;
+       dst->sb_height = height;
+       dst->sb_width = width;
+       dst->sb_bitsPerPixel = 1;
+       dst->sb_x = dst->sb_y = 0;
+
+       WritePacket ((caddr_t) cap);
+
+       if (pm = MakePixmap (bm, 1, 0))
+           return (pm);
+       FreeBitmap (bm);
+       return (NULL);
+#undef h
+#undef src
+#undef dst
+#undef size
+}
+
+/*ARGSUSED*/
+PixmapGet (srcx, srcy, width, height, client, format, swapit)
+       int srcx, srcy, width, height, client, format, swapit;
+{
+       int slop, width1, num, bytes;
+       char padding[2];
+       register CopyAreaPacket *cap;
+#define        h ((PacketHeader *) cap->cap_head)
+#define src ((SubBitmap *) cap->cap_source.image)
+#define dst ((SubBitmap *) cap->cap_destImage)
+#define        size ((Extent *) cap->cap_maskSize)
+
+       width1 = BitmapSize(width, 1);
+       slop = (width1 * height) & 2;
+       num = VBUFSIZE / width1;
+       while (height) {
+           if (height < num)
+               num = height;
+           bytes = num * width1;
+           cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket) +
+                                                   bytes);
+           if (cap == NULL)
+               return;
+           h->ph_copyMod.m_mask = 0;
+           h->ph_copyMod.m_map = 0;
+           h->ph_copyMod.m_clipping = 0;
+           h->ph_copyMod.m_source = 1;
+           h->ph_opcode = COPY_AREA;
+           *(long *) h->ph_next = NULL;
+
+           *(BitMap *) src->sb_base = screen;
+           src->sb_x = srcx;
+           src->sb_y = srcy;
+           size->e_height = num;
+           size->e_width = width;
+
+           *(caddr_t *)dst->sb_address = (caddr_t) cap +
+                                         sizeof (CopyAreaPacket) +
+                                         VSReloc;
+           dst->sb_height = num;
+           dst->sb_width = width;
+           dst->sb_bitsPerPixel = 1;
+           dst->sb_x = dst->sb_y = 0;
+
+           WritePacket ((caddr_t) cap);
+           SynchWrites ();
+           if (swapit)
+               Swap_shorts ((short *) ((caddr_t) cap + sizeof (CopyAreaPacket)),
+                            bytes >> 1);
+           Write (client, (caddr_t) cap + sizeof (CopyAreaPacket), bytes);
+           height -= num;
+           srcy += num;
+       }
+       if (slop)
+           Write (client, padding, slop);
+#undef h
+#undef src
+#undef dst
+#undef size
+}
diff --git a/usr/src/new/X/libvs100/copy.c b/usr/src/new/X/libvs100/copy.c
new file mode 100644 (file)
index 0000000..6c91eb5
--- /dev/null
@@ -0,0 +1,91 @@
+/* $Header: copy.c,v 10.3 86/02/01 15:46:31 tony Rel $ */
+/* copy.c      Copy one section of the framebuffer to another
+ *
+ *     CopyArea        Copies a section of the framebuffer
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+extern BitMap screen;
+extern int VSReloc;
+extern char SSMap[];
+
+char *AllocateSpace();
+
+CopyArea (srcx, srcy, width, height, dstx, dsty, clips, clipcount, func, zmask)
+       int srcx, srcy, width, height, dstx, dsty, clipcount, zmask;
+       register int func;
+       CLIP *clips;
+{
+       register CopyAreaPacket *cap;
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket));
+       if(cap == NULL) return;
+#define h ((PacketHeader *) cap->cap_head)
+#define src ((SubBitmap *) cap->cap_source.image)
+#define size ((Extent *) cap->cap_maskSize)
+#define destOff ((Point *) cap->cap_destOffset)
+#define clip ((RectangleList *) cap->cap_clipping.rectList)
+
+       func = SSMap[func];
+       h->ph_copyMod.m_source = 1;
+       h->ph_copyMod.m_mask = 0;
+       h->ph_copyMod.m_map = MAPTYPE(func);
+       h->ph_opcode = COPY_AREA;
+       *(long *) h->ph_next = NULL;
+
+       *(BitMap *) src->sb_base = screen;
+       src->sb_x = srcx;
+       src->sb_y = srcy;
+       size->e_height = height;
+       size->e_width = width;
+
+       *(BitMap *) cap->cap_destImage = screen;
+       destOff->p_x = dstx;
+       destOff->p_y = dsty;
+
+       *(short *) cap->cap_map.literal = MAPLIT(func);
+
+       if (clipcount == 1) {
+           h->ph_copyMod.m_clipping = 1;
+           *(CLIP *) cap->cap_clipping.litRect = *clips;
+       } else {
+           h->ph_copyMod.m_clipping = 2;
+           *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+           clip->r_count = clipcount;
+       }
+
+       WritePacket ((caddr_t) cap);
+#undef h
+#undef src
+#undef size
+#undef destOff
+#undef clip
+}
diff --git a/usr/src/new/X/libvs100/cursor.c b/usr/src/new/X/libvs100/cursor.c
new file mode 100644 (file)
index 0000000..8b8a3ff
--- /dev/null
@@ -0,0 +1,217 @@
+/* $Header: cursor.c,v 10.3 86/02/01 15:46:34 tony Rel $ */
+/* cursor.c    various stuff with the mouse & cursor
+ *
+ *     StoreCursor             Creates a cursor
+ *     FreeCursor              Frees the storage taken by a cursor
+ *     LoadCursor              Loads a bitmap to use as cursor
+ *     InitMouse               Initialize the mouse
+ *     SetCursorPosition       Forces cursor to a particular position
+ *     SetMouseCharacteristics Controls speed of cursor relative to mouse
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+#include "vsioctl.h"
+
+extern vsIoAddr *VSAddr;
+extern BitMap screen;
+extern char FBMap[];
+
+char *Xalloc(), *AllocateSpace();
+
+CURSOR *StoreCursor (func, image, fore, back, mask, xoff, yoff)
+       register BITMAP *image, *mask;
+       int func, fore, back, xoff, yoff;
+{
+       register CURSOR *cursor;
+       register CursPriv *data;
+
+       cursor = (CURSOR *) Xalloc (sizeof (CURSOR));
+       cursor->width = image->width;
+       cursor->height = image->height;
+       cursor->xoff = xoff;
+       cursor->yoff = yoff;
+       cursor->xmin = xoff;
+       cursor->ymin = yoff;
+       cursor->xmax = screen.bm_width - (image->width - xoff);
+       cursor->ymax = screen.bm_height - (image->height - yoff);
+       cursor->refcnt = 1;
+       data = (CursPriv *) Xalloc (sizeof (CursPriv));
+       data->image = image;
+       image->refcnt++;
+       if (data->mask = mask)
+           mask->refcnt++;
+       if (fore & 1)
+           func += 0x20;
+       if (back & 1)
+           func += 0x10;
+       data->map = FBMap[func];
+       cursor->data = (caddr_t) data;
+       return (cursor);
+}
+
+FreeCursor (cursor)
+       register CURSOR *cursor;
+{
+       register CursPriv *data;
+       register BITMAP *bm;
+
+       data = CDATA(cursor);
+       if ((bm = data->image) && --bm->refcnt == 0)
+           FreeBitmap (bm);
+       if ((bm = data->mask) && --bm->refcnt == 0)
+           FreeBitmap (bm);
+       free ((caddr_t) cursor);
+}
+
+LoadCursor (cursor)
+       register CURSOR *cursor;
+{
+       register CursPriv *data;
+       register BITMAP *bm;
+       register LoadCursorPacket *lcp;
+
+       lcp = (LoadCursorPacket *) AllocateSpace (sizeof (LoadCursorPacket));
+       if (lcp == NULL) return;
+#define h ((PacketHeader *) lcp->lcp_head)
+#define src ((SubBitmap *) lcp->lcp_source.image)
+#define msk ((SubBitmap *) lcp->lcp_sourceMask)
+#define pat ((Halftone *) lcp->lcp_source.pattern)
+#define        size ((Extent *) lcp->lcp_maskSize)
+
+       data = CDATA(cursor);
+       h->ph_cursorMod.m_source = 1;
+       h->ph_cursorMod.m_map = MAPTYPE(data->map);
+       h->ph_opcode = LOAD_CURSOR;
+       *(long *) h->ph_next = NULL;
+
+       bm = data->image;
+       *(caddr_t *) src->sb_address = BDATA(bm)->vsPtr;
+       src->sb_height = bm->height;
+       src->sb_width = bm->width;
+       src->sb_bitsPerPixel = 1;
+       src->sb_x = src->sb_y = 0;
+       size->e_height = bm->height;
+       size->e_width = bm->width;
+
+       if (bm = data->mask) {
+           h->ph_cursorMod.m_mask = 1;
+           *(caddr_t *) msk->sb_address = BDATA(bm)->vsPtr;
+           msk->sb_height = bm->height;
+           msk->sb_width = bm->width;
+           msk->sb_bitsPerPixel = 1;
+           msk->sb_x = msk->sb_y = 0;
+       } else
+           h->ph_cursorMod.m_mask = 0;
+       *(short *) lcp->lcp_map.literal = MAPLIT(data->map);
+
+       lcp->lcp_blink = 0;
+       lcp->lcp_tip_x = cursor->xoff;
+       lcp->lcp_tip_y = cursor->yoff;
+       lcp->lcp_center_x = cursor->xoff;
+       lcp->lcp_center_y = cursor->yoff;
+
+       WritePacket ((caddr_t) lcp);
+#undef h
+#undef src
+#undef msk
+#undef pat
+#undef size
+}
+
+InitMouse ()
+{
+       register AttachCursorPacket *acp;
+       register SetPointingDeviceReportingPacket *spdp;
+
+       acp = (AttachCursorPacket *) AllocateSpace (sizeof (AttachCursorPacket));
+       if (acp == NULL) return;
+#define h ((PacketHeader *) acp->acp_head)
+
+       h->ph_modifier.emptymod = 0;
+       h->ph_opcode = ATTACH_CURSOR;
+       *(long *) h->ph_next = NULL;
+
+       acp->acp_device = 1;
+
+       WritePacket ((caddr_t) acp);
+#undef h
+
+       spdp = (SetPointingDeviceReportingPacket *) AllocateSpace (sizeof (SetPointingDeviceReportingPacket));
+       if (spdp == NULL) return;
+#define h ((PacketHeader *) spdp->spdp_head)
+
+       h->ph_modifier.emptymod = 0;
+       h->ph_opcode = SET_POINTING_DEVICE_REPORTING;
+       *(long *) h->ph_next = NULL;
+
+       spdp->spdp_enable = 1;
+
+       WritePacket ((caddr_t) spdp);
+#undef h
+}
+
+SetCursorPosition(pos)
+       register vsCursor *pos;
+{
+       register SetCursorPositionPacket *scp;
+
+       scp = (SetCursorPositionPacket *) AllocateSpace (sizeof (SetCursorPositionPacket));
+       if (scp == NULL) return;
+#define h ((PacketHeader *) scp->scp_head)
+#define loc ((Point *) scp->scp_position)
+
+       h->ph_modifier.emptymod = 0;
+       h->ph_opcode = SET_CURSOR_POSITION;
+       *(long *) h->ph_next = NULL;
+
+       loc->p_x = pos->x;
+       loc->p_y = pos->y;
+
+       WritePacket ((caddr_t) scp);
+       VSAddr->mouse = *pos;
+#undef h
+#undef loc
+}
+
+SetMouseCharacteristics (threshold, acceleration)
+       int threshold, acceleration;
+{
+       register SetMouseCharacteristicsPacket *smp;
+
+       smp = (SetMouseCharacteristicsPacket *) AllocateSpace (sizeof (SetMouseCharacteristicsPacket));
+       if (smp == NULL) return;
+#define h ((PacketHeader *) smp->smc_head)
+
+       h->ph_mouseMod.m_tracking = 1;
+       h->ph_opcode = SET_MOUSE_CHARACTERISTICS;
+       *(long *) h->ph_next = NULL;
+
+       smp->smc_scale = acceleration;
+       smp->smc_threshold = threshold;
+
+       WritePacket ((caddr_t) smp);
+#undef h
+}
diff --git a/usr/src/new/X/libvs100/dl.c b/usr/src/new/X/libvs100/dl.c
new file mode 100644 (file)
index 0000000..dca1523
--- /dev/null
@@ -0,0 +1,262 @@
+/* $Header: dl.c,v 10.3 86/02/01 15:46:40 tony Rel $ */
+/* dl.c                downloads code into the vs100.  Routines are
+ *
+ *     DownLoad        Determines device version and downloads firmware
+ *
+ *     Takes an int which is the device to download and
+ *             returns 0 if everything went well and -1 if
+ *             there is some problem.
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+#include <sys/ioctl.h>
+#include "vsioctl.h"
+#include "vssite.h"
+
+#define CODE_START_ADDRESS 0x1000
+
+#define BUFSIZE 512            /* Why not?  Everyone uses 512 */
+
+int HexArray[128];
+#define Hex2(p)                ((HexArray[*(p)]<<4)+HexArray[*((p)+1)])
+
+extern int vsdev;              /* File number of the workstation */
+BitMap screen;                 /* The actual screen memory */
+
+/* Determine what version of the vs we have and download the appropriate
+ * firmware.  Determining the version is not trivial and as versions change
+ * this may also have to change.
+ */
+
+int DownLoad ()
+{
+       FILE *fopen(), *fd;     /* The file descriptor */
+       char *AllocateSpace();
+       char *filename;         /* Name of download file */
+       char *buf;              /* The input buffer */
+       char inline[BUFSIZE];   /* The line from the file */
+       int bufpos;             /* The current position in the buffer */
+       int linesize;           /* The number of bytes represented by a line */
+       int lineaddr;           /* The intended address of the line */
+       int nextaddr;           /* The expected next address */
+       int destaddr;           /* The destination for the current buffer */
+       caddr_t pMem;           /* Program memory pointer */
+       caddr_t startAddr;      /* Address to start microcode */
+       MemArea programMemory;  /* Information about program memory */
+       char textVersion[5];    /* The version number reported back */
+       int version;
+       char errmessage[BUFSIZE];       /* error message buffer */
+
+       /* Initialize the device,
+        * figure out just what version of the device we have, and
+        * get the address to load the code into
+        */
+
+       if (PacketInit() ||
+           ioctl (vsdev, (int) VSIOINIT, (caddr_t) NULL) ||
+           ioctl (vsdev, (int) VSIOGETVER, (caddr_t) &version) ||
+           ReportStatus ((int *) textVersion, (short *) NULL, (short *) NULL,
+                         &screen, (MemArea *) NULL, &programMemory,
+                         (MemArea *) NULL, 1)) {
+               VSError ();
+               return(-1);
+       }
+
+       switch (version) {
+           case 8:
+
+               /* Everyone in the world reports 8!  Fortunately I can
+                  tell them apart by other means (Then why isn't that
+                  the version???  You tell me!) */
+
+               if (screen.bm_height != 800) filename = LOAD_FILE_3_8;
+               else filename = LOAD_FILE_2B;
+               break;
+
+           case 1:     /* This is an SBO, I think!  */
+               filename = LOAD_FILE_SBO;
+               break;
+
+           default:
+
+               /* Assume we have a 3.10.  We may even be right */
+
+               filename = LOAD_FILE_3_10;
+               break;
+       }
+
+       pMem = *(caddr_t *) programMemory.m_base;
+       startAddr = pMem + CODE_START_ADDRESS;
+
+       /* Open the file in read mode */
+
+       if ((fd = fopen (filename, "r")) == NULL) {
+               sprintf(errmessage, "Xvs100: Can't open uCode file %s.\n",
+                       filename);
+               DeviceError(errmessage);
+               return (-1);
+       }
+
+       InitHexArray();
+
+       /* Read in the s-line file and copy to the workstation */
+
+       bufpos = 0;
+       buf = AllocateSpace (BUFSIZE);
+       destaddr = 0;
+
+       while (fgets (inline, BUFSIZE, fd) != NULL) {
+           if (inline[0] == '\n') continue;
+           if (ParseLine (inline, &linesize, &lineaddr)) break;
+           if (destaddr == 0) destaddr = nextaddr = lineaddr;
+           if (bufpos > 0 &&
+                   (lineaddr != nextaddr || linesize + bufpos > BUFSIZE)) {
+               if (MoveObjectDownRom (buf, pMem + destaddr, bufpos))
+                   return (-1);
+               buf = AllocateSpace (BUFSIZE);
+               bufpos = 0;
+               destaddr = nextaddr = lineaddr;
+           }
+           CopyLine (inline, buf, linesize, bufpos);
+           bufpos += linesize;
+           nextaddr += linesize;
+       }
+
+       /* Copy the last packet */
+
+       if (bufpos > 0) {
+           if (MoveObjectDownRom (buf, pMem + destaddr, bufpos))
+                   return (-1);
+       }
+
+       fclose (fd);
+
+       /* Sync the writes to make sure it's all been downloaded! */
+
+       if (SynchWrites()) return (-1);
+
+       /* Start microcode */
+
+       if (ioctl (vsdev, (int) VSIOSTART, (caddr_t) &startAddr)) return (-1);
+
+       return (VSMemInit());           /* Initialize memory allocator */
+}
+
+/* The following routines parse the so-called s-line format.  This was
+ * lifted more or less verbatim from the vms software; I don't fully
+ * understand it and you certainly don't want to even bother trying.
+ */
+
+ParseLine (line, linesize, lineaddr)
+       char *line;
+       int *linesize, *lineaddr;
+{
+       if (line[0] != 'S') DLError ("Invalid format", line);
+
+       switch (line[1]) {
+           case '0':
+               break;
+           case '1': case '2':
+#ifdef notdef
+               CheckLine (line);       /* Checks checksum */
+#endif
+               if (line[1] == '1') {
+                   *linesize = Hex2(line+2) - 3;
+                   *lineaddr = Hex (line+4, 4);
+               } else {
+                   *linesize = Hex2(line+2) - 4;
+                   *lineaddr = Hex (line+4, 6);
+               }
+               break;
+           case '9':
+               return (-1);
+           default:
+               DLError ("Invalid format", line);
+               break;
+       }
+       return (0);
+}
+
+CopyLine (line, buffer, count, pos)
+       char *line, *buffer;
+       register int count, pos;
+{
+       register char *start;
+
+       if (line[1] == '1') start = line + 8;
+       else start = line + 10;
+
+       while (--count >= 0) {
+           buffer[pos^1] = Hex2(start);
+           pos++;
+           start += 2;
+       }
+}
+
+CheckLine (line)
+       register char *line;
+{
+       register char *lp;
+       register int count;
+       register char checksum;
+
+       lp = line + 2;
+       count = Hex2(lp);
+       checksum = 0;
+
+       do {
+           checksum += Hex2(lp);
+           lp += 2;
+       } while (--count >= 0);
+
+       if (checksum != 0xff) DLError ("Bad checksum", line);
+}
+
+InitHexArray ()
+{
+    register char c;
+    for (c = 'A'; c <= 'F'; c++) HexArray[c] = c - 'A' + 10;
+    for (c = 'a'; c <= 'f'; c++) HexArray[c] = c - 'a' + 10;
+    for (c= '0'; c <= '9'; c++) HexArray[c] = c - '0';
+}
+
+int Hex (cp, n)
+       register char *cp;
+       register int n;
+{
+       register int i = 0;
+       while (--n >= 0)
+           i = (i<<4) + HexArray[*cp++];
+       return (i);
+}
+
+DLError (str1, str2)
+       char *str1, *str2;
+{
+       fprintf (stderr, "Downloader: %s: %s\n", str1, str2);
+       fflush (stderr);
+       exit (1);
+}
diff --git a/usr/src/new/X/libvs100/draw.c b/usr/src/new/X/libvs100/draw.c
new file mode 100644 (file)
index 0000000..352a3d3
--- /dev/null
@@ -0,0 +1,116 @@
+/* $Header: draw.c,v 10.3 86/02/01 15:46:46 tony Rel $ */
+/* draw.c      Draw lines, curves, and polygons on the screen
+ *
+ *     DrawCurve       Draw a generalized line/polygon/combination
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+extern BitMap screen;
+extern int VSReloc;
+extern char SSMap[];
+
+char *AllocateCopy(), *AllocateSpace();
+
+DrawCurve (verts, vertcount, xbase, ybase, srcpix, altpix, mode,
+          bwidth, bheight, pat, patlen, patmul, clips, clipcount, func, zmask)
+       Vertex *verts;
+       int vertcount, xbase, ybase, srcpix, altpix, mode, bwidth, bheight;
+       int pat, patlen, patmul, clipcount, zmask;
+       register int func;
+       CLIP *clips;
+{
+       register DrawCurvePacket *dcp;
+#define        h ((PacketHeader *) dcp->dcp_head)
+#define        size ((Extent *) dcp->dcp_maskSize)
+#define        destOff ((Point *) dcp->dcp_destOffset)
+#define        path ((SegmentList *) dcp->dcp_path)
+#define        clip ((RectangleList *) dcp->dcp_clipping.rectList)
+#define pstr ((PatternString *) dcp->dcp_pattern)
+#define pstate ((PatternState *) dcp->dcp_patState.literal)
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       if ((verts = (Vertex *) AllocateCopy ((caddr_t) verts, vertcount * sizeof (Vertex))) == NULL ||
+           (dcp = (DrawCurvePacket *) AllocateSpace (sizeof (DrawCurvePacket))) == NULL)
+           return;
+
+       func = SSMap[func];
+       h->ph_drawMod.m_source = 0;     /* Always constant here */
+       h->ph_drawMod.m_mask = 0;
+       h->ph_drawMod.m_map = MAPTYPE(func);
+       if (mode == 0) {
+           h->ph_drawMod.m_drawMode = 0;
+           h->ph_drawMod.m_patMode = 0;
+       } else {
+           h->ph_drawMod.m_drawMode = 1;
+           h->ph_drawMod.m_patMode = mode - 1;
+       }
+       h->ph_drawMod.m_patState = 0;
+       h->ph_opcode = DRAW_CURVE;
+       *(long *) h->ph_next = NULL;
+
+       dcp->dcp_source.const = srcpix & 1;
+       dcp->dcp_secondSource.const = altpix & 1;
+
+       size->e_height = bheight;
+       size->e_width = bwidth;
+
+       *(BitMap *) dcp->dcp_destImage = screen;
+       destOff->p_x = xbase;
+       destOff->p_y = ybase;
+
+       *(short *) dcp->dcp_map.literal = MAPLIT(func);
+
+       pstr->p_pattern = pat;
+       pstr->p_length = patlen;
+       pstr->p_multiplier = patmul;
+       pstate->p_position = 0;
+       pstate->p_count = 0;
+
+       if (clipcount == 1) {
+           h->ph_drawMod.m_clipping = 1;
+           *(CLIP *) dcp->dcp_clipping.litRect = *clips;
+       } else {
+           h->ph_drawMod.m_clipping = 2;
+           *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+           clip->r_count = clipcount;
+       }
+
+       *(caddr_t *) path->seg_first = (caddr_t) verts + VSReloc;
+       path->seg_count = vertcount;
+
+       WritePacket ((caddr_t) dcp);
+#undef h
+#undef size
+#undef destOff
+#undef path
+#undef clip
+#undef pstr
+#undef pstate
+}
diff --git a/usr/src/new/X/libvs100/fill.c b/usr/src/new/X/libvs100/fill.c
new file mode 100644 (file)
index 0000000..c173a80
--- /dev/null
@@ -0,0 +1,145 @@
+/* $Header: fill.c,v 10.5 86/04/04 14:36:44 newman Rel $ */
+/* fill.c      Perform a simple raster operation a section of the screen
+ *
+ *     PixFill Do a function on the screen
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+extern BitMap screen;
+extern int VSReloc;
+extern char SSMap[];
+
+char *AllocateSpace();
+
+PixFill (srcpix, xymask, dstx, dsty, width, height, clips, clipcount,
+        func, zmask)
+       int srcpix, dstx, dsty, width, height, clipcount, zmask;
+       register BITMAP *xymask;
+       register int func;
+       CLIP *clips;
+{
+       register CopyAreaPacket *cap;
+#define        h ((PacketHeader *) cap->cap_head)
+#define mask ((SubBitmap *) cap->cap_sourceMask)
+#define        size ((Extent *) cap->cap_maskSize)
+#define        destOff ((Point *) cap->cap_destOffset)
+#define        clip ((RectangleList *) cap->cap_clipping.rectList)
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket));
+       if (cap == NULL) return;
+
+       func = SSMap[func];
+       h->ph_copyMod.m_source = 0;
+       h->ph_copyMod.m_mask = xymask ? 1 : 0;
+       h->ph_copyMod.m_map = MAPTYPE(func);
+       h->ph_opcode = COPY_AREA;
+       *(long *) h->ph_next = NULL;
+
+       cap->cap_source.const = srcpix & 1;
+
+       if (xymask) {
+               *(caddr_t *) mask->sb_address = BDATA(xymask)->vsPtr;
+               mask->sb_height = xymask->height;
+               mask->sb_width = xymask->width;
+               mask->sb_bitsPerPixel = 1;
+               mask->sb_x = mask->sb_y = 0;
+       }
+       size->e_height = height;
+       size->e_width = width;
+
+       *(BitMap *) cap->cap_destImage = screen;
+       destOff->p_x = dstx;
+       destOff->p_y = dsty;
+
+       *(short *) cap->cap_map.literal = MAPLIT(func);
+
+       if (clipcount == 1) {
+           h->ph_copyMod.m_clipping = 1;
+           *(CLIP *) cap->cap_clipping.litRect = *clips;
+       } else {
+           h->ph_copyMod.m_clipping = 2;
+           *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+           clip->r_count = clipcount;
+       }
+
+       WritePacket ((caddr_t) cap);
+#undef h
+#undef mask
+#undef size
+#undef destOff
+#undef clip
+}
+extern int errno;
+#include <errno.h>
+
+int StippleFill (srcpix, xoff, yoff, stipmask, dstx, dsty, width, height,
+       clips, clipcount, func, zmask)
+       int srcpix;             /* source pixel */
+       int xoff, yoff;         /* stipple origin */
+       BITMAP *stipmask;       /* stipple mask */
+       int dstx, dsty;         /* destination */
+       int width, height;
+       CLIP *clips;            /* clipping rectangles */
+       int clipcount;
+       int func;               /* GX display function */
+       int zmask;              /* plane mask */
+{
+       static char funcmap[16][2] = {
+               {GXandInverted, GXandInverted}, /* GXclear */
+               {GXandInverted, GXnoop},        /* GXand */
+               {GXandInverted, GXxor},         /* GXandReverse */
+               {GXandInverted, GXor},          /* GXcopy */
+               {GXnoop,        GXandInverted}, /* GXandInverted */
+               {GXnoop,        GXnoop},        /* GXnoop */
+               {GXnoop,        GXxor},         /* GXxor */
+               {GXnoop,        GXor},          /* GXor */
+               {GXxor,         GXandInverted}, /* GXnor */
+               {GXxor,         GXnoop},        /* GXequiv */
+               {GXxor,         GXxor},         /* GXinvert */
+               {GXxor,         GXor},          /* GXorReverse */
+               {GXor,          GXandInverted}, /* GXcopyInverted */
+               {GXor,          GXnoop},        /* GXorInverted */
+               {GXor,          GXxor},         /* GXnand */
+               {GXor,          GXor}           /* GXset */
+       };
+       int newfunc = funcmap [func][srcpix & 1];
+       PIXMAP *tile, *MakePixmap();
+
+       if ((stipmask->width != 16) || (stipmask->height != 16)) {
+               errno = EINVAL;
+               return (0);
+       }
+       tile = MakePixmap (stipmask, 1, 0);
+       TileFill (tile, xoff, yoff, 0, dstx, dsty, width, height,
+               clips, clipcount, newfunc, zmask);
+       FreePixmap (tile);
+       return (1);
+}
diff --git a/usr/src/new/X/libvs100/font.c b/usr/src/new/X/libvs100/font.c
new file mode 100644 (file)
index 0000000..362eb73
--- /dev/null
@@ -0,0 +1,193 @@
+/* $Header: font.c,v 10.3 86/02/01 15:46:53 tony Rel $ */
+/* font.c      Reads a font from a file and stores it on the workstation
+ *
+ *     GetFont         Takes a font name and stores it
+ *     FreeFont        Frees the storage taken by a font
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+#include "vssite.h"
+#include <errno.h>
+
+extern int errno;
+
+char *Xalloc(), *AllocateSpace(), *strcpy(), *strcat();
+long lseek();
+VSArea *VSAlloc();
+
+FONT *GetFont (name)
+       char *name;
+{
+       char fontname[256];
+       int fontfile;
+       FontData font;
+       register FontData *fontCopy;
+#define chars ((BitMap *) font.f_characters)
+       int fontsize, leftsize, width;
+       char *fontarea;
+       register short *leftarea;
+       register FONT *fd;
+       FontPriv *fpriv;
+       register BitMap *mychars;
+
+       strcpy (fontname, DEFAULT_FONT_DIRECTORY);
+       strcat (fontname, name);
+       strcat (fontname, DEFAULT_FONT_SUFFIX);
+
+       if ((fontfile = open (fontname, 0)) == -1 &&
+           (errno != ENOENT || (fontfile = open (name, 0)) == -1)) {
+           errno = EINVAL;
+           return (NULL);
+       }
+
+       if (read (fontfile, (caddr_t) &font, sizeof (FontData)) != sizeof (FontData)) {
+           close (fontfile);
+           errno = EINVAL;
+           return (NULL);
+       }
+
+       fontsize = BitmapSize(chars->bm_width, chars->bm_height);
+       fontarea = (char *) Xalloc (fontsize);
+       lseek (fontfile, (long) font.f_characters[0], 0);
+       if (read (fontfile, fontarea, fontsize) != fontsize) {
+           close (fontfile);
+           free (fontarea);
+           errno = EINVAL;
+           return (NULL);
+       }
+
+       if (font.f_fixedWidth == 0) {
+           leftsize = (font.f_lastChar - font.f_firstChar + 2) * sizeof (short);
+           leftarea = (short *) Xalloc (leftsize);
+           lseek (fontfile, (long) font.f_leftArray[0], 0);
+           if (read (fontfile, (caddr_t) leftarea, leftsize) != leftsize) {
+               close (fontfile);
+               free (fontarea);
+               free ((caddr_t) leftarea);
+               errno = EINVAL;
+               return (NULL);
+           }
+       } else {
+           leftsize = 0;
+           leftarea = NULL;
+       }
+
+       close (fontfile);
+
+       if ((fontCopy = (FontData *)
+                               AllocateSpace (sizeof (FontData))) == NULL) {
+           free (fontarea);
+           if (leftarea)
+               free ((caddr_t) leftarea);
+           errno = ENOMEM;
+           return (NULL);
+       }
+       mychars = (BitMap *) fontCopy->f_characters;
+       fd = (FONT *) Xalloc (sizeof (FONT));
+
+       mychars->bm_address[0] = sizeof (FontData);
+       mychars->bm_address[1] = 0;
+       mychars->bm_width = chars->bm_width;
+       fd->height = mychars->bm_height = chars->bm_height;
+       mychars->bm_bitsPerPixel = 1;
+       fd->first = fontCopy->f_firstChar = font.f_firstChar;
+       fd->last = fontCopy->f_lastChar = font.f_lastChar;
+       if (leftarea)
+           fontCopy->f_leftArray[0] = sizeof (FontData) + fontsize;
+       else
+           fontCopy->f_leftArray[0] = 0;
+       fontCopy->f_leftArray[1] = 0;
+
+       fd->base = fontCopy->f_baseline = font.f_baseline;
+       fd->space = fontCopy->f_spaceIndex = font.f_spaceIndex;
+       fd->space += fd->first;
+       if (fd->avg_width = fontCopy->f_fixedWidth = font.f_fixedWidth)
+           fd->fixed = 1;
+       else
+           fd->fixed = 0;
+
+       fd->refcnt = 1;
+       fpriv = (FontPriv *) Xalloc (sizeof (FontPriv));
+       fd->data = (caddr_t) fpriv;
+       fpriv->widths = leftarea;
+
+       if ((fpriv->remote = (VSArea *) VSAlloc (sizeof (FontData) + fontsize + leftsize,
+                                                   FONT_TYPE)) == NULL) {
+           free (fontarea);
+           if (leftarea)
+               free ((caddr_t) leftarea);
+           free ((caddr_t) fd);
+           free ((caddr_t) fpriv);
+           return (NULL);
+       }
+       fd->name = (char *) Xalloc (strlen (name) + 1);
+       strcpy (fd->name, name);
+
+       if (MoveObjectDown ((caddr_t) fontCopy, fpriv->remote->vsPtr, sizeof (FontData)) ||
+           MoveBufferDown (fontarea,
+                           fpriv->remote->vsPtr + sizeof (FontData),
+                           fontsize) ||
+           (leftarea &&
+            MoveBufferDown ((caddr_t) leftarea,
+                            fpriv->remote->vsPtr + sizeof (FontData) + fontsize,
+                            leftsize))) {
+           free (fontarea);
+           FreeFont (fd);
+           errno = ENOMEM;
+           return (NULL);
+       }
+
+       if (leftarea) {
+           leftsize = font.f_lastChar - font.f_firstChar + 1;
+           width = 0;
+           fontsize = 0;
+           while (--leftsize >= 0) {
+               *leftarea = leftarea[1] - *leftarea;
+               if (*leftarea) {
+                   width += *leftarea;
+                   fontsize++;
+               }
+               leftarea++;
+           }
+           fd->avg_width = width / fontsize;
+       }
+       free (fontarea);
+       return (fd);
+#undef chars
+}
+
+FreeFont (font)
+       register FONT *font;
+{
+       register FontPriv *data;
+
+       data = FDATA(font);
+       if (data->widths) free ((caddr_t) data->widths);
+       VSFree (data->remote);
+       free ((caddr_t) data);
+       free (font->name);
+       free ((caddr_t) font);
+}
diff --git a/usr/src/new/X/libvs100/maps.c b/usr/src/new/X/libvs100/maps.c
new file mode 100644 (file)
index 0000000..dfa8f00
--- /dev/null
@@ -0,0 +1,22 @@
+/* $Header: maps.c,v 10.3 86/02/01 15:46:58 tony Rel $ */
+/* foreground/background map */
+
+char FBMap[] = {0x40, 0x40, 0x40, 0x40, 0x45, 0x45, 0x45, 0x45,
+               0x4a, 0x4a, 0x4a, 0x4a, 0x4f, 0x4f, 0x4f, 0x4f,
+
+               0x40, 0x44, 0x48, 0x22, 0x41, 0x45, 0x49, 0x4d,
+               0x42, 0x46, 0x4a, 0x4e, 0x00, 0x47, 0x4b, 0x4f,
+
+               0x40, 0x41, 0x42, 0x00, 0x44, 0x45, 0x46, 0x47,
+               0x48, 0x49, 0x4a, 0x4b, 0x22, 0x4d, 0x4e, 0x4f,
+
+               0x40, 0x45, 0x4a, 0x4f, 0x40, 0x45, 0x4a, 0x4f,
+               0x40, 0x45, 0x4a, 0x4f, 0x40, 0x45, 0x4a, 0x4f};
+
+/* single source map */
+
+char SSMap[] = {0x40, 0x41, 0x42, 0x00, 0x44, 0x45, 0x46, 0x47,
+               0x48, 0x49, 0x4a, 0x4b, 0x22, 0x4d, 0x4e, 0x4f,
+
+               0x40, 0x44, 0x48, 0x22, 0x41, 0x45, 0x49, 0x4d,
+               0x42, 0x46, 0x4a, 0x4e, 0x00, 0x47, 0x4b, 0x4f};
diff --git a/usr/src/new/X/libvs100/mem.h b/usr/src/new/X/libvs100/mem.h
new file mode 100644 (file)
index 0000000..6de4ea0
--- /dev/null
@@ -0,0 +1,62 @@
+/* $Header: mem.h,v 10.3 86/02/01 15:47:01 tony Rel $ */
+/* mem.h       Data structure for maintaining memory allocation of vs100
+ *             framebuffer memory.
+ *
+ * Author:     Paul J. Asente
+ *             Digital Equipment Corporation
+ *             Western Reseach Lab
+ * Date:       June 1983
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "param.h"
+
+typedef struct _VSArea {
+       struct _VSArea *next;
+       struct _VSArea *prev;
+       caddr_t vsPtr;
+       struct {
+           unsigned int _vsFreeFlag : 1;
+           int _vsSize : 31;
+       } s;
+       union {
+           struct {
+               struct _VSArea *next;
+               struct _VSArea *prev;
+           } _vsFree;
+           int _vsType;
+       } u;
+} VSArea;
+
+#define vsFreeFlag s._vsFreeFlag
+#define vsSize s._vsSize
+#define vsFree u._vsFree
+#define vsType u._vsType
+
+#define VS_FREE        0
+#define VS_INUSE 1
+
+#define BITMAP_TYPE 1
+#define HALFTONE_TYPE 2
+#define FONT_TYPE 3
diff --git a/usr/src/new/X/libvs100/move.c b/usr/src/new/X/libvs100/move.c
new file mode 100644 (file)
index 0000000..1937ffd
--- /dev/null
@@ -0,0 +1,159 @@
+/* $Header: move.c,v 10.3 86/02/01 15:47:04 tony Rel $ */
+/* move.c      Routines to move data into and out of the workstation
+ *
+ *     MoveObjectDownRom       Use rom version to move an object down
+ *     MoveObjectDown          Move data into the workstation
+ *     MoveBufferDown          Move buffer into the workstation
+ *     MoveBufferUp            Move date out of the workstation
+ *     SendToPeripheral        Send data to peripheral
+ *
+ * MoveObjectDownRom should be used to download the firmware into the
+ * workstation; after that MoveObjectDown and MoveBufferDown should be used.
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+extern int VSReloc;
+
+char *AllocateSpace();
+
+/* Move size bytes from src to dst.  If rom = 1, use the rom-code version.
+ * This only works for objects which are <= MAXSIZE bytes;
+ */
+
+MoveObjectDownRom (src, dst, size)
+       caddr_t src, dst;
+       int size;
+{
+       return (MoveObject(src + VSReloc, dst, size, 1));
+}
+
+MoveObjectDown (src, dst, size)
+       caddr_t src, dst;
+       int size;
+{
+       return (MoveObject(src + VSReloc, dst, size, 0));
+}
+
+MoveBufferDown (src, dst, size)
+       caddr_t src, dst;
+       int size;
+{
+       register int len;
+       caddr_t buf;
+
+       while (len = size) {
+           if (len > VBUFSIZE) len = VBUFSIZE;
+           if ((buf = (caddr_t) AllocateSpace (len)) == NULL)
+               return (-1);
+           bcopy (src, buf, len);
+           if (MoveObject(buf + VSReloc, dst, len, 0))
+               return (-1);
+           src += len;
+           dst += len;
+           size -= len;
+       }
+       return (0);
+}
+
+MoveBufferUp (src, dst, size)
+       caddr_t src, dst;
+       int size;
+{
+       register int len;
+       caddr_t buf;
+
+       while (len = size) {
+           if (len > VBUFSIZE) len = VBUFSIZE;
+           if ((buf = (caddr_t) AllocateSpace (len)) == NULL ||
+               MoveObject(src, buf + VSReloc, len, 0) ||
+               SynchWrites())
+               return (-1);
+           bcopy (buf, dst, len);
+           src += len;
+           dst += len;
+           size -= len;
+       }
+       return (0);
+}
+
+MoveObject (src, dst, size, rom)
+       caddr_t src, dst;
+       int size, rom;
+{
+       register MoveObjectPacket *mop;
+#define        h ((PacketHeader *) mop->mop_head)
+
+       mop = (MoveObjectPacket *) AllocateSpace (sizeof (MoveObjectPacket));
+       if (mop == NULL) return (-1);
+
+       /* Make sure size is a multiple of 2 */
+
+       if (size & 0x1) size++;
+
+       /* Format the packet */
+
+       h->ph_modifier.emptymod = 0;
+       h->ph_opcode = (rom ? MOVE_OBJECT_ROM : MOVE_OBJECT);
+       *(long *) h->ph_next = NULL;
+
+       mop->mop_objectType = 1;
+       *(caddr_t *) mop->mop_source = src;
+       *(caddr_t *) mop->mop_dest = dst;
+       *(long *) mop->mop_objectSize = size;
+
+       return (WritePacket ((caddr_t) mop));
+#undef h
+}
+
+SendToPeripheral (src, size, device)
+       char *src;
+       int size, device;
+{
+       register MoveObjectPacket *mop;
+#define        h ((PacketHeader *) mop->mop_head)
+
+       mop = (MoveObjectPacket *) AllocateSpace (sizeof (MoveObjectPacket));
+       if (mop == NULL) return;
+
+       /* Make sure size is a multiple of 2 */
+
+       if (size & 0x1) size++;
+
+       /* Format the packet */
+
+       h->ph_modifier.emptymod = 0;
+       h->ph_opcode = MOVE_OBJECT;
+       *(long *) h->ph_next = NULL;
+
+       mop->mop_objectType = 2;
+       *(caddr_t *) mop->mop_source = src + VSReloc;
+       *(int *) mop->mop_dest = device;
+       *(long *) mop->mop_objectSize = size;
+
+       WritePacket ((caddr_t) mop);
+#undef h
+}
diff --git a/usr/src/new/X/libvs100/packet.c b/usr/src/new/X/libvs100/packet.c
new file mode 100644 (file)
index 0000000..8a36983
--- /dev/null
@@ -0,0 +1,258 @@
+/* $Header: packet.c,v 10.4 86/07/29 11:33:13 wesommer Rel $ */
+/* packet.c    Routines to allocate, free, and use packets
+ *
+ *     OpenDisplay             Open it
+ *     InitDisplay             Download it
+ *     DisplayDead             Check if dead
+ *     PacketInit              Set things up
+ *     WritePacket             Buffers a packet for writing
+ *     SynchWrites             Wait for completion of all pending writes
+ *     AllocateSpace           Allocate some temporary storage
+ *     AllocateCopy            Copy data to temporary storage
+ *     DeallocateSpace         Flush space of unsent packet
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+#include <fcntl.h>
+#include <errno.h>
+#include <sys/ioctl.h>
+#include "vsioctl.h"
+#include <vaxuba/vsreg.h>
+#include "reason.h"
+
+extern int errno;
+extern BitMap screen;
+
+char *ErrorString(), *strcpy(), *strcat();
+
+int vsdev;
+
+int VSReloc;
+
+vsIoAddr *VSAddr;
+caddr_t VSBuf;
+int VSBuflen;
+caddr_t VSBufLim;
+short *IOReg;
+short *VSResponse;
+
+int active;
+int upper;
+caddr_t limptr, curptr;
+
+/* Open the display */
+
+OpenDisplay (vsNumber)
+       char *vsNumber;
+{
+       char vsname[10];
+       strcpy (vsname, "/dev/vs");
+       strcat (vsname, vsNumber);
+
+       return (vsdev = open (vsname, O_RDWR|O_NDELAY));
+}
+
+/* Do vs100 specific initialization */
+
+InitDisplay (info)
+       register DEVICE *info;
+{
+       if (DownLoad ())
+           return (-1);
+       info->id = XDEV_VS100;
+       info->width = screen.bm_width;
+       info->height = screen.bm_height;
+       info->planes = 1;
+       info->entries = 0;
+       info->mouse = &VSAddr->mouse;
+       info->mbox = &VSAddr->mbox;
+       info->queue = (vsEventQueue *) &VSAddr->ibuff;
+       return (0);
+}
+
+/* Check if display is dead */
+
+DisplayDead ()
+{
+       int ver;
+
+       return(ioctl(vsdev, (int) VSIOGETVER, (caddr_t) &ver));
+}
+
+PacketInit()
+{
+       if (ioctl (vsdev, (int) VSIOGETIOA, (caddr_t) &VSAddr) ||
+           ioctl (vsdev, (int) VSIOINIT, (caddr_t) NULL))
+           return (-1);
+       VSBuf = VSAddr->obuff;
+       VSBuflen = VSAddr->obufflen;
+       VSBufLim = VSBuf + VSBuflen;
+       IOReg = (short *) VSAddr->ioreg;
+       VSReloc = VSAddr->reloc - (int) VSBuf;
+       VSResponse = (short *) &VSAddr->status;
+        *VSResponse = 0;
+       IOReg[0] &= ~VS_FCN;
+       active = 0;
+       curptr = VSBufLim;
+       limptr = VSBuf;
+       upper = 1;
+       return (0);
+}   
+
+WritePacket (pkt)
+       caddr_t pkt;
+{
+       register int ret;
+       register short *ioreg;
+
+       pkt += VSReloc;
+       limptr = curptr;
+       if (upper) {
+           curptr = VSBuf;
+           upper = 0;
+       } else {
+           curptr = VSBufLim;
+           upper = 1;
+       }
+       if (ret = active) {
+           if (!(*VSResponse)) {
+               if (ret = ioctl(vsdev, (int) VSIOWAITGO, (caddr_t) &pkt))
+                   VSError ();
+               return (ret);
+           }
+           if ((ret = *VSResponse) & VS_ERROR) {
+               errno = ret & VS_REASON + IR_ERROR;
+               VSError ();
+               ret = -1;
+           } else
+               ret = 0;
+       }
+       ioreg = IOReg;  /* C sucks */
+       ioreg[3] = ((short *)&pkt)[0];
+       ioreg[4] = ((short *)&pkt)[1];
+       ioreg[0] &= ~VS_FCN;
+       *VSResponse = 0;
+       ioreg[0] |= VS_IE | (VS_SEND << VS_FCSHIFT) | VS_GO;
+       active = 1;
+       return (ret);
+}
+
+SynchWrites ()
+{
+       register int ret;
+
+       if (!active) return (0);
+       if (!(*VSResponse) && ioctl(vsdev, (int) VSIOUSERWAIT, (caddr_t) NULL))
+           VSError ();
+       if ((ret = *VSResponse) & VS_ERROR) {
+           errno = ret & VS_REASON + IR_ERROR;
+           VSError ();
+           ret = -1;
+       } else
+           ret = 0;
+       *VSResponse = 0;
+       active = 0;
+       if (upper)
+           limptr = VSBuf;
+       else
+           limptr = VSBufLim;
+       return (ret);
+}
+
+caddr_t AllocateSpace (size)
+       register int size;
+{
+       register caddr_t ptr;
+
+       if (size & 1) size++;
+
+       if (upper) {
+           if ((curptr -= size) >= limptr)
+               return (curptr);
+           SynchWrites ();
+           if (curptr >= limptr)
+               return (curptr);
+           curptr = VSBufLim;
+       } else {
+           ptr = curptr;
+           if ((curptr += size) <= limptr)
+               return (ptr);
+           SynchWrites ();
+           if (curptr <= limptr)
+               return (ptr);
+           curptr = VSBuf;
+       }
+       errno = ENOMEM;
+       VSError ();
+       return (NULL);
+}
+
+caddr_t AllocateCopy (buf, size)
+       caddr_t buf;
+       register int size;
+{
+       register caddr_t ptr;
+
+       if (size & 1) size++;
+
+       if (upper) {
+           if ((curptr -= size) < limptr) {
+               SynchWrites ();
+               if (curptr < limptr) {
+                   curptr = VSBufLim;
+                   errno = ENOMEM;
+                   return (NULL);
+               }
+           }
+           ptr = curptr;
+       } else {
+           ptr = curptr;
+           if ((curptr += size) > limptr) {
+               SynchWrites ();
+               if (curptr > limptr) {
+                   curptr = VSBuf;
+                   errno = ENOMEM;
+                   VSError ();
+                   return (NULL);
+               }
+           }
+       }
+       bcopy (buf, ptr, size);
+       return (ptr);
+}
+
+DeallocateSpace ()
+{
+       if (upper)
+           curptr = VSBufLim;
+       else
+           curptr = VSBuf;
+}
+
+VSError ()
+{
+       DeviceError (ErrorString (errno));
+}
diff --git a/usr/src/new/X/libvs100/packet.h b/usr/src/new/X/libvs100/packet.h
new file mode 100644 (file)
index 0000000..d26e332
--- /dev/null
@@ -0,0 +1,453 @@
+/* $Header: packet.h,v 10.3 86/02/01 15:47:13 tony Rel $ */
+/* packet.h    Packet descriptions for Workstation Graphics Architecture
+ *             command packets
+ *
+ *     Each object has two definitions.  The more human-readable one
+ *     has "reasonable" definitions, the one beginning with a_ expresses
+ *     the structure as an array of shorts so that the C compiler doesn't
+ *     move it around for silly alignment reasons.
+ *
+ * Author:     Paul J. Asente
+ *             Digital Equipment Corporation
+ *             Western Reseach Lab
+ * Date:       June 1983
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#ifndef WGA_PACKET
+#define WGA_PACKET
+
+typedef struct _CopyAreaMod {
+       unsigned : 8;
+       unsigned m_source : 3;
+       unsigned m_mask : 3;
+       unsigned : 3;
+       unsigned m_map : 3;
+       unsigned m_clipping : 3;
+} CopyAreaMod;
+
+typedef struct _DrawCurveMod {
+       unsigned : 8;
+       unsigned m_source : 3;
+       unsigned m_mask : 3;
+       unsigned : 3;
+       unsigned m_map : 3;
+       unsigned m_clipping : 3;
+       unsigned m_drawMode : 1;
+       unsigned m_patState : 2;
+       unsigned m_patMode : 2;
+} DrawCurveMod;
+
+typedef struct _PrintTextMod {
+       unsigned : 8;
+       unsigned m_source : 3;
+       unsigned m_mask: 3;
+       unsigned m_dest : 3;
+       unsigned m_map : 3;
+       unsigned m_clipping : 3;
+       unsigned m_textSize : 1;
+       unsigned m_control : 1;
+} PrintTextMod;
+
+typedef struct _FillAreaMod {
+       unsigned : 8;
+       unsigned m_source : 3;
+       unsigned : 6;
+       unsigned m_map : 3;
+       unsigned m_clipping : 3;
+} FillAreaMod;
+
+typedef struct _FloodAreaMod {
+       unsigned : 8;
+       unsigned m_source : 3;
+       unsigned : 9;
+       unsigned m_clipping : 3;
+       unsigned m_boundary : 1;
+} FloodAreaMod;
+
+typedef struct _LoadCursorMod {
+       unsigned : 8;
+       unsigned m_source : 3;
+       unsigned m_mask : 3;
+       unsigned : 3;
+       unsigned m_map : 3;
+} LoadCursorMod;
+
+typedef struct _SetMouseCharacteristicsMod {
+       unsigned : 8;
+       unsigned m_tracking : 3;
+} SetMouseCharacteristicsMod;
+
+typedef struct _SetTabletCharacteristicsMod {
+       unsigned : 8;
+       unsigned m_tracking : 3;
+} SetTabletCharacteristicsMod;
+
+typedef struct _PacketHeader {
+       union {
+           struct {
+               unsigned _opcode : 8;
+               unsigned _modifier : 24;
+           } ph;
+           long emptymod;
+           CopyAreaMod copy;
+           DrawCurveMod draw;
+           PrintTextMod text;
+           FillAreaMod fill;
+           FloodAreaMod flood;
+           LoadCursorMod cursor;
+           SetMouseCharacteristicsMod mouse;
+           SetTabletCharacteristicsMod tablet;
+       } ph_modifier;
+       a_CharPtr ph_next;
+} PacketHeader;
+
+#define ph_copyMod ph_modifier.copy
+#define ph_drawMod ph_modifier.draw
+#define ph_textMod ph_modifier.text
+#define ph_fillMod ph_modifier.fill
+#define ph_floodMod ph_modifier.flood
+#define ph_cursorMod ph_modifier.cursor
+#define ph_mouseMod ph_modifier.mouse
+#define ph_tabletMod ph_modifier.tablet
+
+typedef short a_PacketHeader[4];
+
+#define ph_opcode ph_modifier.ph._opcode
+
+#define COPY_AREA      1
+
+typedef struct _CopyAreaPacket {
+       a_PacketHeader cap_head;
+       union {
+           a_SubBitmap image;
+           Constant const;
+           a_Halftone pattern;
+       } cap_source;
+       a_SubBitmap cap_sourceMask;
+       a_Extent cap_maskSize;
+       a_Bitmap cap_destImage;
+       a_Point cap_destOffset;
+       union {
+           a_MapPtr ptr;
+           a_Map literal;
+       } cap_map;
+       union {
+           a_RectangleList rectList;
+           a_Rectangle litRect;
+       } cap_clipping;
+} CopyAreaPacket;
+
+typedef short a_CopyAreaPacket[33];
+
+#define DRAW_CURVE     2
+
+typedef struct _DrawCurvePacket {
+       a_PacketHeader dcp_head;
+       union {
+           a_SubBitmap image;
+           Constant const;
+           a_Halftone pattern;
+       } dcp_source;
+       a_SubBitmap dcp_sourceMask;
+       a_Extent dcp_maskSize;
+       a_Bitmap dcp_destImage;
+       a_Point dcp_destOffset;
+       union {
+           a_MapPtr ptr;
+           a_Map literal;
+       } dcp_map;
+       union {
+           a_RectangleList rectList;
+           a_Rectangle litRect;
+       } dcp_clipping;
+       a_SegmentList dcp_path;
+       a_PatternString dcp_pattern;
+       union {
+           a_PatternState literal;
+           a_PatternStatePtr ptr;
+       } dcp_patState;
+       union {
+           a_SubBitmap image;
+           Constant const;
+           a_Halftone pattern;
+       } dcp_secondSource;
+} DrawCurvePacket;
+
+typedef short a_DrawCurvePacket[49];
+
+#define PRINT_TEXT     3
+
+typedef struct _PrintTextPacket {
+       a_PacketHeader ptp_head;
+       union {
+           a_FontPtr font;
+           Constant const;
+           a_Halftone pattern;
+       } ptp_source;
+       a_FontPtr ptp_mask;
+       short filler[7];
+       a_Bitmap ptp_destImage;
+       union {
+           a_Point literal;
+           a_PointPtr ptr;
+       } ptp_initialOffset;
+       union {
+           a_MapPtr ptr;
+           a_Map literal;
+       } ptp_map;
+       union {
+           a_RectangleList rectList;
+           a_Rectangle litRect;
+       } ptp_clipping;
+       a_TextString ptp_text;
+       a_ControlString ptp_control;
+       short ptp_charPad;
+       short ptp_spacePad;
+} PrintTextPacket;
+
+typedef short a_PrintTextPacket[41];
+
+#define FILL_AREA      11
+
+typedef struct _FillAreaPacket {
+       a_PacketHeader fap_head;
+       union {
+           Constant const;
+           a_Halftone pattern;
+       } fap_source;
+       a_Bitmap fap_destImage;
+       a_Point fap_destOffset;
+       union {
+           a_MapPtr ptr;
+           a_Map literal;
+       } fap_map;
+       a_Rectangle fap_clippingRec;
+       a_SegmentList fap_path;
+} FillAreaPacket;
+
+typedef short a_FillAreaPacket[28];
+
+#define FLOOD_AREA     4
+
+typedef struct _FloodAreaPacket {
+       a_PacketHeader flp_head;
+       union {
+           Constant const;
+           a_Halftone pattern;
+       } flp_source;
+       a_Bitmap flp_destImage;
+       a_Point flp_seed;
+       Rectangle flp_clippingRec;
+       union {
+           a_MapPtr ptr;
+           a_Map literal;
+       } flp_boundary;
+} FloodAreaPacket;
+
+typedef short a_FloodAreaPacket[24];
+
+#define LOAD_CURSOR    5
+
+typedef struct _LoadCursorPacket {
+       a_PacketHeader lcp_head;
+       union {
+           a_SubBitmap image;
+           Constant const;
+           a_Halftone pattern;
+       } lcp_source;
+       a_SubBitmap lcp_sourceMask;
+       a_Extent lcp_maskSize;
+       union {
+           a_MapPtr ptr;
+           a_Map literal;
+       } lcp_map;
+       short lcp_blink;
+       short lcp_tip_x;
+       short lcp_tip_y;
+       short lcp_center_x;
+       short lcp_center_y;
+} LoadCursorPacket;
+
+typedef short a_LoadCursorPacket[29];
+
+#define SET_CURSOR_POSITION    6
+
+typedef struct _SetCursorPositionPacket {
+       a_PacketHeader scp_head;
+       a_Point scp_position;
+} SetCursorPositionPacket;
+
+typedef short a_SetCursorPositionPacket[6];
+
+#define ATTACH_CURSOR  7
+
+typedef struct _AttachCursorPacket {
+       a_PacketHeader acp_head;
+       short acp_device;
+} AttachCursorPacket;
+
+typedef short a_AttachCursorPacket[5];
+
+#define GET_CURSOR_POSITION    8
+
+typedef struct _GetCursorPositionPacket {
+       a_PacketHeader gcp_head;
+       a_Point gcp_position;
+} GetCursorPositionPacket;
+
+typedef short a_GetCursorPositionPacket[6];
+
+#define MOVE_OBJECT    9
+#define MOVE_OBJECT_ROM        128
+
+typedef struct _MoveObjectPacket {
+       a_PacketHeader mop_head;
+       short mop_objectType;
+       a_MemSize mop_objectSize;
+       a_CharPtr mop_source;
+       a_CharPtr mop_dest;
+} MoveObjectPacket;
+
+typedef short a_MoveObjectPacket[11];
+
+#define REPORT_STATUS  10
+#define REPORT_STATUS_ROM      129
+
+typedef struct _ReportStatusPacket {
+       a_PacketHeader rsp_head;
+       char rsp_deviceType[4];
+       short rsp_deviceVersion;
+       short rsp_ucodeVersion;
+       a_Bitmap rsp_visibleFramebuffer;
+       a_MemArea rsp_freeFramebuffer;
+       a_MemArea rsp_freeProgramMemory;
+       a_MemArea rsp_hostMemory;
+} ReportStatusPacket;
+
+typedef short a_ReportStatusPacket[25];
+
+#define NO_OPERATION   0
+
+typedef struct _NoopPacket {
+       a_PacketHeader nop_head;
+} NoopPacket;
+
+typedef short a_NoopPacket[4];
+#define GET_MOUSE_POSITION     12
+
+typedef struct _GetMousePositionPacket {
+       a_PacketHeader gmp_head;
+       a_Point gmp_position;
+} GetMousePositionPacket;
+
+typedef short a_GetMousePositionPacket[6];
+
+#define SET_MOUSE_CHARACTERISTICS      13
+
+typedef struct _SetMouseCharacteristicsPacket {
+       a_PacketHeader smc_head;
+       union {
+               struct {
+                       short multiplier;
+                       short divisor;
+               } linear;
+               struct {
+                       short scale;
+                       short threshold;
+               } exponential;
+       } tracking;
+} SetMouseCharacteristicsPacket;
+
+
+#define smc_multiplier tracking.linear.multiplier
+#define smc_divisor tracking.linear.divisor
+#define smc_threshold tracking.exponential.threshold
+#define smc_scale tracking.exponential.scale
+
+typedef short a_SetMouseCharacteristicsPacket[6];
+
+#define GET_TABLET_POSITION    14
+
+typedef struct _GetTabletPositionPacket {
+       a_PacketHeader gtp_head;
+       a_Point gtp_position;
+} GetTabletPositionPacket;
+
+typedef short a_GetTabletPositionPacket[6];
+
+#define SET_TABLET_CHARACTERISTICS     16
+
+typedef struct _SetTabletCharacteristicsPacket {
+       a_PacketHeader stc_head;
+       union {
+               struct {
+                       short multiplier;
+                       short divisor;
+               } linear;
+               struct {
+                       a_Point input;
+                       a_Point output;
+               } quantized;
+       } tracking;
+} SetTabletCharacteristicsPacket;
+
+#define stc_multiplier tracking.linear.multiplier
+#define stc_divisor tracking.linear.divisor
+#define stc_input tracking.quantized.input
+#define stc_output tracking.quantized.output
+
+typedef short a_SetTabletCharacteristicsPacket[8];
+
+#define SET_POINTING_DEVICE_REPORTING  15
+
+typedef struct _SetPointingDeviceReportingPacket {
+       a_PacketHeader spdp_head;
+       short spdp_enable;
+} SetPointingDeviceReportingPacket;
+
+typedef short a_SetPointingDeviceReportingPacket[5];
+
+typedef union _Packet {
+       a_CopyAreaPacket copyArea;
+       a_DrawCurvePacket drawCurve;
+       a_PrintTextPacket writeText;
+       a_FillAreaPacket fillArea;
+       a_FloodAreaPacket floodArea;
+       a_LoadCursorPacket loadCursor;
+       a_SetCursorPositionPacket setCursor;
+       a_AttachCursorPacket attachCursor;
+       a_GetCursorPositionPacket getCursor;
+       a_MoveObjectPacket moveObject;
+       a_ReportStatusPacket reportStatus;
+       a_NoopPacket noop;
+       a_GetMousePositionPacket getMouse;
+       a_SetMouseCharacteristicsPacket setMouse;
+       a_GetTabletPositionPacket getTablet;
+       a_SetTabletCharacteristicsPacket setTablet;
+       a_SetPointingDeviceReportingPacket setPointingDevice;
+} Packet;      
+
+#endif
diff --git a/usr/src/new/X/libvs100/param.h b/usr/src/new/X/libvs100/param.h
new file mode 100644 (file)
index 0000000..e71a275
--- /dev/null
@@ -0,0 +1,223 @@
+/* $Header: param.h,v 10.3 86/02/01 15:47:19 tony Rel $ */
+/* param.h     Definitions for primitive objects in Workstation Graphics
+ *             Architecture
+ *
+ *     Each object has two definitions.  The more human-readable one
+ *     has "reasonable" definitions, the one beginning with a_ expresses
+ *     the structure as an array of shorts so that the C compiler doesn't
+ *     move it around for silly alignment reasons.
+ *
+ * Author:     Paul J. Asente
+ *             Digital Equipment Corporation
+ *             Western Reseach Lab
+ * Date:       June 1983
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#ifndef WGA_PARAMS
+#define WGA_PARAMS
+
+typedef short Constant;
+
+typedef struct _Point {
+       short p_x;
+       short p_y;
+} Point;
+typedef Point *PointPtr;
+
+typedef short a_Point[2];
+typedef short a_PointPtr[2];
+
+typedef struct _Extent {
+       short e_width;
+       short e_height;
+} Extent;
+
+typedef short a_Extent[2];
+
+typedef struct _Rectangle {
+       a_Point r_origin;
+       a_Extent r_size;
+} Rectangle;
+typedef Rectangle *RectanglePtr;
+
+typedef short a_Rectangle[4];
+typedef short a_RectanglePtr[2];
+
+#define r_x r_origin[0]
+#define r_y r_origin[1]
+#define r_width r_size[0]
+#define r_height r_size[1]
+
+typedef struct _RectangleList {
+       a_RectanglePtr r_first;
+       short r_count;
+} RectangleList;
+
+typedef short a_RectangleList[3];
+
+typedef short BitmapEntry;
+typedef BitmapEntry *BitmapEntryPtr;
+
+typedef short a_BitmapEntryPtr[2];
+
+typedef struct _Bitmap {
+       a_BitmapEntryPtr bm_address;
+       short bm_width;
+       short bm_height;
+       short bm_bitsPerPixel;
+} BitMap;
+
+typedef short a_Bitmap[5];
+
+typedef struct _SubBitmap {
+       a_Bitmap sb_base;
+       a_Point sb_offset;
+} SubBitmap;
+
+typedef short a_SubBitmap[7];
+
+#define sb_address sb_base
+#define sb_width sb_base[2]
+#define sb_height sb_base[3]
+#define sb_bitsPerPixel sb_base[4]
+#define sb_x sb_offset[0]
+#define sb_y sb_offset[1]
+
+typedef struct _Halftone {
+       a_Bitmap ht_base;
+       a_Point ht_offset;
+} Halftone;
+
+typedef short a_Halftone[7];
+
+#define ht_address ht_base
+#define ht_width ht_base[2]
+#define ht_height ht_base[3]
+#define ht_bitsPerPixel ht_base[4]
+#define ht_x ht_offset[0]
+#define ht_y ht_offset[1]
+
+typedef long Map;
+typedef Map *MapPtr;
+typedef short a_Map[2];
+typedef short a_MapPtr[2];
+
+typedef struct _Segment {
+       a_Point seg_p;
+       short seg_flags;
+} Segment;
+typedef Segment *SegmentPtr;
+
+typedef short a_Segment[3];
+typedef short a_SegmentPtr[2];
+
+#define seg_x seg_p[0]
+#define seg_y seg_p[1]
+
+/* Meanings of bits in seg_flags.  Bit on means the predicate is true */
+
+#define seg_relative 0x0001
+#define seg_dontDraw 0x0002
+#define seg_curved 0x0004
+#define seg_startClosed 0x0008
+#define seg_endClosed 0x0010
+#define seg_drawLastPoint 0x0020
+
+typedef struct _SegmentList {
+       a_SegmentPtr seg_first;
+       short seg_count;
+} SegmentList;
+
+typedef short a_SegmentList[3];
+
+typedef struct _PatternString {
+       short p_length;
+       unsigned short p_pattern;
+       short p_multiplier;
+} PatternString;
+
+typedef short a_PatternString[3];
+
+typedef struct _PatternState {
+       short p_position;
+       short p_count;
+} PatternState;
+typedef PatternState *PatternStatePtr;
+
+typedef short a_PatternState[2];
+typedef short a_PatternStatePtr[2];
+
+typedef short FontWidthEntry;
+typedef FontWidthEntry *FontWidthEntryPtr;
+typedef short a_FontWidthEntryPtr[2];
+
+typedef struct _FontData {
+       a_Bitmap f_characters;
+       short f_firstChar;
+       short f_lastChar;
+       a_FontWidthEntryPtr f_leftArray;
+       short f_baseline;
+       short f_spaceIndex;
+       short f_fixedWidth;
+} FontData;
+typedef FontData *FontPtr;
+
+typedef short a_FontData[12];
+typedef short a_FontPtr[2];
+
+typedef char *CharPtr;
+typedef short a_CharPtr[2];
+
+typedef struct _TextString {
+       a_CharPtr t_first;
+       short t_count;
+} TextString;
+
+typedef short a_TextString[3];
+
+typedef short ControlElement;
+typedef ControlElement *ControlElementPtr;
+typedef short a_ControlElementPtr[2];
+
+typedef struct _ControlString {
+       a_ControlElementPtr c_first;
+       short c_count;
+} ControlString;
+
+typedef short a_ControlString[3];
+
+typedef long MemSize;
+typedef short a_MemSize[2];
+
+typedef struct _MemArea {
+       a_CharPtr m_base;
+       a_MemSize m_size;
+} MemArea;
+
+typedef short a_MemArea[4];
+
+
+
+#endif
diff --git a/usr/src/new/X/libvs100/put.c b/usr/src/new/X/libvs100/put.c
new file mode 100644 (file)
index 0000000..a7b0b0c
--- /dev/null
@@ -0,0 +1,234 @@
+/* $Header: put.c,v 10.3 86/02/01 15:47:24 tony Rel $ */
+/* put.c       Perform a raster operation with a source bitmap
+ *
+ *     PixmapPut       Puts a pixmap up on the screen
+ *     PixmapBitsPut   Puts a pixmap up on the screen
+ *     BitmapBitsPut   Puts a pixmap up on the screen
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+extern BitMap screen;
+extern int VSReloc;
+extern char FBMap[];
+extern char SSMap[];
+
+char *AllocateSpace(), *AllocateCopy(), *Xalloc();
+
+PixmapPut (src, srcx, srcy, width, height, dstx, dsty, clips, clipcount,
+          func, zmask)
+       PIXMAP *src;
+       int srcx, srcy, width, height, dstx, dsty, clipcount, zmask;
+       register int func;
+       CLIP *clips;
+{
+       register CopyAreaPacket *cap;
+#define        h ((PacketHeader *) cap->cap_head)
+#define        img ((SubBitmap *) cap->cap_source.image)
+#define        pat ((Halftone *) cap->cap_source.pattern)
+#define        size ((Extent *) cap->cap_maskSize)
+#define        destOff ((Point *) cap->cap_destOffset)
+#define        clip ((RectangleList *) cap->cap_clipping.rectList)
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket));
+       if (cap == NULL) return;
+
+       func = SSMap[func | (src->kind & 0x10)];
+       h->ph_copyMod.m_mask = 0;
+       h->ph_copyMod.m_map = MAPTYPE(func);
+       h->ph_opcode = COPY_AREA;
+       *(long *) h->ph_next = NULL;
+
+       if (src->kind == 0) {
+           h->ph_copyMod.m_source = 0;
+           cap->cap_source.const = (int) src->data;
+       } else {
+           h->ph_copyMod.m_source = 1;
+#ifdef HTCROCK
+           if (src->kind & 2)
+               *(caddr_t *) img->sb_address = BDATA(TDATA(src)->bitmap)->vsPtr;
+           else
+#endif
+           *(caddr_t *) img->sb_address = BDATA(PDATA(src))->vsPtr;
+           img->sb_height = src->height;
+           img->sb_width = src->width;
+           img->sb_bitsPerPixel = 1;
+           img->sb_x = srcx;
+           img->sb_y = srcy;
+       }
+
+       size->e_height = height;
+       size->e_width = width;
+
+       *(BitMap *) cap->cap_destImage = screen;
+       destOff->p_x = dstx;
+       destOff->p_y = dsty;
+
+       *(long *) cap->cap_map.literal = MAPLIT(func);
+
+       if (clipcount == 1) {
+           h->ph_copyMod.m_clipping = 1;
+           *(CLIP *) cap->cap_clipping.litRect = *clips;
+       } else {
+           h->ph_copyMod.m_clipping = 2;
+           *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+           clip->r_count = clipcount;
+       }
+
+       WritePacket ((caddr_t) cap);
+#undef h
+#undef img
+#undef pat
+#undef size
+#undef destOff
+#undef clip
+}
+
+
+/*ARGSUSED*/
+PixmapBitsPut (width, height, format, data, xymask, dstx, dsty,
+              clips, clipcount, func, zmask)
+       char *data;
+       int width, height, format, dstx, dsty, clipcount, zmask;
+       BITMAP *xymask;
+       CLIP *clips;
+       int func;
+{
+       BitmapBitsPut (width, height, data, 1, 0, xymask, dstx, dsty,
+                      clips, clipcount, func, zmask);
+}
+
+
+BitmapBitsPut (width, height, data, fore, back, xymask, dstx, dsty,
+              clips, clipcount, func, zmask)
+       char *data;
+       int width, height, fore, back, dstx, dsty, clipcount, zmask;
+       register BITMAP *xymask;
+       CLIP *clips;
+       register int func;
+{
+       register CopyAreaPacket *cap;
+#define        h ((PacketHeader *) cap->cap_head)
+#define        src ((SubBitmap *) cap->cap_source.image)
+#define        pat ((Halftone *) cap->cap_source.pattern)
+#define        size ((Extent *) cap->cap_maskSize)
+#define mask ((SubBitmap *) cap->cap_sourceMask)
+#define        destOff ((Point *) cap->cap_destOffset)
+#define        clip ((RectangleList *) cap->cap_clipping.rectList)
+       caddr_t bits;
+       char *boxes = NULL;
+       CLIP clip1;
+       int width1, num, boxbytes, bytes;
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       if (fore & 1)
+           func += 0x20;
+       if (back & 1)
+           func += 0x10;
+       func = FBMap[func];
+
+       width1 = BitmapSize(width, 1);
+       num = VBUFSIZE / width1;
+       if (height > num) {
+           if (clipcount == 1) {
+               clip1 = *clips;
+               clips = &clip1;
+           } else {
+               boxbytes = sizeof (CLIP) * clipcount;
+               boxes = Xalloc (boxbytes);
+               bcopy ((caddr_t) clips, boxes, boxbytes);
+               DeallocateSpace ();
+           }
+       }
+
+       while (height) {
+           if (height < num)
+               num = height;
+           bytes = num * width1;
+           if ((bits = (caddr_t) AllocateCopy (data, bytes)) == NULL ||
+               (boxes && (clips = (CLIP *) AllocateCopy (boxes, boxbytes)) == NULL) ||
+               (cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket))) == NULL)
+               break;
+
+           h->ph_copyMod.m_source = 1;
+           h->ph_copyMod.m_mask = xymask ? 1 : 0;
+           h->ph_copyMod.m_map = MAPTYPE(func);
+           h->ph_opcode = COPY_AREA;
+           *(long *) h->ph_next = NULL;
+
+           *(caddr_t *) src->sb_address = bits + VSReloc;
+           src->sb_height = num;
+           src->sb_width = width;
+           src->sb_bitsPerPixel = 1;
+           src->sb_x = src->sb_y = 0;
+
+           if (xymask) {
+                   *(caddr_t *) mask->sb_address = BDATA(xymask)->vsPtr;
+                   mask->sb_height = xymask->height;
+                   mask->sb_width = xymask->width;
+                   mask->sb_bitsPerPixel = 1;
+                   mask->sb_x = mask->sb_y = 0;
+           }
+           size->e_height = num;
+           size->e_width = width;
+
+           *(BitMap *) cap->cap_destImage = screen;
+           destOff->p_x = dstx;
+           destOff->p_y = dsty;
+
+           *(long *) cap->cap_map.literal = MAPLIT(func);
+
+           if (clipcount == 1) {
+               h->ph_copyMod.m_clipping = 1;
+               *(CLIP *) cap->cap_clipping.litRect = *clips;
+           } else {
+               h->ph_copyMod.m_clipping = 2;
+               *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+               clip->r_count = clipcount;
+           }
+
+           WritePacket ((caddr_t) cap);
+           height -= num;
+           dsty += num;
+           data += bytes;
+       }
+       if (boxes)
+           free (boxes);
+#undef h
+#undef src
+#undef pat
+#undef size
+#undef mask
+#undef destOff
+#undef clip
+}
diff --git a/usr/src/new/X/libvs100/reason.h b/usr/src/new/X/libvs100/reason.h
new file mode 100644 (file)
index 0000000..c1ee325
--- /dev/null
@@ -0,0 +1,320 @@
+/* reason.h    Interrupt reason values for Nov 84 firmware
+ *
+ * Author:     Paul J. Asente
+ *             Digital Equipment Corporation
+ *             Western Reseach Lab
+ * Date:       Sept 1985
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1985 by                                                  *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished under a license and may be used and copied   *
+ *  only in  accordance with  the  terms  of  such  license  and with the   *
+ *  inclusion of the above copyright notice. This software or  any  other   *
+ *  copies thereof may not be provided or otherwise made available to any   *
+ *  other person.  No title to and ownership of  the  software is  hereby   *
+ *  transferred.                                                           *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#ifndef VS_REASONS
+#define VS_REASONS
+
+#define IR_ID          1<<0
+#define IR_ID_MSG      "initialization done"
+#define IR_CD          1<<1
+#define IR_CD_MSG      "command done"
+#define IR_DCI         1<<2
+#define IR_DCI_MSG     "display code initialized"
+#define IR_DE          1<<3
+#define IR_DE_MSG      "device event"
+#define IR_CM          1<<4
+#define IR_CM_MSG      "cursor moved"
+#define IR_DPM         1<<5
+#define IR_DPM_MSG     "data pad moved"
+#define IR_MM          1<<6
+#define IR_MM_MSG      "mouse moved"
+#define IR_PD          1<<7
+#define IR_PD_MSG      "powerup done"
+#define IR_AB_ACK      1<<8
+#define IR_AB_ACK_MSG  "abort acknowledge"
+#define IR_STAT_ACK    1<<9
+#define IR_STAT_ACK_MSG        "status acknowledge"
+#define IR_SAVE_ACK    1<<10
+#define IR_SAVE_ACK_MSG        "save_screen acknowledge"
+
+#define IR_ERROR       (1<<15)
+
+#define ERR_NYI                IR_ERROR+0
+#define ERR_NYI_MSG    "function not yet implemented"
+#define ERR_IFC                IR_ERROR+1
+#define ERR_IFC_MSG    "invalid function code"
+#define ERR_ICC                IR_ERROR+2
+#define ERR_ICC_MSG    "invalid command code"
+#define ERR_BE_NXM_68K IR_ERROR+3
+#define ERR_BE_NXM_68K_MSG     "bus error:  receive nxm -- 68K unibus access"
+#define ERR_BE_RO      IR_ERROR+4
+#define ERR_BE_RO_MSG  "bus error:  retry overflow"
+#define ERR_BE_LD      IR_ERROR+5
+#define ERR_BE_LD_MSG  "bus error:  link down"
+#define ERR_BE_S       IR_ERROR+6
+#define ERR_BE_S_MSG   "bus error:  spurious"
+#define ERR_AE         IR_ERROR+7
+#define ERR_AE_MSG     "address error"
+#define ERR_ZD         IR_ERROR+8
+#define ERR_ZD_MSG     "zero divide"
+#define ERR_II         IR_ERROR+9
+#define ERR_II_MSG     "illegal instruction"
+#define ERR_NXM_BBA    IR_ERROR+10
+#define ERR_NXM_BBA_MSG        "receive nxm -- BBA unibus access"
+#define ERR_BNI                IR_ERROR+11
+#define ERR_BNI_MSG    "BBA not installed"
+#define ERR_KCQO       IR_ERROR+12
+#define ERR_KCQO_MSG   "keyboard command queue overflow"
+#define ERR_DPCQO      IR_ERROR+13
+#define ERR_DPCQO_MSG  "data pad command queue overflow"
+#define ERR_MEQO       IR_ERROR+14
+#define ERR_MEQO_MSG   "mouse event queue overflow"
+#define ERR_DPEQO      IR_ERROR+15
+#define ERR_DPEQO_MSG  "data pad event queue overflow"
+#define ERR_AB_BBA     IR_ERROR+16
+#define ERR_AB_BBA_MSG "unable to abort the BBA"
+#define ERR_KEQO       IR_ERROR+17
+#define ERR_KEQO_MSG   "keyboard event queue overflow"
+#define ERR_KOR                IR_ERROR+18
+#define ERR_KOR_MSG    "keyboard overrun"
+#define ERR_DPOR       IR_ERROR+19
+#define ERR_DPOR_MSG   "data pad overrun"
+#define ERR_KFE                IR_ERROR+20
+#define ERR_KFE_MSG    "keyboard framing error"
+#define ERR_DPFE       IR_ERROR+21
+#define ERR_DPFE_MSG   "data pad framing error"
+
+#define ERR_ISRCM      IR_ERROR+32
+#define ERR_ISRCM_MSG  "invalid source modifiers"
+#define ERR_ISRCBW     IR_ERROR+33
+#define ERR_ISRCBW_MSG "invalid source bitmap width"
+#define ERR_ISRCBH     IR_ERROR+34
+#define ERR_ISRCBH_MSG "invalid source bitmap height"
+#define ERR_ISRCC      IR_ERROR+35
+#define ERR_ISRCC_MSG  "invalid source constant"
+#define ERR_ISRCBD     IR_ERROR+36
+#define ERR_ISRCBD_MSG "invalid source bitmap depth"
+#define ERR_IMSKM      IR_ERROR+38
+#define ERR_IMSKM_MSG  "invalid source mask modifiers"
+#define ERR_IMSKBW     IR_ERROR+39
+#define ERR_IMSKBW_MSG "invalid source mask bitmap width"
+#define ERR_IMSKBH     IR_ERROR+40
+#define ERR_IMSKBH_MSG "invalid source mask bitmap height"
+#define ERR_IMSKBD     IR_ERROR+41
+#define ERR_IMSKBD_MSG "invalid source mask bitmap depth"
+#define ERR_IDSTM      IR_ERROR+44
+#define ERR_IDSTM_MSG  "invalid destination offset modifiers"
+#define ERR_IDSTBW     IR_ERROR+45
+#define ERR_IDSTBW_MSG "invalid destination bitmap width"
+#define ERR_IDSTBH     IR_ERROR+46
+#define ERR_IDSTBH_MSG "invalid destination bitmap height"
+#define ERR_IDSTBD     IR_ERROR+47
+#define ERR_IDSTBD_MSG "invalid destination bitmap depth"
+#define ERR_IMAPM      IR_ERROR+50
+#define ERR_IMAPM_MSG  "invalid mapping function modifiers"
+#define ERR_ICLPM      IR_ERROR+54
+#define ERR_ICLPM_MSG  "invalid clipping rectangle modifiers"
+#define ERR_ICLPC      IR_ERROR+55
+#define ERR_ICLPC_MSG  "invalid clipping rectangle count"
+
+#define ERR_SMC_ITC    IR_ERROR+56
+#define ERR_SMC_ITC_MSG        "set_mouse_characteristics:  invalid tracking constant"
+#define ERR_SCL_CD     IR_ERROR+58
+#define ERR_SCL_CD_MSG "set_cursor_location:  cursor is detached"
+#define ERR_AC_ICD     IR_ERROR+59
+#define ERR_AC_ICD_MSG "attach_cursor:  invalid cursor device"
+
+#define ERR_MO_IBC     IR_ERROR+60
+#define ERR_MO_IBC_MSG "move_object:  invalid byte count"
+#define ERR_MO_IOT     IR_ERROR+61
+#define ERR_MO_IOT_MSG "move_object:  invalid object type"
+#define ERR_MO_IDT     IR_ERROR+62
+#define ERR_MO_IDT_MSG "move_object:  invalid device type"
+
+#define ERR_IPC                IR_ERROR+63
+#define ERR_IPC_MSG    "invalid path count (draw_curve or fill_polygon)"
+
+#define ERR_DC_IPL     IR_ERROR+65
+#define ERR_DC_IPL_MSG "invalid pattern length"
+#define ERR_DC_IPM     IR_ERROR+66
+#define ERR_DC_IPM_MSG "invalid pattern multiplier"
+#define ERR_DC_ICF     IR_ERROR+67
+#define ERR_DC_ICF_MSG "invalid closed figure"
+#define ERR_DC_IPP     IR_ERROR+68
+#define ERR_DC_IPP_MSG "invalid pattern position"
+#define ERR_DC_IPSM    IR_ERROR+69
+#define ERR_DC_IPSM_MSG        "invalid pattern string modifiers"
+#define ERR_DC_IPMM    IR_ERROR+70
+#define ERR_DC_IPMM_MSG        "invalid pattern mode modifiers"
+#define ERR_DC_IPC     IR_ERROR+71
+#define ERR_DC_IPC_MSG "invalid pattern count"
+#define ERR_DC_ISSRCBW IR_ERROR+72
+#define ERR_DC_ISSRCBW_MSG     "invalid second source bitmap width"
+#define ERR_DC_ISSRCBH IR_ERROR+73
+#define ERR_DC_ISSRCBH_MSG     "invalid second source bitmap height"
+#define ERR_DC_ISSRCBD IR_ERROR+74
+#define ERR_DC_ISSRCBD_MSG     "invalid second source bitmap depth"
+#define ERR_DC_ISSRCC  IR_ERROR+75
+#define ERR_DC_ISSRCC_MSG      "invalid second source constant"
+#define ERR_DC_IDPM    IR_ERROR+76
+#define ERR_DC_IDPM_MSG        "incompatible drawing/pattern modes"
+#define ERR_DC_DXO     IR_ERROR+77
+#define ERR_DC_DXO_MSG "delta_x overflow"
+#define ERR_DC_DYO     IR_ERROR+78
+#define ERR_DC_DYO_MSG "delta_y overflow"
+#define ERR_DC_CRSO    IR_ERROR+79
+#define ERR_DC_CRSO_MSG        "clipping rectangle stack overflow"
+
+#define ERR_PT_ICSL    IR_ERROR+80
+#define ERR_PT_ICSL_MSG        "invalid control string length"
+#define ERR_PT_ICSO    IR_ERROR+81
+#define ERR_PT_ICSO_MSG        "invalid control string opcode"
+#define ERR_PT_ICSP    IR_ERROR+82
+#define ERR_PT_ICSP_MSG        "invalid control string parameter"
+#define ERR_PT_ITSL    IR_ERROR+83
+#define ERR_PT_ITSL_MSG        "invalid text string length"
+#define ERR_PT_ICI     IR_ERROR+84
+#define ERR_PT_ICI_MSG "invalid character index"
+#define ERR_PT_TSE     IR_ERROR+85
+#define ERR_PT_TSE_MSG "text string exhausted"
+#define ERR_PT_NFP     IR_ERROR+86
+#define ERR_PT_NFP_MSG "no font present"
+#define ERR_PT_ISRCFW  IR_ERROR+87
+#define ERR_PT_ISRCFW_MSG      "invalid source font width"
+#define ERR_PT_ISRCFH  IR_ERROR+88
+#define ERR_PT_ISRCFH_MSG      "invalid source font height"
+#define ERR_PT_ISRCFD  IR_ERROR+89
+#define ERR_PT_ISRCFD_MSG      "invalid source font depth"
+#define ERR_PT_IMSKFW  IR_ERROR+90
+#define ERR_PT_IMSKFW_MSG      "invalid source mask font width"
+#define ERR_PT_IMSKFH  IR_ERROR+91
+#define ERR_PT_IMSKFH_MSG      "invalid source mask font height"
+#define ERR_PT_IMSKFD  IR_ERROR+92
+#define ERR_PT_IMSKFD_MSG      "invalid source mask font depth"
+#define ERR_PT_CSMF    IR_ERROR+93
+#define ERR_PT_CSMF_MSG        "conflicting source/source mask fonts"
+#define ERR_PT_ILB     IR_ERROR+94
+#define ERR_PT_ILB_MSG "invalid left_array bounds"
+#define ERR_PT_ILE     IR_ERROR+95
+#define ERR_PT_ILE_MSG "invalid left_array element"
+
+#define ERR_FA_ISRCB   IR_ERROR+96
+#define ERR_FA_ISRCB_MSG       "invalid source bitmap"
+#define ERR_FA_SO      IR_ERROR+99
+#define ERR_FA_SO_MSG  "stack overflow"
+#define ERR_FA_IBMM    IR_ERROR+100
+#define ERR_FA_IBMM_MSG        "invalid boundary map modifiers"
+
+#define ERR_FP_ISRCB   IR_ERROR+112
+#define ERR_FP_ISRCB_MSG       "invalid source bitmap"
+#define ERR_FP_ICF     IR_ERROR+115
+#define ERR_FP_ICF_MSG "invalid closed figure"
+#define ERR_FP_DXO     IR_ERROR+116
+#define ERR_FP_DXO_MSG "delta_x overflow"
+#define ERR_FP_DYO     IR_ERROR+117
+#define ERR_FP_DYO_MSG "delta_y overflow"
+
+#define ERR_CPU                IR_ERROR+129
+#define ERR_CPU_MSG    "CPU or supervisor stack error"
+#define ERR_RHB                IR_ERROR+130
+#define ERR_RHB_MSG    "ROM high byte checksum error"
+#define ERR_PR         IR_ERROR+131
+#define ERR_PR_MSG     "program RAM data error"
+#define ERR_CRTC       IR_ERROR+132
+#define ERR_CRTC_MSG   "CRT controller data error"
+#define ERR_DPE                IR_ERROR+133
+#define ERR_DPE_MSG    "data pad EPCI data error or time out"
+#define ERR_KE         IR_ERROR+134
+#define ERR_KE_MSG     "keyboard EPCI data error or time out"
+#define ERR_FOE                IR_ERROR+135
+#define ERR_FOE_MSG    "fiber optics electrical loop back"
+#define ERR_F0         IR_ERROR+137
+#define ERR_F0_MSG     "frame #0 data error"
+#define ERR_BSR                IR_ERROR+138
+#define ERR_BSR_MSG    "BBA scratchpad RAM data error"
+#define ERR_BCC                IR_ERROR+139
+#define ERR_BCC_MSG    "BBA copyarea command data error"
+#define ERR_DPTO       IR_ERROR+140
+#define ERR_DPTO_MSG   "data pad self test time out"
+#define ERR_FOO                IR_ERROR+141
+#define ERR_FOO_MSG    "fiber optics optical loop back"
+#define ERR_KTO                IR_ERROR+142
+#define ERR_KTO_MSG    "keyboard self test time out"
+#define ERR_KST                IR_ERROR+143
+#define ERR_KST_MSG    "keyboard self test error"
+#define ERR_VR         IR_ERROR+144
+#define ERR_VR_MSG     "vector RAM data error"
+#define ERR_F1         IR_ERROR+145
+#define ERR_F1_MSG     "frame #1 data error"
+#define ERR_F2         IR_ERROR+146
+#define ERR_F2_MSG     "frame #2 data error"
+#define ERR_F3         IR_ERROR+147
+#define ERR_F3_MSG     "frame #3 data error"
+#define ERR_DPP                IR_ERROR+148
+#define ERR_DPP_MSG    "data pad port loop back data error"
+#define ERR_KP         IR_ERROR+149
+#define ERR_KP_MSG     "keyboard port loop back data error"
+#define ERR_FOED       IR_ERROR+150
+#define ERR_FOED_MSG   "fiber optics electrical loop back"
+#define ERR_FOOD       IR_ERROR+151
+#define ERR_FOOD_MSG   "fiber optics optical loop back"
+#define ERR_BCTO       IR_ERROR+152
+#define ERR_BCTO_MSG   "BBA copyarea command time out"
+#define ERR_RLB                IR_ERROR+153
+#define ERR_RLB_MSG    "ROM low byte checksum error"
+#define ERR_KD         IR_ERROR+154
+#define ERR_KD_MSG     "key down on keyboard self test"
+#define ERR_BVC                IR_ERROR+155
+#define ERR_BVC_MSG    "BBA vector command data error"
+
+#define ERR_ISRCHW     IR_ERROR+161
+#define ERR_ISRCHW_MSG "invalid source halftone width"
+#define ERR_ISRCHH     IR_ERROR+162
+#define ERR_ISRCHH_MSG "invalid source halftone height"
+#define ERR_ISRCHD     IR_ERROR+163
+#define ERR_ISRCHD_MSG "invalid source halftone depth"
+#define ERR_DC_ISSRCHW IR_ERROR+164
+#define ERR_DC_ISSRCHW_MSG     "invalid second source halftone width"
+#define ERR_DC_ISSRCHH IR_ERROR+165
+#define ERR_DC_ISSRCHH_MSG     "invalid second source halftone height"
+#define ERR_DC_ISSRCHD IR_ERROR+166
+#define ERR_DC_ISSRCHD_MSG     "invalid second source halftone depth"
+
+#define ERR_LC_ICTX    IR_ERROR+167
+#define ERR_LC_ICTX_MSG        "load_cursor:  invalid cursor tip_x"
+#define ERR_LC_ICTY    IR_ERROR+168
+#define ERR_LC_ICTY_MSG        "load_cursor:  invalid cursor tip_y"
+#define ERR_LC_ICCX    IR_ERROR+169
+#define ERR_LC_ICCX_MSG        "load_cursor:  invalid cursor centre_x"
+#define ERR_LC_ICCY    IR_ERROR+170
+#define ERR_LC_ICCY_MSG        "load_cursor:  invalid cursor centre_y"
+#define ERR_LC_ICW     IR_ERROR+171
+#define ERR_LC_ICW_MSG "load_cursor:  invalid cursor width"
+#define ERR_LC_ICH     IR_ERROR+172
+#define ERR_LC_ICH_MSG "load_cursor:  invalid cursor height"
+#define ERR_PT_DXO     IR_ERROR+173
+#define ERR_PT_DXO_MSG "print_text:  destination offset x overflow"
+#define ERR_PT_CRSO    IR_ERROR+174
+#define ERR_PT_CRSO_MSG        "print_text:  clipping rectangle stack overflow"
+
+#define NUM_ERR_CODES 134
+
+#endif
diff --git a/usr/src/new/X/libvs100/report.c b/usr/src/new/X/libvs100/report.c
new file mode 100644 (file)
index 0000000..d049d30
--- /dev/null
@@ -0,0 +1,82 @@
+/* $Header: report.c,v 10.3 86/02/01 15:47:36 tony Rel $ */
+/* report.c    routine to do a ReportStatus call to the vs
+ *
+ *     ReportStatus    Get information about the workstation
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+char *AllocateSpace();
+
+/* Issue a report status.  This returns the device type and version (usually
+ * useless), the microcode version (also useless), a bitmap describing the
+ * frame buffer (very useful), a description of framebuffer memory
+ * that isn't mapped to the screen, a description of the program memory
+ * not used by the firmware (useful for caching data in the workstation),
+ * and a description of where to map the host Vax's memory (useful to the
+ * driver but not to anyone else).  There are two versions; if rom is
+ * 1 the rom version is used; this only works before the firmware is started
+ * up.  Any of the pointers may be NULL if the appropriate information
+ * isn't required.
+ */
+
+ReportStatus (devType, devVersion, ucodeVersion, framebuffer,
+               freeFramebuffer, freeProgram, hostMem, rom)
+       int *devType, rom;
+       short *devVersion, *ucodeVersion;
+       BitMap *framebuffer;
+       MemArea *freeFramebuffer, *freeProgram, *hostMem;
+{
+       register ReportStatusPacket *rsp;
+#define        h ((PacketHeader *) rsp->rsp_head)
+
+       rsp = (ReportStatusPacket *) AllocateSpace (sizeof (ReportStatusPacket));
+       if (rsp == NULL) return (-1);
+
+       /* Format the packet */
+
+       h->ph_modifier.emptymod = 0;
+       h->ph_opcode = (rom ? REPORT_STATUS_ROM : REPORT_STATUS);
+       *(long *) h->ph_next = NULL;
+
+       /* And send it off */
+
+       if (WritePacket ((caddr_t) rsp) || SynchWrites()) return (-1);
+
+       if (devType) *devType = *(long *) rsp->rsp_deviceType;
+       if (devVersion) *devVersion = rsp->rsp_deviceVersion;
+       if (ucodeVersion) *ucodeVersion = rsp->rsp_ucodeVersion;
+       if (framebuffer)
+               *framebuffer = *(BitMap *) rsp->rsp_visibleFramebuffer;
+       if (freeFramebuffer)
+               *freeFramebuffer = *(MemArea *) rsp->rsp_freeFramebuffer;
+       if (freeProgram)
+               *freeProgram = *(MemArea *) rsp->rsp_freeProgramMemory;
+       if (hostMem)
+               *hostMem = *(MemArea *) rsp->rsp_hostMemory;
+
+       return (0);
+}
diff --git a/usr/src/new/X/libvs100/text.c b/usr/src/new/X/libvs100/text.c
new file mode 100644 (file)
index 0000000..3ae586d
--- /dev/null
@@ -0,0 +1,284 @@
+/* $Header: text.c,v 10.3 86/02/01 15:47:40 tony Rel $ */
+/* text.c      Prints a line of text
+ *
+ *     PrintText       Prints text with source font
+ *     PrintTextMask   Prints text with mask font
+ *     CopyText        Copy text to bitmap
+ *     TextWidth       Returns width of a piece of text in a font
+ *     CharWidth       Returns width of a character in a font
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+extern BitMap screen;
+extern int VSReloc;
+extern char FBMap[];
+extern char SSMap[];
+
+char *AllocateCopy(), *AllocateSpace();
+
+PrintText (string, strlen, font, fore, back, charpad, spacepad, dstx, dsty,
+          clips, clipcount, func, zmask)
+       char *string;
+       FONT *font;
+       int strlen, fore, back, charpad, spacepad, dstx, dsty;
+       CLIP *clips;
+       int clipcount, zmask;
+       register int func;
+{
+       register PrintTextPacket *ptp;
+#define        h ((PacketHeader *) ptp->ptp_head)
+#define        dest ((BitMap *) ptp->ptp_destImage)
+#define        destOff ((Point *) ptp->ptp_initialOffset.literal)
+#define        txt ((TextString *) ptp->ptp_text)
+#define        control ((ControlString *) ptp->ptp_control)
+#define        clip ((RectangleList *) ptp->ptp_clipping.rectList)
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       if ((string = (caddr_t) AllocateCopy(string, strlen)) == NULL ||
+           (ptp = (PrintTextPacket *) AllocateSpace (sizeof (PrintTextPacket))) == NULL)
+           return;
+
+       if (fore & 1)
+           func += 0x20;
+       if (back & 1)
+           func += 0x10;
+       func = FBMap[func];
+       h->ph_textMod.m_source = 1;     /* Source font */
+       h->ph_textMod.m_mask = 0;       /* No mask font */
+       h->ph_textMod.m_dest = 0;       /* Dest off. literal */
+       h->ph_textMod.m_map = MAPTYPE(func);
+       h->ph_textMod.m_textSize = 0;   /* 8 bit characters */
+       h->ph_textMod.m_control = 0;    /* No control string */
+       h->ph_opcode = PRINT_TEXT;
+       *(long *) h->ph_next = NULL;
+       *(caddr_t *) ptp->ptp_source.font = FDATA(font)->remote->vsPtr;
+
+       *dest = screen;
+       destOff->p_x = dstx;
+       destOff->p_y = dsty;
+
+       *(short *) ptp->ptp_map.literal = MAPLIT(func);
+
+       if (clipcount == 1) {
+           h->ph_textMod.m_clipping = 1;
+           *(CLIP *) ptp->ptp_clipping.litRect = *clips;
+       } else {
+           h->ph_textMod.m_clipping = 2;
+           *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+           clip->r_count = clipcount;
+       }
+
+       *(caddr_t *) txt->t_first = (caddr_t) string + VSReloc;
+       txt->t_count = strlen;
+
+       *(short **) control->c_first = NULL;
+       control->c_count = 0;
+       ptp->ptp_charPad = charpad;
+       ptp->ptp_spacePad = spacepad;
+
+       WritePacket ((caddr_t) ptp);
+#undef h
+#undef dest
+#undef destOff
+#undef txt
+#undef control
+#undef clip
+}
+
+PrintTextMask (string, strlen, font, srcpix, charpad, spacepad, dstx, dsty,
+              clips, clipcount, func, zmask)
+       char *string;
+       FONT *font;
+       int strlen, srcpix, charpad, spacepad, dstx, dsty;
+       CLIP *clips;
+       int clipcount, zmask;
+       register int func;
+{
+       register PrintTextPacket *ptp;
+#define        h ((PacketHeader *) ptp->ptp_head)
+#define        dest ((BitMap *) ptp->ptp_destImage)
+#define        destOff ((Point *) ptp->ptp_initialOffset.literal)
+#define        txt ((TextString *) ptp->ptp_text)
+#define        control ((ControlString *) ptp->ptp_control)
+#define        clip ((RectangleList *) ptp->ptp_clipping.rectList)
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       if ((string = (caddr_t) AllocateCopy(string, strlen)) == NULL ||
+           (ptp = (PrintTextPacket *) AllocateSpace (sizeof (PrintTextPacket))) == NULL)
+           return;
+
+       func = SSMap[func];
+       h->ph_textMod.m_source = 0;     /* Constant */
+       h->ph_textMod.m_mask = 1;       /* Mask font */
+       h->ph_textMod.m_dest = 0;       /* Dest off. literal */
+       h->ph_textMod.m_map = MAPTYPE(func);
+       h->ph_textMod.m_textSize = 0;   /* 8 bit characters */
+       h->ph_textMod.m_control = 0;    /* No control string */
+       h->ph_opcode = PRINT_TEXT;
+       *(long *) h->ph_next = NULL;
+       ptp->ptp_source.const = srcpix & 1;
+
+       *(caddr_t *) ptp->ptp_mask = FDATA(font)->remote->vsPtr;
+
+       *dest = screen;
+       destOff->p_x = dstx;
+       destOff->p_y = dsty;
+
+       *(short *) ptp->ptp_map.literal = MAPLIT(func);
+
+       if (clipcount == 1) {
+           h->ph_textMod.m_clipping = 1;
+           *(CLIP *) ptp->ptp_clipping.litRect = *clips;
+       } else {
+           h->ph_textMod.m_clipping = 2;
+           *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+           clip->r_count = clipcount;
+       }
+
+       *(caddr_t *) txt->t_first = (caddr_t) string + VSReloc;
+       txt->t_count = strlen;
+
+       *(short **) control->c_first = NULL;
+       control->c_count = 0;
+       ptp->ptp_charPad = charpad;
+       ptp->ptp_spacePad = spacepad;
+
+       WritePacket ((caddr_t) ptp);
+#undef h
+#undef dest
+#undef destOff
+#undef txt
+#undef control
+#undef clip
+}
+
+CopyText (string, strlen, font, bm)
+       char *string;
+       int strlen;
+       FONT *font;
+       BITMAP *bm;
+{
+       register PrintTextPacket *ptp;
+#define        h ((PacketHeader *) ptp->ptp_head)
+#define        dst ((SubBitmap *) ptp->ptp_destImage)
+#define        txt ((TextString *) ptp->ptp_text)
+#define        control ((ControlString *) ptp->ptp_control)
+
+       if ((string = (caddr_t) AllocateCopy(string, strlen)) == NULL ||
+           (ptp = (PrintTextPacket *) AllocateSpace (sizeof (PrintTextPacket))) == NULL)
+           return;
+
+       h->ph_textMod.m_source = 1;     /* Source font */
+       h->ph_textMod.m_mask = 0;       /* No mask font */
+       h->ph_textMod.m_dest = 0;       /* Dest off. literal */
+       h->ph_textMod.m_map = 0;
+       h->ph_textMod.m_textSize = 0;   /* 8 bit characters */
+       h->ph_textMod.m_control = 0;    /* No control string */
+       h->ph_opcode = PRINT_TEXT;
+       *(long *) h->ph_next = NULL;
+       *(caddr_t *) ptp->ptp_source.font = FDATA(font)->remote->vsPtr;
+
+       *(caddr_t *)dst->sb_address = BDATA(bm)->vsPtr;
+       dst->sb_height = bm->height;
+       dst->sb_width = bm->width;
+       dst->sb_bitsPerPixel = 1;
+       dst->sb_x = dst->sb_y = 0;
+
+       *(short *) ptp->ptp_map.literal = 0;
+
+       h->ph_textMod.m_clipping = 0;
+
+       *(caddr_t *) txt->t_first = (caddr_t) string + VSReloc;
+       txt->t_count = strlen;
+
+       *(short **) control->c_first = NULL;
+       control->c_count = 0;
+       ptp->ptp_charPad = 0;
+       ptp->ptp_spacePad = 0;
+
+       WritePacket ((caddr_t) ptp);
+#undef h
+#undef dst
+#undef txt
+#undef control
+}
+
+/* Returns the width of a string in a font */
+
+int TextWidth (string, strlen, spacepad, font)
+       char *string;
+       register int strlen;
+       int spacepad;
+       register FONT *font;
+{
+       register u_char *strptr = (u_char *) string;
+       short c;
+       register short *widths;
+       int width = 0;
+
+       if (font->fixed) {
+           width = strlen * font->avg_width;
+           if (spacepad) {
+               while (--strlen >= 0)
+                   if (*strptr++ == font->space)
+                       width += spacepad;
+           }
+       } else {
+           widths = FDATA(font)->widths;
+           while (--strlen >= 0) {
+               c = *strptr++;
+               if (c >= font->first && c <= font->last) {
+                   if (c == font->space)
+                       width += spacepad;
+                   width += widths[c - font->first];
+               }
+           }
+       }
+
+       return (width);
+}
+
+/* Returns width of a character in a font. */
+
+int CharWidth(c, font)
+       register unsigned int c;
+       register FONT *font;
+{
+
+       if (c < font->first || c > font->last)
+           return (0);
+       else if (font->fixed)
+           return (font->avg_width);
+       else
+           return (FDATA(font)->widths[c - font->first]);
+}
diff --git a/usr/src/new/X/libvs100/tile.c b/usr/src/new/X/libvs100/tile.c
new file mode 100644 (file)
index 0000000..a6e093d
--- /dev/null
@@ -0,0 +1,248 @@
+/* $Header: tile.c,v 10.3 86/02/01 15:47:46 tony Rel $ */
+/* tile.c      Perform a raster operation involving a pattern
+ *
+ *     TileFill        Patterns a portion of the screen
+ *     DrawFilled      Draw a filled generalized line/polygon/combination
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+
+extern BitMap screen;
+extern int VSReloc;
+extern char SSMap[];
+
+char *AllocateSpace(), *AllocateCopy(), *Xalloc();
+
+TileFill (tile, xoff, yoff, xymask, dstx, dsty, width, height,
+         clips, clipcount, func, zmask)
+       register PIXMAP *tile;
+       register BITMAP *xymask;
+       int xoff, yoff, dstx, dsty, width, height, zmask;
+       register int func;
+       CLIP *clips;
+{
+       register CopyAreaPacket *cap;
+#define        h ((PacketHeader *) cap->cap_head)
+#define        pat ((Halftone *) cap->cap_source.pattern)
+#define mask ((SubBitmap *) cap->cap_sourceMask)
+#define        size ((Extent *) cap->cap_maskSize)
+#define        destOff ((Point *) cap->cap_destOffset)
+#define        clip ((RectangleList *) cap->cap_clipping.rectList)
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+#ifdef HTCROCK
+       cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket) + 32);
+#else
+       cap = (CopyAreaPacket *) AllocateSpace (sizeof (CopyAreaPacket));
+#endif
+       if (cap == NULL) return;
+
+       func = SSMap[func | (tile->kind & 0x10)];
+       h->ph_copyMod.m_source = tile->kind;
+       h->ph_copyMod.m_mask = xymask ? 1 : 0;
+       h->ph_copyMod.m_map = MAPTYPE(func);
+       h->ph_opcode = COPY_AREA;
+       *(long *) h->ph_next = NULL;
+
+       if (tile->kind == 0)
+           cap->cap_source.const = (int) tile->data;
+       else {
+#ifdef HTCROCK
+               if ((xoff|yoff) & 0xf) {
+                   *(caddr_t *) pat->ht_address = (caddr_t) cap +
+                                                  sizeof (CopyAreaPacket) +
+                                                  VSReloc;
+                   Align_Halftone (TDATA(tile)->data,
+                                   (short *) ((caddr_t) cap + sizeof (CopyAreaPacket)),
+                                   xoff, yoff);
+               } else
+                   *(caddr_t *) pat->ht_address =
+                                       BDATA(TDATA(tile)->bitmap)->vsPtr;
+               pat->ht_x = pat->ht_y = 0;
+#else
+               *(caddr_t *) pat->ht_address = BDATA(PDATA(tile))->vsPtr;
+               pat->ht_x = xoff;
+               pat->ht_y = yoff;
+#endif
+               pat->ht_height = pat->ht_width = 16;
+               pat->ht_bitsPerPixel = 1;
+       }
+
+       if (xymask) {
+               *(caddr_t *) mask->sb_address = BDATA(xymask)->vsPtr;
+               mask->sb_height = xymask->height;
+               mask->sb_width = xymask->width;
+               mask->sb_bitsPerPixel = 1;
+               mask->sb_x = mask->sb_y = 0;
+       }
+       size->e_height = height;
+       size->e_width = width;
+
+       *(BitMap *) cap->cap_destImage = screen;
+       destOff->p_x = dstx;
+       destOff->p_y = dsty;
+
+       *(short *) cap->cap_map.literal = MAPLIT(func);
+
+       if (clipcount == 1) {
+           h->ph_copyMod.m_clipping = 1;
+           *(CLIP *) cap->cap_clipping.litRect = *clips;
+       } else {
+           h->ph_copyMod.m_clipping = 2;
+           *(caddr_t *) clip->r_first = (caddr_t) clips + VSReloc;
+           clip->r_count = clipcount;
+       }
+
+       WritePacket ((caddr_t) cap);
+#undef h
+#undef pat
+#undef mask
+#undef size
+#undef destOff
+#undef clip
+}
+
+DrawFilled (verts, vertcount, xbase, ybase, srcpix, tile, xoff, yoff,
+           clips, clipcount, func, zmask)
+       Vertex *verts;
+       register PIXMAP *tile;
+       int vertcount, xbase, ybase, srcpix, xoff, yoff, clipcount, zmask;
+       register int func;
+       CLIP *clips;
+{
+       register FillAreaPacket *fap;
+       char *boxes = NULL;
+       Vertex *segs;
+#define        h ((PacketHeader *) fap->fap_head)
+#define        pat ((Halftone *) fap->fap_source.pattern)
+#define        destOff ((Point *) fap->fap_destOffset)
+#define        path ((SegmentList *) fap->fap_path)
+
+       if (!(zmask & 1)) {
+           DeallocateSpace ();
+           return;
+       }
+       if (clipcount > 1) {
+           boxes = Xalloc (sizeof (CLIP) * clipcount);
+           bcopy ((caddr_t) clips, boxes, sizeof (CLIP) * clipcount);
+           clips = (CLIP *) boxes;
+           DeallocateSpace ();
+       }
+
+       if (tile && (tile->kind & 0x10))
+           func |= 0x10;
+       func = SSMap[func];
+       while (--clipcount >= 0) {
+
+#ifdef HTCROCK
+       fap = (FillAreaPacket *) AllocateSpace (sizeof (FillAreaPacket) + 32);
+#else
+       fap = (FillAreaPacket *) AllocateSpace (sizeof (FillAreaPacket));
+#endif
+       if (fap == NULL ||
+           (segs = (Vertex *) AllocateCopy ((caddr_t) verts, vertcount * sizeof (Vertex))) == NULL)
+           break;
+
+       if (tile)
+           h->ph_fillMod.m_source = tile->kind;
+       else
+           h->ph_fillMod.m_source = 0;
+       h->ph_fillMod.m_map = MAPTYPE(func);
+       h->ph_opcode = FILL_AREA;
+       *(long *) h->ph_next = NULL;
+
+       if (tile == NULL)
+           fap->fap_source.const = srcpix & 1;
+       else if (tile->kind == 0)
+           fap->fap_source.const = (int) tile->data;
+       else {
+#ifdef HTCROCK
+               if ((xoff|yoff) & 0xf) {
+                   *(caddr_t *) pat->ht_address = (caddr_t) fap +
+                                                  sizeof (FillAreaPacket) +
+                                                  VSReloc;
+                   Align_Halftone (TDATA(tile)->data,
+                                   (short *) ((caddr_t) fap + sizeof (FillAreaPacket)),
+                                   xoff, yoff);
+               } else 
+                   *(caddr_t *) pat->ht_address =
+                                       BDATA(TDATA(tile)->bitmap)->vsPtr;
+               pat->ht_x = pat->ht_y = 0;
+#else
+               *(caddr_t *) pat->ht_address = BDATA(PDATA(tile))->vsPtr;
+               pat->ht_x = xoff;
+               pat->ht_y = yoff;
+#endif
+               pat->ht_height = pat->ht_width = 16;
+               pat->ht_bitsPerPixel = 1;
+       }
+
+       *(BitMap *) fap->fap_destImage = screen;
+       destOff->p_x = xbase;
+       destOff->p_y = ybase;
+
+       *(short *) fap->fap_map.literal = MAPLIT(func);
+
+       h->ph_fillMod.m_clipping = 1;
+       *(CLIP *) fap->fap_clippingRec = *clips;
+       clips++;
+
+       *(caddr_t *) path->seg_first = (caddr_t) segs + VSReloc;
+       path->seg_count = vertcount;
+
+       WritePacket ((caddr_t) fap);
+       }
+
+       if (boxes)
+           free (boxes);
+#undef h
+#undef pat
+#undef destOff
+#undef path
+}
+
+#ifdef HTCROCK
+Align_Halftone (src, dst, xoff, yoff)
+       register short *src, *dst;
+       register int xoff, yoff;
+{
+       register int i;
+       int shift, mask;
+
+       xoff &= 0xf;
+       yoff = (16 - (yoff & 0xf)) & 0xf;
+       shift = (16 - xoff) & 0xf;
+       mask = (1 << xoff) - 1;
+       for (i = 0; i < 16; i++) {
+           dst[i] = (src[yoff] << xoff) | ((src[yoff] >> shift) & mask);
+           yoff++;
+           yoff &= 0xf;
+       }
+}
+#endif
diff --git a/usr/src/new/X/libvs100/util.c b/usr/src/new/X/libvs100/util.c
new file mode 100644 (file)
index 0000000..0a8ec1f
--- /dev/null
@@ -0,0 +1,300 @@
+/* $Header: util.c,v 10.4 86/11/30 16:45:52 jg Rel $ */
+/* util.c              Various utilities
+ *
+ *     ErrorString     Interprets an error string
+ *     SoundBell       Generate audible bell
+ *     SetKeyClick     Control key click
+ *     SetAutoRepeat   Control auto repeat
+ *     SetLockLED      Control Lock LED
+ *     QueryShape      Determine shapes
+ *     SetVideo        Set video blanking
+ *     ResolveColors   does nothing
+ *     StoreColors     does nothing
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+#include "reason.h"
+
+extern int sys_nerr;
+extern char *sys_errlist[];
+
+char *AllocateSpace();
+
+struct _ErrEntry {
+       int code;
+       char *reason;
+} errorList[NUM_ERR_CODES] = {
+       {IR_ID          , IR_ID_MSG },
+       {IR_CD          , IR_CD_MSG },
+       {IR_DCI         , IR_DCI_MSG },
+       {IR_DE          , IR_DE_MSG },
+       {IR_CM          , IR_CM_MSG },
+       {IR_DPM         , IR_DPM_MSG },
+       {IR_MM          , IR_MM_MSG },
+       {IR_PD          , IR_PD_MSG },
+       {IR_AB_ACK      , IR_AB_ACK_MSG },
+       {IR_STAT_ACK    , IR_STAT_ACK_MSG },
+       {IR_SAVE_ACK    , IR_SAVE_ACK_MSG },
+       {ERR_NYI        , ERR_NYI_MSG },
+       {ERR_IFC        , ERR_IFC_MSG},
+       {ERR_ICC        , ERR_ICC_MSG},
+       {ERR_BE_NXM_68K , ERR_BE_NXM_68K_MSG},
+       {ERR_BE_RO      , ERR_BE_RO_MSG},
+       {ERR_BE_LD      , ERR_BE_LD_MSG},
+       {ERR_BE_S       , ERR_BE_S_MSG},
+       {ERR_AE         , ERR_AE_MSG},
+       {ERR_ZD         , ERR_ZD_MSG},
+       {ERR_II         , ERR_II_MSG},
+       {ERR_NXM_BBA    , ERR_NXM_BBA_MSG},
+       {ERR_BNI        , ERR_BNI_MSG},
+       {ERR_KCQO       , ERR_KCQO_MSG},
+       {ERR_DPCQO      , ERR_DPCQO_MSG},
+       {ERR_MEQO       , ERR_MEQO_MSG},
+       {ERR_DPEQO      , ERR_DPEQO_MSG},
+       {ERR_AB_BBA     , ERR_AB_BBA_MSG},
+       {ERR_KEQO       , ERR_KEQO_MSG},
+       {ERR_KOR        , ERR_KOR_MSG},
+       {ERR_DPOR       , ERR_DPOR_MSG},
+       {ERR_KFE        , ERR_KFE_MSG},
+       {ERR_DPFE       , ERR_DPFE_MSG},
+
+       {ERR_ISRCM      , ERR_ISRCM_MSG},
+       {ERR_ISRCBW     , ERR_ISRCBW_MSG},
+       {ERR_ISRCBH     , ERR_ISRCBH_MSG},
+       {ERR_ISRCC      , ERR_ISRCC_MSG},
+       {ERR_ISRCBD     , ERR_ISRCBD_MSG},
+       {ERR_IMSKM      , ERR_IMSKM_MSG},
+       {ERR_IMSKBW     , ERR_IMSKBW_MSG},
+       {ERR_IMSKBH     , ERR_IMSKBH_MSG},
+       {ERR_IMSKBD     , ERR_IMSKBD_MSG},
+       {ERR_IDSTM      , ERR_IDSTM_MSG},
+       {ERR_IDSTBW     , ERR_IDSTBW_MSG},
+       {ERR_IDSTBH     , ERR_IDSTBH_MSG},
+       {ERR_IDSTBD     , ERR_IDSTBD_MSG},
+       {ERR_IMAPM      , ERR_IMAPM_MSG},
+       {ERR_ICLPM      , ERR_ICLPM_MSG},
+       {ERR_ICLPC      , ERR_ICLPC_MSG},
+
+       {ERR_SMC_ITC    , ERR_SMC_ITC_MSG},
+       {ERR_SCL_CD     , ERR_SCL_CD_MSG},
+       {ERR_AC_ICD     , ERR_AC_ICD_MSG},
+
+       {ERR_MO_IBC     , ERR_MO_IBC_MSG},
+       {ERR_MO_IOT     , ERR_MO_IOT_MSG},
+       {ERR_MO_IDT     , ERR_MO_IDT_MSG},
+
+       {ERR_IPC        , ERR_IPC_MSG},
+
+       {ERR_DC_IPL     , ERR_DC_IPL_MSG},
+       {ERR_DC_IPM     , ERR_DC_IPM_MSG},
+       {ERR_DC_ICF     , ERR_DC_ICF_MSG},
+       {ERR_DC_IPP     , ERR_DC_IPP_MSG},
+       {ERR_DC_IPSM    , ERR_DC_IPSM_MSG},
+       {ERR_DC_IPMM    , ERR_DC_IPMM_MSG},
+       {ERR_DC_IPC     , ERR_DC_IPC_MSG},
+       {ERR_DC_ISSRCBW , ERR_DC_ISSRCBW_MSG},
+       {ERR_DC_ISSRCBH , ERR_DC_ISSRCBH_MSG},
+       {ERR_DC_ISSRCBD , ERR_DC_ISSRCBD_MSG},
+       {ERR_DC_ISSRCC  , ERR_DC_ISSRCC_MSG},
+       {ERR_DC_IDPM    , ERR_DC_IDPM_MSG},
+       {ERR_DC_DXO     , ERR_DC_DXO_MSG},
+       {ERR_DC_DYO     , ERR_DC_DYO_MSG},
+       {ERR_DC_CRSO    , ERR_DC_CRSO_MSG},
+
+       {ERR_PT_ICSL    , ERR_PT_ICSL_MSG},
+       {ERR_PT_ICSO    , ERR_PT_ICSO_MSG},
+       {ERR_PT_ICSP    , ERR_PT_ICSP_MSG},
+       {ERR_PT_ITSL    , ERR_PT_ITSL_MSG},
+       {ERR_PT_ICI     , ERR_PT_ICI_MSG},
+       {ERR_PT_TSE     , ERR_PT_TSE_MSG},
+       {ERR_PT_NFP     , ERR_PT_NFP_MSG},
+       {ERR_PT_ISRCFW  , ERR_PT_ISRCFW_MSG},
+       {ERR_PT_ISRCFH  , ERR_PT_ISRCFH_MSG},
+       {ERR_PT_ISRCFD  , ERR_PT_ISRCFD_MSG},
+       {ERR_PT_IMSKFW  , ERR_PT_IMSKFW_MSG},
+       {ERR_PT_IMSKFH  , ERR_PT_IMSKFH_MSG},
+       {ERR_PT_IMSKFD  , ERR_PT_IMSKFD_MSG},
+       {ERR_PT_CSMF    , ERR_PT_CSMF_MSG},
+       {ERR_PT_ILB     , ERR_PT_ILB_MSG},
+       {ERR_PT_ILE     , ERR_PT_ILE_MSG},
+       {ERR_FA_ISRCB   , ERR_FA_ISRCB_MSG},
+       {ERR_FA_SO      , ERR_FA_SO_MSG},
+       {ERR_FA_IBMM    , ERR_FA_IBMM_MSG},
+
+       {ERR_FP_ISRCB   , ERR_FP_ISRCB_MSG},
+       {ERR_FP_ICF     , ERR_FP_ICF_MSG},
+       {ERR_FP_DXO     , ERR_FP_DXO_MSG},
+       {ERR_FP_DYO     , ERR_FP_DYO_MSG},
+
+       {ERR_CPU                , ERR_CPU_MSG},
+       {ERR_RHB                , ERR_RHB_MSG},
+       {ERR_PR         , ERR_PR_MSG},
+       {ERR_CRTC       , ERR_CRTC_MSG},
+       {ERR_DPE                , ERR_DPE_MSG},
+       {ERR_KE         , ERR_KE_MSG},
+       {ERR_FOE                , ERR_FOE_MSG},
+       {ERR_F0         , ERR_F0_MSG},
+       {ERR_BSR                , ERR_BSR_MSG},
+       {ERR_BCC                , ERR_BCC_MSG},
+       {ERR_DPTO       , ERR_DPTO_MSG},
+       {ERR_FOO                , ERR_FOO_MSG},
+       {ERR_KTO                , ERR_KTO_MSG},
+       {ERR_KST                , ERR_KST_MSG},
+       {ERR_VR         , ERR_VR_MSG},
+       {ERR_F1         , ERR_F1_MSG},
+       {ERR_F2         , ERR_F2_MSG},
+       {ERR_F3         , ERR_F3_MSG},
+       {ERR_DPP                , ERR_DPP_MSG},
+       {ERR_KP         , ERR_KP_MSG},
+       {ERR_FOED       , ERR_FOED_MSG},
+       {ERR_FOOD       , ERR_FOOD_MSG},
+       {ERR_BCTO       , ERR_BCTO_MSG},
+       {ERR_RLB                , ERR_RLB_MSG},
+       {ERR_KD         , ERR_KD_MSG},
+       {ERR_BVC                , ERR_BVC_MSG},
+
+       {ERR_ISRCHW     , ERR_ISRCHW_MSG},
+       {ERR_ISRCHH     , ERR_ISRCHH_MSG},
+       {ERR_ISRCHD     , ERR_ISRCHD_MSG},
+       {ERR_DC_ISSRCHW , ERR_DC_ISSRCHW_MSG},
+       {ERR_DC_ISSRCHH , ERR_DC_ISSRCHH_MSG},
+       {ERR_DC_ISSRCHD , ERR_DC_ISSRCHD_MSG},
+
+       {ERR_LC_ICTX    , ERR_LC_ICTX_MSG},
+       {ERR_LC_ICTY    , ERR_LC_ICTY_MSG},
+       {ERR_LC_ICCX    , ERR_LC_ICCX_MSG},
+       {ERR_LC_ICCY    , ERR_LC_ICCY_MSG},
+       {ERR_LC_ICW     , ERR_LC_ICW_MSG},
+       {ERR_LC_ICH     , ERR_LC_ICH_MSG},
+       {ERR_PT_DXO     , ERR_PT_DXO_MSG},
+       {ERR_PT_CRSO    , ERR_PT_CRSO_MSG},
+};
+
+/* Interpret a string corresponding to an error code.  This doesn't
+ * work very well since the driver can't return enough bits for the
+ * code, but we do our best */
+
+char *ErrorString (error)
+       int error;
+{
+       register int i;
+
+       for (i = 0; i < NUM_ERR_CODES; i++) {
+           if (errorList[i].code == error)
+               return (errorList[i].reason);
+       }
+       if (error > 0 && error < sys_nerr)
+           return (sys_errlist[error]);
+       return ("Unknown error");
+}
+
+SoundBell (volume)
+       int volume;
+{
+       char *buf;
+
+       if ((buf = (char *) AllocateSpace(4)) == NULL)
+           return;
+       buf[0] = 3;
+       buf[1] = 0x23;
+       buf[2] = 0x87 - volume;
+       buf[3] = 0xa7;
+       SendToPeripheral(buf, 4, VSE_DKB);
+}
+
+SetKeyClick (volume)
+       int volume;
+{
+       char *buf;
+
+       if ((buf = (char *) AllocateSpace(3)) == NULL)
+           return;
+       if (volume) {
+           buf[0] = 2;
+           buf[1] = 0x1b;
+           buf[2] = 0x88 - volume;
+       } else {
+           buf[0] = 1;
+           buf[1] = 0x99;
+           buf[2] = 0x99;
+       }
+       SendToPeripheral(buf, 3, VSE_DKB);
+}
+
+QueryShape (shape, width, height)
+       int shape;
+       short *width, *height;
+{
+       switch (shape) {
+       case CursorShape:
+           if (*width > 64)
+               *width = 64;
+           if (*height > 64)
+               *height = 64;
+           break;
+       case TileShape:
+           *width = *height = 16;
+           break;
+       }
+}
+
+SetAutoRepeat (onoff)
+       int onoff;
+{
+       char *buf;
+
+       if ((buf = (char *) AllocateSpace(2)) == NULL)
+           return;
+       buf[0] = 1;
+       buf[1] = onoff ? 0xe3 : 0xe1;
+       SendToPeripheral(buf, 2, VSE_DKB);
+}
+
+/*ARGSUSED*/
+SetLockLED (onoff)
+       int onoff;
+{
+}
+
+SetVideo (onoff)
+       int onoff;
+{
+       return (onoff - 1);
+}
+
+/*ARGSUSED*/
+ResolveColor (red, green, blue)
+       unsigned short *red, *green, *blue;
+{
+}
+
+/*ARGSUSED*/
+StoreColors (count, entries)
+       int count;
+       ColorDef *entries;
+
+{
+}
diff --git a/usr/src/new/X/libvs100/vs100.h b/usr/src/new/X/libvs100/vs100.h
new file mode 100644 (file)
index 0000000..62b314e
--- /dev/null
@@ -0,0 +1,48 @@
+/* $Header: vs100.h,v 10.3 86/02/01 15:47:56 tony Rel $ */
+/* Copyright    Massachusetts Institute of Technology    1985  */
+
+#include <sys/types.h>
+#include <stdio.h>
+#include "param.h"
+#include "packet.h"
+#include "mem.h"
+#include "../X/vsinput.h"
+#include "../X/Xdev.h"
+#include "../X/X.h"
+
+#define HTCROCK                /* Writearound for Halftone alignment problem */
+
+#define VBUFSIZE 2048
+
+#define MAPTYPE(x) (x >> 4)
+#define MAPLIT(x) (x & 0xf)
+
+typedef struct _curspriv {
+       BITMAP *image;
+       BITMAP *mask;
+       short map;
+} CursPriv;
+
+#define CDATA(x) ((CursPriv *) x->data)
+
+typedef struct _fontpriv {
+       short *widths;
+       VSArea *remote;
+} FontPriv;
+
+#define FDATA(x) ((FontPriv *) x->data)
+
+#define BDATA(x) ((VSArea *) x->data)
+
+#define PDATA(x) ((BITMAP *) x->data)
+
+#ifdef HTCROCK
+
+typedef struct _tilepriv {
+       BITMAP *bitmap;
+       short data[16];
+} TilePriv;
+
+#define TDATA(x) ((TilePriv *) x->data)
+
+#endif
diff --git a/usr/src/new/X/libvs100/vsalloc.c b/usr/src/new/X/libvs100/vsalloc.c
new file mode 100644 (file)
index 0000000..3b9a1dc
--- /dev/null
@@ -0,0 +1,228 @@
+/* $Header: vsalloc.c,v 10.3 86/02/01 15:47:58 tony Rel $ */
+/* vsalloc.c   routines to allocate and free vs framebuffer memory
+ *
+ *     VSMemInit       Initializes the free list
+ *     VSAlloc         Allocates a chunk of memory
+ *     VSFree          Frees a chunk of memory
+ *
+ *     The method used is a variant on the method described in Knuth
+ * volume 1, page 441.  The modification is that since we can't directly
+ * modify the memory in the vs, we maintain an ordered linked list of
+ * extents with either free chain pointers or addresses of blocks
+ *
+ */
+
+/****************************************************************************
+ *                                                                         *
+ *  Copyright (c) 1983, 1984 by                                                    *
+ *  DIGITAL EQUIPMENT CORPORATION, Maynard, Massachusetts.                 *
+ *  All rights reserved.                                                   *
+ *                                                                         *
+ *  This software is furnished on an as-is basis and may be used and copied *
+ *  only with inclusion of the above copyright notice. This software or any *
+ *  other copies thereof may be provided or otherwise made available to     *
+ *  others only for non-commercial purposes.  No title to or ownership of   *
+ *  the software is hereby transferred.                                            *
+ *                                                                         *
+ *  The information in this software is  subject to change without notice   *
+ *  and  should  not  be  construed as  a commitment by DIGITAL EQUIPMENT   *
+ *  CORPORATION.                                                           *
+ *                                                                         *
+ *  DIGITAL assumes no responsibility for the use  or  reliability of its   *
+ *  software on equipment which is not supplied by DIGITAL.                *
+ *                                                                         *
+ *                                                                         *
+ ****************************************************************************/
+
+#include "vs100.h"
+#include <errno.h>
+
+extern int errno;
+
+char *Xalloc();
+
+#define slopsize 10    /* Amount we're willing to overallocate */
+
+static VSArea listhead;
+
+/* Initialize the memory structures.  Called by DownLoad, usually */
+
+int VSMemInit()
+{
+       MemArea freefb, freepg;
+       register VSArea *fb, *buf, *pg;
+       VSArea *AllocVSArea();
+
+       if (ReportStatus ((int *) NULL, (short *) NULL, (short *) NULL,
+                         (BitMap *) NULL, &freefb, &freepg, (MemArea *) NULL,
+                         0) == -1) return (-1);
+
+       if ((fb = AllocVSArea()) == NULL) return (-1);
+       if ((buf = AllocVSArea()) == NULL) return (-1);
+       if ((pg = AllocVSArea()) == NULL) return (-1);
+
+       /* Make the list of memory areas */
+
+       listhead.next = buf->prev = fb;
+       fb->next = pg->prev = buf;
+       buf->next = listhead.prev = pg;
+       pg->next = fb->prev = &listhead;
+
+       /* Now set up the free list */
+
+       listhead.vsFree.next = pg->vsFree.prev = fb;
+       fb->vsFree.next = listhead.vsFree.prev = pg;
+       pg->vsFree.next = fb->vsFree.prev = &listhead;
+
+       /* Set up the sizes and addresses */
+
+       listhead.vsPtr = NULL;
+       listhead.vsFreeFlag = VS_INUSE;
+       listhead.vsSize = 0;
+
+       fb->vsPtr = *(caddr_t *) freefb.m_base;
+       fb->vsFreeFlag = VS_FREE;
+       fb->vsSize = *(long *) freefb.m_size;
+
+       /* There's at least one version of the software that returns
+          bogus information there, so... (ug) */
+
+       if (fb->vsPtr == (caddr_t) 0x12ee00) {
+           fb->vsPtr = (caddr_t) 0x117700;
+           fb->vsSize = 35072;
+       }
+
+       /* Hack to deal with the crummy framebuffer bug:  can't use
+          first 8 bytes */
+
+       if (fb->vsPtr == (caddr_t) 0x117700) {
+           fb->vsPtr += 8;
+           fb->vsSize -= 8;
+       }
+
+       buf->vsPtr = 0;
+       buf->vsFreeFlag = VS_INUSE;
+       buf->vsSize = 0;
+
+       pg->vsPtr = *(caddr_t *) freepg.m_base;
+       pg->vsFreeFlag = VS_FREE;
+       pg->vsSize = *(long *) freepg.m_size;
+
+       return (0);
+}
+
+/* Allocate size bytes of specified type (bitmap, halftone, or font) */
+
+VSArea *VSAlloc (size, type)
+       int size, type;
+{
+       register VSArea *f = listhead.vsFree.next, *new;
+       
+       /* Make sure size is a multiple of 2 */
+
+       if (size & 0x1) size++;
+
+       while (f != &listhead && f->vsSize < size) f = f->vsFree.next;
+
+       if (f == &listhead) {
+           DeallocateSpace();
+           errno = ENOMEM;
+           return (NULL);      /* No space */
+       }
+
+       if (f->vsSize <= size + slopsize) {     /* Don't split block */
+           f->vsFree.next->vsFree.prev = f->vsFree.prev;
+           f->vsFree.prev->vsFree.next = f->vsFree.next;
+           f->vsFreeFlag = VS_INUSE;
+           f->vsType = type;
+           return (f);
+
+       } else {        /* Split into two smaller blocks */
+           if ((new = AllocVSArea()) == NULL) return (NULL);
+           new->prev = f->prev;
+           new->next = f;
+           f->prev->next = new;
+           f->prev = new;
+           new->vsSize = size;
+           f->vsSize -= size;
+           new->vsPtr = f->vsPtr;
+           f->vsPtr += size;
+
+           new->vsFreeFlag = VS_INUSE;
+           new->vsType = type;
+
+           return (new);
+       }
+}
+
+/* Free the allocated storage */
+
+int VSFree (block)
+       register VSArea *block;
+{
+       register VSArea *temp;
+
+       if (block->prev->vsFreeFlag == VS_FREE) { /* Coalesce areas */
+           temp = block;
+           block = block->prev;
+           block->vsSize += temp->vsSize;
+           block->next = temp->next;
+           temp->next->prev = block;
+           FreeVSArea (temp);
+           block->vsFree.next->vsFree.prev = block->vsFree.prev;
+           block->vsFree.prev->vsFree.next = block->vsFree.next;
+       }
+
+       if (block->next->vsFreeFlag == VS_FREE) { /* ditto */
+           temp = block;
+           block = block->next;
+           block->vsPtr = temp->vsPtr;
+           block->vsSize += temp->vsSize;
+           block->prev = temp->prev;
+           temp->prev->next = block;
+           FreeVSArea (temp);
+           block->vsFree.next->vsFree.prev = block->vsFree.prev;
+           block->vsFree.prev->vsFree.next = block->vsFree.next;
+       }
+
+       /* Link the block into the free list */
+
+       block->vsFreeFlag = VS_FREE;
+       block->vsFree.next = listhead.vsFree.next;
+       block->vsFree.prev = &listhead;
+       listhead.vsFree.next->vsFree.prev = block;
+       listhead.vsFree.next = block;
+}
+
+/* Boring routines to manage the allocation of the memory area descriptors
+ * on the Vax.
+ */
+
+static VSArea *freeVSAreaHead = NULL;
+#define alloc_at_once 10
+
+VSArea *AllocVSArea()
+{
+       register VSArea *block;
+       register int i;
+
+       if ((block = freeVSAreaHead) == NULL) {
+           block = (VSArea *) Xalloc (alloc_at_once * sizeof (VSArea));
+           freeVSAreaHead = block;
+           i = alloc_at_once;
+           while (--i)
+               block = block->next = block + 1;
+           block->next = NULL;
+           block = freeVSAreaHead;
+       }
+       freeVSAreaHead = block->next;
+
+       return (block);
+}
+
+FreeVSArea(block)
+       VSArea *block;
+{
+       block->next = freeVSAreaHead;
+       freeVSAreaHead = block;
+}
diff --git a/usr/src/new/X/libvs100/vsioctl.h b/usr/src/new/X/libvs100/vsioctl.h
new file mode 100644 (file)
index 0000000..b02e755
--- /dev/null
@@ -0,0 +1,78 @@
+/* $Header: vsioctl.h,v 10.3 86/02/01 15:48:03 tony Rel $ */
+/* $Header: vsioctl.h,v 10.3 86/02/01 15:48:03 tony Rel $ */
+
+/* 
+ * vsio.h - VS100 I/O command definitions
+ * 
+ * Author:     Christopher A. Kent
+ *             Digital Equipment Corporation
+ *             Western Research Lab
+ * Date:       Tue Jun 21 1983
+ */
+
+/* $Log:       vsioctl.h,v $
+ * Revision 10.3  86/02/01  15:48:03  tony
+ * X Version 10.0 Release 3.0
+ * 
+ * Revision 10.2  85/11/24  15:12:05  jg
+ * add RCS id and mark it released...
+ * 
+ * Revision 10.1  85/11/08  17:38:41  newman
+ * X Version 10.0 release
+ * 
+ * Revision 9.1  85/09/04  13:27:15  tony
+ * X Version 9.0 release.
+ * 
+ * Revision 1.1  85/06/30  12:01:32  jg
+ * Initial revision
+ *  */
+
+/* 
+ * Possible ioctl calls
+ */
+
+#define        VSIOINIT        _IO(V, 0)       /* init the device */
+#define        VSIOSTART       _IOW(V, 1, int) /* start microcode */
+#define        VSIOABORT       _IO(V, 2)       /* abort a command chain */
+#define        VSIOPWRUP       _IO(V, 3)       /* power-up reset */
+#define        VSIOGETVER      _IOR(V, 4, int) /* get rom version */
+#define        VSIOSYNC        _IO(V, 6)       /* synch with device */
+#define        VSIOBBACTL      _IOW(V, 8, int) /* control the BBA */
+#define        VSIOFIBCTL      _IOW(V, 9, int) /* lamp on/off */
+#define        VSIOFIBRETRY    _IOW(V,10, int) /* fiber retries */
+#define        VSIOGETSTATS    _IOR(V,11, vsStats)     /* get statistics */
+#define        VSIOGETIOA      _IOR(V,13, vsIoAddrAddr)/* get ioreg address */
+#define        VSIOUSERWAIT    _IO(V, 15)      /* wait for user I/O completion */
+#define VSIOWAITGO     _IOW(V, 16, caddr_t)    /* wait then go */
+
+
+#define        VSIO_OFF        0               /* option off */
+#define        VSIO_ON         1               /* option on */
+
+#define        VS_FIB_FINITE   1               /* finite retries */
+#define        VS_FIB_INFINITE 2               /* infinite retries */
+
+typedef struct _vsStats{
+       int     errors;                 /* count errors */
+       int     unsolIntr;              /* count unsolicited interrupts */
+       int     overruns;               /* event queue overruns */
+       int     flashes;                /* flashes on fiber link */
+       int     ignites;                /* times turned on */
+       int     douses;                 /* times turned off */
+       int     linkErrors;             /* link errors */
+}vsStats;
+
+typedef struct _vsIoAddr {
+       short    *ioreg;
+       short    status;
+       caddr_t  obuff;
+       int      obufflen;
+       int      reloc;
+       vsEvent  *ibuff;
+       int      iqsize;                /* may assume power of 2 */
+       int      ihead;                 /* atomic write */
+       int      itail;                 /* atomic read */
+       vsCursor mouse;                 /* atomic read/write */
+       vsBox    mbox;                  /* atomic read/write */
+} vsIoAddr;
+typedef vsIoAddr *vsIoAddrAddr;
diff --git a/usr/src/new/X/libvs100/vssite.h b/usr/src/new/X/libvs100/vssite.h
new file mode 100644 (file)
index 0000000..5fceb74
--- /dev/null
@@ -0,0 +1,15 @@
+/* $Header: vssite.h,v 10.4 86/02/01 15:48:07 tony Rel $ */
+/* vssite.h
+**
+** This is where any machine-specific information should be stored so that
+** different sites can have control over where things live.
+**
+*/
+
+#define DEFAULT_FONT_DIRECTORY "/usr/new/lib/X/font/"
+#define DEFAULT_FONT_SUFFIX    ".onx"
+
+#define LOAD_FILE_2B "/usr/new/lib/X/s-code/s-code.2b"
+#define LOAD_FILE_3_8 "/usr/new/lib/X/s-code/s-code.3.8"
+#define LOAD_FILE_3_10 "/usr/new/lib/X/s-code/vs100fw.235"
+#define LOAD_FILE_SBO "/usr/new/lib/X/s-code/s-code.sbo"