This is an old version from the tos.hyp. The new is on GitHub!

HomeVDIVDI functions listAES

7.13 VDI structures

7.13.1 COLOR_ENTRY

The union COLOR_ENTRY contains the colour table entry. In future, colour spaces other than RGB may be available:

typedef union
{
   COLOR_RGB   rgb;
   COLOR_CMYK  cmyk;
} COLOR_ENTRY;

7.13.2 COLOR_RGB

typedef struct
{
   uint16   reserved;     /* Set to 0 or the index of the entry */
   uint16   red;          /* Red:   0<->65535 */
   uint16   green;        /* Green: 0<->65535 */
   uint16   blue;         /* Blue:  0<->65535 */
} COLOR_RGB;

If the colour data in a program is present in a sensible format (e.g. 8 bits per channel) already, one can save oneself a transformation with multiplication and division. The Shift and OR functions of the processor perform this faster and more elegantly. eleganter.

Example: The colour value is described by the byte variables r, g, b. The correct conversion to the 16-bit format of the COLOR_RGB structure proceeds as follows:

COLOR_RGB color;

color.reserved = 0;

color.red = r;
color.red |= (color.red << 8);

color.green = g;
color.green |= (color.green << 8);

color.blue = b;
color.blue |= (color.blue << 8);

The structure element reserved should be set to 0 or (for building up a colour table) contain the index of the entry. In each case, however, the upper 8 bits of reserved must be set to 0, as they may be used by the colour routines for some flags.

7.13.3 COLOR_TAB

typedef struct                    /* Colour table                    */
{
   int32 magic;                   /* 'ctab'                          */
   int32 length;
   int32 format;                  /* Format (0)                      */
   int32 reserved;                /* Reserved, set to 0              */
   int32 map_id;                  /* Colour table ID                 */
   int32 color_space;             /* Colour space (at present only
                                     CSPACE_RGB)                     */
   int32 flags;                   /* VDI-internal flags, set to 0    */
   int32 no_colors;               /* Number of colour entries        */
   int32 reserved1;               /* Reserved, must be 0             */
   int32 reserved2;               /* Reserved, must be 0             */
   int32 reserved3;               /* Reserved, must be 0             */
   int32 reserved4;               /* Reserved, must be 0             */
   COLOR_ENTRY colors[];
} COLOR_TAB;

7.13.4 fix31

The data type fix31 corresponds to the type LONG, and is required in connection with vector fonts where one calculates positions and steps in 1/65536. Here the width of a pixel corresponds to the value 65536. The upper 16 bits represent the whole number part and the lower 16 bits the decimal part of the number.

Examples:

Hex Dec  
$00010000 65536 1.0 pixels
$0001c000 114688 1.75 pixels
$fffec000 -81920 -1.25 pixels
$fffe4000 -114688 -1.75 pixels

Important: The decimal part may never be cut off!

If you add advance widths (returned by vqt_advance) and you would like to determine the discrete coordinate for cursor placement, you should use the following code:

int16_t fix31_to_pixel( fix31 a )
{
   int16_t b;

   b = (int16_t) (( a + 32768L ) >> 16 ); /* Round !! */
   return( b );                           /* Return pixel value */
}

See also: GDOS   NVDI   SpeedoGDOS

7.13.5 FONT_HDR

The following structure describes the file-header for a bitmap font in the Digital Research standard format. In this format the font is organised as a wide, monochrome raster image; the width of the raster is the sum of all character widths, the raster height corres- ponds to the height of a single character. From this follows: The left edge of a character does not necessarily have to fall on a byte boundary; only the end of each raster line is filled with NULL- bits so that the next line falls on a WORD boundary again.

