private void MAPButtonClick(object sender, EventArgs e)
        {
            using (OpenFileDialog GenerateFor = new OpenFileDialog())
            {
                GenerateFor.Filter = "All GB/C ROMs|*.gb;*.gbc";
                if (GenerateFor.ShowDialog() == DialogResult.OK && File.Exists(GenerateFor.FileName))
                {
                    if ((new FileInfo(GenerateFor.FileName).Length / 1024) > 1024)
                    {
                        MessageBox.Show("ROM size exceeds the maximum of 1024kByte.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        return;
                    }

                    ROM ROMToProcess = new ROM();
                    using (FileStream FileToAdd = new FileStream(GenerateFor.FileName, FileMode.Open, FileAccess.Read))
                    {
                        using (MemoryStream Mem = new MemoryStream())
                        {
                            FileToAdd.CopyTo(Mem);
                            ROMToProcess = Processing.ParseROM(Mem, GenerateFor.FileName);
                        }
                    }

                    Byte[] MAPBytes = Processing.GenerateStandaloneMAPForROM(ROMToProcess);

                    if (!CheckFolderPermissions(Path.GetDirectoryName(ROMToProcess.File)))
                    {
                        return;
                    }
                    String FileToCreate = Path.GetDirectoryName(ROMToProcess.File) + @"\" + Path.GetFileNameWithoutExtension(ROMToProcess.File) + ".map";
                    File.WriteAllBytes(FileToCreate, MAPBytes);
                    MessageBox.Show("Created:" + Environment.NewLine + FileToCreate);
                }
            }
        }
Exemple #2
0
        private void FileDrop(object sender, DragEventArgs e)
        {
            String[]   FileTypes = new String[] { ".gb", ".gbc", ".bin" };
            String[]   Files     = (String[])e.Data.GetData(DataFormats.FileDrop);
            List <ROM> ROMsToAdd = new List <ROM>();

            foreach (String FileToProcess in Files)
            {
                if (File.Exists(FileToProcess) && FileTypes.Contains(Path.GetExtension(FileToProcess)))
                {
                    Byte[] temp = new Byte[15], temp1 = new Byte[0x10];
                    using (FileStream Reader = new FileStream(FileToProcess, FileMode.Open, FileAccess.Read))
                    {
                        Reader.Position = 0x134;
                        //ROM ASCII title
                        Reader.Read(temp, 0, 15);
                        //Info entry header for Menu
                        Reader.Position = 0x1C000;
                        Reader.Read(temp1, 0, 0x10);
                        if (Encoding.ASCII.GetString(temp) == "NP M-MENU  MENU" && temp1.SequenceEqual(new Byte[] { 0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x44, 0x4D, 0x47, 0x20, 0x2D, 0x4D, 0x45, 0x4E, 0x55 }))
                        {
                            ROMsToAdd.AddRange(Processing.ParseGBMBinary(FileToProcess));
                        }
                        else if (Path.GetExtension(FileToProcess) != ".bin")
                        {
                            using (MemoryStream Mem = new MemoryStream())
                            {
                                Reader.Position = 0;
                                Reader.CopyTo(Mem);;
                                ROMsToAdd.Add(Processing.ParseROM(Mem, FileToProcess));
                            }
                        }
                    }
                }
            }

            foreach (ROM R in ROMsToAdd)
            {
                TitleEntry ROMTitle = new TitleEntry(R.ASCIITitle);
                if (ROMTitle.ShowDialog() == DialogResult.OK)
                {
                    R.Title = ROMTitle.Title;
                }
                else
                {
                    return;
                }
                AddROMToInterface(R);
            }
        }
Exemple #3
0
        private void AddButtonClick(object sender, EventArgs e)
        {
            using (OpenFileDialog AddRom = new OpenFileDialog())
            {
                AddRom.Filter      = "All GB/C ROMs|*.gb;*.gbc";
                AddRom.Multiselect = true;
                if (AddRom.ShowDialog() == DialogResult.OK)
                {
                    List <ROM> ROMsToAdd = new List <ROM>();
                    foreach (String BinaryFile in AddRom.FileNames)
                    {
                        if (!File.Exists(BinaryFile))
                        {
                            continue;
                        }

                        using (FileStream FileToAdd = new FileStream(BinaryFile, FileMode.Open, FileAccess.Read))
                        {
                            using (MemoryStream Mem = new MemoryStream())
                            {
                                FileToAdd.CopyTo(Mem);
                                ROMsToAdd.Add(Processing.ParseROM(Mem, BinaryFile));
                            }
                        }
                    }
                    foreach (ROM R in ROMsToAdd)
                    {
                        TitleEntry ROMTitle = new TitleEntry(R.ASCIITitle);
                        if (ROMTitle.ShowDialog() == DialogResult.OK)
                        {
                            R.Title = ROMTitle.Title;
                        }
                        else
                        {
                            return;
                        }
                        AddROMToInterface(R);
                    }
                }
            }
        }