unit DIOu; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, Buttons, Registry, ExtCtrls ; type TMainFrm = class(TForm) Label5: TLabel; GroupBox1: TGroupBox; ExitButton: TBitBtn; Memo1: TMemo; CardName: TLabel; BeginSample: TButton; RunTimer: TTimer; PortAOut: TPanel; PortAIn: TPanel; PortBIn: TPanel; Label2: TLabel; Label3: TLabel; Label4: TLabel; IsaLabel: TLabel; IsaEdit: TEdit; procedure ExitButtonClick(Sender: TObject); procedure FormCreate(Sender: TObject); procedure RunTimerTimer(Sender: TObject); procedure BeginSampleClick(Sender: TObject); procedure FormActivate(Sender: TObject); private { Private declarations } DriverRegistry:TRegistry; public { Public declarations } end; var MainFrm: TMainFrm; Address : WORD; RunFlag:Boolean; implementation uses ACCES32; {$R *.DFM} procedure TMainFrm.FormCreate(Sender: TObject); var num, i: Integer; found: Boolean; begin if (InPortB($61) = $AA55) then begin Application.MessageBox('ACCESNT.SYS not detected. Please copy ACCESNT.SYS into [NT]/system32/drivers and re-run this sample.'#13#10'Please note: This sample uses ACCESNT.SYS which is not compatible with Vista or Windows 7 based operating systems.', 'Warning', IDOK); end; CardName.Caption:='PC/104 or ISA Digital 8255 Sample'; Memo1.Lines.Clear; Memo1.Lines.Append('If you have a DIO card installed, you may continue running the sample ' + 'by entering the card''s Base Address in the edit box above and continuing as normal.'); RunFlag:=False; DriverRegistry.Free; end; procedure TMainFrm.ExitButtonClick(Sender: TObject); begin Close; end; procedure TMainFrm.RunTimerTimer(Sender: TObject); const value: array[0..2] of Integer = (0, 0, 0); i: Integer = 0; var j: integer; msg: string; begin value[0] := 1 shl i; OutPortB(Address, value[0]); value[1] := InPortB(Address); value[2] := InPortB(Address + 1); inc(i); i := i mod 8; msg := '00000000'; for j := 0 to 7 do if (value[0] and (1 shl j)) <> 0 then msg[8-j] := '1' else msg[8-j] := '0' ; PortAOut.Caption := msg; for j := 0 to 7 do if (value[1] and (1 shl j)) <> 0 then msg[8-j] := '1' else msg[8-j] := '0' ; PortAIn.Caption := msg; for j := 0 to 7 do if (value[2] and (1 shl j)) <> 0 then msg[8-j] := '1' else msg[8-j] := '0' ; PortBIn.Caption := msg; end; procedure TMainFrm.BeginSampleClick(Sender: TObject); begin if not RunFlag then Address := StrToInt('$' + IsaEdit.Text) ; if RunTimer.Enabled then Begin RunTimer.Enabled := False; BeginSample.Caption := 'Perform I/O'; end else begin OutPortB(Address + 3, $82); RunTimer.Enabled := True; BeginSample.Caption := 'Stop I/O'; end; end; procedure TMainFrm.FormActivate(Sender: TObject); begin if not RunFlag then FocusControl(IsaEdit); end; END.