Skip to content

Replace some instances of manual work with endianness with cryptic oneliners.

This changes code like

RawRecord.RawData[NextOfs]:=Byte(ChunkStart);
RawRecord.RawData[NextOfs+1]:=Byte(ChunkStart shr 8);
RawRecord.RawData[NextOfs+2]:=Byte(ChunkStart shr 16);
RawRecord.RawData[NextOfs+3]:=Byte(ChunkStart shr 24);

to

unaligned(PUint32(@RawRecord.RawData[NextOfs{..NextOfs+3}])^):=NtoLE(uint32(ChunkStart));

and, conversely,

EnumeratedDataOffset := RawRec.RawData[NextOfs]+
                       (RawRec.RawData[NextOfs+1] shl 8)+
                       (RawRec.RawData[NextOfs+2] shl 16)+
                       (RawRec.RawData[NextOfs+3] shl 24);

to

EnumeratedDataOffset := LEtoN(unaligned(PUint32(@RawRec.RawData[NextOfs{..NextOfs+3}])^));

saving 140 lines of code, though not in width and mainly in the DOS-related units no one will ever see.

Patch: nton.patch.

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information