Ejemplo n.º 1
0
        public void TestSaveMethod()
        {
            MotionFile motionFile = new MotionFile();

            motionFile.Load(TEST_FILE);

            MemoryStream savedStream = new MemoryStream();

            motionFile.Save(savedStream);

            savedStream.Seek(0, SeekOrigin.Begin);

            MotionFile savedMotionFile = new MotionFile();

            savedMotionFile.Load(savedStream);

            savedStream.Close();

            Assert.AreEqual(motionFile.FramesPerSecond, savedMotionFile.FramesPerSecond, "Frames per second values do not match");
            Assert.AreEqual(motionFile.ChannelCount, savedMotionFile.ChannelCount, "Channel counts do not match");

            for (int i = 0; i < motionFile.ChannelCount; i++)
            {
                Assert.AreEqual(motionFile[i].Type, savedMotionFile[i].Type, "Channel types do not match");
                Assert.AreEqual(motionFile[i].Index, savedMotionFile[i].Index, "Channel index values do not match");
            }

            Assert.AreEqual(motionFile.FramesPerSecond, savedMotionFile.FramesPerSecond, "Frame counts do not match");
        }
Ejemplo n.º 2
0
        static void Main(string[] args)
        {
            AsmMode mode   = AsmMode.Invalid;
            string  input  = "";
            string  output = "";
            string  labels = "";

            if (args.Length == 0)
            {
                Console.WriteLine(HelpText);
                return;
            }
            for (int i = 0; i < args.Length; i++)
            {
                switch (args[i])
                {
                case "-h":
                case "help":
                    Console.WriteLine(HelpText);
                    break;

                case "-d":
                    mode = AsmMode.Disasm;
                    break;

                case "-a":
                    mode = AsmMode.Asm;
                    break;

                case "-l":
                    labels = args[++i];
                    break;

                case "-o":
                    output = args[++i];
                    break;

                default:
                    input = args[i];
                    break;
                }
            }

            if (mode == AsmMode.Invalid)
            {
                Console.WriteLine("Asm mode not set. Use -d or -a, see -h for details");
                return;
            }

            if (string.IsNullOrEmpty(input))
            {
                Console.WriteLine("No input file set. See -h for details");
                return;
            }

            if (string.IsNullOrEmpty(output))
            {
                if (mode == AsmMode.Disasm)
                {
                    output = "output.xml";
                }
                else
                {
                    output = "output_mlist.bin";
                }
            }

            //labels are only used on disassembly. During assembly they are parsed/hashed automatically
            if (string.IsNullOrEmpty(labels) || mode == AsmMode.Asm)
            {
                Labels = new Dictionary <ulong, string>();
            }
            else
            {
                Labels = GetLabels(labels);
            }

            Xml = new XmlDocument();

            if (mode == AsmMode.Disasm)
            {
                MFile = new MotionFile(input);
                Disasm();
                Xml.Save(output);
            }
            else
            {
                Xml.Load(input);
                MFile = new MotionFile();
                Asm();
                MFile.Save(output);
            }
        }