public Frame(byte[] data1, PsxControllerType port1, byte[] data2, PsxControllerType port2, byte[] control, bool text) { _type1 = port1; _type2 = port2; _controller1 = PsxController.GetController(port1, data1, text); _controller2 = PsxController.GetController(port2, data2, text); _console = MakeControl(control, text); }
public static InputLog Read(FileStream stream, PsxControllerType port1, PsxControllerType port2, bool text) { int port1DataSize; int port2DataSize; int controlDataSize; if (text) { port1DataSize = TextDataSize[(int)port1]; port2DataSize = TextDataSize[(int)port2]; controlDataSize = 4; } else { port1DataSize = BinaryDataSize[(int)port1]; port2DataSize = BinaryDataSize[(int)port2]; controlDataSize = 1; } var data1 = new byte[port1DataSize]; var data2 = new byte[port2DataSize]; var control = new byte[controlDataSize]; var list = new List <Frame>(); var endOfStream = false; while (!endOfStream) { endOfStream = stream.Read(data1, 0, port1DataSize) < port1DataSize; if (!endOfStream) { endOfStream = stream.Read(data2, 0, port2DataSize) < port2DataSize; } if (!endOfStream) { endOfStream = stream.Read(control, 0, controlDataSize) < controlDataSize; } if (!endOfStream) { list.Add(new Frame(data1, port1, data2, port2, control, text)); } } // Construct the headers var port1Headers = PsxController.GetHeaders(port1); var port2Headers = PsxController.GetHeaders(port2); var headers = new string[port1Headers.Length + port2Headers.Length + 1]; Array.Copy(port1Headers, 0, headers, 0, port1Headers.Length); Array.Copy(port2Headers, 0, headers, port1Headers.Length, port2Headers.Length); headers[headers.Length - 1] = "Console"; return(new InputLog(headers, list)); }
public void Parse(string[] strings) { var l1 = PsxController.GetHeaders(_type1).Length; var l2 = PsxController.GetHeaders(_type2).Length; var s1 = new string[l1]; Array.Copy(strings, 0, s1, 0, l1); var s2 = new string[l2]; Array.Copy(strings, l1, s2, 0, l2); _controller1.Parse(s1); _controller2.Parse(s2); _console = (Console)Enum.Parse(typeof(Console), strings[strings.Length - 1]); }