コード例 #1
0
        public static void Main(string[] args)
        {
            SyncForm = new Form();

            Hooks.MAIN_TESTCLIENT(args);

            Hooks.MAINFORM_FORM_LOAD_END();


            while (!SpecsSent)
            {
                Application.DoEvents();
                Thread.Sleep(16);
            }

            while (true)
            {
                Hooks.CPU_STEP(false, false);
                Application.DoEvents();
                Thread.Sleep(16);
            }
        }
        private static void OnMessageReceived(object sender, NetCoreEventArgs e)
        {
            try
            {
                // This is where you implement interaction.
                // Warning: Any error thrown in here will be caught by NetCore and handled by being displayed in the console.

                var message         = e.message;
                var simpleMessage   = message as NetCoreSimpleMessage;
                var advancedMessage = message as NetCoreAdvancedMessage;

                ConsoleEx.WriteLine(message.Type);
                switch (message.Type)                 //Handle received messages here
                {
                case "INFINITELOOP":
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        while (true)
                        {
                            Thread.Sleep(10);
                        }
                    });
                    break;


                case REMOTE_ALLSPECSSENT:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        VanguardCore.LoadDefaultRom();
                        Program.SpecsSent = true;
                    });
                    break;

                case SAVESAVESTATE:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        e.setReturnValue(VanguardCore.SaveSavestate_NET(advancedMessage.objectValue as string));
                    });
                    break;

                case LOADSAVESTATE:
                {
                    var cmd      = advancedMessage.objectValue as object[];
                    var path     = cmd[0] as string;
                    var location = (StashKeySavestateLocation)cmd[1];
                    SyncObjectSingleton.FormExecute((o, ea) =>
                        {
                            e.setReturnValue(VanguardCore.LoadSavestate_NET(path, location));
                        });
                    break;
                }

                case REMOTE_LOADROM:
                {
                    var fileName = advancedMessage.objectValue as String;
                    SyncObjectSingleton.FormExecute((o, ea) =>
                        {
                            VanguardCore.LoadRom_NET(fileName);
                        });
                }
                break;

                case REMOTE_DOMAIN_GETDOMAINS:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        e.setReturnValue(Hooks.GetInterfaces());
                    });
                    break;

                case REMOTE_KEY_SETSYNCSETTINGS:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        Hooks.EMU_GETSET_SYNCSETTINGS = (string)advancedMessage.objectValue;
                    });
                    break;

                case REMOTE_KEY_SETSYSTEMCORE:
                {
                    var cmd        = advancedMessage.objectValue as object[];
                    var systemName = (string)cmd[0];
                    var systemCore = (string)cmd[1];
                    SyncObjectSingleton.FormExecute((o, ea) =>
                        {
                            Hooks.EMU_SET_SYSTEMCORE(systemName, systemCore);
                        });
                }
                break;

                case EMU_OPEN_HEXEDITOR_ADDRESS:
                {
                    var    temp    = advancedMessage.objectValue as object[];
                    string domain  = (string)temp[0];
                    long   address = (long)temp[1];

                    MemoryDomainProxy mdp = MemoryDomains.GetProxy(domain, address);
                    long realAddress      = MemoryDomains.GetRealAddress(domain, address);

                    SyncObjectSingleton.FormExecute((o, ea) =>
                        {
                            Hooks.EMU_OPEN_HEXEDITOR_ADDRESS(mdp, realAddress);
                        });

                    break;
                }

                case REMOTE_EVENT_EMU_MAINFORM_CLOSE:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        Hooks.EMU_MAINFORM_CLOSE();
                    });
                    break;

                case REMOTE_EVENT_SAVEBIZHAWKCONFIG:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        Hooks.EMU_MAINFORM_SAVECONFIG();
                    });
                    break;


                case REMOTE_IMPORTKEYBINDS:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        Hooks.EMU_IMPORTCONFIGINI(CorruptCore.bizhawkDir + Path.DirectorySeparatorChar + "import_config.ini", CorruptCore.bizhawkDir + Path.DirectorySeparatorChar + "stockpile_config.ini");
                    });
                    break;

                case REMOTE_MERGECONFIG:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        Hooks.EMU_MERGECONFIGINI(CorruptCore.bizhawkDir + Path.DirectorySeparatorChar + "backup_config.ini", CorruptCore.bizhawkDir + Path.DirectorySeparatorChar + "stockpile_config.ini");
                    });
                    break;

                case REMOTE_RESTOREBIZHAWKCONFIG:
                    SyncObjectSingleton.FormExecute((o, ea) =>
                    {
                        Process.Start(CorruptCore.bizhawkDir + Path.DirectorySeparatorChar + $"RestoreConfigDETACHED.bat");
                    });
                    break;

                case REMOTE_ISNORMALADVANCE:
                    e.setReturnValue(Hooks.isNormalAdvance);
                    break;
                }
            }
            catch (Exception ex)
            {
                if (VanguardCore.ShowErrorDialog(ex, true) == DialogResult.Abort)
                {
                    throw new RTCV.NetCore.AbortEverythingException();
                }
            }
        }