⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dbgpliki.pas

📁 Borland Pascal写的8051单片机模拟仿真器。内有源码
💻 PAS
📖 第 1 页 / 共 3 页
字号:
  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縴wane 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縴wane 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阷ne typy plik體: patrz ni縠j }
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體:    }
  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砤pki     }
  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.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -