unit COSThrdu; interface uses SysUtils, Classes, Windows; type COSThread = class(TThread) private Data: array [0..5] of Byte; protected procedure Execute; override; public procedure UpdateIRQCaption; procedure UpdateStatusCaption; end; implementation uses COSFormu, ACCES32, WIN32COS; { COSThread } procedure COSThread.UpdateIRQCaption; begin Form1.CountLabel.Caption := 'IRQ Count: ' + IntToStr(Form1.IRQ_Count); Form1.DataLabel.Caption := IntToHex(Data[0], 2) + IntToHex(Data[1], 2) + IntToHex(Data[2], 2) + ' ' + IntToHex(Data[3], 2) + IntToHex(Data[4], 2) + IntToHex(Data[5], 2); end; procedure COSThread.UpdateStatusCaption; begin Form1.StatusLabel.Caption := 'Waiting...Generate IRQs now'; end; procedure COSThread.Execute; var IRQ_Occurred : Boolean; Buf: Pointer; Base: DWORD; begin Buf := AllocMem(6); Base := StrToInt('$' + Form1.BaseEdit.Text); Synchronize(UpdateStatusCaption); // set all input OutPortB(Base + $3, $9B); OutPortB(Base + $7, $9B); // clear cos latch OutPortB(Base + $f, 0); // enable cos interrupts OutPortB(Base + $b, 0); data[0] := 0; data[1] := 0; data[2] := 0; data[3] := 0; data[4] := 0; data[5] := 0; repeat IRQ_Occurred := GetCOSData(Buf); if (IRQ_Occurred = true) then begin Inc(Form1.IRQ_Count); MoveMemory(@data,Buf,6); Synchronize(UpdateIRQCaption); end; until Terminated; FreeMem(Buf); end; end.