#ifndef __VDI_H
#define __VDI_H

/* VDI structures */
/* -------------- */
typedef struct _Fontextra {
	struct _distance1 {	/* Calculated from the */
		short base;	/*  values given with */
		short half;	/*  the font for easier */
		short ascent;	/*  text positioning */
		short bottom;
		short descent;
		short top;
	} distance;
	struct _unpacked {
		char *data;	/* 'Unpacked' font data */
		short format;	/* Byte/word per char */
	} unpacked;
	short *width_table;	/* Precalculated widths */
	struct _Fontheader *next_size;
	struct _Fontheader *first_size;
} Fontextra;


typedef struct _Fontheader {
	short id;		/* Face identifier */
	short size;		/* Font size in points */
	char  name[32];		/* Face name */
	struct _code {
		short low;	/* Lowest ASCII value in face */
		short high;	/* Highest ASCII value in face */
	} code;
	struct _distance {
		short top;	/* Top line distance */
		short ascent;	/* Ascent line distance */
		short half;	/* Half line distance */
		short descent;	/* Descent line distance */
		short bottom;	/* Bottom line distance */
	} distance;
	struct _widest {
		short character;/* Width of widest char in font */
		short cell;	/* Width of widest char cell in font */
	} widest;
	struct _offset {
		short left;	/* Left offset */
		short right;	/* Right offset */
	} offset;
	short thickening; 	/* No. of pixels to widen chars */
	short underline;	/* Width in pixels of underline */
	short lightening; 	/* Mask used to drop pixels out */
	short skewing;		/* Mask used to determine skewing */
	short flags;		/* Font flags */
	struct _table {
		short *horizontal; 	/* Pointer to horizontal offset table */
		short *character;	/* Pointer to char offset table */
	} table;
	char  *data;		/* Pointer to font data */
	short width;		/* Font width */
	short height;		/* Font height */
	struct _Fontheader *next;	/* Pointer to next font */
	Fontextra extra;
} Fontheader;

typedef struct _RGB {
   short red;
   short green;
   short blue;
} RGB;

typedef struct _Colour {
   RGB vdi;
   RGB hw;
   long real;
} Colour;

typedef struct _vwk {
   struct _text {
	short font;
	short colour;
	short rotation;
	struct _alignment {
		short horizontal;
		short vertical;
	} alignment;
	struct _character {
		short width;
		short height;
	} character;
	struct _cell {
		short width;
		short height;
	} cell;
	short effects;
	Fontheader *current_font;	/* Not in standard VDI */
   } text;
   struct _line {
	short type;
	short colour;
	struct _ends {
		short beginning;
		short end;
	} ends;
	short width;
	short user_mask;
   } line;
   struct _marker {
	short type;
	short colour;
	struct _size {
		short width;
		short height;
	} size;
   } marker;
   struct _fill {
	short interior;
	short colour;
	short style;
	short perimeter;
	struct _user {
		struct _pattern {
			short *in_use;
			short *extra;
		} pattern;
		short multiplane;
	} user;
   } fill;
   struct _clip {
	short on;
	struct _rectangle {
		short x1;
		short y1;
		short x2;
		short y2;
	} rectangle;
   } clip;
   short mode;
   struct _wk *real_address;
   short standard_handle;
   Colour *palette;
} Virtual;

typedef struct _function {
   	short retvals[2];
   	void *code;
} Function;


typedef struct _MFDB {
   short *address;
   short width;
   short height;
   short wdwidth;
   short standard;
   short bitplanes;
   short reserved[3];
} MFDB;

typedef struct _wk {
   struct _screen {
	short type;
	short colour;
	short bkg_colours;
	short look_up_table;	/* non-direct colour */
	struct _palette {
		short possibilities;
		short size;
		Colour *colours;
		char *transformation;
	} palette;
	MFDB mfdb;
	short wrap;
	void *linea;
	struct _shadow {
		void *buffer;
		void *address;
		short wrap;
	} shadow;
	struct _pixel {
		short width;
		short height;
	} pixel;
	struct _coordinates {
		short course;	/* What's this? */
		short min_x;
		short min_y;
		short max_x;
		short max_y;
	} coordinates;
   } screen;
   struct _writing {
	short fonts;
	Fontheader *first_font;	/* Font chain */
	short effects;
	struct _rotation {
		short possible;
		short type;
	} rotation;
	short justification;
	struct _size1 {			/* From current font? */
		short possibilities;
		struct _height {
			short min;
			short max;
		} height;
		struct _width {
			short min;
			short max;
		} width;
	} size;
   } writing;
   struct _drawing {
	struct _primitives {
		short supported;
		long attributes;
	} primitives;
	short rubber_banding;
	short flood_fill;
	short writing_modes;
	struct _fill1 {
		short possible;
		short patterns;
		short hatches;
	} fill;
	struct _marker1 {
		short types;
		struct _size2 {
			short possibilities;
			struct _height1 {
				short min;
				short max;
			} height;
			struct _width1 {
				short min;
				short max;
			} width;
		} size;
	} marker;
	struct _line1 {
		short types;
		struct _wide {
			struct _width2 {
				short possibilities;
				short max;
				short min;
			} width;
			short types_possible;
			short writing_modes;
		} wide;
	} line;
	struct _cellarray {
		short available;
	} cellarray;
   } drawing;
   struct _raster {
	short scaling;
	short performance;	/* 16x16ops-per-second; */
   } raster;
   struct _various {
	short input_type;
	short inking;		/* 'nedsvartning' */
	short max_ptsin;
	short max_intin;
	short buttons;
	short cursor_movement;
	short number_entry;
	short selection;
	short typing;
	short workstation_type;
   } various;
   struct _console {
/*	Cursor status, position, etc, etc (p278) */
	short dummy;	/* Lattice wants something here */
   } console;
   struct _r {
   	void *set_palette;
   	void *get_colour;
   	void *set_pixel;
   	void *get_pixel;
   	void *line;
	void *expand;
	void *fill;
	void *blit;
	void *text;
   } r;
   struct _fallback {
   	void *line;
	void *expand;
	void *fill;
	void *blit;
	void *text;
   } fallback;
   Function dummy;		/* Table really extends to -1 */
   Function function[256];
   short opcode5_count;
   void *opcode5[24];
   short opcode11_count;
   void *opcode11[11];
} Workstation;

typedef struct _List {
   struct _List *next;
   short type;
   void *value;
} List;


/* A couple of test things */
typedef char chop;
typedef chop hello[3];

typedef struct _some {
   char ch1;
   short t;
   char ch2;
} some;

typedef struct _my {
   char r;
   hello array_of_hello[7];
   some array_of_some[2];
} my;

#endif
