Пример #1
0
        static void CD_f()
        {
            if (Cmd.Argc < 2)
            {
                return;
            }

            string command = Cmd.Argv(1);

            if (Common.SameText(command, "on"))
            {
                _Controller.IsEnabled = true;
                return;
            }

            if (Common.SameText(command, "off"))
            {
                if (_Controller.IsPlaying)
                {
                    _Controller.Stop();
                }

                _Controller.IsEnabled = false;
                return;
            }

            if (Common.SameText(command, "reset"))
            {
                _Controller.IsEnabled = true;
                if (_Controller.IsPlaying)
                {
                    _Controller.Stop();
                }

                _Controller.ReloadDiskInfo();
                return;
            }

            if (Common.SameText(command, "remap"))
            {
                int    ret   = Cmd.Argc - 2;
                byte[] remap = _Controller.Remap;
                if (ret <= 0)
                {
                    for (int n = 1; n < 100; n++)
                    {
                        if (remap[n] != n)
                        {
                            Con.Print("  {0} -> {1}\n", n, remap[n]);
                        }
                    }

                    return;
                }
                for (int n = 1; n <= ret; n++)
                {
                    remap[n] = (byte)Common.atoi(Cmd.Argv(n + 1));
                }

                return;
            }

            if (Common.SameText(command, "close"))
            {
                _Controller.CloseDoor();
                return;
            }

            if (!_Controller.IsValidCD)
            {
                _Controller.ReloadDiskInfo();
                if (!_Controller.IsValidCD)
                {
                    Con.Print("No CD in player.\n");
                    return;
                }
            }

            if (Common.SameText(command, "play"))
            {
                _Controller.Play((byte)Common.atoi(Cmd.Argv(2)), false);
                return;
            }

            if (Common.SameText(command, "loop"))
            {
                _Controller.Play((byte)Common.atoi(Cmd.Argv(2)), true);
                return;
            }

            if (Common.SameText(command, "stop"))
            {
                _Controller.Stop();
                return;
            }

            if (Common.SameText(command, "pause"))
            {
                _Controller.Pause();
                return;
            }

            if (Common.SameText(command, "resume"))
            {
                _Controller.Resume();
                return;
            }

            if (Common.SameText(command, "eject"))
            {
                if (_Controller.IsPlaying)
                {
                    _Controller.Stop();
                }

                _Controller.Edject();
                return;
            }

            if (Common.SameText(command, "info"))
            {
                Con.Print("%u tracks\n", _Controller.MaxTrack);
                if (_Controller.IsPlaying)
                {
                    Con.Print("Currently {0} track {1}\n", _Controller.IsLooping ? "looping" : "playing", _Controller.CurrentTrack);
                }
                else if (_Controller.IsPaused)
                {
                    Con.Print("Paused {0} track {1}\n", _Controller.IsLooping ? "looping" : "playing", _Controller.CurrentTrack);
                }

                Con.Print("Volume is {0}\n", _Controller.Volume);
                return;
            }
        }
Пример #2
0
        private void CD_f(CommandMessage msg)
        {
            if (msg.Parameters == null || msg.Parameters.Length < 1)
            {
                return;
            }

            var command = msg.Parameters[0];

            if (Utilities.SameText(command, "on"))
            {
                _Controller.IsEnabled = true;
                return;
            }

            if (Utilities.SameText(command, "off"))
            {
                if (_Controller.IsPlaying)
                {
                    _Controller.Stop( );
                }
                _Controller.IsEnabled = false;
                return;
            }

            if (Utilities.SameText(command, "reset"))
            {
                _Controller.IsEnabled = true;
                if (_Controller.IsPlaying)
                {
                    _Controller.Stop( );
                }

                _Controller.ReloadDiskInfo( );
                return;
            }

            if (Utilities.SameText(command, "remap"))
            {
                var ret   = msg.Parameters.Length - 1;
                var remap = _Controller.Remap;
                if (ret <= 0)
                {
                    for (var n = 1; n < 100; n++)
                    {
                        if (remap[n] != n)
                        {
                            Host.Console.Print("  {0} -> {1}\n", n, remap[n]);
                        }
                    }
                    return;
                }
                for (var n = 1; n <= ret; n++)
                {
                    remap[n] = ( Byte )MathLib.atoi(msg.Parameters[n]);
                }
                return;
            }

            if (Utilities.SameText(command, "close"))
            {
                _Controller.CloseDoor( );
                return;
            }

            if (!_Controller.IsValidCD)
            {
                _Controller.ReloadDiskInfo( );
                if (!_Controller.IsValidCD)
                {
                    Host.Console.Print("No CD in player.\n");
                    return;
                }
            }

            if (Utilities.SameText(command, "play"))
            {
                _Controller.Play(( Byte )MathLib.atoi(msg.Parameters[1]), false);
                return;
            }

            if (Utilities.SameText(command, "loop"))
            {
                _Controller.Play(( Byte )MathLib.atoi(msg.Parameters[1]), true);
                return;
            }

            if (Utilities.SameText(command, "stop"))
            {
                _Controller.Stop( );
                return;
            }

            if (Utilities.SameText(command, "pause"))
            {
                _Controller.Pause( );
                return;
            }

            if (Utilities.SameText(command, "resume"))
            {
                _Controller.Resume( );
                return;
            }

            if (Utilities.SameText(command, "eject"))
            {
                if (_Controller.IsPlaying)
                {
                    _Controller.Stop( );
                }
                _Controller.Eject( );
                return;
            }

            if (Utilities.SameText(command, "info"))
            {
                Host.Console.Print("%u tracks\n", _Controller.MaxTrack);
                if (_Controller.IsPlaying)
                {
                    Host.Console.Print("Currently {0} track {1}\n", _Controller.IsLooping ? "looping" : "playing", _Controller.CurrentTrack);
                }
                else if (_Controller.IsPaused)
                {
                    Host.Console.Print("Paused {0} track {1}\n", _Controller.IsLooping ? "looping" : "playing", _Controller.CurrentTrack);
                }
                Host.Console.Print("Volume is {0}\n", _Controller.Volume);
                return;
            }
        }