DEFINITION MODULE LowEGA;

FROM SYSTEM IMPORT ADDRESS;
FROM PointLib IMPORT Point;

EXPORT QUALIFIED
  EGAOutWord, InitEGA, SetUpAlpha, SetUpHiRes, CursorOffset,
  BumpCursor, Write, WriteString, SetActivePage, SetPageOffset,
  TurnOnBlinking, TurnOffBlinking, HorScrollLeft, MonitorType,
  HorScrollRight, HorizScroll, ResetHorizScroll, VerticalScrollUp,
  VerticalScrollDown, ResetVerticalScroll, SetCursorPoint, SetCursor,
  WaitForVerticalRetrace, SplitScreenAt, RollSplitScreenUp,
  RollSplitScreenDown, ResetSplitScreen, SetPalette, SetOverscan,
  MakeSecondGraphicsPage, DrawPoint, EGABiosParams, BiosCRTParams,
  DisplayBuffer, RowsOnScreen, BytesPerChar, EGABiosRec, BiosCRTVars,
  ActivePageOffset, MaxPage, FeatureBits, SwitchSettings,
  MemoryInstalled, ActivePage, FillGraphicsPage, SwitchToColorBios,
  SwitchToMonoBios, ColorBiosMode, LoadBiosFont, FontType,
  GetAlternatePrintScreen, PrintScreen, SetActiveFonts, SetModeBios,
  LoadUserFont, ResetVideoPage, TotalVerticalScanLines, MaxVideoPages,
  WriteBiosString, WriteBios, SetBiosCursorPoint, GetCursorPoint,
  EGASavePtr, SetBiosPalette, MemoryInstalled64K, MemoryInstalled128K,
  MemoryInstalled192K, MemoryInstalled256K, WaitForVerticalDisplay;

  CONST     MaxVideoPages = 7;
            MemoryInstalled64K = 0;
            MemoryInstalled128K = 1;
            MemoryInstalled192K = 2;
            MemoryInstalled256K = 3;

  TYPE
    MonitorType = (Monochrome, Color);
    FontType = (MonochromeFont, DoubleDotFont);
    (* Enhanced Graphics Adapter Bios Variables *)
    EGABiosRec = RECORD
            Rows           : CHAR;
            Points         : CARDINAL;
            InfoAndInfo3   : BITSET; (* Info=low 8 bits Info 3=high *)
            SavePtr        : ADDRESS;  END;
    BiosCRTVars = RECORD
            CRTMode        : CHAR;
            CRTCols, CRTLen: CARDINAL;
            CRTStart       : CARDINAL;
            CursorPosition : ARRAY [0..7] OF CARDINAL;
            CursorMode     : CARDINAL;
            ActivePageNum  : CHAR;
            ADDR6845       : CARDINAL;
            CRTCGA3X8      : CHAR;
            CRTCGA3X9      : CHAR;  END;

  VAR
    ActivePageOffset, MaxPage, FeatureBits,
    SwitchSettings, MemoryInstalled, ActivePage,
    TotalVerticalScanLines : CARDINAL;
    (* BIOS RAM Parameters *)
    EGABiosParams [0:484H]    : EGABiosRec;
    BiosCRTParams [0:449H]    : BiosCRTVars;
    DisplayBuffer [0A000H:0H] : ARRAY [0..65500] OF CHAR;
    RowsOnScreen  [0:484H]    : CHAR;
    BytesPerChar  [0:485H]    : CARDINAL;  (* Font character size *)
    EGASavePtr    [0:4A8H]    : POINTER TO ADDRESS;

  PROCEDURE EGAOutWord(EGAPort, DeviceRegister, Value : CARDINAL);
  PROCEDURE InitEGA(EGAMonitor: MonitorType) : BOOLEAN;
  PROCEDURE SetUpAlpha;               
  PROCEDURE SetUpHiRes;
  PROCEDURE SwitchToColorBios;
  PROCEDURE SwitchToMonoBios;
  PROCEDURE ColorBiosMode() : BOOLEAN;
  PROCEDURE CursorOffset(Page : CARDINAL) : CARDINAL;
  PROCEDURE BumpCursor(Page : CARDINAL);
  PROCEDURE Write(Page : CARDINAL; ch : CHAR; color : INTEGER);
  PROCEDURE WriteString(Page : CARDINAL; s : ARRAY OF CHAR;
                        c : CARDINAL);
  PROCEDURE SetActivePage(page : CARDINAL);
  PROCEDURE SetPageOffset(where : CARDINAL);
  PROCEDURE TurnOnBlinking;
  PROCEDURE TurnOffBlinking;
  PROCEDURE HorScrollLeft;
  PROCEDURE HorScrollRight;
  PROCEDURE HorizScroll(Pixels : INTEGER);
  PROCEDURE ResetHorizScroll;
  PROCEDURE VerticalScrollUp;
  PROCEDURE VerticalScrollDown;
  PROCEDURE ResetVerticalScroll;
  PROCEDURE SetCursorPoint(Page : CARDINAL; p : Point);
  PROCEDURE SetCursor(Page : CARDINAL);
  PROCEDURE GetCursorPoint(VAR p : Point; Page : CARDINAL);
  PROCEDURE WaitForVerticalRetrace;
  PROCEDURE WaitForVerticalDisplay;
  PROCEDURE SplitScreenAt(ScanLine : CARDINAL);
  PROCEDURE RollSplitScreenUp(SplitSizeLines : CARDINAL);
  PROCEDURE RollSplitScreenDown;
  PROCEDURE ResetSplitScreen;
  PROCEDURE SetPalette(Palette, Color : CARDINAL);
  PROCEDURE SetBiosPalette(Palette, Color : CARDINAL);
  PROCEDURE SetOverscan(Color : CARDINAL);
  PROCEDURE MakeSecondGraphicsPage;
  PROCEDURE FillGraphicsPage(Color : CARDINAL);
  PROCEDURE DrawPoint(p : Point; Color : CARDINAL);
  PROCEDURE LoadBiosFont(Font : FontType; ResetFlag : BOOLEAN;
                         Block : CARDINAL);
  PROCEDURE GetAlternatePrintScreen;
  PROCEDURE PrintScreen;
  PROCEDURE SetActiveFonts(FontA, FontB : CARDINAL);
  PROCEDURE SetModeBios(Mode : CARDINAL);
  PROCEDURE LoadUserFont(VAR Font : ARRAY OF CHAR;
                             ResetFlag : BOOLEAN;
                             Block, Count, Points : CARDINAL);
  PROCEDURE ResetVideoPage;
  PROCEDURE WriteBios(Character : CHAR; Color : CARDINAL);
  PROCEDURE WriteBiosString(msg : ARRAY OF CHAR; Color : CARDINAL);
  PROCEDURE SetBiosCursorPoint(Page : CARDINAL; p : Point);
END LowEGA.
