Exemplo n.º 1
0
 public static byte[] ReadRomString(Rom input, byte endByte = 0xFF)
 {
     var output = new List<byte>();
     byte current = input.ReadByte();
     while (current != endByte)
     {
         output.Add(current);
         current = input.ReadByte();
     }
     return output.ToArray();
 }
        public void RomComparerStrictCrcOnlyTests_CompareRoms_CompareCorrectly(string firstRomPath, string secondRomPath, int expectedCompareResult)
        {
            var paths = RomComparerStrictCrcOnlyTestStorageAccess.Initialize(firstRomPath, secondRomPath);
            var rom0  = Rom.Create(paths[0], null);

            Assert.NotNull(rom0);
            var rom1 = Rom.Create(paths[1], null);

            Assert.NotNull(rom1);

            var compareResult = RomComparerStrictCrcOnly.Default.Compare(rom0, rom1);

            Assert.Equal(expectedCompareResult, compareResult);
        }
        static public void CreateScript(string rootPath, Rom current, string target, string arguments)
        {
            string inputText;

            if (target == "dolphin5")
            {
                inputText = current.Starter + " -target=" + target + " -ddinumber=" + current.Command;
            }
            else
            {
                inputText = current.Starter + " -target=" + target + " -rom=" + current.Command + arguments;
            }
            File.WriteAllText(rootPath + "\\" + current.Command + ".bat", inputText);
        }
Exemplo n.º 4
0
        private void WriteOam(OamSprite oam)
        {
            Rom.WriteSByte(oam.CoordY);
            Rom.WriteSByte((sbyte)oam.CoordX);

            ushort ch = (ushort)(
                (oam.Tile & 0x3FF) |
                (oam.FlipH ? 0x400 : 0) |
                (oam.FlipV ? 0x800 : 0) |
                ((oam.ObjSize & 3) << 12) |
                ((oam.ObjShape & 3) << 14));

            Rom.WriteUShort(ch);
        }
Exemplo n.º 5
0
        private void SetRomTypeSettings(RomVersion version)
        {
            OpenFileDialog openFile     = new OpenFileDialog();
            DialogResult   result       = DialogResult.OK;
            RomVersion     inputVersion = version;

            //Set openFile title in case we need to look for a rom
            openFile.Title = $"Open {version} rom";

            string romLocation;

            if (!version.IsCustomBuild())
            {
                if (!PathUtil.TryGetRomLocation(version, out romLocation))
                {
                    result = openFile.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        PathUtil.SetRomLocation(version, openFile.FileName);
                        PathUtil.TryGetRomLocation(version, out romLocation);
                    }
                }
            }
            else
            {
                result      = openFile.ShowDialog();
                romLocation = openFile.FileName;

                if (result == DialogResult.OK)
                {
                    using (VersionSelector vs = new VersionSelector())
                    {
                        vs.Game = version.Game;
                        result  = vs.ShowDialog();
                        version = vs.Version;
                    }
                }
            }
            openFile.Dispose();

            rom = result == DialogResult.OK ? Rom.New(romLocation, version) : null;

            //update
            string romStats = rom == null ?
                              $"Error: No Rom!"
                : $"{inputVersion.Game}, File Stats Mode: {version}{Environment.NewLine}{romLocation}";

            outputRichTextBox.Clear();
            outputRichTextBox.AppendText(romStats);
        }
Exemplo n.º 6
0
 /// <summary>
 /// Returns a clone of this revision
 /// </summary>
 /// <returns>Cloned revision</returns>
 public SpectrumEdition Clone()
 {
     return(new SpectrumEdition
     {
         Cpu = Cpu.Clone(),
         Rom = Rom.Clone(),
         Memory = Memory.Clone(),
         Screen = Screen.Clone(),
         Beeper = Beeper.Clone(),
         Sound = Sound?.Clone(),
         Floppy = Floppy?.Clone(),
         UlaIssue = UlaIssue
     });
 }
Exemplo n.º 7
0
        public void RomComparerStrict_CompareLuigiFormatRomToRomFormatRom_CompareAsDifferent()
        {
            var paths = RomComparerStrictTestStorageAccess.Initialize(TestRomResources.TestLuigiFromBinPath, TestRomResources.TestRomPath);
            var rom0  = Rom.Create(paths[0], null);

            Assert.NotNull(rom0);
            var rom1 = Rom.Create(paths[1], null);

            Assert.NotNull(rom1);

            var compareResult = RomComparerStrict.Default.Compare(rom0, rom1);

            Assert.NotEqual(0, compareResult);
        }
