Пример #1
0
 public Frame(byte[] data1, PsxControllerType port1, byte[] data2, PsxControllerType port2, byte control)
 {
     _type1       = port1;
     _type2       = port2;
     _controller1 = PsxController.GetController(port1, data1);
     _controller2 = PsxController.GetController(port2, data2);
     _console     = (Console)control;
 }
Пример #2
0
        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]);
        }
Пример #3
0
        public static InputLog Read(FileStream stream, PsxControllerType port1, PsxControllerType port2)
        {
            var port1DataSize = DataSize[(int)port1];
            var port2DataSize = DataSize[(int)port2];

            var data1   = new byte[port1DataSize];
            var data2   = new byte[port2DataSize];
            var control = 0;

            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 = (control = stream.ReadByte()) == -1;
                }

                if (!endOfStream)
                {
                    list.Add(new Frame(data1, port1, data2, port2, (byte)control));
                }
            }

            // 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));
        }