public static void SetGameSpecificOverscan(bool overrideOverscan, UInt32 top, UInt32 bottom, UInt32 left, UInt32 right) { RomInfo romInfo = InteropEmu.GetRomInfo(); if (romInfo.PrgCrc32 == 0) { return; } GameSpecificInfo existingConfig = ConfigManager.Config.GameSpecificSettings.Find(gameConfig => gameConfig.GamePrgCrc32 == romInfo.GetPrgCrcString()); if (overrideOverscan || existingConfig != null) { //Only add if the config already exists, or if override setting is turned on GameSpecificInfo info = existingConfig ?? new GameSpecificInfo(); info.GameName = romInfo.GetRomName(); info.GamePrgCrc32 = romInfo.GetPrgCrcString(); info.OverrideOverscan = overrideOverscan; info.OverscanTop = top; info.OverscanBottom = bottom; info.OverscanLeft = left; info.OverscanRight = right; if (existingConfig == null) { ConfigManager.Config.GameSpecificSettings.Add(info); } } }
public static GameSpecificInfo GetGameSpecificInfo() { RomInfo romInfo = InteropEmu.GetRomInfo(); GameSpecificInfo existingConfig = ConfigManager.Config.GameSpecificSettings.Find(gameConfig => gameConfig.GamePrgCrc32 == romInfo.GetPrgCrcString()); return(existingConfig); }
private void ApplyRom() { if (listView1.SelectedItems.Count > 0) { this.Close(); Mame.exit_pending = true; Thread.Sleep(100); RomInfo.Rom = RomInfo.GetRomByName(listView1.SelectedItems[0].SubItems[2].Text); this._myParentForm.LoadRom(); if (Machine.bRom) { m68000Form.iStatus = 0; m68000Form.iRAddress = 0; m68000Form.iROp = 0; m68000Form.iValue = 0; z80Form.iStatus = 0; Mame.exit_pending = false; this._myParentForm.resetToolStripMenuItem.Enabled = true; this._myParentForm.gameStripMenuItem.Enabled = true; UI.ui_init(this._myParentForm); mainForm.t1 = new Thread(Mame.mame_execute); mainForm.t1.Start(); } } }
private void InitializeGameSpecificOverscanTab() { RomInfo romInfo = InteropEmu.GetRomInfo(); if (romInfo.PrgCrc32 == 0) { chkEnableGameSpecificOverscan.Enabled = false; } else { chkEnableGameSpecificOverscan.Text += " (" + romInfo.GetRomName() + ")"; GameSpecificInfo info = GameSpecificInfo.GetGameSpecificInfo(); if (info != null) { chkEnableGameSpecificOverscan.Checked = info.OverrideOverscan; if (chkEnableGameSpecificOverscan.Checked) { tabOverscan.SelectedTab = tpgOverscanGameSpecific; } nudGameSpecificOverscanTop.Value = info.OverscanTop; nudGameSpecificOverscanBottom.Value = info.OverscanBottom; nudGameSpecificOverscanLeft.Value = info.OverscanLeft; nudGameSpecificOverscanRight.Value = info.OverscanRight; } } //Change name to share resources with global overscan tab lblGameSpecificOverscanBottom.Name = "lblBottom"; lblGameSpecificOverscanLeft.Name = "lblLeft"; lblGameSpecificOverscanRight.Name = "lblRight"; lblGameSpecificOverscanTop.Name = "lblTop"; }
private void UpdateAvailableTabs() { tabMain.SelectedIndexChanged -= tabMain_SelectedIndexChanged; tabMain.TabPages.Clear(); RomInfo romInfo = EmuApi.GetRomInfo(); if (romInfo.CoprocessorType != CoprocessorType.Gameboy) { tabMain.TabPages.Add(tpgCpu); tabMain.TabPages.Add(tpgSpc); tabMain.SelectedTab = tpgCpu; } if (romInfo.CoprocessorType == CoprocessorType.SA1 || romInfo.CoprocessorType == CoprocessorType.Gameboy || romInfo.CoprocessorType == CoprocessorType.SGB) { TabPage coprocessorTab = new TabPage(ResourceHelper.GetEnumText(romInfo.CoprocessorType)); tabMain.TabPages.Add(coprocessorTab); coprocessorTab.Controls.Add(ctrlProfilerCoprocessor); ctrlProfilerCoprocessor.Dock = DockStyle.Fill; ctrlProfilerCoprocessor.CpuType = romInfo.CoprocessorType == CoprocessorType.SA1 ? CpuType.Sa1 : CpuType.Gameboy; } _selectedTab = tabMain.TabPages[0]; tabMain.SelectedIndexChanged += tabMain_SelectedIndexChanged; }
public static void ImportSymFile(string symPath, bool silent = false) { if (ConfigManager.Config.Debug.DbgIntegration.ResetLabelsOnImport) { ResetLabels(); } string symContent = File.ReadAllText(symPath); if (symContent.Contains("[labels]")) { //Assume WLA-DX symbol files new WlaDxImporter().Import(symPath, silent); } else { RomInfo romInfo = EmuApi.GetRomInfo(); if (romInfo.CoprocessorType == CoprocessorType.Gameboy) { if (RgbdsSymbolFile.IsValidFile(symPath)) { RgbdsSymbolFile.Import(symPath, silent); } else { BassLabelFile.Import(symPath, silent); } } else { BassLabelFile.Import(symPath, silent); } } LabelManager.RefreshLabels(); }
public static void AutoImportSymbols() { if (ConfigManager.Config.Debug.DbgIntegration.AutoImport) { RomInfo romInfo = EmuApi.GetRomInfo(); string romName = romInfo.GetRomName(); string romFolder = ((ResourcePath)romInfo.RomPath).Folder; string dbgPath = Path.Combine(romFolder, romName + ".dbg"); string mslPath = Path.Combine(romFolder, romName + ".msl"); string symPath = Path.Combine(romFolder, romName + ".sym"); string tassPath = Path.Combine(romFolder, romName + ".tass"); if (File.Exists(dbgPath)) { ImportDbgFile(dbgPath, true); } else if (File.Exists(mslPath)) { ImportMslFile(mslPath, true); } else if (File.Exists(symPath)) { ImportSymFile(symPath, true); } else if (File.Exists(tassPath)) { ImportSymFile(tassPath, true); } } }
public GameBoy(byte[] rom) { var romInfo = new RomInfo(rom); Rom = romInfo.Rom; Mmu = new MemoryManagementUnit(romInfo, Timer); Init(); }
public MBC(byte[] rom, RomInfo info) { ROM = rom; this.exRam = info.ExternalRam; if (this.exRam != ExRam.None) { RAM = MemoryMappedFile.CreateFromFile(info.FileName.Remove(info.FileName.IndexOf('.')) + ".sav", FileMode.OpenOrCreate, null, info.ExRamSize).CreateViewAccessor(0, 0, MemoryMappedFileAccess.ReadWrite); } }
public static GameSpecificInfo CreateGameSpecificConfig() { RomInfo romInfo = InteropEmu.GetRomInfo(); GameSpecificInfo info = new GameSpecificInfo(); info.GameName = romInfo.GetRomName(); info.GamePrgCrc32 = romInfo.GetPrgCrcString(); return(info); }
private void UpdateFileOptions() { bool hasChanges = InteropEmu.DebugHasPrgChrChanges(); RomInfo romInfo = InteropEmu.GetRomInfo(); mnuSaveRom.Enabled = romInfo.Format == RomFormat.iNes && hasChanges && !romInfo.RomFile.Compressed; mnuSaveAsIps.Enabled = romInfo.Format == RomFormat.iNes && hasChanges; mnuRevertChanges.Enabled = hasChanges; mnuSaveRomAs.Enabled = romInfo.Format == RomFormat.iNes; mnuEditHeader.Enabled = romInfo.Format == RomFormat.iNes; }
private void OnNotificationReceived(NotificationEventArgs e) { switch (e.NotificationType) { case ConsoleNotificationType.GameLoaded: this.BeginInvoke((Action)(() => { UpdateDebuggerMenu(); ctrlRecentGames.Visible = false; SaveStateManager.UpdateStateMenu(mnuLoadState, false); SaveStateManager.UpdateStateMenu(mnuSaveState, true); RomInfo romInfo = EmuApi.GetRomInfo(); this.Text = "Mesen-S - " + romInfo.GetRomName(); if (DebugWindowManager.HasOpenedWindow) { DebugWorkspaceManager.GetWorkspace(); } })); break; case ConsoleNotificationType.BeforeEmulationStop: this.Invoke((Action)(() => { DebugWindowManager.CloseAll(); })); break; case ConsoleNotificationType.EmulationStopped: this.BeginInvoke((Action)(() => { this.Text = "Mesen-S"; UpdateDebuggerMenu(); ctrlRecentGames.Initialize(); ctrlRecentGames.Visible = true; ResizeRecentGames(); if (_displayManager.ExclusiveFullscreen) { _displayManager.SetFullscreenState(false); } })); break; case ConsoleNotificationType.ResolutionChanged: this.BeginInvoke((Action)(() => { _displayManager.UpdateViewerSize(); })); break; case ConsoleNotificationType.ExecuteShortcut: this.BeginInvoke((Action)(() => { _shortcuts.ExecuteShortcut((EmulatorShortcut)e.Parameter); })); break; } }
public frmCheatImport() { InitializeComponent(); UpdateImportButton(); RomInfo romInfo = InteropEmu.GetRomInfo(); _gameCrc = romInfo.GetPrgCrcString(); _gameName = romInfo.GetRomName(); txtGameName.Text = _gameName; }
private void LoadGame(string romPath) { int archiveFileIndex = -1; if (frmSelectRom.SelectRom(romPath, ref archiveFileIndex)) { RomInfo romInfo = InteropEmu.GetRomInfo(romPath, archiveFileIndex); _gameCrc = romInfo.GetPrgCrcString(); _gameName = romInfo.GetRomName(); txtGameName.Text = _gameName; UpdateImportButton(); } }
public MemoryBankController(RomInfo romInfo) { ri = romInfo; Eram = new byte[romInfo.RamSize.Size]; Wram = new byte[0x1FFF]; Zram = new byte[128]; Rombank = 0; RamBank = 0; ExternalRamOn = false; Mode = MemoryMode.M16_8; }
private void LoadGame(string romPath) { ResourcePath resource = romPath; if (frmSelectRom.SelectRom(ref resource)) { RomInfo romInfo = InteropEmu.GetRomInfo(resource); _gameCrc = romInfo.GetPrgCrcString(); _gameName = romInfo.GetRomName(); txtGameName.Text = _gameName; UpdateImportButton(); } }
private void LoadGame(string romPath) { ResourcePath resource = romPath; if (frmSelectRom.SelectRom(ref resource)) { RomInfo romInfo = InteropEmu.GetRomInfo(resource); _gameCrc = romInfo.GetPrgCrcString(); if (_gameCrc != null) { ((CheatInfo)Entity).GameName = romInfo.GetRomName(); txtGameName.Text = ((CheatInfo)Entity).GameName; } } }
private void LoadGame(string romPath) { int archiveFileIndex = -1; if (frmSelectRom.SelectRom(romPath, ref archiveFileIndex)) { RomInfo romInfo = InteropEmu.GetRomInfo(romPath, archiveFileIndex); _gameCrc = romInfo.GetPrgCrcString(); if (_gameCrc != null) { ((CheatInfo)Entity).GameName = Path.GetFileNameWithoutExtension(romInfo.RomName); txtGameName.Text = ((CheatInfo)Entity).GameName; } } }
private void AutoLoadCdlFiles() { if (ConfigManager.Config.DebugInfo.AutoLoadCdlFiles) { //This loads CDL files that are next to the rom - useful when developing with a compiler that can produce a CDL file RomInfo info = InteropEmu.GetRomInfo(); string cdlPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".cdl"); if (File.Exists(cdlPath)) { if (InteropEmu.DebugLoadCdlFile(cdlPath)) { UpdateDebugger(false, false); } } } }
private void showInfoByElements(IEnumerable <XElement> elements) { RomInfo.romList = new List <RomInfo>(); foreach (var ele in elements) { RomInfo rom = new RomInfo(); rom.Name = ele.Attribute("name").Value; rom.Board = ele.Attribute("board").Value; rom.Parent = ele.Element("parent").Value; rom.Direction = ele.Element("direction").Value; rom.Description = ele.Element("description").Value; rom.Year = ele.Element("year").Value; rom.Manufacturer = ele.Element("manufacturer").Value; RomInfo.romList.Add(rom); loadform.listView1.Items.Add(new ListViewItem(new string[] { rom.Description, rom.Year, rom.Name, rom.Parent, rom.Direction, rom.Manufacturer, rom.Board })); } }
private void btnCreateCheat_Click(object sender, EventArgs e) { RomInfo romInfo = InteropEmu.GetRomInfo(); CheatInfo newCheat = new CheatInfo { GameCrc = romInfo.GetPrgCrcString(), GameName = romInfo.GetRomName(), Address = (uint)lstAddresses.CurrentAddress, CheatType = CheatType.Custom }; frmCheat frm = new frmCheat(newCheat); if (frm.ShowDialog() == DialogResult.OK) { OnAddCheat?.Invoke(newCheat, new EventArgs()); } }
public MBC5(byte[] rom, RomInfo info) : base(rom, info) { switch (exRam) { case ExRam.k8: ramBytes = 1 << 13; break; case ExRam.k32: ramBytes = 1 << 15; break; case ExRam.k128: ramBytes = 1 << 17; break; } }
/// <summary> /// Gets the content of the ROM specified by its resource name /// </summary> /// <param name="romResourceName">ROM resource name</param> /// <returns>Content of the ROM</returns> public RomInfo LoadRom(string romResourceName) { RomInfo result; // --- Obtain the ROM annotations var resMan = GetFileResource(ResourceAssembly, romResourceName, ".disann"); if (resMan == null) { throw new InvalidOperationException($"Input stream for the '{romResourceName}' .disann file not found."); } using (var reader = new StreamReader(resMan)) { var serialized = reader.ReadToEnd(); var annotations = DisassemblyAnnotation.Deserialize(serialized); result = new RomInfo { MemorySections = new List <MemorySection>(annotations.MemoryMap), Annotations = annotations, LoadBytesInvalidHeaderAddress = annotations.Literals.FirstOrDefault(kvp => kvp.Value.Contains("$LoadBytesInvalidHeaderAddress")).Key, LoadBytesResumeAddress = annotations.Literals.FirstOrDefault(kvp => kvp.Value.Contains("$LoadBytesResumeAddress")).Key, LoadBytesRoutineAddress = annotations.Literals.FirstOrDefault(kvp => kvp.Value.Contains("$LoadBytesRoutineAddress")).Key, SaveBytesRoutineAddress = annotations.Literals.FirstOrDefault(kvp => kvp.Value.Contains("$SaveBytesRoutineAddress")).Key, SaveBytesResumeAddress = annotations.Literals.FirstOrDefault(kvp => kvp.Value.Contains("$SaveBytesResumeAddress")).Key, MainExecAddress = annotations.Literals.FirstOrDefault(kvp => kvp.Value.Contains("$MainExecAddress")).Key }; } // --- Obtain the ROM contents resMan = GetFileResource(ResourceAssembly, romResourceName, ".rom"); if (resMan == null) { throw new InvalidOperationException($"Input stream for the '{romResourceName}' .rom file not found."); } using (var stream = new StreamReader(resMan).BaseStream) { stream.Seek(0, SeekOrigin.Begin); var bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); result.RomBytes = bytes; } return(result); }
protected override void OnShown(EventArgs e) { base.OnShown(e); _cheats = NestopiaCheatLoader.Load(ResourceManager.GetZippedResource("MesenCheatDb.xml"), "", ""); _gamesByCrc = new Dictionary <string, GameInfo>(); foreach (CheatInfo cheat in _cheats) { if (_gamesByCrc.ContainsKey(cheat.GameName)) { _gamesByCrc[cheat.GameCrc].CheatCount++; } else { _gamesByCrc[cheat.GameCrc] = new GameInfo() { Name = cheat.GameName, Crc = cheat.GameCrc, CheatCount = 1 }; } } lblCheatCount.Text = ResourceHelper.GetMessage("CheatsFound", _gamesByCrc.Count.ToString(), _cheats.Count.ToString()); lstGames.Sorted = true; txtSearch.Focus(); UpdateList(); RomInfo info = InteropEmu.GetRomInfo(); if (!string.IsNullOrWhiteSpace(info.GetRomName())) { string loadedGameCrc = info.GetPrgCrcString(); for (int i = 0, len = lstGames.Items.Count; i < len; i++) { if (((GameInfo)lstGames.Items[i]).Crc == loadedGameCrc) { lstGames.TopIndex = Math.Max(0, i - 10); lstGames.SelectedIndex = i; break; } } } }
public static void AutoLoadDbgFiles(bool silent) { Ld65DbgImporter oldSymbolProvider = SymbolProvider; if (ConfigManager.Config.DebugInfo.AutoLoadDbgFiles) { RomInfo info = InteropEmu.GetRomInfo(); string dbgPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".dbg"); if (File.Exists(dbgPath)) { DateTime lastDbgUpdate = File.GetLastWriteTime(dbgPath); if (lastDbgUpdate != oldSymbolProvider?.DbgFileStamp) { ImportDbgFile(dbgPath, silent); } else { //Currently loaded symbol provider is still valid return; } } else { string mlbPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".mlb"); if (File.Exists(mlbPath)) { ImportMlbFile(mlbPath, silent); } else { string fnsPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".fns"); if (File.Exists(fnsPath)) { ImportNesasmFnsFile(fnsPath, silent); } } } } if (oldSymbolProvider == SymbolProvider) { SymbolProvider = null; } }
public static void ImportDbgFile() { _symbolProvider = null; if (ConfigManager.Config.Debug.DbgIntegration.AutoImport) { RomInfo romInfo = EmuApi.GetRomInfo(); string dbgPath = Path.Combine(((ResourcePath)romInfo.RomPath).Folder, romInfo.GetRomName() + ".dbg"); if (File.Exists(dbgPath)) { _symbolProvider = new DbgImporter(); _symbolProvider.Import(dbgPath, true); SymbolProviderChanged?.Invoke(_symbolProvider); LabelManager.RefreshLabels(); } } SymbolProviderChanged?.Invoke(_symbolProvider); }
private void showInfoByElements(IEnumerable <XElement> elements) { RomInfo.romList = new List <RomInfo>(); //StreamWriter sw1 = new StreamWriter("1.txt", false); foreach (var ele in elements) { RomInfo rom = new RomInfo(); rom.Name = ele.Attribute("name").Value; rom.Board = ele.Attribute("board").Value; rom.Parent = ele.Element("parent").Value; rom.Direction = ele.Element("direction").Value; rom.Description = ele.Element("description").Value; rom.Year = ele.Element("year").Value; rom.Manufacturer = ele.Element("manufacturer").Value; RomInfo.romList.Add(rom); loadform.listView1.Items.Add(new ListViewItem(new string[] { rom.Description, rom.Year, rom.Name, rom.Parent, rom.Direction, rom.Manufacturer, rom.Board })); //sw1.WriteLine(rom.Name + "\t" + rom.Board + "\t" + rom.Parent + "\t" + rom.Direction + "\t" + rom.Description + "\t" + rom.Year + "\t" + rom.Manufacturer); } //sw1.Close(); }
private void AutoLoadDbgFiles(bool silent) { if (ConfigManager.Config.DebugInfo.AutoLoadDbgFiles) { RomInfo info = InteropEmu.GetRomInfo(); string dbgPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".dbg"); if (File.Exists(dbgPath)) { Ld65DbgImporter dbgImporter = new Ld65DbgImporter(); dbgImporter.Import(dbgPath, silent); } else { string mlbPath = Path.Combine(info.RomFile.Folder, info.GetRomName() + ".mlb"); if (File.Exists(mlbPath)) { MesenLabelFile.Import(mlbPath, silent); } } } }
public static MemoryBankController Factory(RomInfo ri) { switch (ri.CartridgeInfo.MbcType) { case MbcType.Mbc1: return(new Mbc1(ri)); case MbcType.Mbc2: return(new Mbc2(ri)); case MbcType.Mbc3: return(new Mbc3(ri)); case MbcType.Mbc5: return(new Mbc5(ri)); case MbcType.Rumble: return(new MbcRumble(ri)); } throw new NotSupportedException("MbcType: " + ri.CartridgeInfo.MbcType + " is not yet supported."); }
/// <summary> /// Reads the table of tokens from the ROM /// </summary> private static void ReadTokenTable(RomInfo info) { var tokenPtr = info.TokenTableAddress; tokenPtr++; var tokenCount = info.TokenCount; var token = ""; while (tokenCount > 0) { var nextChar = info.RomBytes[tokenPtr++]; if ((nextChar & 0x80) > 0) { token += (char)(nextChar & 0xFF7F); info.TokenTable.Add(token); tokenCount--; token = ""; } else { token += (char)nextChar; } } }