Exemplo n.º 8
0
        public void RomComparerStrict_CompareTwoBinFormatRomsWithDifferentCfgFile_CompareAsDifferent()
        {
            var paths = RomComparerStrictTestStorageAccess.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath, TestRomResources.TestBinMetadataPath, TestRomResources.TestCfgMetadataPath);
            var rom0  = Rom.Create(paths[0], paths[1]);

            Assert.NotNull(rom0);
            var rom1 = Rom.Create(paths[2], paths[3]);

            Assert.NotNull(rom1);

            var compareResult = RomComparerStrict.Default.Compare(rom0, rom1);

            Assert.NotEqual(0, compareResult);
        }
Exemplo n.º 9
0
 public static void Init()
 {
     Rom.Seek(Address);
     for (int i = 0; i < Num; i++)
     {
         var rgp = new RoomGfxPal();
         rgp.index = i;
         for (int j = 0; j < Length; j++)
         {
             rgp.Data[j] = Rom.ReadByte();
         }
         RoomGfxPalEntries[i] = rgp;
     }
 }
Exemplo n.º 10
0
 public static void Init()
 {
     Rom.Seek(Address);
     for (int i = 0; i < Num; i++)
     {
         var ri = new RoomInfo();
         ri.index = i;
         for (int j = 0; j < Length; j++)
         {
             ri.Data[j] = Rom.ReadByte();
         }
         RoomInfoEntries[i] = ri;
     }
 }
Exemplo n.º 11
0
        private static Func <DisassemblyTask, bool> GetDisassembleOverlayFilter(DisassembleFileOptions opts, RomVersion version, string path)
        {
            Func <DisassemblyTask, bool> filter = x => false;

            if (opts.FileStart != null)
            {
                if (int.TryParse(opts.FileStart, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int fileStart))
                {
                    filter = x => x.VRom.Start == fileStart;
                }
                else
                {
                    Console.WriteLine($"invalid start address {opts.FileStart}");
                    return(null);
                }
            }
            else if (opts.File != null)
            {
                filter = x => x.Name == opts.File || x.Name == $"ovl_{opts.File}";
            }
            else
            {
                Rom           rom = Rom.New(path, version);
                OverlayRecord dlf_record;

                if (!int.TryParse(opts.ActorIndex, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out int actorIndex))
                {
                    Console.WriteLine($"actor index {actorIndex} is invalid");
                    return(null);
                }

                if (actorIndex == 0)
                {
                    dlf_record = rom.Files.GetPlayPauseOverlayRecord(1);
                }
                else
                {
                    dlf_record = rom.Files.GetActorOverlayRecord(actorIndex);
                    if (dlf_record.VRom.Size == 0)
                    {
                        Console.WriteLine($"actor 0x{opts.ActorIndex:X4} does not have an overlay file");
                        return(null);
                    }
                }
                filter = x => x.VRom.Start == dlf_record.VRom.Start;
            }

            return(filter);
        }
Exemplo n.º 12
0
        private void LoadPictures()
        {
            try
            {
                pictureBoxBoxart.Image   = null;
                pictureBoxTitle.Image    = null;
                pictureBoxGameplay.Image = null;

                if (dataGridView.SelectedRows.Count == 0)
                {
                    return;
                }

                Rom rom = (Rom)dataGridView.SelectedRows[0].Tag;

                if (rom == null)
                {
                    return;
                }

                if (rom.Platform == null)
                {
                    return;
                }

                var box      = RomFunctions.GetRomPicture(rom, Values.BoxartFolder);
                var title    = RomFunctions.GetRomPicture(rom, Values.TitleFolder);
                var gameplay = RomFunctions.GetRomPicture(rom, Values.GameplayFolder);

                if (!string.IsNullOrEmpty(box))
                {
                    pictureBoxBoxart.Image = Functions.CreateBitmap(box);
                }

                if (!string.IsNullOrEmpty(title))
                {
                    pictureBoxTitle.Image = Functions.CreateBitmap(title);
                }

                if (!string.IsNullOrEmpty(gameplay))
                {
                    pictureBoxGameplay.Image = Functions.CreateBitmap(gameplay);
                }
            }
            catch (Exception ex)
            {
                FormCustomMessage.ShowError(ex.Message);
            }
        }
