private void ExecCommand(Command cmd)
        {
            if (this.checkBoxSaveState.Checked)
            {
                ClientApi.SaveState(SaveStateName);
            }

            for (int i = 0; i < cmd.ButtonPresses.Length; i++)
            {
                for (int f = 0; f < cmd.ButtonPresses[i].Frames; f++)
                {
                    this.AddButtons(cmd.ButtonPresses[i].Buttons);
                    ClientApi.DoFrameAdvance();
                }
            }

            Joypad controller = ClientApi.GetInput(1);

            controller.ClearInputs();
            ClientApi.SetInput(1, controller);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            for (int i = 0; i < 600; i++)
            {
                if (i % 60 == 0)
                {
                    Joypad j1 = ClientApi.GetInput(1);
                    j1.AddInput(JoypadButton.A);
                    ClientApi.SetInput(1, j1);

                    ClientApi.DoFrameAdvance();

                    j1.RemoveInput(JoypadButton.A);
                    ClientApi.SetInput(1, j1);
                    ClientApi.DoFrameAdvance();
                }
                ClientApi.DoFrameAdvance();
            }
            Joypad j = ClientApi.GetInput(1);

            j.ClearInputs();
            ClientApi.SetInput(1, j);
        }
        void AddButtons(SnesButtons buttons)
        {
            Joypad controller = ClientApi.GetInput(1);

            controller.ClearInputs();
            ClientApi.SetInput(1, controller);

            // D Pad
            if (buttons.HasFlag(SnesButtons.Left))
            {
                controller.AddInput(JoypadButton.Left);
            }
            if (buttons.HasFlag(SnesButtons.Right))
            {
                controller.AddInput(JoypadButton.Right);
            }
            if (buttons.HasFlag(SnesButtons.Down))
            {
                controller.AddInput(JoypadButton.Down);
            }
            if (buttons.HasFlag(SnesButtons.Up))
            {
                controller.AddInput(JoypadButton.Up);
            }

            // Toward/Away
            if (buttons.HasFlag(SnesButtons.Toward))
            {
                controller.AddInput(this.radioButtonLeft.Checked ? JoypadButton.Left : JoypadButton.Right);
            }
            if (buttons.HasFlag(SnesButtons.Away))
            {
                controller.AddInput(this.radioButtonLeft.Checked ? JoypadButton.Right : JoypadButton.Left);
            }

            // Face Buttons
            if (buttons.HasFlag(SnesButtons.A))
            {
                controller.AddInput(JoypadButton.A);
            }
            if (buttons.HasFlag(SnesButtons.B))
            {
                controller.AddInput(JoypadButton.B);
            }
            if (buttons.HasFlag(SnesButtons.X))
            {
                controller.AddInput(JoypadButton.X);
            }
            if (buttons.HasFlag(SnesButtons.Y))
            {
                controller.AddInput(JoypadButton.Y);
            }

            // S/s
            if (buttons.HasFlag(SnesButtons.Select))
            {
                controller.AddInput(JoypadButton.Select);
            }
            if (buttons.HasFlag(SnesButtons.Start))
            {
                controller.AddInput(JoypadButton.Start);
            }

            // Shoulder buttons
            if (buttons.HasFlag(SnesButtons.L))
            {
                controller.AddInput(JoypadButton.L);
            }
            if (buttons.HasFlag(SnesButtons.R))
            {
                controller.AddInput(JoypadButton.R);
            }

            if (this.checkBoxStrafe.Checked)
            {
                controller.AddInput(JoypadButton.R);
            }

            ClientApi.SetInput(1, controller);
        }