private unsafe void SetMemoryDomains() { var mm = new List <MemoryDomain>(); for (int i = LibGPGX.MIN_MEM_DOMAIN; i <= LibGPGX.MAX_MEM_DOMAIN; i++) { IntPtr area = IntPtr.Zero; int size = 0; IntPtr pname = Core.gpgx_get_memdom(i, ref area, ref size); if (area == IntPtr.Zero || pname == IntPtr.Zero || size == 0) { continue; } string name = Marshal.PtrToStringAnsi(pname); if (name == "VRAM") { // vram pokes need to go through hook which invalidates cached tiles byte *p = (byte *)area; mm.Add(new MemoryDomain(name, size, MemoryDomain.Endian.Unknown, delegate(long addr) { if (addr < 0 || addr >= 65536) { throw new ArgumentOutOfRangeException(); } return(p[addr ^ 1]); }, delegate(long addr, byte val) { if (addr < 0 || addr >= 65536) { throw new ArgumentOutOfRangeException(); } Core.gpgx_poke_vram(((int)addr) ^ 1, val); }, byteSize: 2)); } else { var byteSize = name.Contains("Z80") ? 1 : 2; mm.Add(MemoryDomain.FromIntPtrSwap16(name, size, MemoryDomain.Endian.Big, area, writable: true, byteSize: byteSize)); } } var m68Bus = new MemoryDomain("M68K BUS", 0x1000000, MemoryDomain.Endian.Big, delegate(long addr) { var a = (uint)addr; if (a >= 0x1000000) { throw new ArgumentOutOfRangeException(); } return(Core.gpgx_peek_m68k_bus(a)); }, delegate(long addr, byte val) { var a = (uint)addr; if (a >= 0x1000000) { throw new ArgumentOutOfRangeException(); } Core.gpgx_write_m68k_bus(a, val); }, 2); mm.Add(m68Bus); var s68Bus = new MemoryDomain("S68K BUS", 0x1000000, MemoryDomain.Endian.Big, delegate(long addr) { var a = (uint)addr; if (a >= 0x1000000) { throw new ArgumentOutOfRangeException(); } return(Core.gpgx_peek_s68k_bus(a)); }, delegate(long addr, byte val) { var a = (uint)addr; if (a >= 0x1000000) { throw new ArgumentOutOfRangeException(); } Core.gpgx_write_s68k_bus(a, val); }, 2); if (IsSegaCD) { mm.Add(s68Bus); } MemoryDomains = new MemoryDomainList(mm); MemoryDomains.SystemBus = m68Bus; (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains); }
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian) { _previous = _prevFrame = domain.PeekWord(Address % domain.Size, bigendian); }
public WatchList(MemoryDomain domain) { _domain = domain; }
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian) { _previous = domain.PeekByte(Address % domain.Size); }
public void SetPreviousToCurrent(MemoryDomain domain, bool bigendian) { _previous = domain.PeekDWord(Address, bigendian); }
/// <summary> /// Generates a new <see cref="Watch"/> instance /// Can be either <see cref="ByteWatch"/>, <see cref="WordWatch"/>, <see cref="DWordWatch"/> or <see cref="SeparatorWatch"/> /// </summary> /// <param name="domain">The <see cref="MemoryDomain"/> where you want to watch</param> /// <param name="address">The address into the <see cref="MemoryDomain"/></param> /// <param name="size">The size</param> /// <param name="type">How the watch will be displayed</param> /// <param name="bigEndian">Endianess (true for big endian)</param> /// <returns>New <see cref="Watch"/> instance. True type is depending of size parameter</returns> public static Watch GenerateWatch(MemoryDomain domain, long address, WatchSize size, DisplayType type, bool bigEndian) { return(GenerateWatch(domain, address, size, type, bigEndian, string.Empty, 0, 0, 0)); }
public string Disassemble(MemoryDomain m, uint addr, out int length) { return(MOS6502X.Disassemble((ushort)addr, out length, a => m.PeekByte(a))); }
public string Disassemble(MemoryDomain m, uint addr, out int length) { string ret = Disassemble((ushort)addr, a => m.PeekByte(a), out length); return(ret); }
void SetupMemoryDomains() { var domains = new List <MemoryDomain>(10); int mainmemorymask = Ram.Length - 1; var MainMemoryDomain = new MemoryDomain("Main Memory", Ram.Length, MemoryDomain.Endian.Little, addr => Ram[addr], (addr, value) => Ram[addr] = value, byteSize: 2); domains.Add(MainMemoryDomain); var SystemBusDomain = new MemoryDomain("System Bus (21 bit)", 0x200000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 0x200000) { throw new ArgumentOutOfRangeException(); } return(Cpu.ReadMemory21((int)addr)); }, (addr, value) => { if (addr < 0 || addr >= 0x200000) { throw new ArgumentOutOfRangeException(); } Cpu.WriteMemory21((int)addr, value); }, byteSize: 2); domains.Add(SystemBusDomain); var CpuBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 0x10000) { throw new ArgumentOutOfRangeException(); } return(Cpu.ReadMemory((ushort)addr)); }, (addr, value) => { if (addr < 0 || addr >= 0x10000) { throw new ArgumentOutOfRangeException(); } Cpu.WriteMemory((ushort)addr, value); }, byteSize: 2); domains.Add(CpuBusDomain); var RomDomain = new MemoryDomain("ROM", RomLength, MemoryDomain.Endian.Little, addr => RomData[addr], (addr, value) => RomData[addr] = value, byteSize: 2); domains.Add(RomDomain); if (BRAM != null) { var BRAMMemoryDomain = new MemoryDomain("Battery RAM", Ram.Length, MemoryDomain.Endian.Little, addr => BRAM[addr], (addr, value) => BRAM[addr] = value, byteSize: 2); domains.Add(BRAMMemoryDomain); } if (TurboCD) { var CDRamMemoryDomain = new MemoryDomain("TurboCD RAM", CDRam.Length, MemoryDomain.Endian.Little, addr => CDRam[addr], (addr, value) => CDRam[addr] = value, byteSize: 2); domains.Add(CDRamMemoryDomain); var AdpcmMemoryDomain = new MemoryDomain("ADPCM RAM", ADPCM.RAM.Length, MemoryDomain.Endian.Little, addr => ADPCM.RAM[addr], (addr, value) => ADPCM.RAM[addr] = value, byteSize: 2); domains.Add(AdpcmMemoryDomain); if (SuperRam != null) { var SuperRamMemoryDomain = new MemoryDomain("Super System Card RAM", SuperRam.Length, MemoryDomain.Endian.Little, addr => SuperRam[addr], (addr, value) => SuperRam[addr] = value, byteSize: 2); domains.Add(SuperRamMemoryDomain); } } if (ArcadeCard) { var ArcadeRamMemoryDomain = new MemoryDomain("Arcade Card RAM", ArcadeRam.Length, MemoryDomain.Endian.Little, addr => ArcadeRam[addr], (addr, value) => ArcadeRam[addr] = value, byteSize: 2); domains.Add(ArcadeRamMemoryDomain); } if (PopulousRAM != null) { var PopulusRAMDomain = new MemoryDomain("Cart Battery RAM", PopulousRAM.Length, MemoryDomain.Endian.Little, addr => PopulousRAM[addr], (addr, value) => PopulousRAM[addr] = value, byteSize: 2); domains.Add(PopulusRAMDomain); } memoryDomains = new MemoryDomainList(domains); (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(memoryDomains); }
public BizhawkMemoryDomain(MemoryDomain md) { MD = md; }
private MemoryDomainList CreateMemoryDomains(int romsize) { var s = new LibmGBA.MemoryAreas(); var mm = new List <MemoryDomain>(); LibmGBA.BizGetMemoryAreas(core, s); var l = MemoryDomain.Endian.Little; mm.Add(MemoryDomain.FromIntPtr("IWRAM", 32 * 1024, l, s.iwram, true, 4)); mm.Add(MemoryDomain.FromIntPtr("EWRAM", 256 * 1024, l, s.wram, true, 4)); mm.Add(MemoryDomain.FromIntPtr("BIOS", 16 * 1024, l, s.bios, false, 4)); mm.Add(MemoryDomain.FromIntPtr("PALRAM", 1024, l, s.palram, false, 4)); mm.Add(MemoryDomain.FromIntPtr("VRAM", 96 * 1024, l, s.vram, true, 4)); mm.Add(MemoryDomain.FromIntPtr("OAM", 1024, l, s.oam, false, 4)); mm.Add(MemoryDomain.FromIntPtr("ROM", romsize, l, s.rom, false, 4)); // special combined ram memory domain { var ew = mm[1]; var iw = mm[0]; MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little, delegate(long addr) { if (addr < 0 || addr >= (256 + 32) * 1024) { throw new IndexOutOfRangeException(); } if (addr >= 256 * 1024) { return(PeekWRAM(s.iwram, addr & 32767)); } else { return(PeekWRAM(s.wram, addr)); } }, delegate(long addr, byte val) { if (addr < 0 || addr >= (256 + 32) * 1024) { throw new IndexOutOfRangeException(); } if (addr >= 256 * 1024) { PokeWRAM(s.iwram, addr & 32767, val); } else { PokeWRAM(s.wram, addr, val); } }, 4); mm.Add(cr); } _gpumem = new GBAGPUMemoryAreas { mmio = s.mmio, oam = s.oam, palram = s.palram, vram = s.vram }; return(new MemoryDomainList(mm)); }
private bool LoadFile(string path, bool append) { var domain = string.Empty; var file = new FileInfo(path); if (file.Exists == false) { return(false); } var isBizHawkWatch = true; // Hack to support .wch files from other emulators var isOldBizHawkWatch = false; using (var sr = file.OpenText()) { string line; if (!append) { Clear(); } while ((line = sr.ReadLine()) != null) { // .wch files from other emulators start with a number representing the number of watch, that line can be discarded here // Any properly formatted line couldn't possibly be this short anyway, this also takes care of any garbage lines that might be in a file if (line.Length < 5) { isBizHawkWatch = false; continue; } if (line.Length >= 6 && line.Substring(0, 6) == "Domain") { domain = line.Substring(7, line.Length - 7); isBizHawkWatch = true; } if (line.Length >= 8 && line.Substring(0, 8) == "SystemID") { continue; } var numColumns = line.HowMany('\t'); int startIndex; if (numColumns == 5) { // If 5, then this is a post 1.0.5 .wch file if (isBizHawkWatch) { // Do nothing here } else { startIndex = line.IndexOf('\t') + 1; line = line.Substring(startIndex, line.Length - startIndex); // 5 digit value representing the watch position number } } else if (numColumns == 4) { isOldBizHawkWatch = true; // This supports the legacy .wch format from 1.0.5 and earlier } else { continue; // If not 4, something is wrong with this line, ignore it } // Temporary, rename if kept int addr; var memDomain = _memoryDomains.MainMemory; var temp = line.Substring(0, line.IndexOf('\t')); try { addr = int.Parse(temp, NumberStyles.HexNumber); } catch { continue; } startIndex = line.IndexOf('\t') + 1; line = line.Substring(startIndex, line.Length - startIndex); // Type var size = Watch.SizeFromChar(line[0]); startIndex = line.IndexOf('\t') + 1; line = line.Substring(startIndex, line.Length - startIndex); // Signed var type = Watch.DisplayTypeFromChar(line[0]); startIndex = line.IndexOf('\t') + 1; line = line.Substring(startIndex, line.Length - startIndex); // Endian try { startIndex = short.Parse(line[0].ToString()); } catch { continue; } var bigEndian = startIndex != 0; if (isBizHawkWatch && !isOldBizHawkWatch) { startIndex = line.IndexOf('\t') + 1; line = line.Substring(startIndex, line.Length - startIndex); // Domain temp = line.Substring(0, line.IndexOf('\t')); memDomain = _memoryDomains[temp] ?? _memoryDomains.MainMemory; } startIndex = line.IndexOf('\t') + 1; var notes = line.Substring(startIndex, line.Length - startIndex); _watchList.Add( Watch.GenerateWatch( memDomain, addr, size, type, notes, bigEndian)); _domain = _memoryDomains[domain]; } Domain = _memoryDomains[domain] ?? _memoryDomains.MainMemory; _currentFilename = path; } if (!append) { Global.Config.RecentWatches.Add(path); Changes = false; } else { Changes = true; } return(true); }
public WatchList(IMemoryDomains core, MemoryDomain domain, string systemid) { _memoryDomains = core; _domain = domain; _systemid = systemid; }
private void SetUpMemoryDomains() { _domainList.Clear(); // this must be first to coincide with "main memory" // note that ewram could also be considered main memory depending on which hairs you split AddMemoryDomain(LibMeteor.MemoryArea.iwram, 32 * 1024, "IWRAM"); AddMemoryDomain(LibMeteor.MemoryArea.ewram, 256 * 1024, "EWRAM"); AddMemoryDomain(LibMeteor.MemoryArea.bios, 16 * 1024, "BIOS"); AddMemoryDomain(LibMeteor.MemoryArea.palram, 1024, "PALRAM"); AddMemoryDomain(LibMeteor.MemoryArea.vram, 96 * 1024, "VRAM"); AddMemoryDomain(LibMeteor.MemoryArea.oam, 1024, "OAM"); // even if the rom is less than 32MB, the whole is still valid in meteor AddMemoryDomain(LibMeteor.MemoryArea.rom, 32 * 1024 * 1024, "ROM"); // special domain for system bus { MemoryDomain sb = new MemoryDomain("System Bus", 1 << 28, MemoryDomain.Endian.Little, delegate(long addr) { if (addr < 0 || addr >= 0x10000000) { throw new IndexOutOfRangeException(); } return(LibMeteor.libmeteor_peekbus((uint)addr)); }, delegate(long addr, byte val) { if (addr < 0 || addr >= 0x10000000) { throw new IndexOutOfRangeException(); } LibMeteor.libmeteor_writebus((uint)addr, val); }); _domainList.Add(sb); } // special combined ram memory domain { var ew = _domainList[1]; var iw = _domainList[0]; MemoryDomain cr = new MemoryDomain("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little, delegate(long addr) { if (addr < 0 || addr >= (256 + 32) * 1024) { throw new IndexOutOfRangeException(); } if (addr >= 256 * 1024) { return(iw.PeekByte(addr & 32767)); } else { return(ew.PeekByte(addr)); } }, delegate(long addr, byte val) { if (addr < 0 || addr >= (256 + 32) * 1024) { throw new IndexOutOfRangeException(); } if (addr >= 256 * 1024) { iw.PokeByte(addr & 32767, val); } else { ew.PokeByte(addr, val); } }); _domainList.Add(cr); } _memoryDomains = new MemoryDomainList(_domainList); (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(_memoryDomains); }
private bool LoadBotFile(string path) { var file = new FileInfo(path); if (!file.Exists) { return(false); } var json = File.ReadAllText(path); var botData = (BotData)ConfigService.LoadWithType(json); _bestBotAttempt = botData.Best; var probabilityControls = ControlProbabilityPanel.Controls .OfType <BotControlsRow>() .ToList(); foreach (var kvp in botData.ControlProbabilities) { var control = probabilityControls.Single(c => c.ButtonName == kvp.Key); control.Probability = kvp.Value; } MaximizeAddress = botData.Maximize; TieBreaker1Address = botData.TieBreaker1; TieBreaker2Address = botData.TieBreaker2; TieBreaker3Address = botData.TieBreaker3; try { MainComparisonType = botData.ComparisonTypeMain; Tie1ComparisonType = botData.ComparisonTypeTie1; Tie2ComparisonType = botData.ComparisonTypeTie2; Tie3ComparisonType = botData.ComparisonTypeTie3; } catch { MainComparisonType = 0; Tie1ComparisonType = 0; Tie2ComparisonType = 0; Tie3ComparisonType = 0; } FrameLength = botData.FrameLength; FromSlot = botData.FromSlot; Attempts = botData.Attempts; Frames = botData.Frames; _currentDomain = !string.IsNullOrWhiteSpace(botData.MemoryDomain) ? MemoryDomains[botData.MemoryDomain] : MemoryDomains.MainMemory; _bigEndian = botData.BigEndian; _dataSize = botData.DataSize > 0 ? botData.DataSize : 1; UpdateBestAttempt(); if (_bestBotAttempt != null) { PlayBestButton.Enabled = true; } CurrentFileName = path; Settings.RecentBotFiles.Add(CurrentFileName); MessageLabel.Text = Path.GetFileNameWithoutExtension(path) + " loaded"; return(true); }
public string Disassemble(MemoryDomain m, uint addr, out int length) { return(Components.M6502.MOS6502X.Disassemble((ushort)addr, out length, (a) => m.PeekByte(a))); }
private void SetMemoryDomain(string name) { _currentDomain = MemoryDomains[name]; _bigEndian = MemoryDomains[name].EndianType == MemoryDomain.Endian.Big; }
public WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, ushort prev, int changeCount, string notes = null) : this(domain, address, type, bigEndian, notes) { _previous = prev; _changecount = changeCount; }
public MemoryDomain GetExRAM() { return(MemoryDomain.FromByteArray("ExRAM", MemoryDomain.Endian.Little, EXRAM)); }
public bool Contains(MemoryDomain domain, long address) { return(_cheatList.Any(c => c.Domain == domain && c.Address == address)); }
public MiniByteWatch(MemoryDomain domain, long addr) { Address = addr; _previous = domain.PeekByte(Address % domain.Size); }
private void InitMemoryDomains() { var mm = new List <MemoryDomain>(); var s = new LibVBANext.MemoryAreas(); var l = MemoryDomain.Endian.Little; LibVBANext.GetMemoryAreas(Core, s); mm.Add(MemoryDomain.FromIntPtr("IWRAM", 32 * 1024, l, s.iwram, true, 4)); mm.Add(MemoryDomain.FromIntPtr("EWRAM", 256 * 1024, l, s.ewram, true, 4)); mm.Add(MemoryDomain.FromIntPtr("BIOS", 16 * 1024, l, s.bios, false, 4)); mm.Add(MemoryDomain.FromIntPtr("PALRAM", 1024, l, s.palram, false, 4)); mm.Add(MemoryDomain.FromIntPtr("VRAM", 96 * 1024, l, s.vram, true, 4)); mm.Add(MemoryDomain.FromIntPtr("OAM", 1024, l, s.oam, true, 4)); mm.Add(MemoryDomain.FromIntPtr("ROM", 32 * 1024 * 1024, l, s.rom, true, 4)); mm.Add(new MemoryDomainDelegate("System Bus", 0x10000000, l, delegate(long addr) { if (addr < 0 || addr >= 0x10000000) { throw new ArgumentOutOfRangeException(); } return(LibVBANext.SystemBusRead(Core, (int)addr)); }, delegate(long addr, byte val) { if (addr < 0 || addr >= 0x10000000) { throw new ArgumentOutOfRangeException(); } LibVBANext.SystemBusWrite(Core, (int)addr, val); }, 4)); // special combined ram memory domain { var ew = mm[1]; var iw = mm[0]; MemoryDomain cr = new MemoryDomainDelegate("Combined WRAM", (256 + 32) * 1024, MemoryDomain.Endian.Little, delegate(long addr) { if (addr < 0 || addr >= (256 + 32) * 1024) { throw new IndexOutOfRangeException(); } if (addr >= 256 * 1024) { return(iw.PeekByte(addr & 32767)); } else { return(ew.PeekByte(addr)); } }, delegate(long addr, byte val) { if (addr < 0 || addr >= (256 + 32) * 1024) { throw new IndexOutOfRangeException(); } if (addr >= 256 * 1024) { iw.PokeByte(addr & 32767, val); } else { ew.PokeByte(addr, val); } }, 4); mm.Add(cr); } _memoryDomains = new MemoryDomainList(mm); (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(_memoryDomains); }
public MiniDWordWatch(MemoryDomain domain, long addr, bool bigEndian) { Address = addr; _previous = domain.PeekDWord(Address % domain.Size, bigEndian); }
public string Disassemble(MemoryDomain m, uint addr, out int length) { byte P = 0; //TODO - user preferences somehow... return(disassemblerCpu.Disassemble(addr, m.PeekByte, ref P, out length)); }
public MiniByteWatchDetailed(MemoryDomain domain, long addr) { Address = addr; SetPreviousToCurrent(domain, false); }
public static void ViewInHexEditor(MemoryDomain domain, IEnumerable <long> addresses, Watch.WatchSize size) { GlobalWin.Tools.Load <HexEditor>(); GlobalWin.Tools.HexEditor.SetToAddresses(addresses, domain, size); }
public MiniDWordWatchDetailed(MemoryDomain domain, long addr, bool bigEndian) { Address = addr; SetPreviousToCurrent(domain, bigEndian); }
public void Detach() { md = null; }