Exemplo n.º 1
0
        public bool ReadRom()
        {
            bool valid = false;

            try
            {
                FileInfo fInfo = new FileInfo(Filename);
                RomSize = fInfo.Length;

                if (!(fInfo.Extension.ToLower() == ".smc") && !(fInfo.Extension.ToLower() == ".sfc"))
                {
                    Console.Error.WriteLine("Invalid ROM extension: " + fInfo.Extension);
                }
                else if (RomSize < 0x300000 || RomSize > 0x600000)
                {
                    Console.Error.WriteLine("Invalid ROM size: $" + RomSize.ToString("X8"));
                }
                else
                {
                    FileStream   fStream = new FileStream(Filename, FileMode.Open, FileAccess.Read);
                    BinaryReader br      = new BinaryReader(fStream);
                    Content = br.ReadBytes((int)fInfo.Length);
                    br.Close();
                    fStream.Close();
                    RemoveHeader();
                    valid = true;
                }
            }
            catch (Exception e)
            {
                Console.Error.WriteLine("Unable to read ROM " + Filename, "Error: " + e.Message);
            }

            return(valid);
        }
Exemplo n.º 2
0
        public void WriteToIni(IniData iniData, int romIndex)
        {
            string sectionName = "ROM" + romIndex.ToString();

            iniData.Sections.AddSection(sectionName);
            iniData[sectionName].AddKey("FULL_ID", FullId);
            iniData[sectionName].AddKey("ID", Id);
            iniData[sectionName].AddKey("NAME", Name);
            iniData[sectionName].AddKey("TV", GetTvString());
            iniData[sectionName].AddKey("CIC", GetCicString());
            iniData[sectionName].AddKey("SAVE", GetSaveString());
            iniData[sectionName].AddKey("SAVE_OFFSET", SaveOffset.ToString());
            iniData[sectionName].AddKey("ROM_SIZE", RomSize.ToString());
            iniData[sectionName].AddKey("ROM_CRC", RomCrc.ToString("X08"));

            for (int i = 0; i < 32; i++)
            {
                string mappingKey = "MAPPING" + i.ToString();
                byte   mapping    = 0;
                if (FlashPartitions.Length > i)
                {
                    mapping = FlashPartitions[i].Offset;
                }
                iniData[sectionName].AddKey(mappingKey, mapping.ToString());
            }
        }