Changeset 438 for trunk/CmdList.pas
- Timestamp:
- May 18, 2022, 11:12:29 AM (2 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/CmdList.pas
r355 r438 5 5 6 6 uses 7 Classes ;7 Classes, SysUtils, Math; 8 8 9 9 const 10 10 MaxDataSize = 1024; 11 CommandDataElementSize = 4; 12 CommandDataElementCountMask = $f; 13 CommandDataMaxSize = CommandDataElementSize * CommandDataElementCountMask; 11 14 12 15 type … … 44 47 end; 45 48 49 function CommandWithData(Command: Integer; DataSize: Byte): Integer; 50 51 resourcestring 52 SCommandDataSizeError = 'Command data size %d out of range (0-%d).'; 53 54 46 55 implementation 47 56 … … 55 64 TData = array [0 .. MaxDataSize - 1] of Cardinal; 56 65 PData = ^TData; 66 67 function CommandWithData(Command: Integer; DataSize: Byte): Integer; 68 var 69 DataElementCount: Byte; 70 begin 71 if DataSize > CommandDataMaxSize then 72 raise Exception.Create(Format(SCommandDataSizeError, [DataSize, CommandDataMaxSize])); 73 DataElementCount := Ceil(DataSize / CommandDataElementSize); 74 Result := Command or (DataElementCount and CommandDataElementCountMask); 75 end; 57 76 58 77 constructor TCmdList.Create; … … 139 158 end; 140 159 141 if Command and $F= 0 then160 if Command and CommandDataElementCountMask = 0 then 142 161 Data := nil 143 162 else 144 163 begin 145 164 Data := @LogData[FState.LoadPos]; 146 inc(FState.LoadPos, Command and $F * 4);165 inc(FState.LoadPos, Command and CommandDataElementCountMask * CommandDataElementSize); 147 166 end; 148 167 end; … … 232 251 end; 233 252 end; 234 if Command and $F<> 0 then235 PutData(Data, Command and $F * 4);253 if Command and CommandDataElementCountMask <> 0 then 254 PutData(Data, Command and CommandDataElementCountMask * CommandDataElementSize); 236 255 end; 237 256
Note:
See TracChangeset
for help on using the changeset viewer.