示例#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 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);
 }
示例#3
0
        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));
        }
示例#4
0
        public static string[] GetHeaders(PsxControllerType type)
        {
            switch (type)
            {
            case PsxControllerType.Mouse:
                return(new[] { "Buttons", "Movement" });

            case PsxControllerType.Joystick:
            case PsxControllerType.AnalogController:
                return(new[] { "Buttons", "Left", "Right" });

            default:
                return(new[] { "Buttons" });
            }
        }
示例#5
0
        public static PsxController GetController(PsxControllerType type, byte[] data, bool text)
        {
            switch (type)
            {
            case PsxControllerType.StandardController:
                return(new StandardController(data, text));

            case PsxControllerType.Mouse:
                return(new Mouse(data, text));

            case PsxControllerType.Joystick:
            case PsxControllerType.AnalogController:
                return(new AnalogController(data, text));

            default:
                return(new StandardController(new byte[2], false));
            }
        }
示例#6
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));
        }