STRUCTURES(3R)

NAME
structures: Word, Code, Point, Rectangle, Bitmap, Texture16, Font, Fontchar, msgbuf, message_list, msqid_ds - 630 MTG Structures

SYNOPSIS
#include <dmd.h>

#include <font.h>

#include <message.h>

DESCRIPTION
In the following summaries, all coordinates are screen or Bitmap coordinates (which are scaled the same) unless specified as window coordinates. Word , Code , Point , Rectangle , Bitmap and Texture16 are included in a program by including dmd.h. Font and Fontchar are defined in font.h. Msgbuf, message_list, and msqid_ds are defined in message.h.

Word
    typedef short Word;
    typedef unsigned short UWord;

A Word is a 16-bit integer and is the unit of storage used in the graphics software.

Code
    typedef int Code;

Code is the functional constant used in all graphical drawing or copying operations. Available Codes are:

    F_STORE     target  =  source
    F_OR        target |=  source
    F_XOR       target ^=  source
    F_CLR       target &= ~source

Point
    typedef struct Point {
       short  x;	/* x-coordinate */
       short  y;	/* y-coordinate */
    } Point;

A Point is a location in a Bitmap, such as the display. The coordinate system has x increasing to the right and y increasing down.

Rectangle
    typedef struct Rectangle {
       Point  origin;        /* Upper left corner */
       Point  corner;        /* Lower right corner*/
    } Rectangle;

A Rectangle is a rectangular area in a Bitmap. By definition origin.x<=corner.x and origin.y<=corner.y define the rectangle. By convention, the right (maximum x) and bottom (maximum y) edges are excluded from the represented rectangle, so abutting rectangles have no points in common. Thus corner is the coordinates of the first point beyond the rectangle. The data on the screen of the 630 MTG is contained in the Rectangle {0, 0, XMAX, YMAX} where XMAX=1024 and YMAX=1024.

Bitmap
    typedef struct Bitmap {
       Word      *base;/* pointer to start of data */
       unsigned short width;/* width in Words of total data area */
       Rectangle rect;	/* rectangle describing data area */
       char      *_null;	/* unused, must always be zero */
    } Bitmap;

A Bitmap holds a rectangular image stored in contiguous memory starting at base. Each width words of memory form a scan-line of the image. The rect argument defines the coordinate system inside the Bitmap. Argument rect.origin is the location in the Bitmap of the upper-leftmost point in the image and is not necessarily (0,0). Graphical operations performed on a Bitmap are clipped to rect.

Texture16
    typedef struct Texture16 {
    	Word   bits[16];
    } Texture16;

A Texture16 is a 16×16 bit dot pattern. Texture16's are aligned to absolute display positions, so adjacent areas colored with the same Texture16 align smoothly.

Font and Fontchar
    typedef struct Fontchar
    {
       short         x;       /* left edge of character cell in Font.bits */
       unsigned char top;     /* first non-zero scan-line of character image */
       unsigned char bottom;  /* last non-zero scan-line of character image */
       char          left;    /* offset of baseline from x; used for kerning */
       unsigned char width;   /* width of baseline for character image */
    } Fontchar;
    typedef struct Font
    {
       short    n;       /* number of characters in font */
       char     height;  /* height of the Bitmap bits */
       char     ascent;  /* top of Bitmap to baseline of character image */
       long     unused;
       Bitmap   *bits;   /* Bitmap where the characters are stored */
       Fontchar info[1]; /* n+1 character descriptors */
    } Font;

A Font is a character set. For each character in a Font there is information stored in a Fontchar structure. Font.info[n] is a dummy fontchar descriptor used to determine the right edge of the last character in Font.bits. The actual character images in the Font are stored in a single Bitmap pointed to by bits. The Bitmap contains the bit pattern for each character, arrayed adjacently into a long horizontal strip. The characters in the Bitmap must appear in ASCII order and are aligned on the same baseline. Characters in the Bitmap abut exactly, so the width of a character c is Font.info[c+1].x-Font.info[c].x. When a character is displayed on the screen at a point p , the upper left-hand corner of the rectangle enclosing the character image coincides with the point p.

msqid_ds, message_list and msgbuf
    typedef struct msgbuf
    {
       long	 mtype;	    /* message type */
       char	 mtext[1];	/* text of message */
    } msgbuf;
    typedef struct message_list
    {
       msgbuf *msg;			/* the message in the queue */
       int    size;			/* size of the message */
       struct message_list  *next;	/* link to next message */
    } message_list;
    typedef struct msqid_ds
    {
       Struct Proc	*cid;		/* creator process id */
       short		msg_qnum;	/* number of messages */
       short		msg_qbytes;	/* max number of bytes */
       Struct Proc	*msg_lspid;	/* last process to send */
       Struct Proc	*msg_lrpid;	/* last process to rcv */
       unsigned long	msg_stime;	/* time of last send */
       unsigned long	msg_rtime;	/* time of last rcv */
       unsigned long	msg_ctime;	/* time of last change */
       message_list	*msg_list;	/* linked list of messages */
       short		msg_curbytes	/* current # of bytes */
       short		state;	/* remove queue if cid exits? */
       long		name;		/* name of queue (key) */
       struct msqid_ds *next;	/* link to next queue */
    } msqid_ds;

A msqid_ds is a message queue. The messages in the queue are kept in a linked list referenced by the pointer msg_list. The actual messages are stored in msgbufs which are pointed to by message_list. Msg_qbytes is initialized to MAX_QBYTES where MAX_QBYTES=020000 (decimal 8192). The msqid_ds is stored in a linked list in the 630 so that the number of message queues is limited only by memory.

FILES
$DMD/include/dmd.h
$DMD/include/font.h
$DMD/include/message.h