public EmulatorHostForm(MsxEmulationEnvironment emulationEnvironment)
 {
     this.emulationEnvironment = emulationEnvironment;
     InitializeComponent();
     pluginsMenu.Enabled = false;
     canvas.Paint       += CanvasOnPaint;
 }
Exemple #2
0
        private static MsxEmulationEnvironment CreateEmulationEnvironment(string[] args)
        {
            MsxEmulationEnvironment environment = null;

            try {
                environment = (new Program()).CreateEmulationEnvironmentCore(args);
            }
            catch (ConfigurationException ex) {
                Tell("Sorry, something went wrong with the configuration file:\r\n\r\n{0}", ex.Message);
            }
            catch (EmulationEnvironmentCreationException ex) {
                Tell("Sorry, I couldn't create the emulation environment:\r\n\r\n{0}", ex.Message);
            }
            catch (Exception ex) {
                Tell("Ooops, something went wrong and I am not sure why... here are the ugly details:\r\n\r\n{0}",
                     ex.ToString().Replace(BasePathInDevelopmentEnvironment, "", StringComparison.InvariantCultureIgnoreCase));
            }
            return(environment);
        }
Exemple #3
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.ThreadException += Application_ThreadException;
            AppDomain.CurrentDomain.UnhandledException += CurrentDomainOnUnhandledException;

            var waitForDebugger = false;
            var allocateConsole = false;

            stateFilePath = Path.Combine(
                ConfigurationManager.AppSettings["stateFileDirectory"].AsApplicationFilePath(),
                "NestorMSX.state");

            foreach (var arg in args)
            {
                if (argIs(arg, "keytest"))
                {
                    Application.Run(new KeyTestForm());
                    return;
                }
                else if (argIs(arg, "sc"))
                {
                    allocateConsole = true;
                }
                else if (argIs(arg, "wd"))
                {
                    allocateConsole = true;
                    waitForDebugger = true;
                }
                else if (arg.StartsWith("machine=", StringComparison.InvariantCultureIgnoreCase))
                {
                    machineName = arg.Substring("machine=".Length);
                }
            }

            if (machineName == null)
            {
                machineName = GetMachineName();
            }

            if (machineName == null)
            {
                return;
            }

            SaveMachineNameAsState(machineName);

            if (allocateConsole)
            {
                CreateDebugConsole();
            }

            if (waitForDebugger)
            {
                WaitForDebuggerAttachment();
            }

            if (consoleAllocated)
            {
                Trace.Listeners.Add(new ConsoleTraceListener());
                Trace.WriteLine($"[{DateTime.Now:yyyy-MM-dd HH:mm:ss}] Starting NestorMSX, machine name: {machineName}\r\n");
                if (!waitForDebugger)
                {
                    Console.WriteLine($"My PID is: {Process.GetCurrentProcess().Id}\r\n");
                }
            }

            emulationEnvironment = CreateEmulationEnvironment(args);
            if (emulationEnvironment == null)
            {
                FreeConsoleIfAllocated();
                return;
            }

            Application.ApplicationExit += Application_ApplicationExit;

            emulationEnvironment.Run();
        }