{$A+,B-,D+,E+,F+,G+,I-,L+,N-,O+,P-,Q-,R-,S+,T-,V+,X+}
{$M 65520,0,655360}
Unit BGIDriv;

INTERFACE

Uses GRAPH, BGIFONT, WRMODE, GEMFONTU;

CONST
  GPtr : POINTER = NIL;
  BPtr : POINTER = NIL;
  RPtr : POINTER = NIL;

VAR
  Lead1  : WORD;
  Lead2  : WORD;
  Lead3  : WORD;
  ECode1 : WORD;
  ECode2 : WORD;
  ECode3 : WORD;

PROCEDURE BGI256Proc;
PROCEDURE InitBGI256;

IMPLEMENTATION

PROCEDURE BGI256Proc; EXTERNAL;
{$L BGI256}

PROCEDURE InitBGI256;
VAR
  Error,GD,GM : INTEGER;
BEGIN
  GD    := InstallUserDriver('BGI256',NIL);
  GM    := Mode480; {start in 640x480x256 mode}
  Error := REGISTERBGIDRIVER(@BGI256Proc);
  IF BPtr = NIL THEN BPtr := RegisterGEMfont(@Bit5x8FontProc,Lead1,ECode1);
  IF GPtr = NIL THEN GPtr := RegisterGEMfont(@SystemFontProc,Lead2,ECode2);
  IF RPtr = NIL THEN RPtr := RegisterGEMfont(@Bit8x14FontProc,Lead3,ECode3);
  INITGRAPH(GD,GM,'');
  Error := GRAPHRESULT;
  IF Error <> 0 THEN BEGIN
    WRITELN('Error: ',Error);
    WRITELN('Could not initialize the VESA/SVGA driver!');
    HALT;
  END;
END;

END.
