(* * * * * * * * * * * * * * * * * * *
 *
 * prog4-2.pas
 *
 *      Demonstrates
 *          - Get hardware configuration
 *          - Get number of raw pages
 *
 * * * * * * * * * * * * * * * * * * *)

program     prog4_2;

uses        _globals,
            _ems;

var
    ems:                EMS_Ems;

    hwConfig:           EMS_HardwareConfigInfo;

    freeRawPages:       Word;
    totalRawPages:      Word;

    totalHandles:       Word;


begin

    (*
     *  First check for presence of EMS
     *)
    if ems.init then begin
        writeln('EMS is not present');
        Halt;
        end;

    (*
     *  Start by getting the hardware configuration
     *)
    if ems.getHWConfig40(hwConfig) then begin
        ems_demoError('EMS_Ems.getHWConfig40');
        end;

    (*
     *  Now get the raw page counts
     *)
    if ems.getNumRawPages40(totalRawPages, freeRawPages) then begin
        ems_demoError('EMS_Ems.getNumRawPages40');
        end;

    (*
     *  Get the total handles that can be used.
     *)
    if ems.getTotalHandles40(totalHandles) then begin
        ems_demoError('EMS_Ems.getTotalHandles40');
        end;

    (*
     *  Print the info out:
     *)
    writeln('Total # of raw pages:       ', totalRawPages);
    writeln('# of free raw pages:        ', freeRawPages);
    writeln;
    writeln('Total # of handles:         ', totalHandles);
    writeln;
    writeln('Raw page size (bytes):      ', 16*hwConfig.rawPgSize);
    writeln('Alternate reg sets:         ', hwConfig.altRegSets);
    writeln('Context Save area size:     ', hwConfig.saveAreaSz);
    writeln('# Regs assignable to DMA:   ', hwConfig.regsDma);
    writeln;
    write('DMA ');
    if hwConfig.dmaType = 0 then begin
        write('can');
        end
    else begin
        write('cannot');
        end;
    writeln(' be used with alternate registers');
end.