typedef struct font_hdr
{
   int16_t     font_id;        /* Font number                        */
   int16_t     point;          /* Size in points                     */
   int8_t      name[32];       /* Name of the font                   */
   uint16_t    first_ade;      /* First character in font            */
   uint16_t    last_ade;       /* Last character in font             */
   uint16_t    top;            /* Distance: Top line    <-> Baseline */
   uint16_t    ascent;         /* Distance: Ascent line <-> Baseline */
   uint16_t    half;           /* Distance: Half line   <-> Baseline */
   uint16_t    descent;        /* Distance: Descent line<-> Baseline */
   uint16_t    bottom;         /* Distance: Bottom line <-> Baseline */
   uint16_t    max_char_width; /* Largest character width            */
   uint16_t    max_cell_width; /* Largest character cell width       */
   uint16_t    left_offset;    /* Left offset for italic (skewed)    */
   uint16_t    right_offset;   /* Right offset for italic (skewed)   */
   uint16_t    thicken;        /* Thickening factor for bold         */
   uint16_t    ul_size;        /* Width of underline                 */
   uint16_t    lighten;        /* Mask for light (0x5555)            */
   uint16_t    skew;           /* Mask for italic (0x5555)           */
   uint16_t    flags;          /* Various flags:
                                  Set for system font
                                   Bit 1: Set if horizontal offset
                                          table is in use
                                   Bit 2: Set if Motorola format
                                   Bit 3: Set if non-proportional    */
   uint8_t     *hor_table;     /* Pointer to horizontal offset table */
   uint16_t    *off_table;     /* Pointer to character offset table  */
   uint16_t    *dat_table;     /* Pointer to font image              */
   uint16_t    form_width;     /* Width of the font image            */
   uint16_t    form_height;    /* Height of the font image           */
   font_hdr    *next_font;     /* Pointer to next font header        */
} FONT_HDR;

Note: As GEM was originally developed on the PC, all data is normally in the Intel format, so that on computers with Motorola processors we have to swap the upper and lower bytes of all words. Warning: To be able to interrogate the Motorola/Intel flag (bit 2 of the component flags), one must actually know already in which format the font is present. The solution to this problem: Start from the assumption that bit 10 of the flag will never be used and test whether bit 2 of the 67th byte of the header is set (because then the font is present in the Motorola format).

The character offset table contains entries of 16-bit values that hold the horizontal pixel offsets for each character within the font raster. So for the index one must use the character's ASCII code minus the ASCII code of the first character in the font (component first_ade). The width of a character results from the difference to the offset value of the next higher character; so that this formula works for the last character as well, the table always has one more entry than the number of characters available.

The horizontal offset table contains positive or negative offset values that are added to the X-poisition before the output of a character; however, this is supported only for a few fonts.

Last but not least one should point out that a normal application should never have to deal with this format; this infomation is of importance only for developers of font editors or GDOS versions.

See also:
GDOS   NVDI   SpeedoGDOS   Vector fonts   vst_alignment   vst_load_fonts   vst_unload_fonts   vqt_fontheader

7.13.6 GCBITMAP

typedef struct _gcbitmap /* Published bitmap description (structure     */
                         /* with version header)                        */
{
   LONG       magic;      /* Structure identifier 'cbtm'                 */
   LONG       length;     /* Structure length                            */
   LONG       format;     /* Structure format (0)                        */
   LONG       reserved;   /* Reserved (0)                                */
   BYTE       *addr;      /* Address of bitmap                           */
   LONG       width;      /* Width of a line in bytes                    */
   LONG       bits;       /* Bit-depth                                   */
   ULONG      px_format;  /* Pixel format                                */
   LONG       xmin;       /* Minimum discrete X-coordinate of bitmap     */
   LONG       ymin;       /* Minimum discrete Y-coordinate of bitmap     */
   LONG       xmax;       /* Maximum discrete X-coordinate of bitmap + 1 */
   LONG       ymax;       /* Maximum discrete Y-coordinate of bitmap + 1 */
   CTAB_REF   ctab;       /* Reference to colour table, or 0L            */
   ITAB_REF   itab;       /* Reference to inverse colour table, or 0L    */
   LONG       reserved0;  /* Reserved, must be 0                         */
   LONG       reserved1;  /* Reserved, must be 0                         */
} GCBITMAP;

See also: NVDI   v_open_bm   vr_transfer_bits

7.13.7 MFDB

The Memory Form Definition Block is a data structure that is used by the VDI to describe destination and source memory blocks for raster operations.

C-declaration:

