private void UpdatePins(ref PinsState state, StringBuilder data) { if (data[0] != ' ') { state = PinsState.Idle; } switch (state) { case PinsState.Idle: { if (data[0] == ' ') { break; } var str = BoardUtil.SplitLine(data, 3); if (str[2] == null) { break; } if (str[0] == "Part") { skipPart = false; var part = new Part(); part.Name = str[1]; part.Side = GetSide(str[2]); part.FirstPin = Pins.Count; if (Parts.Count > 0 && part.Name == Parts[Parts.Count - 1].Name) { skipPart = true; break; } Parts.Add(part); state = PinsState.PartPinEntry; } } break; // ' 1 1 0.1138 0.0701 1 MIC_GND 3' case PinsState.PartPinEntry: if (!skipPart) { var str = BoardUtil.SplitLine(data, 6); var pin = new Pin(); //pin.PartIndex = Parts.Count-1; var loc = new Vector2(); loc.X = ParseDouble(str[2]); loc.Y = ParseDouble(str[3]); pin.Location = loc; pin.Name = str[5]; pin.Net = -1; Pins.Add(pin); Parts[Parts.Count - 1].PinCount++; } break; } }
public bool Configure(PinsState pinsState, List <string> parameters) { _pinsState = pinsState; if (parameters.Count < 2) { return(false); } // Parse start address (required) if (!ushort.TryParse(parameters[0].Replace("0x", ""), NumberStyles.HexNumber, null, out _startAddress)) { return(false); } // Parse end address (required) if (!ushort.TryParse(parameters[1].Replace("0x", ""), NumberStyles.HexNumber, null, out _endAddress)) { return(false); } _memory = new byte[Size]; // Parse image file (optional) if (parameters.Count > 2) { var imagePath = parameters[2]; if (!File.Exists(imagePath)) { return(false); } var atIndex = 0; // Parse image start index (optional) if (parameters.Count > 3) { if (!int.TryParse(parameters[3].Replace("0x", ""), NumberStyles.HexNumber, null, out atIndex)) { return(false); } } var imageBytes = File.ReadAllBytes(imagePath); Array.Copy(imageBytes, 0, _memory, atIndex, imageBytes.Length); } return(true); }
public M6502Core(uint frequency) { Pins = new PinsState(); Bus = new Bus(this); Registers = new RegistersState(); _instructionDecoder = new InstructionDecoder(this); _interruptsLogic = new InterruptsLogic(this); _frequency = frequency; if (frequency != 0) { _ticksPerCycle = TimeSpan.TicksPerSecond / (ulong)_frequency; } }
private void Update(ref State currentState, ref FormatState fState, ref NailsState nState, ref PinsState pState, StringBuilder data) { if (data.Length == 0 || data[0] == '\r') { //currentState = State.Idle; return; } if (data[0] == '<') { currentState = State.Idle; } switch (currentState) { case State.Idle: switch (data.ToString()) { case "<<format.asc>>": currentState = State.Format; break; case "<<nails.asc>>": currentState = State.Nails; break; case "<<pins.asc>>": currentState = State.Pins; break; } break; case State.Format: UpdateFormat(ref fState, data); break; case State.Nails: UpdateNails(ref nState, data); break; case State.Pins: UpdatePins(ref pState, data); break; } }