unit modul_image;

{$mode objfpc}{$H+}

interface

uses
  SysUtils,
  GlobalConst,
  GPIO,
  GlobalConfig,
  Platform,
  wincpm;




type


  Tmod_image = class(TObject)

    constructor Create; overload;
    destructor Destroy; override;

  private
    Datei_Zeiger : LongInt;

  public

    procedure Spur_und_Sektor_in_Datei_Zeiger(V_TRACK, V_SECTOR, V_DISKNO : Integer);
    procedure Read_IMAGE_Sektor;
    procedure Write_IMAGE_Sektor;
    procedure Save_Files;

  end; // Tmod_image = class(TObject)



var
  mod_image : Tmod_image;




implementation


uses
  modul_itp3;



constructor Tmod_image.Create;
begin
  inherited Create;

  // IMAGE
  wcpm_Drive := Twcpm.Create('C:\DRIVE');
  wcpm_Drive.load_dpb_FormatE_8MB;
  wcpm_Drive.Import_Files_To_Image;

end; { constructor Tmod_image.Create }




//
procedure Tmod_image.Spur_und_Sektor_in_Datei_Zeiger(V_TRACK, V_SECTOR, V_DISKNO : Integer);
begin

  Datei_Zeiger:=V_TRACK*wcpm_Drive.DPB.SPT;
  Datei_Zeiger:=Datei_Zeiger+V_SECTOR;
  Datei_Zeiger:=Datei_Zeiger*128;

end; { procedure Tmod_image.Spur_und_Sektor_in_Datei_Zeiger }








procedure Tmod_image.Read_IMAGE_Sektor;
var
  B_Zaehler : Integer;
  DATA_Byte : Byte;

begin

  mod_itp3.LED_READ_ein;

  wcpm_Drive.IMG_File.Position:=Datei_Zeiger;

  for B_Zaehler:=0 to 127 do begin
    wcpm_Drive.IMG_File.Read(DATA_Byte,1);
    mod_itp3.ITP3_Byte_ausgeben(DATA_Byte);
  end; { for B_Zaehler:=0 to 127 do }

end; { procedure Tmod_image.Read_IMAGE_Sektor }













procedure Tmod_image.Write_IMAGE_Sektor;
var
  B_Zaehler : Integer;
  DATA_Byte : Byte;

begin

  mod_itp3.LED_WRITE_ein;

  wcpm_Drive.IMG_File.Position:=Datei_Zeiger;

  for B_Zaehler:=0 to 127 do begin
    DATA_Byte:=mod_itp3.ITP3_Byte_einlesen;
    wcpm_Drive.IMG_File.Write(DATA_Byte,1);
  end; { for B_Zaehler:=0 to 127 do }

end; { procedure Tmod_image.Write_IMAGE_Sektor }







procedure Tmod_image.Save_Files;
var
  B_Zaehler : Integer;
  DATA_Byte : Byte;

begin

  wcpm_Drive.Export_Files_From_Image;

end; { procedure Tmod_image.Save_Files }






destructor Tmod_image.Destroy;
begin

  inherited Destroy;
end; { destructor Tmod_image.Destroy }





end.

