Esempio n. 1
0
        public override void Execute(string line, string[] args)
        {
            if (line.Length > 4)
            {
                string file = "", realFile = "*ERROR";
                if (args[1] == "-d")
                {
                    if (line.Length > 7)
                    {
                        CPU.DebugVisible = true;
                        file             = line.Substring(7, line.Length - 7);
                        realFile         = TryParseFile(file, true);
                    }
                    else
                    {
                        CLI.WriteLine("Invalid arguments!", Color.Red);
                    }
                }
                else
                {
                    CPU.DebugVisible = false;
                    file             = line.Substring(4, line.Length - 4);
                    realFile         = TryParseFile(file, true);
                }

                if (realFile != "*ERROR")
                {
                    if (realFile.ToUpper().EndsWith(".BIN") || realFile.ToUpper().EndsWith(".PRG"))
                    {
                        try
                        {
                            byte[] data = PMFAT.ReadBytes(realFile);
                            Runner.Reset(true);
                            Memory.WriteArray(0, data, data.Length);
                            Runner.Start();
                        }
                        catch (Exception ex)
                        {
                            CLI.WriteLine("Error occurred attempting to execute \"" + realFile + "\"", Color.Red);
                            CLI.Write("[INTERNAL] ", Color.Red); CLI.WriteLine(ex.Message, Color.White);
                        }
                    }
                    else
                    {
                        CLI.WriteLine("File is not marked as executable", Color.Red); CLI.WriteLine("Expected file extension .BIN or .PRG", Color.White);
                    }
                }
                else
                {
                    CLI.WriteLine("Error occurred attempting to execute \"" + file + "\"", Color.Red);
                }
            }
        }