Example #1
0
        private void replace(string filename)
        {
            byte[] gbc_data_arr = File.ReadAllBytes(filename);
            object h            = listBox1.SelectedItem;

            if (h == null)
            {
                MessageBox.Show("No item is selected.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
            else if (h is Stateheader)
            {
                try {
                    GameBoyAdvanceSRAM new_data = loaded_sram.CopyAndReplace((Stateheader)h, gbc_data_arr);
                    loaded_sram = new_data;
                    dirty       = true;

                    int sel = listBox1.SelectedIndex;
                    headerScan();
                    if (listBox1.Items.Count > sel)
                    {
                        listBox1.SelectedIndex = sel;
                    }
                } catch (GoombaException e) {
                    MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
            else
            {
                MessageBox.Show("You cannot replace data for this type of header.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Example #2
0
        private void btnDelete_Click(object sender, EventArgs e)
        {
            Stateheader sh = listBox1.SelectedItem as Stateheader;

            if (sh == null)
            {
                return;
            }

            string msg = $"Are you sure you want to remove the save data for {sh.Title} from this file? You will need to run Goomba if you want to add new save data later.";

            if (MessageBox.Show(this, msg, Text, MessageBoxButtons.YesNo) == DialogResult.Yes)
            {
                try {
                    GameBoyAdvanceSRAM new_data = loaded_sram.CopyAndRemove(sh);
                    loaded_sram = new_data;
                    dirty       = true;

                    int sel = listBox1.SelectedIndex;
                    headerScan();
                    if (listBox1.Items.Count > sel)
                    {
                        listBox1.SelectedIndex = sel;
                    }
                } catch (GoombaException ex) {
                    MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Example #3
0
        private void load(string filename)
        {
            if (!okToClose())
            {
                return;
            }

            try {
                byte[] arr = File.ReadAllBytes(filename);

                var extractedRoms1 = GameBoyROM.Extract(arr);
                var extractedRoms2 = PocketNESROM.Extract(arr);
                var extractedRoms3 = SMSAdvanceROM.Extract(arr);
                if (extractedRoms1.Any() || extractedRoms2.Any() || extractedRoms3.Any())
                {
                    loaded_sram         = null;
                    loaded_rom_contents = new List <ExtractedROM>();
                    loaded_rom_contents.AddRange(extractedRoms1);
                    loaded_rom_contents.AddRange(extractedRoms2);
                    loaded_rom_contents.AddRange(extractedRoms3);
                }
                else
                {
                    if (arr.Length > GameBoyAdvanceSRAM.ExpectedSize)
                    {
                        MessageBox.Show("This file is more than " + GameBoyAdvanceSRAM.ExpectedSize +
                                        " bytes. If you overwrite the file, the last " + (arr.Length - GameBoyAdvanceSRAM.ExpectedSize) +
                                        " bytes will be discarded.", "Note", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    }
                    loaded_sram         = new GameBoyAdvanceSRAM(arr, true);
                    loaded_rom_contents = null;
                    dirty = false;
                }

                filePath  = filename;
                this.Text = (filename == null)
                                        ? TITLE
                                        : TITLE + " - " + Path.GetFileName(filename);

                headerScan();
            } catch (GoombaException e) {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }