/// <summary> /// Takes a span aligned to a major record, and attempts to locate the game setting type. /// Will throw if the span is misaligned or doesn't start at a valid major record header. /// </summary> /// <param name="span">Data beginning at the start of a major record</param> /// <param name="meta">Game meta information to use in parsing</param> /// <returns>A response of the GameSettingType if found, or a reason if not.</returns> public static GetResponse <GameSettingType> GetGameSettingType(ReadOnlyMemorySlice <byte> span, GameConstants meta) { var majorMeta = meta.MajorRecordFrame(span); var edidLoc = UtilityTranslation.FindFirstSubrecord(majorMeta.Content, meta, Constants.EditorID); if (edidLoc == null) { return(GetResponse <GameSettingType> .Fail($"EDID was not located")); } var edidMeta = meta.SubrecordFrame(majorMeta.Content.Slice(edidLoc.Value)); var edid = BinaryStringUtility.ProcessWholeToZString(edidMeta.Content); if (edid.Length == 0) { return(GetResponse <GameSettingType> .Fail("No EDID parsed.")); } if (!TryGetGameSettingType(edid[0], out var settingType)) { return(GetResponse <GameSettingType> .Fail($"Unknown game setting type: {edid[0]}")); } return(GetResponse <GameSettingType> .Succeed(settingType)); }
public static void CompileSetGroupLength( IEnumerable <Stream> streams, byte[] bytes) { UtilityTranslation.SetGroupLength(bytes, (uint)streams.NotNull().Sum(i => i.Length)); }