Exemplo n.º 13
0
        public void Rom_ReplaceCfgWithDifferentValidCfgPath_UpdatesConfigPath()
        {
            var paths = RomTestStorageAccess.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath, TestRomResources.TestCfgMetadataPath);
            var rom   = Rom.Create(paths[0], paths[1]);

            Assert.NotNull(rom);
            Assert.Equal(paths[0], rom.RomPath);
            Assert.Equal(paths[1], rom.ConfigPath);
            Assert.Equal(TestRomResources.TestCfgCrc, rom.CfgCrc);

            Rom.ReplaceCfgPath(rom, paths[2]);

            Assert.Equal(paths[2], rom.ConfigPath);
            Assert.Equal(TestRomResources.TestMetadataCfgCrc, rom.CfgCrc);
        }
Exemplo n.º 14
0
        private static bool RenameRomDir(Rom rom, string changeFileName)
        {
            string oldFile = rom.Platform.DefaultRomPath + "\\" + rom.FileName;
            string newFile = rom.Platform.DefaultRomPath + "\\" + changeFileName;

            if (Directory.Exists(newFile))
            {
                throw new Exception("A directory named \"" + newFile + "\" already exists!");
            }

            Directory.Move(oldFile, newFile);
            rom.FileName = changeFileName;

            return(true);
        }
Exemplo n.º 15
0
        private void buttonOpenEmu_Click(object sender, EventArgs e)
        {
            if (dataGridView.SelectedRows.Count == 0)
            {
                return;
            }
            if (comboBoxEmulators.SelectedItem == null)
            {
                return;
            }
            Rom      rom = (Rom)dataGridView.SelectedRows[0].Tag;
            Emulator emu = (Emulator)comboBoxEmulators.SelectedItem;

            RunAppFunctions.RunPlatform(emu);
        }
Exemplo n.º 16
0
        private void pictureBoxRun_Click(object sender, EventArgs e)
        {
            if (dataGridView.SelectedRows.Count == 0)
            {
                return;
            }
            if (comboBoxEmulators.SelectedItem == null)
            {
                return;
            }
            Rom      rom = (Rom)dataGridView.SelectedRows[0].Tag;
            Emulator emu = (Emulator)comboBoxEmulators.SelectedItem;

            RunAppFunctions.OpenApplication(rom, emu);
        }
Exemplo n.º 17
0
        public static void loadChrRom(ref Rom romFile)
        {
            uint chrDataAddress = (uint)(0x4000 * romFile.getProgramRomSize());

            if (romFile.getCHRRomSize() != 0)
            {
                for (uint i = 0; i < 0x2000; i++)
                {
                    if ((chrDataAddress + i) < (Core.rom.getExactDataLength() - 16)) //16 in order to skip the INES header
                    {
                        Core.ppu.writePPURamByte((ushort)i, Core.rom.readByte(chrDataAddress + i + 16));
                    }
                }
            }
        }
Exemplo n.º 18
0
        public void Rom_ReplaceCfgOnNonBinFormatRom_HasNoEffect()
        {
            var paths = RomTestStorageAccess.Initialize(TestRomResources.TestRomPath, TestRomResources.TestCfgPath, TestRomResources.TestCfgMetadataPath);
            var rom   = Rom.Create(paths[0], paths[1]);

            Assert.NotNull(rom);
            Assert.Equal(paths[0], rom.RomPath);
            Assert.Null(rom.ConfigPath);
            Assert.Equal(0u, rom.CfgCrc);

            Rom.ReplaceCfgPath(rom, paths[2]);

            Assert.Null(rom.ConfigPath);
            Assert.Equal(0u, rom.CfgCrc);
        }
Exemplo n.º 19
0
        public bool PlayGame(int gameId)
        {
            Rom game = GetGameById(gameId);

            if (game != null)
            {
                Emulator emulator = Emulators.ToList().Find(x => x.IdRomType == game.IdRomType);
                if (emulator != null)
                {
                    return(EmulatorManager.Instance.RunGame(emulator, game));
                }
            }

            return(false);
        }
Exemplo n.º 20
0
        public int EncodeNew()
        {
            int result = 0;

            foreach (var sample in Samples)
            {
                var slice   = Rom.Slice(sample);
                var decoded = Yaz.Decode(slice);
                result = Yaz.EncodeWithHeader(decoded, slice);
                // Fill remaining bytes with 0.
                slice.Slice(result).Fill(0);
            }

            return(result);
        }
