public override string Disassemble(MemoryDomain m, uint addr, out int length) { ushort tmp; string ret = Common.Components.Z80GB.NewDisassembler.Disassemble((ushort)addr, (a) => m.PeekByte(a), out tmp); length = tmp; return ret; }
private void SetupMemoryDomains() { var domains = new List<MemoryDomain>(3); var MainMemoryDomain = new MemoryDomain("Main RAM", Ram.Length, MemoryDomain.Endian.Little, addr => Ram[addr], (addr, value) => Ram[addr] = value); var VRamDomain = new MemoryDomain("Video RAM", VDP.VRAM.Length, MemoryDomain.Endian.Little, addr => VDP.VRAM[addr], (addr, value) => VDP.VRAM[addr] = value); var SystemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 65536) { throw new ArgumentOutOfRangeException(); } return Cpu.ReadMemory((ushort)addr); }, (addr, value) => { if (addr < 0 || addr >= 65536) { throw new ArgumentOutOfRangeException(); } Cpu.WriteMemory((ushort)addr, value); }); domains.Add(MainMemoryDomain); domains.Add(VRamDomain); domains.Add(SystemBusDomain); memoryDomains = new MemoryDomainList(domains); (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(memoryDomains); }
private void SetupMemoryDomains() { var domains = new List<MemoryDomain> { MemoryDomain.FromByteArray("Main RAM", MemoryDomain.Endian.Little, _ram) }; var systemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); return Cpu.ReadMemory((ushort)addr); }, (addr, value) => { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); Cpu.WriteMemory((ushort)addr, value); }); domains.Add(systemBusDomain); _memoryDomains = new MemoryDomainList(domains); (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains); }
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); }
public MemoryLuaLibrary(Lua lua) : base(lua) { if (MemoryDomainCore != null) { _currentMemoryDomain = MemoryDomainCore.MainMemory; } }
public MemoryLuaLibrary(Lua lua, Action<string> logOutputCallback) : base(lua, logOutputCallback) { if (MemoryDomainCore != null) { _currentMemoryDomain = MemoryDomainCore.MainMemory; } }
public string Disassemble(MemoryDomain m, uint addr, out int length) { if (_selectedDisassemblable == null) { SetDefaultDisassemblable(); } return _selectedDisassemblable.Disassemble(m, addr, out length); }
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 MemoryDomain("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 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); }, 4); mm.Add(cr); } _memoryDomains = new MemoryDomainList(mm); (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains); }
public WrappedMemoryDomain(string name, MemoryDomain m) { _m = m; Name = name; Size = m.Size; WordSize = m.WordSize; EndianType = m.EndianType; Writable = m.Writable; }
public string Disassemble(MemoryDomain m, uint addr, out int length) { _disassemblerInstance.ReadWord = (a) => (short)m.PeekUshort(a, m.EndianType == MemoryDomain.Endian.Big); _disassemblerInstance.ReadByte = (a) => (sbyte)m.PeekByte(a); _disassemblerInstance.ReadLong = (a) => (int)m.PeekUint(a, m.EndianType == MemoryDomain.Endian.Big); var info = _disassemblerInstance.Disassemble((int)addr); length = info.Length; return string.Format("{0:X4} {1,-7} {2}", info.RawBytes.Substring(0, 4), info.Mnemonic, info.Args); }
private void SetDomainSelected(Emu.MemoryDomain domain) { foreach (var item in DomainDropDown.Items) { if (item.ToString() == domain.Name) { DomainDropDown.SelectedItem = item; return; } } }
public string Disassemble(MemoryDomain m, uint addr, out int length) { length = 4; // TODO: is this right? var instruction = m.PeekUint(addr, true); //TODO - reserve buffer here for disassembling into. allocating repeatedly will be slower var result = api.m64p_decode_op(instruction, addr); string strResult = Marshal.PtrToStringAnsi(result); return strResult; }
/// <summary> /// Inialize a new instance of <see cref="WordWatch"/> /// </summary> /// <param name="domain"><see cref="MemoryDomain"/> where you want to track</param> /// <param name="address">The address you want to track</param> /// <param name="type">How you you want to display the value See <see cref="DisplayType"/></param> /// <param name="bigEndian">Specify the endianess. true for big endian</param> /// <param name="note">A custom note about the <see cref="Watch"/></param> /// <param name="value">Current value</param> /// <param name="previous">Previous value</param> /// <param name="changeCount">How many times value has changed</param> /// <exception cref="ArgumentException">Occurs when a <see cref="DisplayType"/> is incompatible with <see cref="WatchSize.Word"/></exception> internal WordWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string note, ushort value, ushort previous, int changeCount) : base(domain, address, WatchSize.Word, type, bigEndian, note) { if (value == 0) { this._value = GetWord(); } else { this._value = value; } this._previous = previous; this._changecount = changeCount; }
public ByteWatch(MemoryDomain domain, long address, DisplayType type, bool bigEndian, string notes) { _address = address; _domain = domain; _value = _previous = GetByte(); if (AvailableTypes(WatchSize.Byte).Contains(type)) { _type = type; } _bigEndian = bigEndian; if (notes != null) { Notes = notes; } }
public static string ToString(Watch watch, MemoryDomain domain) { var numDigits = (domain.Size - 1).NumHexDigits(); var sb = new StringBuilder(); sb .Append((watch.Address ?? 0).ToHexString(numDigits)).Append('\t') .Append(watch.SizeAsChar).Append('\t') .Append(watch.TypeAsChar).Append('\t') .Append(watch.BigEndian ? '1' : '0').Append('\t') .Append(watch.DomainName).Append('\t') .Append(watch.Notes.Trim(new[] { '\r', '\n' })); return sb.ToString(); }
public void SetWatch(MemoryDomain domain, IEnumerable<Watch> watches = null, Mode mode = Mode.New) { if (watches != null) { _watchList.AddRange(watches); } _mode = mode; DomainDropDown.Items.Clear(); DomainDropDown.Items.AddRange(MemoryDomains .Select(d => d.ToString()) .ToArray()); DomainDropDown.SelectedItem = MemoryDomains.MainMemory.ToString(); SetTitle(); }
public void SetWatch(Emu.MemoryDomain domain, IEnumerable <Watch> watches = null, Mode mode = Mode.New) { if (watches != null) { _watchList.AddRange(watches); } _mode = mode; DomainDropDown.Items.Clear(); DomainDropDown.Items.AddRange(MemoryDomains .Select(d => d.ToString()) .ToArray()); DomainDropDown.SelectedItem = domain.ToString(); SetTitle(); }
private void SetupMemoryDomains() { var domains = new List<MemoryDomain>(); var mainRamDomain = new MemoryDomain("Main Ram", 0xC000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 0xC000) throw new ArgumentOutOfRangeException(); return (byte)_machine.Memory.Read((int)addr); }, (addr, value) => { if (addr < 0 || addr >= 0xC000) throw new ArgumentOutOfRangeException(); _machine.Memory.Write((int)addr, value); }); domains.Add(mainRamDomain); var systemBusDomain = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, (addr) => { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); return (byte)_machine.Memory.Read((int)addr); }, (addr, value) => { if (addr < 0 || addr >= 65536) throw new ArgumentOutOfRangeException(); _machine.Memory.Write((int)addr, value); }); domains.Add(systemBusDomain); _memoryDomains = new MemoryDomainList(domains); (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains); }
public override string Disassemble(MemoryDomain m, uint addr, out int length) { if (_cpu == "ARM v4 (Thumb)") { addr &= unchecked((uint)~1); int op = m.PeekByte((int)addr) | m.PeekByte((int)addr + 1) << 8; string ret = Emulation.Cores.Components.ARM.Darm.DisassembleStuff(addr | 1, (uint)op); length = 2; return ret; } else { addr &= unchecked((uint)~3); int op = m.PeekByte((int)addr) | m.PeekByte((int)addr + 1) << 8 | m.PeekByte((int)addr + 2) << 16 | m.PeekByte((int)addr + 3) << 24; string ret = Emulation.Cores.Components.ARM.Darm.DisassembleStuff(addr, (uint)op); length = 4; return ret; } }
public void Restart() { if (_currentDomain == null || MemoryDomains.Contains(_currentDomain)) { _currentDomain = MemoryDomains.MainMemory; _bigEndian = _currentDomain.EndianType == MemoryDomain.Endian.Big; _dataSize = 1; } if (_isBotting) { StopBot(); } else if (_replayMode) { FinishReplay(); } if (_lastRom != GlobalWin.MainForm.CurrentlyOpenRom) { _lastRom = GlobalWin.MainForm.CurrentlyOpenRom; SetupControlsAndProperties(); } }
private void SetupMemoryDomains() { var domains = new List<MemoryDomain>(); var RAM = new MemoryDomain("RAM", 0x800, MemoryDomain.Endian.Little, addr => ram[addr], (addr, value) => ram[addr] = value); var SystemBus = new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, addr => PeekMemory((ushort)addr), (addr, value) => ApplySystemBusPoke((int)addr, value)); var PPUBus = new MemoryDomain("PPU Bus", 0x4000, MemoryDomain.Endian.Little, addr => ppu.ppubus_peek((int)addr), (addr, value) => ppu.ppubus_write((int)addr, value)); var CIRAMdomain = new MemoryDomain("CIRAM (nametables)", 0x800, MemoryDomain.Endian.Little, addr => CIRAM[addr], (addr, value) => CIRAM[addr] = value); var OAMdoman = new MemoryDomain("OAM", 64 * 4, MemoryDomain.Endian.Unknown, addr => ppu.OAM[addr], (addr, value) => ppu.OAM[addr] = value); domains.Add(RAM); domains.Add(SystemBus); domains.Add(PPUBus); domains.Add(CIRAMdomain); domains.Add(OAMdoman); if (!(Board is FDS) && Board.SaveRam != null) { var BatteryRam = new MemoryDomain("Battery RAM", Board.SaveRam.Length, MemoryDomain.Endian.Little, addr => Board.SaveRam[addr], (addr, value) => Board.SaveRam[addr] = value); domains.Add(BatteryRam); } if (Board.ROM != null) { var PRGROM = new MemoryDomain("PRG ROM", cart.prg_size * 1024, MemoryDomain.Endian.Little, addr => Board.ROM[addr], (addr, value) => Board.ROM[addr] = value); domains.Add(PRGROM); } if (Board.VROM != null) { var CHRROM = new MemoryDomain("CHR VROM", cart.chr_size * 1024, MemoryDomain.Endian.Little, addr => Board.VROM[addr], (addr, value) => Board.VROM[addr] = value); domains.Add(CHRROM); } if (Board.VRAM != null) { var VRAM = new MemoryDomain("VRAM", Board.VRAM.Length, MemoryDomain.Endian.Little, addr => Board.VRAM[addr], (addr, value) => Board.VRAM[addr] = value); domains.Add(VRAM); } if (Board.WRAM != null) { var WRAM = new MemoryDomain("WRAM", Board.WRAM.Length, MemoryDomain.Endian.Little, addr => Board.WRAM[addr], (addr, value) => Board.WRAM[addr] = value); domains.Add(WRAM); } // if there were more boards with special ram sets, we'd want to do something more general if (Board is FDS) { domains.Add((Board as FDS).GetDiskPeeker()); } else if (Board is ExROM) { domains.Add((Board as ExROM).GetExRAM()); } _memoryDomains = new MemoryDomainList(domains); (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains); }
private void SetDomain(MemoryDomain domain) { SetMemoryDomain(domain.Name); }
private void SetMemoryDomain(string name) { if (name == _romDomain.Name) { _domain = _romDomain; } else { _domain = MemoryDomains[name]; } BigEndian = _domain.EndianType == MemoryDomain.Endian.Big; _maxRow = _domain.Size / 2; SetUpScrollBar(); if (0 >= HexScrollBar.Minimum && 0 <= HexScrollBar.Maximum) { HexScrollBar.Value = 0; } if (_domain.CanPoke()) { AddressesLabel.ForeColor = SystemColors.ControlText; } else { AddressesLabel.ForeColor = SystemColors.ControlDarkDark; } UpdateGroupBoxTitle(); SetHeader(); UpdateValues(); }
public void SetToAddresses(IEnumerable<long> addresses, MemoryDomain domain, Watch.WatchSize size) { DataSize = (int)size; SetDataSize(DataSize); var addrList = addresses.ToList(); if (addrList.Any()) { SetDomain(domain); SetHighlighted(addrList[0]); _secondaryHighlightedAddresses.Clear(); _secondaryHighlightedAddresses.AddRange(addrList.Where(addr => addr != addrList[0]).ToList()); ClearNibbles(); UpdateValues(); MemoryViewerBox.Refresh(); AddressLabel.Text = GenerateAddressString(); } }
public void Restart() { _rom = GetRomBytes(); _romDomain = MemoryDomain.FromByteArray("File on Disk", MemoryDomain.Endian.Little, _rom); if (_domain.Name == _romDomain.Name) { _domain = _romDomain; } else if (MemoryDomains.Any(x => x.Name == _domain.Name)) { _domain = MemoryDomains[_domain.Name]; } else { _domain = MemoryDomains.MainMemory; } BigEndian = _domain.EndianType == MemoryDomain.Endian.Big; _maxRow = _domain.Size / 2; // Don't reset scroll bar if restarting the same rom if (_lastRom != GlobalWin.MainForm.CurrentlyOpenRom) { _lastRom = GlobalWin.MainForm.CurrentlyOpenRom; ResetScrollBar(); } SetDataSize(DataSize); SetHeader(); UpdateValues(); AddressLabel.Text = GenerateAddressString(); }
public DWordWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, uint prev, int changeCount, string notes = null) : this(domain, address, type, bigEndian, notes) { _previous = prev; _changecount = changeCount; _type = type; _bigEndian = bigEndian; }
public ByteWatch(MemoryDomain domain, int address, DisplayType type, bool bigEndian, byte prev, int changeCount, string notes = null) : this(domain, address, type, bigEndian, notes) { _previous = prev; _changecount = changeCount; }
public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, bool bigendian, int prev, int changecount) { switch (size) { default: case WatchSize.Separator: return SeparatorWatch.Instance; case WatchSize.Byte: return new ByteWatch(domain, address, type, bigendian, (byte)prev, changecount); case WatchSize.Word: return new WordWatch(domain, address, type, bigendian, (ushort)prev, changecount); case WatchSize.DWord: return new DWordWatch(domain, address, type, bigendian, (uint)prev, changecount); } }
public static Watch GenerateWatch(MemoryDomain domain, int address, WatchSize size, DisplayType type, string notes, bool bigEndian) { switch (size) { default: case WatchSize.Separator: return SeparatorWatch.Instance; case WatchSize.Byte: return new ByteWatch(domain, address, type, bigEndian, notes); case WatchSize.Word: return new WordWatch(domain, address, type, bigEndian, notes); case WatchSize.DWord: return new DWordWatch(domain, address, type, bigEndian, notes); } }
public string Disassemble(MemoryDomain m, uint addr, out int length) { return MOS6502X.Disassemble((ushort)addr, out length, (a) => m.PeekByte(a)); }
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; MainBestRadio.Checked = botData.MainCompareToBest; TieBreak1BestRadio.Checked = botData.TieBreaker1CompareToBest; TieBreak2BestRadio.Checked = botData.TieBreaker2CompareToBest; TieBreak3BestRadio.Checked = botData.TieBreaker3CompareToBest; MainValueRadio.Checked = !botData.MainCompareToBest; TieBreak1ValueRadio.Checked = !botData.TieBreaker1CompareToBest; TieBreak2ValueRadio.Checked = !botData.TieBreaker2CompareToBest; TieBreak3ValueRadio.Checked = !botData.TieBreaker3CompareToBest; MainValueNumeric.Value = botData.MainCompareToValue; TieBreak1Numeric.Value = botData.TieBreaker1CompareToValue; TieBreak2Numeric.Value = botData.TieBreaker2CompareToValue; TieBreak3Numeric.Value = botData.TieBreaker3CompareToValue; } catch { MainComparisonType = 0; Tie1ComparisonType = 0; Tie2ComparisonType = 0; Tie3ComparisonType = 0; MainBestRadio.Checked = true; TieBreak1BestRadio.Checked = true; TieBreak2BestRadio.Checked = true; TieBreak3BestRadio.Checked = true; MainBestRadio.Checked = false; TieBreak1BestRadio.Checked = false; TieBreak2BestRadio.Checked = false; TieBreak3BestRadio.Checked = false; MainValueNumeric.Value = 0; TieBreak1Numeric.Value = 0; TieBreak2Numeric.Value = 0; TieBreak3Numeric.Value = 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(); UpdateComparisonBotAttempt(); if (_bestBotAttempt != null) { PlayBestButton.Enabled = true; } CurrentFileName = path; Settings.RecentBotFiles.Add(CurrentFileName); MessageLabel.Text = Path.GetFileNameWithoutExtension(path) + " loaded"; return true; }
private void SetMemoryDomain(string name) { _currentDomain = MemoryDomains[name]; _bigEndian = MemoryDomains[name].EndianType == MemoryDomain.Endian.Big; }
public override string Disassemble(MemoryDomain m, uint addr, out int length) => _baseDisassembler.Disassemble(m, addr, out length);