www.pudn.com > DBG8051.rar > Dbgpliki.pas
unit DbgPliki;
interface
uses WinTypes;
procedure ZapiszBajty(Okno:HWnd;selektor,maxoffset:word);
procedure WczytajEPROM(Okno:HWnd);
procedure ZapiszEPROM(Okno:HWnd);
procedure WczytajEPROMhex(Okno:HWnd);
procedure ZapiszEPROMhex(Okno:HWnd);
procedure ZapiszEPROMDeasm(Okno:HWnd);
procedure WczytajRAM(Okno:HWnd);
procedure ZapiszRAM(Okno:HWnd);
procedure WczytajRAMhex(Okno:HWnd);
procedure ZapiszRAMhex(Okno:HWnd);
procedure WczytajRAMInt(Okno:HWnd);
procedure ZapiszRAMInt(Okno:HWnd);
procedure WczytajRAMInthex(Okno:HWnd);
procedure ZapiszRAMInthex(Okno:HWnd);
procedure SymbWczytaj(Okno:HWnd);
procedure SymbZapisz(Okno:HWnd);
procedure ZapiszRozm(Okno:HWnd);
procedure WczytajRozm(Okno:HWnd);
procedure WczytajPula(Okno:HWnd);
procedure ZapiszPula(Okno:HWnd);
procedure WczytajAutomat(Okno:HWnd;numer:byte);
procedure WczytajListePlikow;
procedure DodajDoListyPlikow(nazwa:PChar;typ:char);
procedure WyczyscListePlikow;
implementation
uses WinProcs, WinDOS, CommDlg, Strings, BWCC, DbgZmTypy, DbgAsm;
procedure ZapiszBajty(Okno:HWnd;selektor,maxoffset:word);
const DefExt = 'asm';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik,linia:string;
txt:string[6];
Info:HWnd;
code,b:integer;
off,dlug:word;
d1:longint;
bajt:byte;
wy:text;
litera,nic:boolean;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(83));
StrCopy(@Filter[StrLen(Filter)+1],'*.asm');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
if off>maxoffset then
begin
MessageBeep(mb_IconHand);
BWCCMessageBox(0,Napis1(25),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
Exit;
end;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if code<>0 then Exit;
if dlug=0 then Exit;
if adrost then d1:=longint(dlug)+1-off else d1:=dlug;
Assign(wy,Plik);
{$I-} Rewrite(wy); {$I+}
if IOResult<>0 then Exit;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
linia:=' db ';
litera:=false;
nic:=true;
repeat
bajt:=Mem[selektor:off];
if (bajt<32) or (bajt=39) or (bajt>126) then
begin
if litera then
begin
litera:=false;
txt:=#39','+StrFunW(bajt);
end else
begin
if nic then
begin
txt:=StrFunW(bajt);
nic:=false;
end
else txt:=','+StrFunW(bajt);
end
end else
if litera then txt:=char(bajt) else
begin
litera:=true;
if nic then
begin
txt:=#39+char(bajt);
nic:=false;
end else txt:=','#39+char(bajt);
end;
if off=maxoffset then d1:=0 else
begin
Inc(off);
Dec(d1);
end;
linia:=linia+txt;
if (Length(linia)>72) or (d1=0) then
begin
if litera then Writeln(wy,linia,#39) else Writeln(wy,linia);
linia:=' db ';
litera:=false;
nic:=true;
end;
until d1=0;
Close(wy);
DestroyWindow(Info);
OdrysujWszystkie;
end;
procedure WczytajAutoEPROM(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure WczytajEPROM(Okno:HWnd);
const DefExt = 'bin';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(21));
StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoEPROM(Okno,FileName,true);
end;
procedure WczytajAutoEPROM(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
Plik:string;
code,b:integer;
off:word;
Info:HWnd;
d1:longint;
we:file;
begin
Plik:=StrPas(nazwa);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
Assign(we,Plik);
{$I-} Reset(we,1); {$I+}
if IOResult<>0 then Exit;
Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
if longint(off)+FileSize(we)>65536 then d1:=65536-off else d1:=FileSize(we);
BlockRead(we,Mem[selROM:off],d1,code);
Close(we);
DestroyWindow(Info);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'E');
end;
procedure ZapiszEPROM(Okno:HWnd);
const DefExt = 'bin';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik:string;
Info:HWnd;
code,b:integer;
off,dlug:word;
d1:longint;
bajt:byte;
wy:file;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(21));
StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if code<>0 then Exit;
if dlug=0 then Exit;
if adrost then dlug:=dlug-off+1;
Assign(wy,Plik);
{$I-} Rewrite(wy,1); {$I+}
if IOResult<>0 then Exit;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
if longint(off)+dlug>65536 then d1:=65536-off else d1:=dlug;
BlockWrite(wy,Mem[selROM:off],d1,code);
Close(wy);
DestroyWindow(Info);
DodajDoListyPlikow(FileName,'E');
OdrysujWszystkie;
end;
procedure WczytajAutoEPROMhex(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure WczytajEPROMhex(Okno:HWnd);
const DefExt = 'hex';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,0);
FillChar(Filter,24,0);
StrCopy(Filter,Napis1(22));
StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
FillChar(OpenFN,SizeOf(TOpenFileName),0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoEPROMhex(Okno,FileName,true);
end;
procedure WczytajAutoEPROMhex(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
Info:HWnd;
Plik,linia:string;
off,radr:word;
bajt,rlen,rtyp,x,n:byte;
we:text;
begin
Plik:=StrPas(nazwa);
Assign(we,Plik);
{$I-} Reset(we); {$I+}
if IOResult<>0 then Exit;
rtyp:=0;
off:=65535;
Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
repeat
Readln(we,linia);
if linia[1]=':' then
begin
rlen:=HEXtoB(Copy(linia,2,2));
radr:=HEXtoW(Copy(linia,4,4));
rtyp:=HEXtoB(Copy(linia,8,2));
if off=65535 then off:=radr;
if rtyp=0 then
begin
x:=10;
for n:=1 to rlen do
begin
bajt:=HEXtoB(Copy(linia,x,2));
Mem[selROM:radr]:=bajt;
Inc(x,2);
Inc(radr);
end;
end;
end;
until (rtyp=1) or Eof(we);
Close(we);
DestroyWindow(Info);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'H');
end;
procedure ZapiszEPROMhex(Okno:HWnd);
const DefExt = 'hex';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik:string;
linia:string[80];
Info:HWnd;
off,radr:word;
d1,dlug:longint;
b,code:integer;
rsum,rlen,n:byte;
wy:text;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(22));
StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if code<>0 then Exit;
if dlug=0 then Exit;
if adrost then dlug:=dlug-off+1;
Assign(wy,Plik);
{$I-} Rewrite(wy); {$I+}
if IOResult<>0 then Exit;
if longint(off)+dlug>65536 then d1:=65536-off else d1:=dlug;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
radr:=off;
repeat
rsum:=0;
if d1>32 then rlen:=32 else rlen:=d1;
linia:=':'+BtoHEX(rlen)+WtoHEX(radr)+'00';
for n:=0 to rlen-1 do
begin
linia:=linia+BtoHEX(Mem[selROM:radr]);
rsum:=rsum+Mem[selROM:radr];
Inc(radr);
Dec(d1);
end;
linia:=linia+BtoHEX(byte(0)-rsum);
Writeln(wy,linia);
until d1=0;
Writeln(wy,':00000001FF');
Close(wy);
DestroyWindow(Info);
DodajDoListyPlikow(FileName,'H');
OdrysujWszystkie;
end;
procedure ZapiszEPROMdeasm(Okno:HWnd);
const DefExt = 'asm';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik:String;
Info:HWnd;
adr,off,dlug,koniec,x,aktadresnr,ileadresow:word;
b,code:integer;
bajt,y,z:byte;
wy:text;
mnem,mnem1:KodRozk;
TablicaAdresow:PWordArr;
function JestTakiAdres(jaki:word):boolean;
var l:word;
begin
JestTakiAdres:=true;
if ileadresow>0 then
for l:=0 to ileadresow-1 do
if TablicaAdresow^[l]=jaki then Exit;
JestTakiAdres:=false;
end;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(83));
StrCopy(@Filter[StrLen(Filter)+1],'*.asm');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if (code<>0) or (dlug=0) then Exit;
if adrost then koniec:=dlug else
if longint(off)+dlug>65535 then koniec:=65535 else koniec:=off+dlug-1;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
GetMem(TablicaAdresow,65520);
aktadresnr:=0;
x:=off;
while (x<=koniec) do
begin
if Mem[selROM:x] IN [1,2,$10,$11,$12,$20,$21,$30,$31,$40,$41,$50,$51,$60,$61,$70,$71,$80,
$81,$91,$A1,$B1,$B4..$BF,$C1,$D1,$D5,$D8..$DF,$E1,$F1] then
begin
mnem:=Deasm(x);
TablicaAdresow^[aktadresnr]:=HEXtoW(Copy(mnem,Length(mnem)-4,4));
Inc(aktadresnr);
end;
y:=TabIleBajtow[bajt];
if longint(x)+y>koniec then break else Inc(x,y);
end;
ileadresow:=aktadresnr;
Assign(wy,Plik);
{$I-} Rewrite(wy); {$I+}
if IOResult<>0 then Exit;
Writeln(wy,'$MOD51'#13#10#13#10' org ',WtoHEX(off),'h'#13#10);
x:=off;
while (x<=koniec) do
begin
if JestTakiAdres(x) then Writeln(wy,'l_',LoCaseStr(WtoHEX(x)),':');
bajt:=Mem[selROM:x];
mnem:=Deasm(x);
y:=byte(mnem[1]);
if (mnem[Length(mnem)]='H') and
(mnem[Length(mnem)-1] IN ['0'..'9','A'..'F']) and
(mnem[Length(mnem)-2] IN ['0'..'9','A'..'F']) and
(mnem[Length(mnem)-3] IN ['0'..'9','A'..'F']) and
(mnem[Length(mnem)-4] IN ['0'..'9','A'..'F']) and
(Pos('DPTR,',mnem)=0) then {to jest rozkaz skoku}
mnem:=Copy(mnem,1,Length(mnem)-5)+'l_'+Copy(mnem,Length(mnem)-4,4);
Delete(mnem,1,1);
mnem:=LoCaseStr(mnem);
z:=Pos(#9,mnem);
if z=0 then Writeln(wy,' ',mnem) else
begin
mnem1:=Copy(mnem,1,z-1);
Delete(mnem,1,z);
Writeln(wy,' ',mnem1,Copy(' ',1,8-z),mnem);
end;
if longint(x)+y>koniec then break else Inc(x,y);
end;
Writeln(wy,#13#10'END');
Close(wy);
FreeMem(TablicaAdresow,65520);
DestroyWindow(Info);
OdrysujWszystkie;
end;
procedure WczytajAutoRAM(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure WczytajRAM(Okno:HWnd);
const DefExt = 'bin';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(24));
StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoRAM(Okno,FileName,true);
end;
procedure WczytajAutoRAM(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
Plik:string;
Info:HWnd;
code,b:integer;
d1:longint;
off:word;
we:file;
begin
Plik:=StrPas(nazwa);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
Assign(we,Plik);
{$I-} Reset(we,1); {$I+}
if IOResult<>0 then Exit;
Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
if longint(off)+FileSize(we)>65536 then d1:=65536-off else d1:=FileSize(we);
BlockRead(we,Mem[selRAM:off],d1,code);
Close(we);
DestroyWindow(Info);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'R');
end;
procedure ZapiszRAM(Okno:HWnd);
const DefExt = 'bin';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik:string;
Info:HWnd;
code,b:integer;
off,dlug:word;
d1:longint;
bajt:byte;
wy:file;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(24));
StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if code<>0 then Exit;
if dlug=0 then Exit;
if adrost then dlug:=dlug-off+1;
Assign(wy,Plik);
{$I-} Rewrite(wy,1); {$I+}
if IOResult<>0 then Exit;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
if longint(off)+dlug>65536 then d1:=65536-off else d1:=dlug;
BlockWrite(wy,Mem[selRAM:off],d1,code);
Close(wy);
DestroyWindow(Info);
DodajDoListyPlikow(FileName,'R');
OdrysujWszystkie;
end;
procedure WczytajAutoRAMhex(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure WczytajRAMhex(Okno:HWnd);
const DefExt = 'hex';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,0);
FillChar(Filter,24,0);
StrCopy(Filter,Napis1(22));
StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
FillChar(OpenFN,SizeOf(TOpenFileName),0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoRAMhex(Okno,FileName,true);
end;
procedure WczytajAutoRAMhex(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
Info:HWnd;
Plik,linia:string;
off,radr:word;
bajt,rlen,rtyp,x,n:byte;
we:text;
begin
Plik:=StrPas(nazwa);
Assign(we,Plik);
{$I-} Reset(we); {$I+}
if IOResult<>0 then Exit;
rtyp:=0;
off:=65535;
Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
repeat
Readln(we,linia);
if linia[1]=':' then
begin
rlen:=HEXtoB(Copy(linia,2,2));
radr:=HEXtoW(Copy(linia,4,4));
rtyp:=HEXtoB(Copy(linia,8,2));
if off=65535 then off:=radr;
if rtyp=0 then
begin
x:=10;
for n:=1 to rlen do
begin
bajt:=HEXtoB(Copy(linia,x,2));
Mem[selRAM:radr]:=bajt;
Inc(x,2);
Inc(radr);
end;
end;
end;
until (rtyp=1) or Eof(we);
Close(we);
DestroyWindow(Info);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'A');
end;
procedure ZapiszRAMhex(Okno:HWnd);
const DefExt = 'hex';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik:string;
linia:string[80];
Info:HWnd;
off,radr:word;
d1,dlug:longint;
b,code:integer;
rsum,rlen,n:byte;
wy:text;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(22));
StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if code<>0 then Exit;
if dlug=0 then Exit;
if adrost then dlug:=dlug-off+1;
Assign(wy,Plik);
{$I-} Rewrite(wy); {$I+}
if IOResult<>0 then Exit;
if longint(off)+dlug>65536 then d1:=65536-off else d1:=dlug;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
radr:=off;
repeat
rsum:=0;
if d1>32 then rlen:=32 else rlen:=d1;
linia:=':'+BtoHEX(rlen)+WtoHEX(radr)+'00';
for n:=0 to rlen-1 do
begin
linia:=linia+BtoHEX(Mem[selRAM:radr]);
rsum:=rsum+Mem[selRAM:radr];
Inc(radr);
Dec(d1);
end;
linia:=linia+BtoHEX(byte(0)-rsum);
Writeln(wy,linia);
until d1=0;
Writeln(wy,':00000001FF');
Close(wy);
DestroyWindow(Info);
DodajDoListyPlikow(FileName,'A');
OdrysujWszystkie;
end;
procedure WczytajAutoRAMInt(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure WczytajRAMInt(Okno:HWnd);
const DefExt = 'bin';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(24));
StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoRAMInt(Okno,FileName,true);
end;
procedure WczytajAutoRAMInt(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
Plik:string;
Info:HWnd;
code,b:integer;
d1:longint;
off:word;
we:file;
begin
Plik:=StrPas(nazwa);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
if off>255 then
begin
MessageBeep(mb_IconHand);
BWCCMessageBox(0,Napis1(25),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
Exit;
end;
Assign(we,Plik);
{$I-} Reset(we,1); {$I+}
if IOResult<>0 then Exit;
Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
if longint(off)+FileSize(we)>256 then d1:=256-off else d1:=FileSize(we);
BlockRead(we,Mem[selRAMInt:off],d1,code);
Close(we);
DestroyWindow(Info);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'I');
end;
procedure ZapiszRAMInt(Okno:HWnd);
const DefExt = 'bin';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik:string;
Info:HWnd;
code,b:integer;
off,dlug:word;
d1:longint;
bajt:byte;
wy:file;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(24));
StrCopy(@Filter[StrLen(Filter)+1],'*.bin');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
if off>255 then
begin
MessageBeep(mb_IconHand);
BWCCMessageBox(0,Napis1(25),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
Exit;
end;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if code<>0 then Exit;
if dlug=0 then Exit;
if adrost then dlug:=dlug-off+1;
Assign(wy,Plik);
{$I-} Rewrite(wy,1); {$I+}
if IOResult<>0 then Exit;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
if longint(off)+dlug>256 then d1:=256-off else d1:=dlug;
BlockWrite(wy,Mem[selRAMInt:off],d1,code);
Close(wy);
DestroyWindow(Info);
DodajDoListyPlikow(FileName,'I');
OdrysujWszystkie;
end;
procedure WczytajAutoRAMInthex(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure WczytajRAMInthex(Okno:HWnd);
const DefExt = 'hex';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,0);
FillChar(Filter,24,0);
StrCopy(Filter,Napis1(22));
StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
FillChar(OpenFN,SizeOf(TOpenFileName),0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoRAMInthex(Okno,FileName,true);
end;
procedure WczytajAutoRAMInthex(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
Info:HWnd;
Plik,linia:string;
off,radr:word;
bajt,rlen,rtyp,x,n:byte;
we:text;
begin
Plik:=StrPas(nazwa);
Assign(we,Plik);
{$I-} Reset(we); {$I+}
if IOResult<>0 then Exit;
rtyp:=0;
off:=65535;
Info:=CreateDialog(hInstance,Dial('CZYTAM'),Okno,nil);
repeat
Readln(we,linia);
if linia[1]=':' then
begin
rlen:=HEXtoB(Copy(linia,2,2));
radr:=HEXtoW(Copy(linia,4,4));
rtyp:=HEXtoB(Copy(linia,8,2));
if off=65535 then off:=radr;
if rtyp=0 then
begin
x:=10;
for n:=1 to rlen do
begin
bajt:=HEXtoB(Copy(linia,x,2));
Mem[selRAMInt:Lo(radr)]:=bajt;
Inc(x,2);
Inc(radr);
end;
end;
end;
until (rtyp=1) or Eof(we);
Close(we);
DestroyWindow(Info);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'N');
end;
procedure ZapiszRAMInthex(Okno:HWnd);
const DefExt = 'hex';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
Plik:string;
linia:string[80];
Info:HWnd;
off,dlug,radr:word;
b,code:integer;
rsum,rlen,n:byte;
wy:text;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(22));
StrCopy(@Filter[StrLen(Filter)+1],'*.hex');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
b:=PokazDialog('OFFSET',@FunOffset);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,off,code);
if code<>0 then Exit;
if off>255 then
begin
MessageBeep(mb_IconHand);
BWCCMessageBox(0,Napis1(25),Napis2(2),mb_OK or mb_TaskModal or mb_IconExclamation);
Exit;
end;
b:=PokazDialog('DLUGOSC',@FunDlugosc);
if b<>1 then Exit;
if (Length(wynik)>4) or (wynik='') then Exit;
Val('$'+wynik,dlug,code);
if code<>0 then Exit;
if dlug=0 then Exit;
if adrost then dlug:=dlug-off+1;
Assign(wy,Plik);
{$I-} Rewrite(wy); {$I+}
if IOResult<>0 then Exit;
if off+dlug>256 then dlug:=256-off;
Info:=CreateDialog(hInstance,Dial('ZAPISUJE'),Okno,nil);
radr:=off;
repeat
rsum:=0;
if dlug>32 then rlen:=32 else rlen:=dlug;
linia:=':'+BtoHEX(rlen)+WtoHEX(radr)+'00';
for n:=0 to rlen-1 do
begin
linia:=linia+BtoHEX(Mem[selRAMInt:radr]);
rsum:=rsum+Mem[selRAMInt:radr];
Inc(radr);
Dec(dlug);
end;
linia:=linia+BtoHEX(byte(0)-rsum);
Writeln(wy,linia);
until dlug=0;
Writeln(wy,':00000001FF');
Close(wy);
DestroyWindow(Info);
DodajDoListyPlikow(FileName,'N');
OdrysujWszystkie;
end;
procedure WczytajAutoSymb(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure SymbWczytaj(Okno:HWnd);
const DefExt = 'sym';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(23));
StrCopy(@Filter[StrLen(Filter)+1],'*.sym');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoSymb(Okno,FileName,true);
end;
procedure WczytajAutoSymb(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
txt:array[0..63] of char;
Plik,linia:string;
we:text;
begin
Plik:=StrPas(nazwa);
Assign(we,Plik);
{$I-} Reset(we); {$I+}
if IOResult<>0 then Exit;
SymbROM^.DeleteAll;
repeat
Readln(we,linia);
if linia<>'*' then SymbROM^.Insert(StrNew(StrPCopy(txt,linia)));
until linia='*';
SymbRAM^.DeleteAll;
repeat
Readln(we,linia);
if linia<>'*' then SymbRAM^.Insert(StrNew(StrPCopy(txt,linia)));
until linia='*';
SymbReg^.DeleteAll;
repeat
Readln(we,linia);
if linia<>'*' then SymbReg^.Insert(StrNew(StrPCopy(txt,linia)));
until linia='*';
SymbBit^.DeleteAll;
repeat
Readln(we,linia);
if linia<>'' then SymbBit^.Insert(StrNew(StrPCopy(txt,linia)));
until Eof(we);
Close(we);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'S');
end;
procedure SymbZapisz(Okno:HWnd);
const DefExt = 'sym';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
txt:array[0..63] of char;
Plik:string;
wy:text;
n:integer;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(23));
StrCopy(@Filter[StrLen(Filter)+1],'*.sym');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
Assign(wy,Plik);
{$I-} Rewrite(wy); {$I+}
if IOResult<>0 then Exit;
if SymbROM^.Count>0 then
for n:=0 to SymbROM^.Count-1 do
begin
StrCopy(txt,SymbROM^.At(n));
Writeln(wy,StrPas(txt));
end;
Writeln(wy,'*');
if SymbRAM^.Count>0 then
for n:=0 to SymbRAM^.Count-1 do
begin
StrCopy(txt,SymbRAM^.At(n));
Writeln(wy,StrPas(txt));
end;
Writeln(wy,'*');
if SymbReg^.Count>0 then
for n:=0 to SymbReg^.Count-1 do
begin
StrCopy(txt,SymbReg^.At(n));
Writeln(wy,StrPas(txt));
end;
Writeln(wy,'*');
if SymbBit^.Count>0 then
for n:=0 to SymbBit^.Count-1 do
begin
StrCopy(txt,SymbBit^.At(n));
Writeln(wy,StrPas(txt));
end;
Close(wy);
DodajDoListyPlikow(FileName,'S');
OdrysujWszystkie;
end;
(*** zmienne używane przez Fun_PoKolei oraz ZapiszRozm ***)
var
d,f:array[0..63] of char;
e:array[0..7] of char;
numer:integer;
tmp:string[64];
(*** zmienne używane przez Fun_PoKolei oraz ZapiszRozm ***)
function Fun_PoKolei(Okno:HWnd;LParam:longint):Bool; EXPORT;
var
R:TRect;
co:PChar;
begin
Fun_PoKolei:=true;
if GetParent(Okno)<>Klient then Exit;
e[0]:='n';
StrPCopy(e+1,StrFunI(numer));
tmp:=StrFunI(GetWindowWord(Okno,0)); {typ okienka}
if GetWindowWord(Okno,2)=0 then {0-nieaktywne, 1-aktywne}
tmp:=tmp+'-' else tmp:=tmp+'+';
GetWindowRect(Okno,R);
tmp:=tmp+':'+StrFunI(R.left)+','+StrFunI(R.top)+','+
StrFunI(R.right-R.left)+','+StrFunI(R.bottom-R.top);
StrPCopy(f,tmp);
(*
buforzn3[0]:=#0;
co:=PChar(SendMessage(Okno,wm_Command,us_GetWinInfo,0));
if buforzn3[0]<>#0 then
begin
StrCat(f,':');
StrCat(f,buforzn3);
end;
*)
WritePrivateProfileString('Windows',e,f,d);
Inc(numer);
end;
procedure ZapiszRozm(Okno:HWnd);
var
p:array[0..63] of char;
a:TFarProc;
i:word;
begin
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
numer:=GetPrivateProfileInt('Windows','n',0,d);
e[0]:='n';
if numer>0 then
for i:=0 to numer-1 do
begin
StrPCopy(@e[1],StrFunI(i));
WritePrivateProfileString('Windows',e,nil,d);
end;
numer:=0;
a:=MakeProcInstance(@Fun_PoKolei,hInstance);
EnumChildWindows(Klient,a,0);
FreeProcInstance(a);
StrPCopy(e,StrFunI(numer));
WritePrivateProfileString('Windows','n',e,d);
end;
procedure WczytajRozm(Okno:HWnd);
const
MDICreate:TMDICreateStruct=(
szClass : nil;
szTitle : '';
hOwner : 0;
x : cw_UseDefault;
y : cw_UseDefault;
cx : cw_UseDefault;
cy : cw_UseDefault;
style : 0;
LParam : 0);
var
p,d,f:array[0..63] of char;
e:array[0..7] of char;
numer,i:integer;
l:byte;
tmp:string[64];
typ:word;
pt1,pt2:TPoint;
okn:HWnd;
aktyw:char;
begin
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
numer:=GetPrivateProfileInt('Windows','n',-1,d);
if numer=-1 then
begin
MessageBeep(mb_IconHand);
Exit;
end;
DoWszystkich(255,wm_Close,0,0);
if numer=0 then
begin
ListaOkien;
Exit;
end;
for i:=numer-1 downto 0 do
begin
e[0]:='n';
StrPCopy(@e[1],StrFunI(i));
GetPrivateProfileString('Windows',e,'',f,63,d);
tmp:=StrPas(f);
l:=Pos(':',tmp);
if tmp[l-1]='-' then aktyw:='0' else aktyw:='1';
typ:=ValFunI(Copy(tmp,1,l-2));
Delete(tmp,1,l);
l:=Pos(',',tmp);
pt1.x:=ValFunI(Copy(tmp,1,l-1));
Delete(tmp,1,l);
l:=Pos(',',tmp);
pt1.y:=ValFunI(Copy(tmp,1,l-1));
Delete(tmp,1,l);
l:=Pos(',',tmp);
pt2.x:=ValFunI(Copy(tmp,1,l-1));
pt2.y:=ValFunI(Copy(tmp,l+1,255));
ScreenToClient(Klient,pt1);
with MDICreate do
begin
hOwner:=hInstance;
szTitle:=Napis1(typ+26);
LParam:=typ;
x:=pt1.x; y:=pt1.y;
cx:=pt2.x; cy:=pt2.y;
StrCopy(buforzn2,'DBGMDICL1');
buforzn2[8]:=aktyw;
szClass:=@buforzn2;
end;
SendMessage(Klient,wm_MDICreate,0,longint(@MDICreate));
end;
OdrysujWszystkie;
PostMessage(OknoGlowne,wm_Command,us_ListaOkien,0);
end;
procedure WczytajAutoPula(Okno:HWnd;nazwa:PChar;dodac:boolean); forward;
procedure WczytajPula(Okno:HWnd);
const DefExt = 'brk';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(70));
StrCopy(@Filter[StrLen(Filter)+1],'*.brk');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_FileMustExist or ofn_HideReadOnly;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetOpenFileName(OpenFN) then Exit;
WczytajAutoPula(Okno,FileName,true);
end;
procedure WczytajAutoPula(Okno:HWnd;nazwa:PChar;dodac:boolean);
var
txt:array[0..63] of char;
Plik,linia:string;
we:text;
begin
Plik:=StrPas(nazwa);
Assign(we,Plik);
{$I-} Reset(we); {$I+}
if IOResult<>0 then Exit;
SymbBrk^.DeleteAll;
repeat
Readln(we,linia);
SymbBrk^.Insert(StrNew(StrPCopy(txt,linia)));
until Eof(we);
Close(we);
OdrysujWszystkie;
if dodac then DodajDoListyPlikow(nazwa,'P');
end;
procedure ZapiszPula(Okno:HWnd);
const DefExt = 'brk';
var
OpenFN:TOpenFileName;
Filter:array [0..23] of char;
FileName:array [0..255] of char;
txt:array[0..63] of char;
Plik:string;
wy:text;
n:integer;
begin
FillChar(FileName,256,#0);
FillChar(Filter,24,#0);
StrCopy(Filter,Napis1(70));
StrCopy(@Filter[StrLen(Filter)+1],'*.brk');
FillChar(OpenFN,SizeOf(TOpenFileName),#0);
with OpenFN do
begin
hInstance := HInstance;
hwndOwner := Okno;
lpstrDefExt := DefExt;
lpstrFile := FileName;
lpstrFilter := Filter;
lpstrFileTitle:= nil;
flags := ofn_PathMustExist or ofn_HideReadOnly or ofn_OverwritePrompt;
lStructSize := SizeOf(TOpenFileName);
nFilterIndex := 1;
nMaxFile := SizeOf(FileName);
end;
if not GetSaveFileName(OpenFN) then Exit else Plik:=StrPas(FileName);
Assign(wy,Plik);
{$I-} Rewrite(wy); {$I+}
if IOResult<>0 then Exit;
if SymbBrk^.Count>0 then
for n:=0 to SymbBrk^.Count-1 do
begin
StrCopy(txt,SymbBrk^.At(n));
Writeln(wy,StrPas(txt));
end;
Close(wy);
DodajDoListyPlikow(FileName,'P');
OdrysujWszystkie;
end;
procedure WczytajAutomat(Okno:HWnd;numer:byte);
var
p,d:array[0..63] of char;
numr:array[0..1] of char;
begin
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
numr[0]:=char(numer+48);
numr[1]:=#0;
GetPrivateProfileString('LastFiles',numr,'',p,61,d);
case UpCase(p[0]) of
#0: Exit;
'E': WczytajAutoEPROM(Okno,@p[2],false);
'H': WczytajAutoEPROMhex(Okno,@p[2],false);
'R': WczytajAutoRAM(Okno,@p[2],false);
'A': WczytajAutoRAMhex(Okno,@p[2],false);
'I': WczytajAutoRAMInt(Okno,@p[2],false);
'N': WczytajAutoRAMInthex(Okno,@p[2],false);
'S': WczytajAutoSymb(Okno,@p[2],false);
'P': WczytajAutoPula(Okno,@p[2],false);
end;
end;
procedure WczytajListePlikow;
var
m1,m2:HMenu;
n:word;
typ:char;
p,d:array[0..63] of char;
numr:array[0..1] of char;
dod:boolean;
const ListaTypow='EHRAINSP'; { dostępne typy plików: patrz niżej }
begin
m1:=GetSubMenu(MenuGlownePL,0);
m2:=GetSubMenu(MenuGlowneEN,0);
for n:=us_PlikNr1 to us_PlikNr1+7 do
begin
DeleteMenu(m1,n,MF_BYCOMMAND);
DeleteMenu(m2,n,MF_BYCOMMAND);
end;
DeleteMenu(m1,9,MF_BYPOSITION);
DeleteMenu(m2,9,MF_BYPOSITION);
dod:=false;
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
numr[1]:=#0;
for n:=1 to 8 do
begin
numr[0]:=char(n+48);
GetPrivateProfileString('LastFiles',numr,'',@p[2],61,d);
if p[2]<>#0 then
begin
typ:=UpCase(p[2]);
p[0]:='&';
p[1]:=numr[0];
p[2]:=' ';
p[3]:=' ';
StrCat(p,#9#0);
StrCat(p,Napis1(Pos(typ,ListaTypow)+73));
AppendMenu(m1,MF_STRING,us_PlikNr1+n-1,p);
AppendMenu(m2,MF_STRING,us_PlikNr1+n-1,p);
dod:=true;
end;
end;
if dod then
begin
InsertMenu(m1,9,MF_BYPOSITION or MF_SEPARATOR,0,nil);
InsertMenu(m2,9,MF_BYPOSITION or MF_SEPARATOR,0,nil);
end;
end;
procedure DodajDoListyPlikow(nazwa:PChar;typ:char);
var
n:word; { lista typów: }
numr:array[0..1] of char; { E - EPROM bin }
txt,p,d:array[0..63] of char; { H - EPROM hex }
begin { R - RAM bin }
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil); { A - RAM hex }
StrCat(d,'DBG8051.INI'); { I - RAM Int bin }
numr[1]:=#0; { N - RAM Int hex }
StrCopy(@txt[2],nazwa); { S - symbole }
txt[0]:=UpCase(typ); { P - pułapki }
txt[1]:=',';
for n:=1 to 8 do
begin
numr[0]:=char(n+48);
GetPrivateProfileString('LastFiles',numr,'',p,63,d);
if StrComp(p,txt)=0 then Exit; { plik juz jest na liscie }
end;
for n:=2 to 8 do
begin
numr[0]:=char(n+48);
GetPrivateProfileString('LastFiles',numr,'',p,63,d);
numr[0]:=char(n+47);
WritePrivateProfileString('LastFiles',numr,p,d);
end;
WritePrivateProfileString('LastFiles','8',txt,d);
WczytajListePlikow;
end;
procedure WyczyscListePlikow;
var
m1,m2:HMenu;
n:word;
p,d:array[0..63] of char;
numr:array[0..1] of char;
begin
m1:=GetSubMenu(MenuGlownePL,0);
m2:=GetSubMenu(MenuGlowneEN,0);
for n:=us_PlikNr1 to us_PlikNr1+7 do
begin
DeleteMenu(m1,n,MF_BYCOMMAND);
DeleteMenu(m2,n,MF_BYCOMMAND);
end;
DeleteMenu(m1,9,MF_BYPOSITION);
DeleteMenu(m2,9,MF_BYPOSITION);
FileSplit(StrPCopy(p,ParamStr(0)),d,nil,nil);
StrCat(d,'DBG8051.INI');
numr[1]:=#0;
for n:=1 to 8 do
begin
numr[0]:=char(n+48);
WritePrivateProfileString('LastFiles',numr,nil,d);
end;
end;
end.