示例#1
0
    public static void Main()
    {
        AutoResetEvent waiter = new AutoResetEvent(false);

        // X8086.Models.IBMPC_5150 is required as fake86 does not properly handle eflags
        cpu = new X8086(true, false, null /* Conversion error: Set to default value for this argument */, X8086.Models.IBMPC_5150)
        {
            Clock = 47700000
        };
        cpu.EmulationHalted += () =>
        {
            Compare();
            Console.WriteLine();
            waiter.Set();
        };

        X8086.LogToConsole = false;

        foreach (System.IO.FileInfo f in (new System.IO.DirectoryInfo(System.IO.Path.Combine(System.IO.Directory.GetParent(Application.ExecutablePath).ToString(), "80186_tests\\"))).GetFiles("*.bin"))
        {
            string fileName     = f.Name.Replace(f.Extension, "");
            string dataFileName = System.IO.Path.Combine(f.DirectoryName, $"res_{fileName}.bin");

            // If fileName <> "segpr" Then Continue For

            if (!System.IO.File.Exists(dataFileName))
            {
                continue;
            }
            validData = System.IO.File.ReadAllBytes(dataFileName);

            prefix = $"Running: {fileName}";
            Console.Write(prefix);

            if (cpu.IsHalted)
            {
                cpu.HardReset();
            }
            cpu.LoadBIN(f.FullName, 0xF000, 0x0);
            cpu.Run(false, 0xF000, 0x0);

            // While Not cpu.IsHalted
            // DisplayInstructions()
            // cpu.StepInto()
            // End While

            waiter.WaitOne();
        }
        cpu.Close();

        int passedTotal = testsTotal - failedTotal;

        Console.ForegroundColor = ConsoleColor.Magenta;
        Console.WriteLine($"Score: {passedTotal}/{testsTotal} [{passedTotal / (double)testsTotal * 100}%]");
        Console.ForegroundColor = ConsoleColor.Gray;
        Console.WriteLine();

        Console.WriteLine("Press any key to exit");
        Console.ReadKey();
    }
示例#2
0
        public static void Main()
        {
            X8086.LogToConsole = false;

            X8086.Error += (object s, X8086.EmulatorErrorEventArgs e) =>
            {
                if (e.Message.ToLower().StartsWith("opcode"))
                {
                    return;
                }
                cpu?.Pause();
                Console.WriteLine(e.Message);
                cpu?.Close();
                Environment.Exit(1);
            };

            cpu = new X8086(true, true, null);

            cpu.EmulationTerminated += () => Environment.Exit(0);

            cpu.Adapters.Add(new FloppyControllerAdapter(cpu));
            cpu.Adapters.Add(new CGAConsole(cpu));
            cpu.Adapters.Add(new KeyboardAdapter(cpu));
            // cpu.Adapters.Add(New MouseAdapter(cpu)) ' So far, useless in Console mode
#if Win32_dbg
            cpu.Adapters.Add(new SpeakerAdpater(cpu));
#endif

#if Win32
            cpu.Adapters.Add(new AdlibAdapter(cpu));
#endif

            LoadSettings();

            cpu.Run();

            do
            {
                System.Threading.Thread.Sleep(500);
            } while (true);
        }