📄 debug.cpp
字号:
for (i=0;i<debugLogCount;i++)
{
if (debugLogClass[i]==LOG_VALUE)
{
if (!(debugLogType[i]&type)) continue;
if ((addr>(debugLogLow[i]-size))&&
(addr<=debugLogHigh[i]))
{
char str[64];
if (type==DATABREAK_READ)
{
if (size==1)
sprintf(str,"Read byte %2.2X from %X at PC=%X",getmem(addr)&0xff,addr,pc&0xffffff);
else if (size==2)
sprintf(str,"Read word %4.4X from %X at PC=%X",getmem_word(addr)&0xffff,addr,pc&0xffffff);
else
sprintf(str,"Read long %8.8X from %X at PC=%X",getmem_dword(addr),addr,pc&0xffffff);
}
else
{
if (size==1)
sprintf(str,"Write byte %2.2X to %X at PC=%X",v&0xff,addr,pc&0xffffff);
else if (size==2)
sprintf(str,"Write word %4.4X to %X at PC=%X",v&0xffff,addr,pc&0xffffff);
else
sprintf(str,"Write long %8.8X to %X at PC=%X",v,addr,pc&0xffffff);
}
LogDlg->List->Items->Add(str);
}
}
else
{
if (type==DATABREAK_READ) continue;
if (!((addr>(debugLogLow[i]-size))&&
(addr<=debugLogLow[i])))
continue;
int j,b,nv;
char str[64];
nv=v&0xff;
if (size==2)
{
if ((debugLogLow[i]-addr)==0)
nv=(v>>8)&0xff;
else
nv=v&0xff;
}
else if (size==4)
{
if ((debugLogLow[i]-addr)==0)
nv=(v>>24)&0xff;
else if ((debugLogLow[i]-addr)==1)
nv=(v>>16)&0xff;
else if ((debugLogLow[i]-addr)==2)
nv=(v>>8)&0xff;
else if ((debugLogLow[i]-addr)==3)
nv=v&0xff;
}
for (j=0,b=1;j<8;j++,b<<=1)
{
if (!debugLogCheck[i]&b) continue;
if (debugLogAny[i]&b)
{
if ((debugLogLast[i]&b)!=(nv&b))
{
if ((z80)&&((debugLogLow[i]>>20)==6))
{
if (nv&b)
sprintf(str,"Set bit %d of I/O port %X at PC=%X",j,debugLogLow[i]&0xff,pc&0xffffff);
else
sprintf(str,"Clear bit %d of I/O port %X at PC=%X",j,debugLogLow[i]&0xff,pc&0xffffff);
}
else
{
if (nv&b)
sprintf(str,"Set bit %d of %X at PC=%X",j,debugLogLow[i],pc&0xffffff);
else
sprintf(str,"Clear bit %d of %X at PC=%X",j,debugLogLow[i],pc&0xffffff);
}
LogDlg->List->Items->Add(str);
}
}
else
{
if ((debugLogLast[i]&b)==(nv&b)) continue;
if ((debugLogState[i]&b)==(nv&b))
{
if ((z80)&&((debugLogLow[i]>>20)==6))
{
if (nv&b)
sprintf(str,"Set bit %d of I/O port %X at PC=%X",j,debugLogLow[i]&0xff,pc&0xffffff);
else
sprintf(str,"Clear bit %d of I/O port %X at PC=%X",j,debugLogLow[i]&0xff,pc&0xffffff);
}
else
{
if (nv&b)
sprintf(str,"Set bit %d of %X at PC=%X",j,debugLogLow[i],pc&0xffffff);
else
sprintf(str,"Clear bit %d of %X at PC=%X",j,debugLogLow[i],pc&0xffffff);
}
LogDlg->List->Items->Add(str);
}
}
}
debugLogLast[i]=v;
}
}*/
return 0;
}
void DataBreak()
{
debugDataBreak=1;
}
void UpdateDebugCheckEnable()
{
if (debugCodeBreakCount||debugDataBreakCount||
debugProgBreak||debugStepOver||debugLogEnable||
exceptBPCount||debugRunToCursor||DebugWnd->Visible||
enableDebugWarnings)
debugCheckEnable=1;
else
debugCheckEnable=0;
/* if (debugDataBreakCount||debugLogEnable||enableDebugWarnings)
{
_readmem=debug_readmem;
_readmem_word=debug_readmem_word;
_readmem_dword=debug_readmem_dword;
_writemem=debug_writemem;
_writemem_word=debug_writemem_word;
_writemem_dword=debug_writemem_dword;
}
else
{
_readmem=asm_readmem;
_readmem_word=asm_readmem_word;
_readmem_dword=asm_readmem_dword;
_writemem=asm_writemem;
_writemem_word=asm_writemem_word;
_writemem_dword=asm_writemem_dword;
}*/
}
void __fastcall TDebugWnd::FormCreate(TObject *Sender)
{
Code->ItemHeight=MulDiv(10,GetDeviceCaps(Code->Canvas->
Handle, LOGPIXELSY),96)+4;
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::Runtocursor1Click(TObject *Sender)
{
if (!romLoaded) return;
if (Code->ItemIndex==-1) return;
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
int pc,i,j;
// PauseStart();
debugRunToCursor=1;
sscanf(Code->Items->Strings[Code->ItemIndex].c_str(),
"%x",&pc);
debugCursorAddr=pc;
debugStepOver=0;
run=1;
Hide();
OneInstruction();
// PauseEnd();
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::Palettes1Click(TObject *Sender)
{
PalView->DoUpdate();
PalView->Show();
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::IMEClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
char str[4];
// sprintf(str,"%X",R.IFF1&1);
sprintf(str,"%X",imeFlag);
NewValueDlg->Address->Text=str;
NewValueDlg->Address->SelectAll();
NewValueDlg->ActiveControl=NewValueDlg->Address;
if (NewValueDlg->ShowModal()==1)
{
// sscanf(NewValueDlg->Address->Text.c_str(),"%x",&R.IFF1);
sscanf(NewValueDlg->Address->Text.c_str(),"%x",&imeFlag);
// R.IFF2=R.IFF1;
Update();
}
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::ROMPgClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
char str[4];
sprintf(str,"%3.3X",romPage);
NewValueDlg->Address->Text=str;
NewValueDlg->Address->SelectAll();
NewValueDlg->ActiveControl=NewValueDlg->Address;
if (NewValueDlg->ShowModal()==1)
{
sscanf(NewValueDlg->Address->Text.c_str(),"%x",&romPage);
while ((romPage<<14)>=romSize)
{
if (debugWarn[DBW_PAGERANGE])
DebugWarn(DBW_PAGERANGE);
romPage-=romSize>>14;
}
mem[4]=&rom[romPage<<14];
mem[5]=&rom[(romPage<<14)+0x1000];
mem[6]=&rom[(romPage<<14)+0x2000];
mem[7]=&rom[(romPage<<14)+0x3000];
Update();
}
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::RAMPgClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
char str[4];
sprintf(str,"%X",ramPage);
NewValueDlg->Address->Text=str;
NewValueDlg->Address->SelectAll();
NewValueDlg->ActiveControl=NewValueDlg->Address;
if (NewValueDlg->ShowModal()==1)
{
if (ram)
{
sscanf(NewValueDlg->Address->Text.c_str(),"%x",&ramPage);
while ((ramPage<<13)>=ramSize)
{
if (debugWarn[DBW_PAGERANGE])
DebugWarn(DBW_PAGERANGE);
ramPage-=romSize>>13;
}
if (ramEnable)
{
mem[0xa]=&ram[ramPage<<13];
mem[0xb]=&ram[(ramPage<<13)+0x1000];
}
Update();
}
}
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::RAMEnableClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
char str[4];
sprintf(str,"%X",ramEnable);
NewValueDlg->Address->Text=str;
NewValueDlg->Address->SelectAll();
NewValueDlg->ActiveControl=NewValueDlg->Address;
if (NewValueDlg->ShowModal()==1)
{
if (ram)
{
sscanf(NewValueDlg->Address->Text.c_str(),"%x",&ramEnable);
if (ramEnable)
{
mem[0xa]=&ram[ramPage<<13];
mem[0xb]=&ram[(ramPage<<13)+0x1000];
}
else
{
mem[0xa]=NULL;
mem[0xb]=NULL;
}
Update();
}
}
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::CPUClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
clkMult=3-clkMult;
hiRam[0x4d]=(hiRam[0x4d]&1)|((clkMult==1)?0:0x80);
Update();
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::VBlankClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
hiRam[0xff]^=1;
Update();
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::LCDCClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
hiRam[0xff]^=2;
Update();
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::TimerClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
hiRam[0xff]^=4;
Update();
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::SerialClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
hiRam[0xff]^=8;
Update();
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::ButtonClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
hiRam[0xff]^=16;
Update();
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::LYClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
char str[4];
sprintf(str,"%2.2X",lcdY);
NewValueDlg->Address->Text=str;
NewValueDlg->Address->SelectAll();
NewValueDlg->ActiveControl=NewValueDlg->Address;
if (NewValueDlg->ShowModal()==1)
{
sscanf(NewValueDlg->Address->Text.c_str(),"%x",&lcdY);
Update();
}
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::LYCClick(TObject *Sender)
{
#ifdef DEMO
MessageBox(NULL,"This feature is disabled in the demo version.","VGBC",MB_OK|MB_TASKMODAL);
return;
#else
char str[4];
sprintf(str,"%2.2X",hiRam[0x45]);
NewValueDlg->Address->Text=str;
NewValueDlg->Address->SelectAll();
NewValueDlg->ActiveControl=NewValueDlg->Address;
if (NewValueDlg->ShowModal()==1)
{
sscanf(NewValueDlg->Address->Text.c_str(),"%x",&hiRam[0x45]);
Update();
}
#endif
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::Tiles1Click(TObject *Sender)
{
TileWnd->Show();
TileWnd->DoUpdate();
}
//---------------------------------------------------------------------------
void __fastcall TDebugWnd::Map1Click(TObject *Sender)
{
MapWnd->Show();
MapWnd->DoUpdate();
}
//---------------------------------------------------------------------------
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -