Esempio n. 1
0
        //construct
        public ChainChompApplication()
        {
            InitializeComponent();

            if (!Directory.Exists(appDataPath))
            {
                Directory.CreateDirectory(appDataPath);
            }

            if (!Directory.Exists(outputPath))
            {
                Directory.CreateDirectory(outputPath);
            }

            //load library
            ImageEmuLibrary.LoadSettings();
            PopulateComboBoxes();
            if (ImageEmuLibrary.images.Count > 0)
            {
                romImageComboBox.SelectedIndex = 0;
            }

            ChainEditor root = new ChainEditor(chainTab);

            root.removeChainButton.Enabled = false;
            rootTabPage.Controls.Add(root);
            root.ResizeRack(panel1.Height - 136);
        }
Esempio n. 2
0
        // RUN

        public void runButton_Click(object sender, EventArgs e)
        {
            //the fun part!
            if (game != null && game.length > 0)
            {
                //get ready for another round
                try
                {
                    if (Directory.Exists(outputPath))
                    {
                        Directory.Delete(outputPath, true);
                        Directory.CreateDirectory(outputPath);
                    }
                    else
                    {
                        Directory.CreateDirectory(outputPath);
                    }
                }
                catch (IOException error)
                {
                    MessageBox.Show(error.Message, "Error", MessageBoxButtons.OK);
                    return;
                }

                game.ClearCorruptions();

                //gather chains & prepare threads
                List <Chain> chains = new List <Chain>();
                //List<BackgroundWorker> threads = new List<BackgroundWorker>();

                for (int i = 0; i < chainTab.TabCount - 1; i++)
                {
                    ChainEditor ce = (ChainEditor)chainTab.TabPages[i].Controls[0];
                    if (ce.enableChainCheckBox.Checked)
                    {
                        chains.Add((chainTab.TabPages[i].Controls[0] as ChainEditor).chain);
                    }
                }

                //corrupt stuff
                List <ROMSample> corruptions = new List <ROMSample>();
                chains.ForEach(i => corruptions.Add(i.RunChain(game.GetSample(i.startOffset, i.endOffset))));
                game.CommitSampleRangeToROM(corruptions);

                //string p = string.Format(@"{0}\chainChomp{1}", outputPath, Path.GetExtension(game.fileName));



                if (game.Dump(p) && selectedEmu != null && selectedEmu.Text != "None")
                {
                    // stop/start emulator
                    if (emulator != null && !emulator.HasExited)
                    {
                        emulator.Kill();
                    }

                    // Set-up process
                    string fileName  = selectedEmu.Text;
                    string location  = fileName.Substring(0, fileName.LastIndexOf("\\") - 1);
                    var    startInfo = new System.Diagnostics.ProcessStartInfo();
                    startInfo.FileName  = fileName;
                    startInfo.Arguments = p;

                    //emulator = System.Diagnostics.Process.Start(startInfo);

                    emulator = System.Diagnostics.Process.Start("\"" + fileName + "\"", "\"" + p + "\"");
                }
            }
            else
            {
                MessageBox.Show("Invalid ROM Image selected. Chains were not run.", "Run Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }