unit I8255;

interface

uses
  Classes, SysUtils;

type

  { T8255 }

  T8255 = class
    PortA: Byte;
    PortB: Byte;
    PortC: Byte;
    Active: Boolean;
    ControlWord: Byte;
    procedure Write(Address: Word; Data: Byte);
    function Read(Address: Word): Byte;
  end;


implementation

{ T8255 }

procedure T8255.Write(Address: Word; Data: Byte);
begin
  case Address of
    0: PortA := Data;
    1: PortB := Data;
    2: PortC := Data;
    3: begin
      ControlWord := Data;
      Active := (ControlWord and $80) > 0;
    end;
  end;
end;

function T8255.Read(Address: Word): Byte;
begin
  case Address of
    0: Result := PortA;
    1: Result := PortB;
    2: Result := PortC;
    3: begin
      Result := ControlWord;
    end;
  end;
end;

end.