typedef struct mfdb
{
   VOID *fd_addr;                /* Pointer to the start of the
                                    memory block, e.g. the
                                    screen memory base address  */
   WORD  fd_w;                   /* Width in pixels             */
   WORD  fd_h;                   /* Height in pixels            */
   WORD  fd_wdwidth;             /* Width of a line in words    */
   WORD  fd_stand;               /* 0 = Device-specific format  */
                                 /* 1 = Standard format         */
   WORD  fd_nplanes;             /* Number of planes            */
   WORD  fd_r1, fd_r2, fd_r3;    /* Reserved, must be 0         */
} MFDB;

Note: If the component fd_addr contains a 0, the rest of the MFDB does not have to be filled out. The raster operations vrt_cpyfm and vro_cpyfm then automatically refer to the screen (or, in the case of a printer driver to the printer bitmap). The reserved words fd_r1, fd_r2 and fd_r3 should be set to 0 to cater for future extensions!

See also: Raster formats   Raster functions

7.13.8 POINT16

typedef struct                     /* Point for 16-bit coordinates */
{
   int16 x;
   int16 y;
} POINT16;

7.13.9 POINT32

typedef struct                     /* Point for 32-bit coordinates */
{
   int32 x;
   int32 y;
} POINT32;

7.13.10 pxyarray

pxyarray is used in VDI to depict various graphical objects based on several coordinate pairs (x,y). Examples for the use of a pxyarray are for the depiction of rectangles:

pxyarray[0] X-coordinate of the top left corner point
pxyarray[1] Y-coordinate of the top left corner point
pxyarray[2] X-coordinate of the bottom right corner point
pxyarray[3] Y-coordinate of the bottom right corner point

Or generally, for n point-pairs:

pxyarray[0] X-coordinate of the first point-pair
pxyarray[1] Y-coordinate of the first point-pair
pxyarray[2] X-coordinate of the second point-pair
pxyarray[3] Y-coordinate of the second point-pair
:  
:  
:  
pxyarray[2*n - 2] X-coordinate of the n-th point-pair
pxyarray[2*n - 1] Y-coordinate of the n-th point-pair

See also: About the VDI   VDI bindings

7.13.11 RECT16

typedef struct                 /* Rectangle for 16-bit coordinates */
{
   int16 x1;
   int16 y1;
   int16 x2;
   int16 y2;
} RECT16;

7.13.12 RECT32

typedef struct                 /* Rectangle for 32-bit coordinates */
{
   int32 x1;
   int32 y1;
   int32 x2;
   int32 y2;
} RECT32;

7.13.13 XFNT_INFO

typedef struct
{
   int32_t  size;             /* Length of the structure; initialize
                                 this entry before calling vqt_xfntinfo  */
   int16_t  format;           /* Font format, e.g. 4 for TrueType        */
   int16_t  id;               /* Font ID, e.g. 6059                      */
   int16_t  index;            /* Index                                   */
   int8_t  font_name[50];     /* Font name, e.g. "Century 725 Italic BT" */
   int8_t  family_name[50];   /* Font family name, e.g. "Century725 BT"  */
   int8_t  style_name[50];    /* Font style name, e.g. "Italic"          */
   int8_t  file_name1[200];   /* Name and path of the first font file,   */
                              /* e.g. "C:\FONTS\TT1059M_.TTF"            */
   int8_t  file_name2[200];   /* Name of the 2nd font file               */
   int8_t  file_name3[200];   /* Name of the 3rd font file               */
   int16_t  pt_cnt;           /* Number of available point sizes         */
                              /* (vst_point), e.g. 10                    */
   int16_t  pt_sizes[64];     /* Available point sizes, e.g. { 8, 9, 10, */
                              /*            11, 12, 14, 18, 24, 36, 48 } */
} XFNT_INFO;

Note: So that the information can be entered in the structure, the size of the structure must be entered into the component size.

The following apply for the component format:

1 = Bitmap font
2 = Speedo font
4 = TrueType font
8 = Type-1 font

All character strings are NULL-terminated strings in C format. Structure elements that are not demanded have no defined contents.

See also: GEM   NVDI   vqt_xfntinfo


HomeVDIVDI functions listAES