//--------------------------------------------------------------------------- #include #pragma hdrstop #include "Unit1.h" #include "BaseAddress.h" #include "Acces32.h" #include //--------------------------------------------------------------------------- #pragma package(smart_init) #pragma resource "*.dfm" TForm1 *Form1; //--------------------------------------------------------------------------- __fastcall TForm1::TForm1(TComponent* Owner) : TForm(Owner) { AddrEdit->Text = "300"; } //--------------------------------------------------------------------------- void __fastcall TForm1::StartBtnClick(TObject *Sender) { AnsiString temp; if (Timer1->Enabled == false) //we are starting { StartBtn->Caption = "Stop"; outChar = 0; temp = "0x" + AddrEdit->Text; Addr = temp.ToInt(); Timer1->Enabled = true; } else { Timer1->Enabled = false; StartBtn->Caption = "Start"; } } //--------------------------------------------------------------------------- void __fastcall TForm1::Timer1Timer(TObject *Sender) { char temp[33]; unsigned short inBytes[4] = {0,0,0,0}; for (int i = 0; i < 3; i++) inBytes[i] = InPortB(Addr + i); OutPortB(Addr, outChar); for (int i = 3; i >= 0; i--) temp[3 - i] = ((outChar >> i) % 2) ? '1' : '0'; temp[4] = '\0'; OutPanel->Caption = temp; for (int j = 3; j >=0; j--) for (int i = 7; i >=0; i--) temp[((3 - j) * 8) + (7 - i)] = ((inBytes[j] >> i) % 2) ? '1' : '0'; temp[32] = '\0'; InPanel->Caption = temp; switch (outChar) { case 0: outChar = 1; break; case 8: outChar = 0; break; default: outChar <<= 1; break; } } //--------------------------------------------------------------------------- void __fastcall TForm1::ExitBtnClick(TObject *Sender) { exit(0); } //---------------------------------------------------------------------------