|
@@ -77,8 +77,10 @@ interface
|
|
|
|
|
|
TOmfRawRecord = class
|
|
TOmfRawRecord = class
|
|
private
|
|
private
|
|
|
|
+ function GetChecksumByte: Byte;
|
|
function GetRecordLength: Word;
|
|
function GetRecordLength: Word;
|
|
function GetRecordType: Byte;
|
|
function GetRecordType: Byte;
|
|
|
|
+ procedure SetChecksumByte(AValue: Byte);
|
|
procedure SetRecordLength(AValue: Word);
|
|
procedure SetRecordLength(AValue: Word);
|
|
procedure SetRecordType(AValue: Byte);
|
|
procedure SetRecordType(AValue: Byte);
|
|
public
|
|
public
|
|
@@ -86,6 +88,10 @@ interface
|
|
property RecordType: Byte read GetRecordType write SetRecordType;
|
|
property RecordType: Byte read GetRecordType write SetRecordType;
|
|
property RecordLength: Word read GetRecordLength write SetRecordLength;
|
|
property RecordLength: Word read GetRecordLength write SetRecordLength;
|
|
|
|
|
|
|
|
+ procedure CalculateChecksumByte;
|
|
|
|
+ function VerifyChecksumByte: boolean;
|
|
|
|
+ property ChecksumByte: Byte read GetChecksumByte write SetChecksumByte;
|
|
|
|
+
|
|
procedure ReadFrom(aReader: TObjectReader);
|
|
procedure ReadFrom(aReader: TObjectReader);
|
|
procedure WriteTo(aWriter: TObjectWriter);
|
|
procedure WriteTo(aWriter: TObjectWriter);
|
|
end;
|
|
end;
|
|
@@ -115,6 +121,46 @@ implementation
|
|
RawData[-1]:=Byte(AValue shr 8);
|
|
RawData[-1]:=Byte(AValue shr 8);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
+ function TOmfRawRecord.GetChecksumByte: Byte;
|
|
|
|
+ begin
|
|
|
|
+ if RecordLength>0 then
|
|
|
|
+ Result:=RawData[RecordLength-1]
|
|
|
|
+ else
|
|
|
|
+ Result:=0;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ procedure TOmfRawRecord.SetChecksumByte(AValue: Byte);
|
|
|
|
+ begin
|
|
|
|
+ if RecordLength>0 then
|
|
|
|
+ RawData[RecordLength-1]:=AValue;
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ procedure TOmfRawRecord.CalculateChecksumByte;
|
|
|
|
+ var
|
|
|
|
+ I: Integer;
|
|
|
|
+ b: Byte;
|
|
|
|
+ begin
|
|
|
|
+ b:=0;
|
|
|
|
+ for I:=-3 to RecordLength-2 do
|
|
|
|
+ b:=byte(b+RawData[I]);
|
|
|
|
+ SetChecksumByte($100-b);
|
|
|
|
+ end;
|
|
|
|
+
|
|
|
|
+ function TOmfRawRecord.VerifyChecksumByte: boolean;
|
|
|
|
+ var
|
|
|
|
+ I: Integer;
|
|
|
|
+ b: Byte;
|
|
|
|
+ begin
|
|
|
|
+ { according to the OMF spec, some tools always write a 0 rather than
|
|
|
|
+ computing the checksum, so it should also be accepted as correct }
|
|
|
|
+ if ChecksumByte=0 then
|
|
|
|
+ exit(true);
|
|
|
|
+ b:=0;
|
|
|
|
+ for I:=-3 to RecordLength-1 do
|
|
|
|
+ b:=byte(b+RawData[I]);
|
|
|
|
+ Result:=(b=0);
|
|
|
|
+ end;
|
|
|
|
+
|
|
procedure TOmfRawRecord.ReadFrom(aReader: TObjectReader);
|
|
procedure TOmfRawRecord.ReadFrom(aReader: TObjectReader);
|
|
begin
|
|
begin
|
|
aReader.read(RawData, 3);
|
|
aReader.read(RawData, 3);
|