(* * * * * * * * * * * * * * * * * * */
 *
 * prog3-1.pas
 *
 *      Demonstrates
 *          - Testing for presence of EMS
 *          - Getting EMS status
 *          - Getting Page Frame Address
 *          - Getting EMS Version #
 *
 * * * * * * * * * * * * * * * * * * *)

program prog3_1;

uses    _globals,
        _ems;


var
    version:            Word;
    pfa:                EMS_PageFrame;
    ems:                EMS_Ems;    
    

begin

    (*
     *  First check to see whether EMS is there:
     *)
    if ems.init then begin
        writeln('EMM is not present');
        Halt;
        end
    else begin
        writeln('EMM is present');
        end;

    (*
     *  Now get the EMS status. This should be 0, indicating
     *  no problem.
     *)
    if ems.getStatus then;
    writeln('EMS status is 0x', hex(errno, 2));

    (*
     *  Now get the EMS version number and print it:
     *)
    if ems.getVersion(version) then begin
        ems_demoError('ems.getVersion');
        end;
    writeln('EMS version is ', (version shr 4) and $0F, '.',
                               (version) and $0F);

    (*
     *  Now get the Page Frame Address:
     *)
    if ems.getPFA(pfa) then begin
        ems_demoError('ems.getPFA');
        end;
    writeln('Page Frame address is ', hex(Seg(pfa^), 4), ':',
                                      hex(Ofs(pfa^), 4));

end.
