public void Visit(PlmItem item, byte data) { var memoryLocation = this.memoryLocation; var run = (PLMRun)Model.GetNextRun(memoryLocation); // part 1: contraction (if they entered the end token) if (CurrentText == EggMoveRun.GroupStart + EggMoveRun.GroupEnd) { for (int i = this.memoryLocation; i < run.Start + run.Length; i += 2) { Model.WriteMultiByteValue(i, 2, CurrentChange, 0xFFFF); } Model.ObserveRunWritten(CurrentChange, new PLMRun(Model, run.Start)); return; } // part 2: validation if (!CurrentText.Contains(" ")) { return; } var quoteCount = CurrentText.Count(c => c == StringDelimeter); if (quoteCount % 2 != 0) { return; } if (!CurrentText.EndsWith(StringDelimeter.ToString()) && !CurrentText.EndsWith(" ")) { return; } ErrorText = ValidatePlmText(run, quoteCount, out var level, out var move); if (ErrorText != null || move == -1) { return; } // part 3: write to the model NewDataIndex = memoryLocation + 2; Result = true; var value = (level << 9) + move; var initialItemValue = Model.ReadMultiByteValue(memoryLocation, 2); Model.WriteMultiByteValue(memoryLocation, 2, CurrentChange, value); // part 4: expansion if (initialItemValue == 0xFFFF) { var newRun = Model.RelocateForExpansion(CurrentChange, run, run.Length + 2); if (newRun.Start != run.Start) { MessageText = $"Level Up Moves were automatically moved to {newRun.Start.ToString("X6")}. Pointers were updated."; memoryLocation += newRun.Start - run.Start; NewDataIndex = memoryLocation + 2; DataMoved = true; } Model.WriteMultiByteValue(memoryLocation + 2, 2, CurrentChange, 0xFFFF); var lvlRun = new PLMRun(Model, newRun.Start); Model.ObserveRunWritten(CurrentChange, lvlRun); } }
public void Visit(PlmItem item, byte data) => Content.Add(item.ToString());
public void Visit(PlmItem item, byte data) => buffer.WriteMultiByteValue(index, 2, currentChange, 0x0200);
public void Visit(PlmItem item, byte data) => Result = item.ToString();