Exemplo n.º 21
0
        public void Rom_ReplaceCfgWithNullCfgPath_RemovesConfigPath()
        {
            var paths = RomTestStorageAccess.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgPath);
            var rom   = Rom.Create(paths[0], paths[1]);

            Assert.NotNull(rom);
            Assert.Equal(paths[0], rom.RomPath);
            Assert.Equal(paths[1], rom.ConfigPath);
            Assert.Equal(TestRomResources.TestCfgCrc, rom.CfgCrc);

            Rom.ReplaceCfgPath(rom, null);

            Assert.Null(rom.ConfigPath);
            Assert.Equal(0u, rom.CfgCrc);
        }
Exemplo n.º 22
0
        /// <inheritdoc />
        public override bool Validate()
        {
            var isValid = ResolvedRom != null;

            if (!isValid)
            {
                ResolvedRom = Rom.Create(RomPath, ConfigPath);
            }
            IsValid = ResolvedRom != null;
            if (IsValid)
            {
                isValid = ResolvedRom.Validate();
            }
            return(isValid);
        }
Exemplo n.º 23
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.Error.WriteLine(USAGE);
                Environment.Exit(1);
            }

            ConfigureLogging();

            Rom rom = RomLoader.Load(args[0], failIfCorrupted: false);

            PrintRomInformation(rom.Information);
            Emulator.Init(rom);
        }
Exemplo n.º 24
0
        public static void loadChrRomBank(ref Rom romFile)
        {
            //0x0000-0x0FFF Chr Rom Data Bank 1
            //0x1000-0x1FFF Chr Rom Data Bank 2

            uint chrDataAddress = (uint)(0x2000 * romFile.getProgramRomSize());

            for (uint i = 0; i < 0x2000; i++)
            {
                if ((chrDataAddress + i) < (Core.rom.getExactDataLength() - 16)) //16 in order to skip the INES header
                {
                    Core.ppu.writePPURamByte((ushort)i, Core.rom.readByte(chrDataAddress + i + 16));
                }
            }
        }
Exemplo n.º 25
0
        public static void Init()
        {
            Rom.Seek(Address);
            for (int i = 0; i < Entries; i++)
            {
                ActionTable at = new ActionTable();

                for (int j = 0; j < at.Data.Length; j++)
                {
                    at.Data[j] = Rom.ReadUShort();
                }

                Actions[i] = at;
            }
        }
        public void CfgFileMetadataProgramInformation_CreateUsingRomWithUnknownMetadataBlockType_ContainsValidMetadata()
        {
            var romPaths = CfgFileMetadataProgramInformationTestStorageAccess.Initialize(TestRomResources.TestBinPath, TestRomResources.TestCfgMetadataPath);
            var rom      = Rom.AsSpecificRomType <BinFormatRom>(Rom.Create(romPaths[0], romPaths[1]));

            rom.MetadataCacheEnabled = true;
            Assert.NotNull(rom.Metadata);
            var metadata = (List <CfgVarMetadataBlock>)rom.Metadata;

            metadata.Add(new CfgVarMetadataFeatureCompatibility(CfgVarMetadataIdTag.Invalid));

            var cfgMetadataInformation = new CfgFileMetadataProgramInformation(rom);

            Assert.NotNull(cfgMetadataInformation.Metadata);
        }
