(* * * * * * * * * * * * * * * * * * *
 *
 * _mcb.pas
 *
 * Unit file for the MCB functions
 *
 * * * * * * * * * * * * * * * * * * *)

unit    _mcb;

INTERFACE

uses    _globals;


(* * * * * * * * * * * * * * * * * * *
 *
 * Memory Control Block Structure
 *
 * * * * * * * * * * * * * * * * * * *)


type
    MCB_Mcb = record
        chain_status:       Char;
        owner_psp:          Word;
        size_paragraphs:    Word;
        dummy:              array[1..3] of Byte;
        file_name:          array[0..7] of Char;
        end;

    MCB_McbPtr = ^MCB_Mcb;



function    getMcbPointer
                :   MCB_McbPtr;
function    getVecPointer(
                vecNum: Byte)
                :   DWord;


IMPLEMENTATION

uses    dos;

function    getMcbPointer: MCB_McbPtr;

var
    regs:               Registers;
    firstMCBSeg:        Word;

begin

    (*
     *  Use int21 subcode $52 to look up the vector
     *)
    regs.AH:= $52;
    MsDos(regs);
    firstMCBSeg:= WordPtr(Ptr(regs.ES, regs.BX-2))^;
    getMcbPointer:= Ptr(firstMCBSeg, 0);

end;

function    getVecPointer(vecNum: Byte): DWord;

var
    regs:               Registers;

begin

    (*
     *  Use int21 subcode $35 to look up the vector
     *)
    regs.AL:= vecNum;
    regs.AH:= $35;
    MsDos(regs);
    getVecPointer:= DWord(Ptr(regs.ES, regs.BX));

end;


end.

