Пример #1
0
        private 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.Eject();
                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;
            }
        }