www.pudn.com > DBG8051.rar > Dbg8051.pas
program Debugger8051;
uses WinTypes, WinProcs, WinDos, Win31, Objects, Strings, ToolHelp, BWCC,
DbgZmTypy, DbgAsm, DbgPliki, DbgClass, DbgWykonaj;
{$R DBG8051.RES}
{$D ADD Debugger 8051}
const
us_Reset=101; us_Nowy=102; us_Koniec=107;
us_EWczytaj=201; us_EWczytajHEX=202; us_EZapisz=203; us_EZapiszHex=204; us_EZapiszBajty=205;
us_EZapiszDeasm=206;
us_RWczytaj=301; us_RWczytajHex=302; us_RZapisz=303; us_RZapiszHex=304; us_RZapiszBajty=305;
us_IWczytaj=401; us_IWczytajHex=402; us_IZapisz=403; us_IZapiszHex=404; us_IZapiszBajty=405;
us_PulaFlip=505; us_SymbWczytaj=501; us_SymbZapisz=502; us_PulaWczytaj=503; us_PulaZapisz=504;
us_WykS=601; us_WykTu=602; us_WykAdr=603; us_WykRET=604; us_WykI=605; us_WykK=606;
us_WykAnim=607; us_WykAktual=608;
us_PrzerwZ0=701; us_PrzerwT0=702; us_PrzerwZ1=703; us_PrzerwT1=704; us_PrzerwTI=705;
us_PrzerwRI=706;
us_JezPL=801; us_JezEN=802; us_ZapRozm=803; us_WczytRozm=804; us_WyczyscListe=805;
us_WielkCzcionki=808; us_RAMInt128=806; us_RAMInt256=807; us_Wtyczki=900;
us_OknoIns=150; us_OknoRej=151; us_OknoBit=152; us_OknoROM=153; us_OknoRAM=154;
us_OknoRAMInt=155; us_OknoSymb=156; us_OknoStan=157; us_OknoBreak=158; us_OknoPorty=159;
us_OknoCalc=160; us_OknoTerminal=161;
us_OknoRozmiesc=170; us_OknoOdrysuj=171; us_OknoNastepne=172; us_OknoZamknij=173;
var
aktywne:boolean;
Meldunek:TMsg;
TabAkcel:THandle;
starydir,param0,progdir:array[0..63] of char;
wtrakciezmian:boolean;
procedure WykAnim(Okno:Hwnd;z:byte); forward;
procedure WykAktual(Okno:Hwnd;z:byte); forward;
procedure WykBigMem(Okno:HWnd;z:byte); forward;
procedure UruchomWtyczki(Okno:HWnd);
begin
IleWtyczek:=0;
end;
procedure ZakonczWtyczki(Okno:HWnd);
begin
end;
procedure WybranaWtyczka(Okno:HWnd;wParam:word);
var a:TFarProc;
m1,m2:HMenu;
begin
end;
procedure PrzywrocMenu(Okno:HWnd);
begin
if jezykpl then SetMenu(Okno,MenuGlownePL) else SetMenu(Okno,MenuGlowneEN);
end;
procedure ZmienJezyk(Okno:HWnd;polski:boolean);
var p,d:array[0..63] of char;
begin
if polski=jezykpl then Exit;
jezykpl:=polski;
PrzywrocMenu(Okno);
DoWszystkich(255,wm_Command,us_ZmianaJez,0);
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
if polski then WritePrivateProfileString('Settings','Language','PL',d) else
WritePrivateProfileString('Settings','Language','EN',d);
ListaOkien;
end;
procedure Inicjuj(Okno:HWnd;jak:byte);
var
DC:HDC;
tmp:PChar;
szerwys:longint;
wielk,code:integer;
oldFont:HFont;
bold:integer;
p,d:array[0..63] of char;
jez:array[0..3] of char;
begin
intflipflop:=0; runprog:=0; RejPC:=0; licznikcykli:=0; licznikcykliwewn:=0;
wtrakciezmian:=false; poprz_int0:=true; poprz_int1:=true; poprz_t0:=true; poprz_t1:=true;
if jak=0 then
begin
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
{pobieramy nazw?i wielkość czcionki "systemowej" z pliku .INI}
GetPrivateProfileString('Settings','FontOEM','',p,63,d);
if StrLen(p)=0 then
begin
wielk:=12;
StrCopy(p,'Terminal');
WritePrivateProfileString('Settings','FontOEM','Terminal,12',d);
end else
begin
if p[StrLen(p)-1]='B' then bold:=FW_BOLD else bold:=FW_NORMAL;
p[StrLen(p)-1]:=#0;
tmp:=StrRScan(p,',');
tmp^:=#0;
Val(StrPas(tmp+1),wielk,code);
end;
{tworzymy czcionk?OEM i zapamiętujemy rozmiar znaku}
CzcionkaOEM:=CreateFont(-wielk,0,0,0,bold,0,0,0,OEM_CHARSET,
OUT_RASTER_PRECIS,CLIP_DEFAULT_PRECIS,DRAFT_QUALITY,0,p);
DC:=GetDC(Okno);
oldfont:=SelectObject(DC,CzcionkaOEM);
szerwys:=GetTextExtent(DC,'B',1);
FontOEMszer:=LoWord(szerwys);
FontOEMwys:=HiWord(szerwys);
SelectObject(DC,oldfont);
ReleaseDC(Okno,DC);
{pobieramy rozmiary pozostałych elementów}
RamkaSzer:=GetSystemMetrics(SM_CXFRAME)*2;
RamkaWys:=GetSystemMetrics(SM_CYFRAME)*2+GetSystemMetrics(SM_CYCAPTION);
WindaSzer:=GetSystemMetrics(SM_CXVSCROLL);
WindaWys:=GetSystemMetrics(SM_CYHSCROLL);
{dalsza jednorazowa inicjalizacja}
jezykpl:=true; aktywne:=true;
OknoAktualne:=0; OknoInstr:=0; OknoTerm:=0;
SymbROM:=New(PStrCollection,Init(100,100));
SymbRAM:=New(PStrCollection,Init(100,100));
SymbReg:=New(PStrCollection,Init(100,100));
SymbBit:=New(PStrCollection,Init(100,100));
SymbBrk:=New(PStrCollection,Init(100,100));
BlokPamROM:=GlobalAlloc(GHND or GMEM_NOCOMPACT,65536);
BlokPamRAM:=GlobalAlloc(GHND or GMEM_NOCOMPACT,65536);
BlokPamRAMInt:=GlobalAlloc(GHND or GMEM_NOCOMPACT,384);
selROM:=GlobalHandleToSel(BlokPamROM);
selRAM:=GlobalHandleToSel(BlokPamRAM);
selRAMInt:=GlobalHandleToSel(BlokPamRAMInt);
UruchomWtyczki(Okno);
GetPrivateProfileString('Settings','Language','xx',jez,3,d);
if StrComp(jez,'xx')=0 then WritePrivateProfileString('Settings','Language','PL',d) else
if StrComp(jez,'EN')=0 then ZmienJezyk(Okno,false);
if GetPrivateProfileInt('Settings','Animation',1,d)=1 then
WykAnim(Okno,1) else WykAnim(Okno,0);
if GetPrivateProfileInt('Settings','UpdatingPI',1,d)=1 then
WykAktual(Okno,1) else WykAktual(Okno,0);
if GetPrivateProfileInt('Settings','InternalMem',128,d)=128 then
WykBigMem(Okno,0) else WykBigMem(Okno,1);
WczytajListePlikow;
end;
SymbROM^.DeleteAll;
SymbRAM^.DeleteAll;
SymbReg^.DeleteAll;
SymbBit^.DeleteAll;
SymbBrk^.DeleteAll;
FillChar(Mem[selROM:0],65535,0); Mem[selROM:65535]:=0;
FillChar(Mem[selRAM:0],65535,0); Mem[selRAM:65535]:=0;
FillChar(Mem[selRAMInt:0],384,0);
Mem[selRAMInt:128]:=255; Mem[selRAMInt:144]:=255;
Mem[selRAMInt:160]:=255; Mem[selRAMInt:176]:=255; {P0-P3}
Mem[selRAMInt:129]:=7; {SP}
if jak=1 then
begin
if OknoInstr<>0 then
SendMessage(GetWindow(OknoInstr,gw_Child),wm_Command,us_OdnowCoTrzeba,0);
OdrysujWszystkie;
end;
end;
procedure NoToKoniec(Okno:HWnd);
begin
runprog:=0;
DoWszystkich(255,wm_Close,0,0);
ZakonczWtyczki(Okno);
GlobalFree(BlokPamROM);
GlobalFree(BlokPamRAM);
GlobalFree(BlokPamRAMInt);
Dispose(SymbROM,Done);
Dispose(SymbRAM,Done);
Dispose(SymbReg,Done);
Dispose(SymbBit,Done);
Dispose(SymbBrk,Done);
DeleteObject(CzcionkaOEM);
end;
procedure ResetProc(Okno:HWnd);
begin
intflipflop:=0; runprog:=0; licznikcykli:=0; licznikcykliwewn:=0; RejPC:=0;
poprz_int0:=true; poprz_int1:=true; poprz_t0:=true; poprz_t1:=true;
FillChar(Mem[selRAMInt:128],128,0);
Mem[selRAMInt:128]:=255; Mem[selRAMInt:144]:=255;
Mem[selRAMInt:160]:=255; Mem[selRAMInt:176]:=255; {P0-P3}
Mem[selRAMInt:129]:=7; {SP}
if OknoInstr<>0 then SendMessage(GetWindow(OknoInstr,gw_Child),wm_Command,us_OdnowCoTrzeba,0);
OdrysujWszystkie;
end;
function OdrysujAktyw(Okno:HWnd;k,w:word;l:longint):longint;
var
DC,m:HDC;
y1:integer;
b:HBitmap;
begin
if w=0 then aktywne:=false else aktywne:=true;
DefWindowProc(Okno,k,w,l);
DC:=GetWindowDC(Okno);
y1:=GetSystemMetrics(SM_CYFRAME);
m:=CreateCompatibleDC(DC);
if aktywne then b:=LoadBitmap(hInstance,'TYTUL') else b:=LoadBitmap(hInstance,'TYTULN');
SelectObject(m,b);
BitBlt(DC,GetSystemMetrics(SM_CXSIZE)+7,y1+1,80,16,m,0,0,SrcCopy);
DeleteDC(m);
DeleteObject(b);
ReleaseDC(Okno,DC);
OdrysujAktyw:=1;
end;
procedure Odrysuj(Okno:HWnd;k,w:word;l:longint);
var
DC,m:HDC;
y1:integer;
b:HBitmap;
begin
DefWindowProc(Okno,k,w,l);
DC:=GetWindowDC(Okno);
y1:=GetSystemMetrics(SM_CYFRAME);
m:=CreateCompatibleDC(DC);
if aktywne then b:=LoadBitmap(hInstance,'TYTUL') else b:=LoadBitmap(hInstance,'TYTULN');
SelectObject(m,b);
BitBlt(DC,GetSystemMetrics(SM_CXSIZE)+7,y1+1,80,16,m,0,0,SrcCopy);
DeleteDC(m);
DeleteObject(b);
DeleteDC(m);
ReleaseDC(Okno,DC);
end;
procedure WykTutaj(Okno:HWnd);
var off:word;
begin
if (runprog>0) or (OknoInstr=0) then
begin
MessageBeep(mb_IconHand);
Exit;
end;
SendMessage(OknoInstr,wm_Command,us_PodajAdres0,0);
end;
procedure WykTutaj1(Okno:HWnd;off:word);
begin
runto:=off;
runprog:=2;
SetMenu(Okno,MenuStop);
end;
procedure WykAdres(Okno:HWnd);
var
code,b:integer;
off:word;
begin
if runprog>0 then
begin
MessageBeep(mb_IconHand);
Exit;
end;
b:=PokazDialog('OFFSET',@FunOffset);
if (b<>1) or (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then
begin
MessageBeep(mb_IconHand);
BWCCMessageBox(0,Napis1(1),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
Exit;
end;
runto:=off;
runprog:=2;
SetMenu(Okno,MenuStop);
end;
procedure WykKrok(Okno:HWnd);
var i:byte;
begin
if runprog>0 then
begin
MessageBeep(mb_IconHand);
Exit;
end;
i:=Mem[selROM:RejPC];
if (i<>$12) and ((i and $1f)<>$11) then { ani LCALL, ani ACALL }
begin
Wykonaj;
if OknoInstr<>0 then SendMessage(GetWindow(OknoInstr,gw_Child),
wm_Command,us_OdnowCoTrzeba,0);
OdrysujWszystkie;
AktualizujWtyczki(OknoGlowne);
Exit;
end;
if i=$12 then runto:=RejPC+3 else runto:=RejPC+2;
runprog:=2;
SetMenu(Okno,MenuStop);
end;
procedure WykAnim(Okno:Hwnd;z:byte);
var
m1,m2:HMenu;
p,d:array[0..63] of char;
begin
m1:=GetSubMenu(MenuGlownePL,5);
m2:=GetSubMenu(MenuGlowneEN,5);
case z of
0: anim:=false;
1: anim:=true;
2: anim:=not anim;
end;
if anim then
begin
CheckMenuItem(m1,607,MF_BYCOMMAND or MF_CHECKED);
CheckMenuItem(m2,607,MF_BYCOMMAND or MF_CHECKED);
end
else
begin
CheckMenuItem(m1,607,MF_BYCOMMAND or MF_UNCHECKED);
CheckMenuItem(m2,607,MF_BYCOMMAND or MF_UNCHECKED);
end;
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
if anim then WritePrivateProfileString('Settings','Animation','1',d) else
WritePrivateProfileString('Settings','Animation','0',d);
end;
procedure WykAktual(Okno:Hwnd;z:byte);
var
m1,m2:HMenu;
p,d:array[0..63] of char;
begin
m1:=GetSubMenu(MenuGlownePL,5);
m2:=GetSubMenu(MenuGlowneEN,5);
case z of
0: aktual:=false;
1: aktual:=true;
2: aktual:=not aktual;
end;
if aktual then
begin
CheckMenuItem(m1,608,MF_BYCOMMAND or MF_CHECKED);
CheckMenuItem(m2,608,MF_BYCOMMAND or MF_CHECKED);
end
else
begin
CheckMenuItem(m1,608,MF_BYCOMMAND or MF_UNCHECKED);
CheckMenuItem(m2,608,MF_BYCOMMAND or MF_UNCHECKED);
end;
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
if aktual then WritePrivateProfileString('Settings','UpdatingPI','1',d) else
WritePrivateProfileString('Settings','UpdatingPI','0',d);
end;
procedure WykBigMem(Okno:Hwnd;z:byte);
var
m1,m2:HMenu;
p,d:array[0..63] of char;
begin
m1:=GetSubMenu(MenuGlownePL,7);
m2:=GetSubMenu(MenuGlowneEN,7);
bigmem:=boolean(z);
if bigmem then
begin
CheckMenuItem(m1,806,MF_BYCOMMAND or MF_UNCHECKED);
CheckMenuItem(m2,806,MF_BYCOMMAND or MF_UNCHECKED);
CheckMenuItem(m1,807,MF_BYCOMMAND or MF_CHECKED);
CheckMenuItem(m2,807,MF_BYCOMMAND or MF_CHECKED);
end
else
begin
CheckMenuItem(m1,806,MF_BYCOMMAND or MF_CHECKED);
CheckMenuItem(m2,806,MF_BYCOMMAND or MF_CHECKED);
CheckMenuItem(m1,807,MF_BYCOMMAND or MF_UNCHECKED);
CheckMenuItem(m2,807,MF_BYCOMMAND or MF_UNCHECKED);
end;
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
if bigmem then WritePrivateProfileString('Settings','InternalMem','256',d) else
WritePrivateProfileString('Settings','InternalMem','128',d);
OdrysujOkna(5); {HEX RAM Int}
end;
procedure ZmienStanPulapki;
begin
if OknoInstr=0 then MessageBeep(mb_IconHand) else
SendMessage(OknoInstr,wm_Command,us_ZmienPulapke,0);
end;
procedure ZmienAktywnego(wParam:word);
var
m:HMenu;
nazwa:array[0..63] of char;
begin
m:=GetSubMenu(MenuGlownePL,8);
if GetMenuString(m,wParam,nazwa,63,MF_BYCOMMAND)<>0 then
DoWszystkich(255,wm_Command,us_ZmienAktywnego,longint(@nazwa));
end;
procedure SkoczDoPC;
var adr:PAdresy;
begin
if OknoInstr=0 then MessageBeep(mb_IconHand) else
begin
adr:=pointer(GetWindowLong(GetWindow(OknoInstr,gw_Child),0));
adr^[1]:=RejPC;
SetWindowWord(GetWindow(OknoInstr,gw_Child),4,0);
PostMessage(OknoInstr,wm_Command,us_OdnowWidok,0);
end;
end;
procedure ZmienWielkoscCzcionki(Okno:HWnd);
var
b,code:integer;
p,d:array[0..63] of char;
czcionki:PStrCollection;
info:TCzcionkaInfo;
tmp:PChar;
begin
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
{pobieramy nazw?i wielkość czcionki "systemowej" z pliku .INI}
GetPrivateProfileString('Settings','FontOEM','',p,63,d);
if p[StrLen(p)-1]='B' then info.bold:=true else info.bold:=false;
p[StrLen(p)-1]:=#0;
tmp:=StrRScan(p,',');
tmp^:=#0;
Val(StrPas(tmp+1),info.wielk,code);
New(czcionki,Init(15,15));
WyliczCzcionkiF(czcionki);
info.fonts:=czcionki;
info.numer:=-1;
for b:=0 to czcionki^.Count-1 do
if StrComp(p,czcionki^.At(b))=0 then info.numer:=b;
b:=PokazDialogParam('FONTSIZE',@FunFontSize,longint(@info));
if (b<>1) or (Length(wynik1)>3) or (wynik='') or (wynik1='') then
begin
Dispose(czcionki,Done);
Exit;
end;
Val(wynik1,b,code);
if code<>0 then
begin
MessageBeep(mb_IconHand);
BWCCMessageBox(0,Napis1(1),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
Dispose(czcionki,Done);
Exit;
end;
if (b<1) or (b>99) then
begin
MessageBeep(mb_IconHand);
BWCCMessageBox(0,Napis1(84),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
Dispose(czcionki,Done);
Exit;
end;
StrPCopy(p,wynik+','+wynik1+wynik2);
WritePrivateProfileString('Settings','FontOEM',p,d);
MessageBeep(mb_OK);
BWCCMessageBox(0,Napis1(85),'Debugger 8051',mb_OK or mb_TaskModal or mb_IconInformation);
Dispose(czcionki,Done);
end;
function NoweOknoMDI(wParam:word;aktyw,ustaw:boolean;ax,ay,acx,acy:integer):word;
const
MDICreate:TMDICreateStruct=(
szClass : nil; szTitle : nil;
hOwner : 0;
x : 0; y : 0;
cx : 0; cy : 0;
style : 0; LParam : 0);
var a:array[0..15] of char;
begin
if aktyw then StrCopy(a,'DBGMDICL1') else StrCopy(a,'DBGMDICL0');
with MDICreate do
begin
szClass:=@a;
hOwner:=hInstance;
szTitle:=''; {Napis1(wParam-us_OknoIns+26)}
LParam:=wParam-us_OknoIns;
if ustaw then begin x:=ax; y:=ay; cx:=acx; cy:=acy; end else
begin x:=cw_UseDefault; y:=cw_UseDefault; cx:=cw_UseDefault; cy:=cw_UseDefault; end;
end;
if (wParam IN [us_OknoPorty,us_OknoTerminal]) and not(wtrakciezmian) then
DoWszystkich(wParam-us_OknoIns,wm_Close,0,0); {okno portow lub terminala moze byc tylko 1}
NoweOknoMDI:=SendMessage(Klient,wm_MDICreate,0,longint(@MDICreate));
PostMessage(OknoGlowne,wm_Command,us_ListaOkien,0);
end;
function FunDbgMDICl(Okno:HWnd;Kod_meldunku,wParam:word;LParam:longint):longint; EXPORT;
var
s:^TMDICreateStruct;
lpmmi:^TMinMaxInfo;
a,b:word;
R,R2:TRect;
o:HWnd;
txt:PChar;
clname:array[0..10] of char;
begin
FunDbgMDICl:=0;
case Kod_meldunku of
wm_KeyDown: begin
SendMessage(GetWindow(Okno,GW_CHILD),wm_KeyDown,wParam,LParam);
FunDbgMDICl:=DefMDIChildProc(Okno,wm_KeyDown,wParam,LParam);
end;
wm_NCActivate: begin
if wParam<>0 then
begin
OknoAktualne:=Okno;
if (GetWindowWord(Okno,0)=0) and {okienko instrukcji}
(GetWindowWord(Okno,2)=1) then OknoInstr:=Okno; {i do tego aktywne}
if (GetWindowWord(Okno,0)=11) then OknoTerm:=Okno; {okienko terminala}
UpdateWindow(Okno);
end;
FunDbgMDICl:=DefMDIChildProc(Okno,wm_NCActivate,wParam,LParam);
end;
wm_NCLButtonDblClk: PostMessage(Okno,wm_Command,us_ZmianaAkt,0);
wm_Close: begin
PostMessage(OknoGlowne,wm_Command,us_ListaOkien,0);
FunDbgMDICl:=DefMDIChildProc(Okno,wm_Close,wParam,LParam);
end;
wm_Destroy: begin
if (GetWindowWord(Okno,0)=0) and (Okno=OknoInstr) then OknoInstr:=0;
if (GetWindowWord(Okno,0)=11) and (Okno=OknoTerm) then OknoTerm:=0;
end;
wm_Size: if wParam=SIZE_RESTORED then
SendMessage(GetWindow(Okno,GW_CHILD),wm_Command,us_ZmienRozmiary,LParam);
wm_GetMinMaxInfo: begin
lpmmi:=pointer(LParam);
case GetWindowWord(Okno,0) of
3..5: begin
lpmmi^.ptMinTrackSize.x:=FontOEMszer*38+RamkaSzer+WindaSzer+3;
lpmmi^.ptMaxTrackSize.x:=lpmmi^.ptMinTrackSize.x;
end;
11: begin
lpmmi^.ptMaxTrackSize.x:=FontOEMszer*80+RamkaSzer;
lpmmi^.ptMaxTrackSize.y:=FontOEMwys*25+RamkaWys;
end;
end;
end;
wm_Command: case wParam of
us_ZmianaJez: PostMessage(GetWindow(Okno,gw_Child),wm_Command,wParam,LParam);
us_ZmienAktywnego: begin
txt:=pointer(LParam);
GetWindowText(Okno,buforzn2,63);
if StrComp(txt,buforzn2)=0 then
SendMessage(Klient,wm_MDIActivate,Okno,0);
end;
us_OdnowWidok: SendMessage(GetWindow(Okno,gw_Child),wm_Command,us_OdnowWidok,
LParam);
us_OdnowCoTrzeba: if GetWindowWord(Okno,2)=1 then
SendMessage(GetWindow(Okno,gw_Child),wm_Command,
us_OdnowWidok,LParam);
us_ZmianaAkt: begin
a:=GetWindowWord(Okno,0); {typ okienka}
b:=GetWindowWord(Okno,2); {0-nieaktywne, 1-aktywne}
GetWindowRect(Okno,R);
MapWindowPoints(HWND_DESKTOP,Klient,R,2);
wtrakciezmian:=true;
if b=0 then
o:=NoweOknoMDI(a+us_OknoIns,true,true,R.left,
R.top,R.right-R.left,R.bottom-R.top)
else
o:=NoweOknoMDI(a+us_OknoIns,false,true,R.left,R.top,
R.right-R.left,R.bottom-R.top);
wtrakciezmian:=false;
DestroyWindow(GetWindow(o,gw_Child)); {usu?now?zawartość}
SetParent(GetWindow(Okno,gw_Child),o); {środek przełóż}
SendMessage(o,wm_NCActivate,1,0); {uaktywnij nowe okno}
UpdateWindow(o); {odrysuj zawartość}
SetWindowWord(o,2,1-b); {zmie?informacj?o aktywności}
if (a=0) and (b=0) then OknoInstr:=o;
PostMessage(Okno,wm_Close,0,0); {i zamknij stare okienko}
end;
else PostMessage(GetWindow(Okno,gw_Child),wm_Command,wParam,LParam);
end;
wm_Create: begin
s:=pointer(PCreateStruct(LParam)^.lpCreateParams);
a:=s^.LParam;
SetWindowWord(Okno,0,a);
GetClassName(Okno,clname,10);
if clname[8]='0' then SetWindowWord(Okno,2,0) else SetWindowWord(Okno,2,1);
SetWindowLong(Okno,GWL_STYLE,GetWindowLong(Okno,GWL_STYLE) xor ws_MaximizeBox);
if not (a IN [3,4,5,11]) then {można zmienia?wielkości niektórych okienek}
SetWindowLong(Okno,GWL_STYLE,GetWindowLong(Okno,GWL_STYLE) xor ws_ThickFrame);
GetClientRect(Okno,R2);
GetWindowRect(Okno,R);
MapWindowPoints(HWND_DESKTOP,Klient,R,2);
case a of
0: begin
o:=CreateWindow('KLASAINSTR','',ws_Child or ws_Visible,
0,0,458,320,Okno,0,hInstance,nil);
R.right:=R.left+458;
R.bottom:=R.top+320+GetSystemMetrics(SM_CYCAPTION);
end;
1: begin
o:=CreateWindow('KLASAREGS','',ws_Child or ws_Visible,
0,0,192,226,Okno,0,hInstance,nil);
R.right:=R.left+192;
R.bottom:=R.top+226+GetSystemMetrics(SM_CYCAPTION);
end;
2: begin
o:=CreateWindow('KLASABIT','',ws_Child or ws_Visible,
2,1,FontOEMszer*24+16,5*FontOEMwys+19,Okno,0,hInstance,nil);
R.right:=R.left+FontOEMszer*24+20;
R.bottom:=R.top+5*FontOEMwys+20+GetSystemMetrics(SM_CYCAPTION);
end;
3..5: o:=CreateWindow('KLASAHEX','',ws_Child or ws_Visible,
-1,-1,324,112,Okno,0,hInstance,Ptr(0,a-3));
6: begin
o:=CreateWindow('KLASASYMB','',ws_Child or ws_Visible,
0,0,366,226,Okno,0,hInstance,nil);
R.right:=R.left+366;
R.bottom:=R.top+225+GetSystemMetrics(SM_CYCAPTION);
end;
7: begin
o:=CreateWindow('KLASASTAN','',ws_Child or ws_Visible,
0,0,40+FontOEMszer*23,Max(32,FontOEMwys+2),Okno,0,hInstance,nil);
R.right:=R.left+40+FontOEMszer*23;
R.bottom:=R.top+Max(34,FontOEMwys+4)+GetSystemMetrics(SM_CYCAPTION);
end;
8: begin
o:=CreateWindow('KLASABREAK','',ws_Child or ws_Visible,
0,0,366,226,Okno,0,hInstance,nil);
R.right:=R.left+366;
R.bottom:=R.top+225+GetSystemMetrics(SM_CYCAPTION);
end;
9: begin
o:=CreateWindow('KLASAPORTY','',ws_Child or ws_Visible,
0,0,155,124,Okno,0,hInstance,nil);
R.right:=R.left+155;
R.bottom:=R.top+124+GetSystemMetrics(SM_CYCAPTION);
end;
10: begin
o:=CreateWindow('KLASACALC','',ws_Child or ws_Visible,
0,0,DialogSzer(74),DialogWys(40),Okno,0,hInstance,nil);
R.right:=R.left+DialogSzer(74);
R.bottom:=R.top+DialogWys(40)+GetSystemMetrics(SM_CYCAPTION);
end;
11: o:=CreateWindow('KLASATERMINAL','',ws_Child or ws_Visible,
0,0,R2.right-R2.left,R2.bottom-R2.top,Okno,0,hInstance,nil);
else FunDbgMDICl:=-1;
end;
if a<=11 then
begin
MoveWindow(Okno,R.left,R.top,R.right-R.left,R.bottom-R.top,true);
PostMessage(o,wm_Command,us_OdnowWidok,0);
end;
end;
else FunDbgMDICl:=DefMDIChildProc(Okno,Kod_meldunku,wParam,LParam);
end;
end;
function FunRamki(Okno:HWnd;Kod_meldunku,wParam:word;LParam:longint):longint; EXPORT;
const ParKlienta:TClientCreateStruct=(hWindowMenu:0; idFirstChild:1000);
var ProcDial:TFarProc;
begin
FunRamki:=0;
if Kod_meldunku=wm_Activate then FunRamki:=OdrysujAktyw(Okno,Kod_meldunku,WParam,LParam);
case Kod_meldunku of
wm_Create : begin
Klient:=CreateWindow('MDIClient',nil,ws_Child or ws_ClipChildren or
ws_Visible,0,0,0,0,Okno,1,hInstance,@ParKlienta);
Inicjuj(Okno,0);
PostMessage(Okno,wm_Command,us_WczytRozm,0);
end;
wm_NCPaint, wm_Paint : Odrysuj(Okno,Kod_meldunku,WParam,LParam);
wm_Destroy: begin
NoToKoniec(Okno);
PostQuitMessage(0);
end;
wm_Command: case wParam of
us_Reset: ResetProc(Okno);
us_Nowy: Inicjuj(Okno,1);
us_Koniec: DestroyWindow(Okno);
us_PlikNr1..us_PlikNr1+7: WczytajAutomat(Okno,wParam-us_PlikNr1+1);
us_EWczytaj: WczytajEPROM(Okno);
us_EZapisz: ZapiszEPROM(Okno);
us_EWczytajHex: WczytajEPROMhex(Okno);
us_EZapiszHex: ZapiszEPROMhex(Okno);
us_EZapiszBajty: ZapiszBajty(Okno,selROM,$FFFF);
us_EZapiszDeasm: ZapiszEPROMDeasm(Okno);
us_RWczytaj: WczytajRAM(Okno);
us_RZapisz: ZapiszRAM(Okno);
us_RWczytajHex: WczytajRAMhex(Okno);
us_RZapiszHex: ZapiszRAMhex(Okno);
us_RZapiszBajty: ZapiszBajty(Okno,selRAM,$FFFF);
us_IWczytaj: WczytajRAMInt(Okno);
us_IZapisz: ZapiszRAMInt(Okno);
us_IWczytajHex: WczytajRAMInthex(Okno);
us_IZapiszHex: ZapiszRAMInthex(Okno);
us_IZapiszBajty: ZapiszBajty(Okno,selRAMInt,$FF);
us_PulaFlip: ZmienStanPulapki;
us_SymbWczytaj: SymbWczytaj(Okno);
us_SymbZapisz: SymbZapisz(Okno);
us_PulaWczytaj: WczytajPula(Okno);
us_PulaZapisz: ZapiszPula(Okno);
us_WykS: if runprog>0 then MessageBeep(mb_IconHand) else
begin
SetMenu(Okno,MenuStop);
runprog:=1;
end;
us_WykTu: WykTutaj(Okno);
us_PodajAdres1: WykTutaj1(Okno,LoWord(LParam));
us_WykAdr: WykAdres(Okno);
us_WykRET: if runprog>0 then MessageBeep(mb_IconHand) else
begin
SetMenu(Okno,MenuStop);
runprog:=3;
end;
us_WykI: if runprog>0 then MessageBeep(mb_IconHand) else
begin
Wykonaj;
if OknoInstr<>0 then SendMessage(GetWindow(OknoInstr,gw_Child),
wm_Command,us_OdnowCoTrzeba,0);
OdrysujWszystkie;
AktualizujWtyczki(OknoGlowne);
end;
us_WykK: WykKrok(Okno);
us_WykAnim: WykAnim(Okno,2);
us_WykAktual: WykAktual(Okno,2);
us_PrzerwZ0..us_PrzerwRI: GenPrzerwanie(wParam-us_PrzerwZ0,false);
us_JezPL: ZmienJezyk(Okno,true);
us_JezEN: ZmienJezyk(Okno,false);
us_ZapRozm: ZapiszRozm(Okno);
us_WczytRozm: WczytajRozm(Okno);
us_WyczyscListe: WyczyscListePlikow;
us_WielkCzcionki: ZmienWielkoscCzcionki(Okno);
us_RAMInt128: WykBigMem(Okno,0);
us_RAMInt256: WykBigMem(Okno,1);
us_Wtyczki .. us_Wtyczki+31: WybranaWtyczka(Okno,wParam);
us_OknoIns .. us_OknoTerminal: NoweOknoMDI(wParam,true,false,0,0,0,0);
us_OknoRozmiesc: SendMessage(Klient,wm_MDICascade,0,0);
us_OknoOdrysuj: OdrysujWszystkie;
us_OknoNastepne: SendMessage(Klient,wm_MDINext,
SendMessage(Klient,wm_MDIGetActive,0,0),0);
us_OknoZamknij: begin
SendMessage(Klient,wm_MDIDestroy,
SendMessage(Klient,wm_MDIGetActive,0,0),0);
ListaOkien;
end;
us_OknoNr0 .. us_OknoNr0+29: ZmienAktywnego(wParam);
us_About: begin
MessageBeep(mb_IconExclamation);
PokazDialog('ABOUT',@FunDialogu);
end;
us_StopNow: if runprog>0 then
begin
runprog:=0;
PrzywrocMenu(Okno);
OdrysujWszystkie;
AktualizujWtyczki(Okno);
SkoczDoPC;
end;
us_ListaOkien: ListaOkien;
us_SkoczDoPC: SkoczDoPC;
end;
else FunRamki:=DefFrameProc(Okno,Klient,Kod_meldunku,wParam,LParam);
end;
end;
const NaszaKlasa: TWndClass = (
style : 0;
lpfnWndProc : @FunRamki;
cbClsExtra : 0;
cbWndExtra : 0;
hInstance : 0;
hIcon : 0;
hCursor : 0;
hbrBackground : COLOR_APPWORKSPACE+1;
lpszMenuName : nil;
lpszClassName : 'DBG8051');
begin
if HPrevInst<>0 then
begin
MessageBeep(mb_IconExclamation);
BWCCMessageBox(0,'Program ju?pracuje!'#13#10#13#10'Program is working already!',
'Debugger 8051',mb_IconStop);
Halt;
end;
NaszaKlasa.hInstance:=hInstance;
NaszaKlasa.hIcon:=LoadIcon(hInstance,'IKONA');
if not RegisterClass(NaszaKlasa) then Halt;
NaszaKlasa.lpszClassName:='DBGMDICL1';
NaszaKlasa.cbWndExtra:=4;
NaszaKlasa.lpfnWndProc:=@FunDbgMDICl;
NaszaKlasa.hIcon:=LoadIcon(hInstance,'OKNO1');
NaszaKlasa.hbrBackground:=GetStockObject(LTGRAY_BRUSH);
if not RegisterClass(NaszaKlasa) then Halt;
NaszaKlasa.lpszClassName:='DBGMDICL0';
NaszaKlasa.hIcon:=LoadIcon(hInstance,'OKNO0');
if not RegisterClass(NaszaKlasa) then Halt;
GetCurDir(starydir,0);
FileSplit(StrPCopy(param0,ParamStr(0)),progdir,nil,nil);
SetCurDir(progdir);
MenuGlownePL:=LoadMenu(hInstance,'MENU');
MenuGlowneEN:=LoadMenu(hInstance,'EMENU');
MenuStop:=LoadMenu(hInstance,'STOPMENU');
SetMessageQueue(64);
OknoGlowne:=CreateWindow('DBG8051','''51',ws_OverlappedWindow,
cw_UseDefault,cw_UseDefault,cw_UseDefault,cw_UseDefault,0,MenuGlownePL,hInstance,nil);
ShowWindow(OknoGlowne,sw_ShowMaximized);
TabAkcel:=LoadAccelerators(hInstance,'AKCELERATORY');
repeat
if runprog>0 then
begin
RuszajSie;
if PeekMessage(Meldunek,0,0,0,pm_Remove) then
if Meldunek.message<>wm_Quit then
if (TranslateMDISysAccel(OknoGlowne,Meldunek)=false) and
(TranslateAccelerator(OknoGlowne,TabAkcel,Meldunek)=0) then
begin
TranslateMessage(Meldunek);
DispatchMessage(Meldunek);
end;
end
else
begin
if GetMessage(Meldunek,0,0,0) then
if (TranslateMDISysAccel(OknoGlowne,Meldunek)=false) and
(TranslateAccelerator(OknoGlowne,TabAkcel,Meldunek)=0) then
begin
TranslateMessage(Meldunek);
DispatchMessage(Meldunek);
end;
end;
until Meldunek.message=wm_Quit;
DestroyMenu(MenuGlownePL);
DestroyMenu(MenuGlowneEN);
DestroyMenu(MenuStop);
SetCurDir(starydir);
Halt(Meldunek.wParam);
end.