Exemplo n.º 27
0
        public static bool IsRomPack(Rom rom)
        {
            var ext = RomFunctions.GetFileExtension(rom.FileName).ToLower();

            if (ext == ".gdi" || ext == ".ccd" || ext == ".cue" || ext == ".rom")
            {
                FileInfo file = new FileInfo(rom.FileName);
                if (file.Directory.Name.ToLower() == rom.Name.ToLower())
                {
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 28
0
        public void Save()
        {
            Rom.Seek(Address + (index * Length));

            Rom.SeekAdd(4);

            Rom.WriteByte(this.ItemType);

            Rom.SeekAdd(3);

            Rom.WriteByte((byte)(this.KeyItem ? 0 : 1));

            Rom.SeekAdd(1);

            Rom.WriteUShort(this.Sell);
            Rom.WriteByte(this.EquipOwner);

            Rom.SeekAdd(3);

            Rom.WriteInt(this.Hp);
            Rom.WriteShort(this.Pp);

            Rom.SeekAdd(2);

            Rom.WriteSByte(this.Off);
            Rom.WriteSByte(this.Def);
            Rom.WriteSByte(this.Iq);
            Rom.WriteSByte(this.Speed);

            Rom.SeekAdd(4);

            for (int j = 0; j < this.ProtectionAilment.Length; j++)
            {
                Rom.WriteShort(this.ProtectionAilment[j]);
            }

            for (int j = 0; j < this.ProtectionPsi.Length; j++)
            {
                Rom.WriteSByte(this.ProtectionPsi[j]);
            }

            Rom.SeekAdd(0x13);

            Rom.WriteUShort(this.Hp1);
            Rom.WriteUShort(this.Hp2);

            M3Rom.IsModified = true;
        }
Exemplo n.º 29
0
        private static bool Set(Rom rom, string oldfile = null)
        {
            if (!XML.xmlRoms.ContainsKey(rom.Platform.Name))
            {
                if (!File.Exists(Values.PlatformsPath + "\\" + rom.Platform.Name + "\\roms.xml"))
                {
                    CreateRomXML(rom.Platform.Name);
                }
            }

            XmlNode node    = null;
            var     xmlRoms = XML.xmlRoms[rom.Platform.Name];

            if (oldfile == null)
            {
                node = XML.GetRomNode(rom.Platform.Name, rom.FileName);
            }
            else
            {
                node = XML.GetRomNode(rom.Platform.Name, oldfile);
            }

            if (node == null)
            {
                node = SetRomNode(rom.Platform.Name);
                var parent = XML.GetParentNode(xmlRoms, "Roms");
                xmlRoms.ChildNodes[1].AppendChild(node);
                RomList.Add(rom);
            }

            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Id", rom.Id);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Name", rom.Name);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "DBName", rom.DBName);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "FileName", rom.FileName);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Platform", rom.Platform == null ? "" : rom.Platform.Name);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Genre", rom.Genre == null ? "" : rom.Genre.Name);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "YearReleased", rom.YearReleased);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Publisher", rom.Publisher);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Developer", rom.Developer);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Description", rom.Description);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "IdLocked", rom.IdLocked.ToString());
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Rating", rom.Rating == 0 ? string.Empty : rom.Rating.ToString("#.#"));
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Favorite", rom.Favorite.ToString());
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Emulator", rom.Emulator);
            Functions.CreateOrSetXmlAttribute(xmlRoms, node, "Series", rom.Series);

            return(true);
        }
Exemplo n.º 30
0
        public void ProgramDescription_ValidateWithValidRom_ReturnsTrue()
        {
            var romPath = ProgramDescriptionTestStorage.Initialize(TestRomResources.TestRomPath).First();
            var rom     = Rom.Create(romPath, null);

            Assert.NotNull(rom);
            var information = new TestProgramInformation();
            var crc         = rom.Crc;
            var name        = "AgletMaster 5500";

            information.AddCrc(crc, name);

            var description = new ProgramDescription(crc, rom, information);

            Assert.True(ProgramDescription.Validate(description, null, null, reportMessagesChanged: false));
        }
Exemplo n.º 31
0
        public static string GetText(int index)
        {
            int a = Address + 12 + (index << 1);

            int addr = Rom.ReadUShort(a);

            if (Version != RomVersion.Japanese)
            {
                addr <<= 1;
            }

            addr += Address;

            return(TextProvider.GetText(addr, 1024,
                                        (Version == RomVersion.Japanese) ? TextType.Japanese : TextType.EnglishWide, true));
        }
Exemplo n.º 32
0
        public Gameboy(Rom rom, bool useBios = true)
        {
            MemoryRouter = new MemoryRouter(rom.Memory);
            Cpu = new Cpu(MemoryRouter);
            timer = new GameboyTimer();
            Video = new Video();
            Joypad = new Joypad();
            Audio = new Audio();
            Disassembler = new Disassembler(MemoryRouter);

            Video.MemoryRouter = MemoryRouter;
            MemoryRouter.Video = Video;
            Joypad.MemoryRouter = MemoryRouter;
            MemoryRouter.Joypad = Joypad;
            timer.MemoryRouter = MemoryRouter;
            MemoryRouter.Timer = timer;
            MemoryRouter.Audio = Audio;

            if (!useBios) InitDevice();
        }
Exemplo n.º 33
0
 public SoundfontViewer(Rom rome)
 {
     rom = rome;
     InitializeComponent();
     setup();
 }
Exemplo n.º 34
0
		public SoundfontViewer(Rom _rom)
		{
			rom = _rom;
			InitializeComponent();
			setup();
		}
Exemplo n.º 35
0
 void Start()
 {
     lobby = GetComponent<Lobby> ();
     rom = GetComponent<Rom> ();
     spawnControl = GetComponent<SpawnControl> ();
 }