%option '-low'

type

half = 0..65535;
byte = 0..255 ;
str255 = VARYING [ 255 ] OF CHAR ;
colourmap = packed array [0..255] of half ;

const

black=0; red=1; green=2; blue=4;
yellow=red+green; magenta=red+blue; cyan=blue+green;
white=red+green+blue;

mouseleft=1; mousemiddle=2; mouseright=4;

function mousebuttons %alias 'FRED_GRAPHICS_MOUSEB' : INTEGER ; EXTERNAL ;

function relmousex %alias 'FRED_GRAPHICS_MOUSEX' : INTEGER ; EXTERNAL ;
function relmousey %alias 'FRED_GRAPHICS_MOUSEY' : INTEGER ; EXTERNAL ;
{ Returns the relative change in the mouse position since last call. }

procedure vline %alias 'FRED_GRAPHICS_VLINE' (x, y0, y1:integer) ; EXTERNAL ;
{ Draws vertical line from (x, y0) to (x, y1). }

procedure hline %alias 'FRED_GRAPHICS_HLINE' (x0, x1, y:integer) ; EXTERNAL ;
{ Draws horizontal line from (x0, y) to (x1, y). }

procedure offset %alias 'FRED_GRAPHICS_OFFSET' (x, y:integer) ; EXTERNAL ;
{ Sets display area so that screen origin is at (x&(\15), y) within framestore. }

procedure colour %alias 'FRED_GRAPHICS_COLOUR' (colour:integer); EXTERNAL ;
{ Sets colour for drawing to 'colour'. }

procedure enable %alias 'FRED_GRAPHICS_ENABLE' (planes:integer); EXTERNAL ;
{ Allows writing to planes that have bits in 'planes' 1, disables other planes. }

procedure updatecolourmap %alias 'FRED_GRAPHICS_UPCMAP'(var z:colourmap);
  EXTERNAL ;
{ Writes 256 new half word entries into the colour map from an address }
{ starting with new map                                                }


procedure clear %alias 'FRED_GRAPHICS_CLEAR' ; EXTERNAL ;
{ Sets whole of framestore to colour 0.                           }
{ The currently selected colour and enabled palnes are unaltered. }

procedure halfclear %alias 'FRED_GRAPHICS_HCLEAR' (h:integer) ; EXTERNAL ;
{ Clears half the frame store for fast animation                  }
{ If h = 0 the box (0, 0), (687, 511) is cleared                  }
{ If h = 1 the box (0, 512), (687, 1023) is cleared               }
{ The currently selected colour and enabled planes are unaltered. }

procedure line %alias 'FRED_GRAPHICS_LINE' (x0, y0, x1, y1:integer) ; EXTERNAL ;
{ Draws arbitrary line from (x0, y0) to (x1, y1). }

procedure fill %alias 'FRED_GRAPHICS_FILL' (x0, y0, x1, y1:integer) ; EXTERNAL ;
{ Draws filled orthogonal box with diagonal corners at (x0, y0, x1, y1). }

procedure triangle %alias 'FRED_GRAPHICS_TRIANGLE'
  (x0, y0, x1, y1, x2, y2:integer) ; EXTERNAL ;
{ Draws filled triangle with vertices at (x0, y0), (x1, y1), (x2, y2). }

procedure trapeze %alias 'FRED_GRAPHICS_TRAPEZE'
  (x00, x01, y0, x10, x11, y1:integer) ; EXTERNAL ;
{ Draws a filled trapezium with vertices     }
{ (x00, y0), (x01, y0), (x10, y1), (x11, y1). }

procedure disc %alias 'FRED_GRAPHICS_DISC' (x, y, r:integer) ; EXTERNAL ;
{ Draws a filled circle of radius r and centre (x, y). }

procedure ring %alias 'FRED_GRAPHICS_RING' (x, y, r:integer) ; EXTERNAL ;
{ Draws the outline of a circle of radius r and centre (x, y). }

procedure plot %alias 'FRED_GRAPHICS_PLOT' (x, y:integer) ; EXTERNAL ;
{ Draws a single pixel at (x, y). }

procedure textat %alias 'FRED_GRAPHICS_TEXTAT' (x,y:integer) ; EXTERNAL ;
{ Sets the position for drawing text to (x, y). }

procedure readfont %alias 'FRED_GRAPHICS_READFONT' 
   (ffile : str255 ; VAR font:integer) ; EXTERNAL ;
{ Reads pre-processed font from 'ffile' and returns }
{ heap address as integer in 'font'.                }

procedure showsymbol %alias 'FRED_GRAPHICS_SHOWSYM' (k:integer) ; EXTERNAL ;
{ Draws character 'k' in currently selected font     }
{ at currently selected screen position.             }
{ As a result the text screen position is updated so }
{ that subsequent showsymbol and showstring calls    }
{ draw beyond the character.                         }

procedure showstring %alias 'FRED_GRAPHICS_SHOWSTR' (s : str255) ; EXTERNAL ;
{ Draws characters in 's' in currently selected font }
{ starting at currently selected screen position.    }
{ As a result the text screen position is updated so }
{ that subsequent show symbol and showstring calls   }
{ draw beyond the string.                            }

procedure font %alias 'FRED_GRAPHICS_FONT' (f:integer) ; EXTERNAL ;
{ Selects font used by subsequent calls to showsymbol and show string. }
{ 'f' is the integer address returned by 'readfont', above.            }
{ If 'f' is 0 the default Visual 200 font is selected.                 }

function fontheight %alias 'FRED_GRAPHICS_FONTHT' : INTEGER ; EXTERNAL ;
function fontdepth %alias 'FRED_GRAPHICS_FONTDP' : INTEGER ; EXTERNAL ;
function maxfontwidth %alias 'FRED_GRAPHICS_FONTWX' : INTEGER ; EXTERNAL ;
function minfontwidth %alias 'FRED_GRAPHICS_FONTWN' : INTEGER ; EXTERNAL ;
function stringwidth %alias 'FRED_GRAPHICS_STRNGW' (s:str255) : INTEGER ;
  EXTERNAL ;
function charheight %alias 'FRED_GRAPHICS_CHARHT' (c:integer) : INTEGER ;
  EXTERNAL ;
function chardepth %alias 'FRED_GRAPHICS_CHARDP' (c:integer) : INTEGER ;
  EXTERNAL ;
function charwidth %alias 'FRED_GRAPHICS_CHARWD' (c:integer) : INTEGER ;
  EXTERNAL ;
function textxpos %alias 'FRED_GRAPHICS_XPOS' : INTEGER ; EXTERNAL ;
function textypos %alias 'FRED_GRAPHICS_YPOS' : INTEGER ; EXTERNAL ;
procedure poly %alias 'FRED_GRAPHICS_POLY' (x, y:integer) ; EXTERNAL ;
{ Defines a single vertex of (x, y) for subsequent call to closepoly.  }

procedure closepoly %alias 'FRED_GRAPHICS_CLOSEPOLY' ; EXTERNAL ;
{ Draws a filled polygon with vertices defined by prior calls of poly.  }
{ As a result all previous vertex definitions are lost and furthe calls }
{ to poly specify vertices for the next polygon to be drawn.            }

