Beispiel #1
0
        public override bool SetRomImage(RomName romName, byte[] data, int startIndex, int length)
        {
            if (length > 16384)
            {
                length = 16384;
            }
            switch (romName)
            {
            case RomName.ROM_128:
                this.setImage(this._ROMS[0], data, startIndex, length);
                break;

            case RomName.ROM_48:
                this.setImage(this._ROMS[1], data, startIndex, length);
                break;

            case RomName.ROM_TRDOS:
                this.setImage(this._ROMS[2], data, startIndex, length);
                break;

            case RomName.ROM_PROFI:
                this.setImage(this._ROMS[3], data, startIndex, length);
                break;

            default:
                return(false);
            }
            base.OnUpdateState();
            return(true);
        }
Beispiel #2
0
Datei: Rom.cs Projekt: Y2JB/Y2Gba
        public Rom(string fn)
        {
            RomFileName = fn;

            romData = new MemoryStream(File.ReadAllBytes(fn)).ToArray();

            // Cache the entire ROM along 32 bit boundaries. This lets us do fast access when advancing and refilling the CPU pipeline.
            Cache32BitRomValues();
            Cache16BitRomValues();

            DetectSaveType(fn);

            sRam        = new byte[Max_SRam_Size];
            this.Eeprom = new Eeprom(this);

            RomName = Encoding.UTF8.GetString(romData, RomNameOffset, 12).TrimEnd((Char)0);
            RomName = RomName.Replace("/", String.Empty);

            EntryPoint = ReadWord(0);

            switch (SaveGameBackupType)
            {
            case BackupType.SRAM:
                LoadSramData();
                break;

            case BackupType.EEPROM:
                Eeprom.Load();
                break;
            }
        }
Beispiel #3
0
 public override int GetRomIndex(RomName romId)
 {
     switch (romId)
     {
         case RomName.ROM_128: return 0;		// +3 Editor
         case RomName.ROM_SYS: return 1;		// +3 Syntax
         case RomName.ROM_DOS: return 2;		// +3 DOS
         case RomName.ROM_SOS: return 3;		// +3 SOS
     }
     LogAgent.Error("Unknown RomName: {0}", romId);
     throw new InvalidOperationException("Unknown RomName");
 }
Beispiel #4
0
        public void RomNameParsingTest()
        {
            var romName = new RomName("Final Fantasy VII (Europe) (Disc 1)[SCES-00867]");

            Assert.AreEqual("Disc 1", romName.DiscName);
            Assert.AreEqual("Final Fantasy VII", romName.SanitizedName);
            Assert.AreEqual("Europe", romName.Properties[0]);
            Assert.AreEqual("Disc 1", romName.Properties[1]);
            Assert.AreEqual("SCES-00867", romName.Properties[2]);

            romName = new RomName("Battlezone 2000(USA, Europe)");
            Assert.AreEqual("Battlezone 2000", romName.SanitizedName);
            Assert.AreEqual("USA", romName.Properties[0]);
            Assert.AreEqual("Europe", romName.Properties[1]);
        }
Beispiel #5
0
 public void LoadROMS()
 {
     try
     {
         string name = Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "roms.zip");
         using (ZipFile zipFile = new ZipFile(name))
         {
             foreach (object obj in zipFile)
             {
                 ZipEntry zipEntry = (ZipEntry)obj;
                 if (zipEntry.IsFile && zipEntry.CanDecompress)
                 {
                     string value = Path.GetFileNameWithoutExtension(zipEntry.Name).ToLower();
                     foreach (object obj2 in Enum.GetValues(typeof(RomName)))
                     {
                         RomName romName = (RomName)obj2;
                         if (romName.ToString().Equals(value, StringComparison.InvariantCultureIgnoreCase))
                         {
                             using (Stream inputStream = zipFile.GetInputStream(zipEntry))
                             {
                                 int num = (int)zipEntry.Size;
                                 if (num >= 16384)
                                 {
                                     num = 16384;
                                 }
                                 byte[] array = new byte[num];
                                 inputStream.Read(array, 0, num);
                                 this._spec.SetRomImage(romName, array, 0, num);
                                 break;
                             }
                         }
                     }
                 }
             }
         }
     }
     catch (FileNotFoundException)
     {
         PlatformFactory.Platform.ShowWarning("Load ROM images failed!\nFile not found: roms.zip", "Error");
     }
 }
Beispiel #6
0
 public abstract bool SetRomImage(RomName romName, byte[] data, int startIndex, int length);
Beispiel #7
0
 public virtual int GetRomIndex(RomName romId)
 {
     switch (romId)
     {
         case RomName.ROM_128: return 0;
         case RomName.ROM_SOS: return 1;
         case RomName.ROM_DOS: return 2;
         case RomName.ROM_SYS: return 3;
     }
     LogAgent.Error("Unknown RomName: {0}", romId);
     throw new InvalidOperationException("Unknown RomName");
 }
Beispiel #8
0
 public override int GetRomIndex(RomName romId)
 {
     switch (romId)
     {
         case RomName.ROM_SOS: return 4;
         case RomName.ROM_DOS: return 5;
         case RomName.ROM_128: return 6;
         case RomName.ROM_SYS: return 7;
     }
     throw new NotImplementedException();
 }