private void openROMToolStripMenuItem_Click(object sender, EventArgs e) { openFileDialog1.Title = "Open ROM"; openFileDialog1.FileName = ""; openFileDialog1.Filter = "GBA ROMs|*.gba"; if (openFileDialog1.ShowDialog() != DialogResult.OK) { return; } using (GBABinaryReader gb = new GBABinaryReader(openFileDialog1.FileName)) { gb.BaseStream.Seek(0xA0, SeekOrigin.Begin); string name = gb.ReadString(12); string code = gb.ReadString(4); //MessageBox.Show(string.Format("Name: {0}\nCode: {1}", name, code)); if (!goodROMCodes.Contains(code)) { MessageBox.Show(string.Format("{0} is not a recognized Pokémon ROM code!", code), "Uh-oh!", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } romFile = openFileDialog1.FileName; }
private string LoadROMCode() { if (ROMFilePath == string.Empty) { return(null); } string code; using (GBABinaryReader gb = new GBABinaryReader(ROMFilePath)) { gb.BaseStream.Seek(0xAC, SeekOrigin.Begin); code = gb.ReadString(4); } return(code); }