📄 mainform.cpp
字号:
MemoHex->Cells[0][i]=IntToHex(CurrAddr,8);
s = "";
s1 = "";
for (j=1; j<=16; j++) {
s = s+IntToHex(*LocP,2);
b=*LocP++;
if (b<0x20) b='.';
s1 = s1 + b;
}
MemoHex->Cells[1][i]=s;
MemoHex->Cells[2][i]=s1;
CurrAddr+=16;
}
}
}
//---------------------------------------------------------------------------
void __fastcall TForm1::E_AddrChange(TObject *Sender)
{
B_SetMemory->Enabled = true;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_MaskClick(TObject *Sender)
{
if (!B_Mask->Checked) {
Sum_Ticks = Flag_Tim;
HwCtrl->IRQMasked = TRUE;
HwCtrl->Port[Word(HwCtrl->LPTBasePort+2)] = (Byte)0x00;
C_LPT_IRQ->Checked = FALSE;
}
else {
IRQ = SpinIRQ->Position;
HwCtrl->IRQNumber = (Byte)IRQ;
Flag_Intr = 0;
Sum_Ticks = 0;
Flag_Tim = 0;
Scan_Code = 0;
HwCtrl->IRQMasked = FALSE;
};
ShowButtons();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::C_LPT_IRQClick(TObject *Sender)
{
Word n = Word(HwCtrl->LPTBasePort+2);
if (C_LPT_IRQ->Checked)
HwCtrl->Port[n] = (Byte)0x10;
else
HwCtrl->Port[n] = (Byte)0x00;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::WPin1Click(TObject *Sender)
{
for (Byte nPin = 1; nPin<=17; nPin++)
HwCtrl->Pin[nPin] = (boolean)CPinWrite[nPin]->Checked;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::C_InitClick(TObject *Sender)
{
HwCtrl->LPTInit();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_ClearClick(TObject *Sender)
{
TextMemo->Clear();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_PrintClick(TObject *Sender)
{
if (FlagPrint) return;
NumLine = 0;
NumSymbol = 1;
FlagPrint = TRUE;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_StopClick(TObject *Sender)
{
FlagPrint = FALSE;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_OpenClick(TObject *Sender)
{
HwCtrl->OpenDriver();
// L_Debug.caption:='DebugCode='+IntToStr(HwCtrl.DebugCode);
if (!HwCtrl->ActiveHW) {
MessageBeep(0);
Application->MessageBox("Driver VICHWxx not found",
" Warning! ",IDOK);
}
else {
IRQ = SpinIRQ->Position;
HwCtrl->IRQNumber = (Byte)IRQ;
Timer1->Enabled = TRUE;
};
B_SetMemory->Enabled = TRUE;
ShowButtons();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::B_CloseDriverClick(TObject *Sender)
{
Timer1->Enabled = FALSE;
HwCtrl->Port[Word(HwCtrl->LPTBasePort+2)] = 0x00;
C_LPT_IRQ->Checked = FALSE;
HwCtrl->CloseDriver();
B_Mask->Checked = FALSE;
PointPhys = NULL;
B_SetMemory->Enabled = FALSE;
Flag_Intr = 0;
ShowButtons();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
// ShortString s;
AnsiString s;
if (HwCtrl->ActiveHW) L_Gen->Caption = IntToStr(IRQCounter);
// L_Debug->caption = "DebugCode="+IntToStr(DebugCode);
L_ScanCode->Caption = ": "+IntToHex(Scan_Code,2)+"h";
L_LPT_Data->Caption = ": "+IntToHex(Data_Reg,2)+"h";
L_LPT_STATUS->Caption = ": "+IntToHex(Status_Reg,2)+"h";
L_Timers->Caption = IntToStr(Flag_Tim / 1000);
L_Flag->Caption = IntToStr(Flag_Intr);
if (HwCtrl->ActiveHW && (!HwCtrl->IRQMasked)){
CurrTicker = GetTickCount();
Flag_Tim = Sum_Ticks+CurrTicker-OldTicker;
}
else OldTicker = GetTickCount();
for ( Byte nPin = 1; nPin<=17; nPin++)
CPinRead[nPin]->Checked = HwCtrl->Pin[nPin];
C_ACKWL->Checked = HwCtrl->LPTAckwl;
C_BUSY->Checked = HwCtrl->LPTBusy;
C_ERROR->Checked = HwCtrl->LPTError;
C_PE->Checked = HwCtrl->LPTPaperEnd;
C_SLCT->Checked = HwCtrl->LPTSlct;
if (FlagPrint) {
Timer1->Enabled = FALSE;
for ( Byte i = 1; i<100; i++) {
Application->ProcessMessages();
s = TextMemo->Lines->Strings[NumLine];
s = s+(char)0x0D+(char)0x0A;
if (NumSymbol>(Word)strlen(s.c_str())) {
if (NumLine == TextMemo->Lines->Count) {
Timer1->Enabled = TRUE;
FlagPrint = FALSE; return;
};
NumLine++;
s = TextMemo->Lines->Strings[NumLine]+(char)0x0D+(char)0x0A;
NumSymbol = 1;
};
if (HwCtrl->LPTPrintChar(s[NumSymbol])) NumSymbol++;
};
Timer1->Enabled = TRUE;
};
B_Stop->Enabled = FlagPrint;
B_Print->Enabled = ! FlagPrint;
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpinIRQClick(TObject *Sender, TUDBtnType Button)
{
IRQ = SpinIRQ->Position;
L_IRQ->Caption = IntToStr(IRQ);
HwCtrl->IRQNumber = IRQ;
ShowButtons();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::SpinLPTClick(TObject *Sender, TUDBtnType Button)
{
HwCtrl->LPTNumber = SpinLPT->Position;
ShowButtons();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::BitBtn3Click(TObject *Sender)
{
int i;
TIniFile* MyIniFile = new TIniFile("HW_test");
MyIniFile->WriteInteger("misc","ADDR",PhysAddr);
MyIniFile->WriteInteger("misc","IRQ",IRQ);
for (i = 1; i<=MaxPorts; i++) {
MyIniFile->WriteString("PortW","Port"+IntToStr(i),GWrite->Cells[1][i]);
MyIniFile->WriteString("Values","Val"+IntToStr(i),GWrite->Cells[2][i]);
MyIniFile->WriteString("PortR","Port"+IntToStr(i),GRead->Cells[1][i]);
};
MyIniFile->Free();
Close();
}
//---------------------------------------------------------------------------
void __fastcall TForm1::HwCtrlHwInterrupt(TObject *Sender, long HwCounter,
BYTE LPT_DataReg, BYTE LPT_StatusReg, BYTE Keyb_ScanCode)
{
Data_Reg = LPT_DataReg;
Status_Reg = LPT_StatusReg;
Scan_Code = Keyb_ScanCode;
IRQCounter = HwCounter;
Flag_Intr++;
}
#define FILE_DEVICE_CD_ROM 0x00000002
#define IOCTL_CDROM_BASE FILE_DEVICE_CD_ROM
#define METHOD_BUFFERED 0
#define METHOD_IN_DIRECT 1
#define METHOD_OUT_DIRECT 2
#define METHOD_NEITHER 3
#define FILE_READ_ACCESS ( 0x0001 ) // file & pipe
#define CTL_CODE( DeviceType, Function, Method, Access ) ( \
((DeviceType) << 16) | ((Access) << 14) | ((Function) << 2) | (Method) \
)
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{
Label22->Caption = IntToHex(
CTL_CODE(IOCTL_CDROM_BASE, 0x000F, METHOD_OUT_DIRECT, FILE_READ_ACCESS),8);
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -