Einzelnen Beitrag anzeigen

Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
43.167 Beiträge
 
Delphi 12 Athens
 
#6

Re: Brauche mal Hilfe von einen C++ Spezi

  Alt 1. Mär 2010, 06:07
Ach menno, hatte mir diese Zahlen als Bit-Positionen gemerkt und nicht als Bit-Anzahl.

Wenn alles nur ein Bit groß wäre, dann ginge das mit dem SET.

Über ein SET ginge das dann nur noch so, aber dieses wäre umständlich zu nutzen.
Delphi-Quellcode:
X: Set of (characterPositionBit0, characterPositionBit1, characterPositionBit2,
           characterPositionBit3, blockBit0, blockBit1, blockBit2, bDBC);
OK, da der TE zum Glück mindestens ein D20006/TDE besitzt, kommt hier die ultimative Lösung:
Delphi-Quellcode:
type
  cdTextPackage = record
              packType: Byte;
              trackNumber: Byte;
              sequenceNumber: Byte;
  private
              _block: Byte;
    function GetCharPos: Byte;
    procedure SetCharPos (B: Byte);
    function GetBlock: Byte;
    procedure SetBlock (B: Byte);
    function GetDBC: Byte;
    procedure SetDBC (B: Byte);
  public
    property characterPosition: Byte read GetCharPos write SetCharPos;
    property block: Byte read GetBlock write SetBlock;
    property bDBC: Byte read GetDBC write SetDBC;
  public
              data: Array[0..11] of Byte;
              crc0: Byte;
              crc1: Byte;
  end;


function cdTextPackage.GetCharPos: Byte;
begin
  Result := _block and $0F;
end;

procedure cdTextPackage.SetCharPos(B: Byte);
begin
  _block := _block and $F0 or B and $0F;
end;

function cdTextPackage.GetBlock: Byte;
begin
  Result := (_block shr 4) and $07;
end;

procedure cdTextPackage.SetBlock(B: Byte);
begin
  _block := _block and $8F or (B shl 4) and $70;
end;

function cdTextPackage.GetDBC: Byte;
begin
  Result := (_block shr 7) and $01;
end;

procedure cdTextPackage.SetDBC(B: Byte);
begin
  _block := _block and $7F or (B shl 7) and $80;
end;
Garbage Collector ... Delphianer erzeugen keinen Müll, also brauchen sie auch keinen Müllsucher.
my Delphi wish list : BugReports/FeatureRequests
  Mit Zitat antworten Zitat