-
+ 50379B31ED9F6B3E63C7037DB679ADE8309A44C6B0510520288AFC535A8FFD55E006CC20A479374E992991116253625C588278B21B0E12C254AD035A64E57258
smg_comms/src/data_structs.ads
(0 . 0)(1 . 80)
204 -- Data structures for SMG Communication Protocol
205 -- S.MG, 2018
206
207 with Interfaces; -- for fixed-size types
208 with Raw_Types; -- for protocol raw types
209 with System; -- for Bit_Order
210 with Serpent; -- for Serpent.Key type
211
212 package Data_Structs is
213 Pragma Pure(Data_Structs);
214
215 -- an object in the world, with record layout fully specified
216 -- a storage element is 8-bit aka 1 octet
217 -- "at" gives number of storage element
218 -- "range" gives bits inside storage element
219
220 type SMG_Object is
221 record
222 -- ID of the object
223 ID : Interfaces.Unsigned_32;
224
225 -- Position of the object in the world.
226 -- For a world with map coordinates (MC) between -500 and +500,
227 -- the relationship with given figure (GF) is:
228 -- MC = GF / 65.535 - 500
229 -- where 65.535 comes from the mapping 65535 / (500 - - 500)
230 X, Y, Z : Interfaces.Integer_16;
231
232 -- Rotation of the object (RO) linked to GF by:
233 -- RO = GF / 128*pi
234 RX, RY, RZ : Interfaces.Unsigned_8;
235 end record;
236 for SMG_Object'Size use 104; -- in bits!
237 for SMG_Object'Bit_Order use System.Low_Order_First;
238 for SMG_Object use
239 record
240 ID at 0 range 0 .. 31;
241 X at 4 range 0 .. 15;
242 Y at 6 range 0 .. 15;
243 Z at 8 range 0 .. 15;
244 RX at 10 range 0 .. 7;
245 RY at 11 range 0 .. 7;
246 RZ at 12 range 0 .. 7;
247 end record;
248
249 -------------------------
250 -- A set of Serpent Keys
251 -- parametrized record for a Serpent Keyset
252 -- parameters:
253 -- N is number of Serpent Keys contained
254 -- this can be the content of messages 4.1 or 5.2 in protocol spec.
255
256 -- an array of Serpent Keys
257 -- MAXIMUM 40 keys allowed in a message, hence subtype for key count
258 subtype Keys_Count is Interfaces.Unsigned_8 range 1..40;
259 type SKeys_Array is array( Keys_Count range <>) of Serpent.Key;
260
261 type Serpent_Keyset( N : Keys_Count := Keys_Count'Last) is
262 record
263 -- actual Serpent Keys
264 Keys : SKeys_Array( 1..N );
265 -- whether for talking to client (LSB set) or talking to server (MSB set)
266 Flag : Interfaces.Unsigned_8;
267 end record;
268
269 ------------------------------
270 -- Serpent Keys Management
271 type Keys_Mgm (N_Burnt: Interfaces.Unsigned_8) is
272 record
273 -- count of server keys requested
274 N_Server: Interfaces.Unsigned_8;
275 -- count of client keys requested
276 N_Client: Interfaces.Unsigned_8;
277 -- ID of Serpent key preferred for further inbound Serpent msgs.
278 Key_ID : Interfaces.Unsigned_8;
279 -- IDs of Serpent keys burnt by this message
280 Burnt : SKeys_Array( 1..N_Burnt );
281 end record;
282
283 end Data_Structs;