home *** CD-ROM | disk | FTP | other *** search
/ CP/M / CPM_CDROM.iso / mbug / mbug094.arc / DISPSECT.PRO < prev    next >
Text File  |  1979-12-31  |  2KB  |  80 lines

  1.  
  2.  
  3. {This will display a sector
  4.    **** SectorBuff is a type = array [0..127] of byte }
  5.  
  6. Procedure DisplaySector(Var Sector:SectorBuff);
  7. var
  8.    ch     :char;
  9.    count :integer;
  10.    x:integer;
  11. const
  12.    InvB:string[2]=#27')';
  13.    InvE:string[2]=#27'(';{begin and end inverse}
  14.    CR  :string[2]=#13#10;
  15.  
  16.  
  17. Function Hex(x:byte) :char;
  18. Var
  19.    HexDigit:String[1];
  20.  
  21. begin
  22.   if x<10 then str(x,hexDigit) else hexDigit:= Chr(x+55);
  23.   Hex:=HexDigit;
  24. end;
  25.  
  26.  
  27. Procedure BytetoHex(byt:byte);
  28.  
  29. Var
  30.    HexDigit1,HexDigit2:Char;
  31.  
  32. begin
  33.    HexDigit1 := Hex(trunc(byt/16));
  34.    HexDigit2 := Hex(byt mod 16);
  35.    Write(HexDigit1,HexDigit2);
  36. end;
  37.  
  38. Procedure BytetoAscii(Byt:Byte);
  39.  
  40. Var
  41.    Ch:char;
  42.    Byt2:byte;
  43.    Highlight:Boolean;
  44. begin
  45.      Highlight:=False;
  46.  
  47.      If (Byt and $80) = $80 then begin
  48.                                Highlight:=True;
  49.                                Byt := $7F and Byt;
  50.                             end;
  51.      If NOT(Byt in [32..125]) then begin
  52.                                    Highlight:=False;
  53.                                    Byt := Ord('.');
  54.                                end;
  55.      If Highlight then lowvideo;
  56.      Write(Chr(Byt));
  57.      If Highlight then HighVideo;
  58.  end;
  59.  
  60. begin
  61.   Writeln;
  62.   writeln;
  63.   write('   ');
  64.   for x:=0 to 15 do write('  ',Hex(x));
  65.   write('   ');
  66.   for x:=0 to 15 do write(Hex(x));
  67.   writeln;
  68.   for count:=0 to 7 do begin
  69.       write(Hex(count),'0: ');
  70.       for x:=0 to 15 do
  71.           begin
  72.                BytetoHex(Sector[count*16+x]);
  73.                write(' ');
  74.           end;
  75.       Write('  ');
  76.       for x:=0 to 15 do BytetoAscii(Sector[count*16+x]);
  77.       Writeln;
  78.   end;
  79. end;
  80.