private static T FirstTextSegmentMatch <T>(string pattern, MemoryAddress start, int count, string label) { return(CodePattern.Parse(pattern) .Matches(_ctx.Text.Start, _ctx.TextBuffer, start, count) .First() .Read <T>(_ctx.Dump, label)); }
private ICodeNode VisitAssignExpression(BinaryExpression node) { V_0 = CodePattern.Match(SelfAssignment.IncrementPattern, node); if (V_0.get_Success()) { V_1 = (Expression)V_0.get_Item("Target"); V_2 = (BinaryOperator)V_0.get_Item("Operator"); if (V_2 == 1 || V_2 == 3) { return new UnaryExpression(SelfAssignment.GetCorrespondingOperator(V_2), V_1.CloneExpressionOnly(), node.get_UnderlyingSameMethodInstructions()); } } V_0 = CodePattern.Match(SelfAssignment.AssignmentOperatorPattern, node); if (V_0.get_Success()) { V_1 = (Expression)V_0.get_Item("Target"); V_3 = (BinaryExpression)V_0.get_Item("RightSide"); V_4 = (Expression)V_0.get_Item("Value"); if (this.normalToAssignOperatorMap.ContainsKey(V_3.get_Operator())) { V_5 = new List<Instruction>(); V_5.AddRange(V_3.get_MappedInstructions()); V_5.AddRange(V_1.get_MappedInstructions()); stackVariable41 = this.normalToAssignOperatorMap.get_Item(V_3.get_Operator()); V_6 = V_1.CloneExpressionOnlyAndAttachInstructions(V_3.get_Left().get_MappedInstructions()); return new BinaryExpression(stackVariable41, V_6, V_4, this.typeSystem, V_5, false); } } return this.VisitBinaryExpression(node); }
private static T FirstTextSegmentMatch <T>(string pattern, string label) { return(CodePattern.Parse(pattern) .Matches(_ctx.Text.Start, _ctx.TextBuffer) .First() .Read <T>(_ctx.Dump, label)); }
private bool TryMatchCanCastPattern(BinaryExpression node, IEnumerable <ICodePattern> patterns, out CanCastExpression result) { V_0 = patterns.GetEnumerator(); try { while (V_0.MoveNext()) { V_1 = CodePattern.Match(V_0.get_Current(), node); if (!V_1.get_Success()) { continue; } result = this.CreateCanCastExpression(V_1, node); V_2 = true; goto Label1; } goto Label0; } finally { if (V_0 != null) { V_0.Dispose(); } } Label1: return(V_2); Label0: result = null; return(false); }
private static readonly byte[] Revert12_2 = { 0xC3, 0xFE, 0xFF, 0x54 }; // bl public ShinyRateSWSH(byte[] data, int offset = 0x700_000) : base(data) { CodeOffset1 = CodePattern.IndexOfBytes(data, Pattern, offset); CodeOffset2 = CodePattern.IndexOfBytes(data, Pattern, CodeOffset1 + 8); // after CodeOffset1 Debug.Assert(CodeOffset2 - 0x30 == CodeOffset1); }
public TMEditorGG(byte[] data) { NSO = new NSO(data); Data = NSO.DecompressedRO; // tm list is stored immediately after TM item index list var pattern = CodePattern.TMHM_GG; Offset = CodePattern.IndexOfBytes(Data, pattern, 0x200_000); if (Valid) { Offset += pattern.Length; } }
public HapticHandle CreateCodeHaptic() { //Debug.Log("Hit\n"); CodeSequence seq = new CodeSequence(); seq.AddEffect(0.0f, new CodeEffect("buzz", .2f)); seq.AddEffect(0.3f, new CodeEffect("click", 0.0f)); //seq.Play(AreaFlag.All_Areas); CodePattern pat = new CodePattern(); pat.AddSequence(0.5f, AreaFlag.Lower_Ab_Both, seq); pat.AddSequence(1.0f, AreaFlag.Mid_Ab_Both, seq); pat.AddSequence(1.5f, AreaFlag.Upper_Ab_Both, seq); pat.AddSequence(2.0f, AreaFlag.Chest_Both, seq); pat.AddSequence(2.5f, AreaFlag.Shoulder_Both, seq); pat.AddSequence(2.5f, AreaFlag.Back_Both, seq); pat.AddSequence(3.0f, AreaFlag.Upper_Arm_Both, seq); pat.AddSequence(3.5f, AreaFlag.Forearm_Both, seq); return(pat.Play()); }
public void EditTypeChart() { var path = Path.Combine(ROM.PathExeFS, "main"); var data = FileMitm.ReadAllBytes(path); var nso = new NSO(data); byte[] pattern = // N2nn3pia9transport18UnreliableProtocolE { 0x4E, 0x32, 0x6E, 0x6E, 0x33, 0x70, 0x69, 0x61, 0x39, 0x74, 0x72, 0x61, 0x6E, 0x73, 0x70, 0x6F, 0x72, 0x74, 0x31, 0x38, 0x55, 0x6E, 0x72, 0x65, 0x6C, 0x69, 0x61, 0x62, 0x6C, 0x65, 0x50, 0x72, 0x6F, 0x74, 0x6F, 0x63, 0x6F, 0x6C, 0x45, 0x00 }; int ofs = CodePattern.IndexOfBytes(nso.DecompressedRO, pattern); if (ofs < 0) { WinFormsUtil.Alert("Not able to find type chart data in ExeFS."); return; } ofs += pattern.Length + 0x24; // 0x5B4C0C in lgpe 1.0 RO var cdata = new byte[18 * 18]; var types = ROM.GetStrings(TextName.Types); Array.Copy(nso.DecompressedRO, ofs, cdata, 0, cdata.Length); var chart = new TypeChartEditor(cdata); using var editor = new TypeChart(chart, types); editor.ShowDialog(); if (!editor.Modified) { return; } chart.Data.CopyTo(nso.DecompressedRO, ofs); data = nso.Write(); FileMitm.WriteAllBytes(path, data); }
/// <summary> /// Begins an emanating impulse at the provided origin. /// Defaults to a simple 'hum' effect if you don't call WithEffect() /// Remember to call .Play() on the returned impulse. /// </summary> /// <param name="origin">The starting AreaFlag. Only provided a single AreaFlag pad.</param> /// <param name="depth">How many pads this will traverse before ending (will not reverb off 'end paths')</param> /// <returns>An Impulse object which can be given a CodeSequence, duration or Attenuation parameters /// Remember to call Play() on the returned object to begin the emanation /// <returns>The Impulse that you can call .Play() on to play a create a HapticHandle referencing that Haptic</returns> public static Impulse BeginEmanatingEffect(AreaFlag origin, int depth = 2) { if (depth < 0) { Debug.LogError("Depth for emanation is negative: " + depth + "\n\tThis will be clamped to 0 under the hood, negative numbers will likely do nothing"); } CreateImpulse creation = delegate(float attenuation, float totalLength, CodeSequence seq) { CodePattern emanation = new CodePattern(); var stages = _grapher.BFS(origin, depth); float timeStep = totalLength / stages.Count; float time = 0.0f; for (int i = 0; i < stages.Count; i++) { AreaFlag area = AreaFlag.None; foreach (var item in stages[i]) { area |= item.Location; } if (i > 0) { seq.Strength *= (1.0f - attenuation); } seq.Strength = Mathf.Clamp((float)seq.Strength, 0, 1.0f); emanation.AddSequence(time, area, seq); time += timeStep; } return(emanation.Play()); }; return(new Impulse(creation)); }
/// <summary> /// Begins a traversing impulse at the provided origin. /// Will play on pads that are the origin, destination or 'in-between' them. /// Defaults to a simple 'hum' effect if you don't call WithEffect() /// Remember to call .Play() on the returned impulse. /// </summary> /// <param name="origin">The starting AreaFlag. Only provided a single AreaFlag pad.</param> /// <param name="destination">The ending location for the traversing impulse.</param> /// <returns>The Impulse that you can call .Play() on to play a create a HapticHandle referencing that Haptic</returns> public static Impulse BeginTraversingImpulse(AreaFlag origin, AreaFlag destination) { CreateImpulse creation = delegate(float attenuation, float totalLength, CodeSequence seq) { CodePattern emanation = new CodePattern(); var stages = _grapher.Dijkstras(origin, destination); float timeStep = totalLength / stages.Count; float time = 0.0f; for (int i = 0; i < stages.Count; i++) { if (i > 0) { seq.Strength *= (1.0f - attenuation); } emanation.AddSequence(time, stages[i].Location, seq); time += timeStep; } return(emanation.Play()); }; return(new Impulse(creation)); }
private static CodePatternMatch FirstDataSegmentMatch(string pattern) { return(CodePattern.Parse(pattern) .Matches(_ctx.Data.Start, _ctx.DataBuffer) .First()); }
private static CodePatternMatch FirstTextSegmentMatch(string pattern, MemoryAddress start, int count) { return(CodePattern.Parse(pattern) .Matches(_ctx.Text.Start, _ctx.TextBuffer, start, count) .First()); }
private static IEnumerable <CodePatternMatch> TextSegmentMatches(string pattern, MemoryAddress start, int count) { return(CodePattern.Parse(pattern) .Matches(_ctx.Text.Start, _ctx.TextBuffer, start, count)); }
private static IEnumerable <CodePatternMatch> TextSegmentMatches(string pattern) { return(CodePattern.Parse(pattern) .Matches(_ctx.Text.Start, _ctx.TextBuffer)); }