(* * * * * * * * * * * * * * * * * * *
 *
 * prog5-2.pas
 *
 * Get XMS Version Number
 *
 * * * * * * * * * * * * * * * * * * *)


program prog5_2;


uses
    _Globals,
    _Xms;

type
    SegOff_type = record
        Offset:     Word;
        Segment:    Word;
        end;

var
    xms:            XMS_Xms;
    xmsHandlerAddr: SegOff_type absolute xmsHandler;
    xmsVersion:     Word;
    xmmVersion:     Word;
    hmaFlag:        Word;

begin

    (*
     *  Print out the address of the XMS handler before it's
     *  initialized.
     *)
    writeln('Before initialization: XMS handler= 0x',
                hex(xmsHandlerAddr.Segment, 4),':0x',
                hex(xmsHandlerAddr.Offset, 4));

    (*
     *  Attempt to initialize XMS. If there is an error, report it.
     *)
    if not xms.init then begin
        writeln('XMS is present');
        end
    else begin
        writeln('XMS is not present');
        end;

    (*
     *  Now print out the address of the XMS handler after it's been
     *  initialized.
     *)
    writeln('After initialization: XMS handler= 0x',
                hex(xmsHandlerAddr.Segment, 4),':0x',
                hex(xmsHandlerAddr.Offset, 4));

    if xms.getVersion(xmsVersion, xmmVersion, hmaFlag) then begin
        xms_demoError('xms.getVersion')
        end;

    write('XMS Version= ', ((xmsVersion div 4096) mod 16):1,
                           ((xmsVersion div 256) mod 16):1, '.',
                           ((xmsVersion div 16) mod 16):1,
                           ((xmsVersion) mod 16):1);
    write(', XMM Version= ', ((xmmVersion div 4096) mod 16):1,
                             ((xmmVersion div 256) mod 16):1, '.',
                             ((xmmVersion div 16) mod 16):1,
                             ((xmmVersion) mod 16):1);
    write(', HMA is ');
    if hmaFlag <> 0 then begin
        writeln('present')
        end
    else begin
        writeln('not present')
        end;
        
        
end.


