Beispiel #1
0
 private void EmulatorThread_DoWork(object sender, DoWorkEventArgs e)
 {
     while (true)
     {
         if (!_remu.halt && (_emulatorState == EmulatorState.Execution || _emulatorState == EmulatorState.StepByStep))
         {
             _remu.step();
         }
         else
         {
             Thread.Sleep(100); // wait for Run button press
         }
     }
 }
Beispiel #2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: ./remu [/gui] *.R200 [run]");
                return;
            }
            bool   runAll      = args.Length >= 2 && args.Last().ToLower() == "run";
            var    fileNamePos = runAll ? args.Length - 2 : args.Length - 1;
            string progLine    = File.ReadAllText(args[fileNamePos]);

            // Parse additional options
            foreach (var arg in args.Take(fileNamePos))
            {
                switch (arg)
                {
                case "/gui": EnableGUI = true; break;
                }
            }


            Preprocessor pr = new Preprocessor();
            //pr.debug = true;
            var res = pr.go(progLine);

            Console.WriteLine("Compilation: ok!");
            Console.WriteLine("Used ROM: \t" + res.prog.Length + " / 64");
            Console.WriteLine("Used CONST: \t" + res.constUsed + " / " + Preprocessor.constMemSize);
            Console.WriteLine("Used RAM: \t" + res.ramUsed + " / " + Preprocessor.ramSize);

            Remulator remulator = new Remulator(res.cmem, res.prog);
            MainForm  guiForm   = null;

            if (EnableGUI)
            {
                guiForm = new MainForm(remulator, res, runAll);
                Application.EnableVisualStyles();
                Application.Run(guiForm);
                return;
            }

            Console.WriteLine("\nPress any key to start emulation.");
            if (!runAll)
            {
                Console.WriteLine("Press 'q' to break or any other key to advance one step.");
            }
            Console.WriteLine("");
            if (Console.ReadKey().KeyChar == 'q')
            {
                return;
            }

            while (!remulator.halt)
            {
                remulator.step();
                Console.WriteLine("\nCycle: " + remulator.cycle.ToString());
                Console.WriteLine("CMD: " + remulator.prvCmd);
                Console.WriteLine("State:\n" + remulator.state.ToString());
                Console.Write("CONST: ");
                foreach (int i in res.cmem)
                {
                    Console.Write(i + " ");
                }
                Console.WriteLine("");
                if (!runAll)
                {
                    var k = Console.ReadKey();
                    if (k.KeyChar == 'q')
                    {
                        break;
                    }
                }
            }
            Console.WriteLine("HALT.");
            Console.WriteLine("\nYour programm would have been running on the real machine around " +
                              remulator.cycle * secPerTick + " sec.");
        }
Beispiel #3
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("Usage: ./remu *.R200 [run]");
                return;
            }
            string progLine = File.ReadAllText(args[0]);
            bool   runAll   = args.Length >= 2 && args[1].ToLower() == "run";


            Preprocessor pr = new Preprocessor();
            //pr.debug = true;
            var res = pr.go(progLine);

            Console.WriteLine("Compilation: ok!");
            Console.WriteLine("Used ROM: \t" + res.prog.Length + " / 64");
            Console.WriteLine("Used CONST: \t" + res.constUsed + " / " + Preprocessor.constMemSize);
            Console.WriteLine("Used RAM: \t" + res.ramUsed + " / " + Preprocessor.ramSize);

            Console.WriteLine("\nPress any key to start emulation.");
            if (!runAll)
            {
                Console.WriteLine("Press 'q' to break or any other key to advance one step.");
            }
            Console.WriteLine("");
            if (Console.ReadKey().KeyChar == 'q')
            {
                return;
            }

            Remulator remulator = new Remulator(res.cmem, res.prog);
            Thread    guiThread = null;
            MainForm  guiForm   = null;

            if (EnableGUI)
            {
                guiForm = new MainForm(remulator);
                Application.EnableVisualStyles();
                guiThread = new Thread(() => System.Windows.Forms.Application.Run(guiForm));
                guiThread.Start();
            }

            while (!remulator.halt)
            {
                remulator.step();
                Console.WriteLine("\nCycle: " + remulator.cycle.ToString());
                Console.WriteLine("CMD: " + remulator.prvCmd);
                Console.WriteLine("State:\n" + remulator.state.ToString());
                Console.Write("CONST: ");
                foreach (int i in res.cmem)
                {
                    Console.Write(i + " ");
                }
                Console.WriteLine("");
                if (!runAll)
                {
                    var k = Console.ReadKey();
                    if (k.KeyChar == 'q')
                    {
                        break;
                    }
                }
            }
            Console.WriteLine("HALT.");
            Console.WriteLine("\nYour programm would have been running on the real machine around " +
                              remulator.cycle * secPerTick + " sec.");

            if (guiThread != null)
            {
                Console.WriteLine("Press 'q' to exit.");
                while (Console.ReadKey().KeyChar != 'q')
                {
                    ;
                }
                guiForm.Close();
                guiThread.Join();
            }
        }