private void InitMemoryDomains()
        {
            CreateMemoryDomain(LibGambatte.MemoryAreas.wram, "WRAM");
            CreateMemoryDomain(LibGambatte.MemoryAreas.rom, "ROM");
            CreateMemoryDomain(LibGambatte.MemoryAreas.vram, "VRAM");
            CreateMemoryDomain(LibGambatte.MemoryAreas.cartram, "CartRAM");
            CreateMemoryDomain(LibGambatte.MemoryAreas.oam, "OAM");
            CreateMemoryDomain(LibGambatte.MemoryAreas.hram, "HRAM");

            // also add a special memory domain for the system bus, where calls get sent directly to the core each time
            _memoryDomains.Add(new MemoryDomainDelegate("System Bus", 65536, MemoryDomain.Endian.Little,
                                                        delegate(long addr)
            {
                if (addr < 0 || addr >= 65536)
                {
                    throw new ArgumentOutOfRangeException();
                }

                return(LibGambatte.gambatte_cpuread(GambatteState, (ushort)addr));
            },
                                                        delegate(long addr, byte val)
            {
                if (addr < 0 || addr >= 65536)
                {
                    throw new ArgumentOutOfRangeException();
                }

                LibGambatte.gambatte_cpuwrite(GambatteState, (ushort)addr, val);
            }, 1));

            MemoryDomains = new MemoryDomainList(_memoryDomains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
Exemple #2
0
        private unsafe void SetMemoryDomains()
        {
            List <MemoryDomain> mm = new();

            foreach (int i in Enum.GetValues(typeof(BsnesApi.SNES_MEMORY)))
            {
                void *data = Api.core.snes_get_memory_region(i, out int size, out int wordSize);
                if (data == null)
                {
                    continue;
                }
                if (i == (int)BsnesApi.SNES_MEMORY.CARTRIDGE_RAM)
                {
                    _saveRam     = (byte *)data;
                    _saveRamSize = size;
                }
                mm.Add(new MemoryDomainIntPtrMonitor(Enum.GetName(typeof(BsnesApi.SNES_MEMORY), i), MemoryDomain.Endian.Little, (IntPtr)data, size, true, wordSize, Api));
            }

            mm.Add(new MemoryDomainDelegate(
                       "System Bus",
                       0x1000000,
                       MemoryDomain.Endian.Little,
                       address => Api.core.snes_bus_read((uint)address),
                       (address, value) => Api.core.snes_bus_write((uint)address, value), wordSize: 4));
            mm.Add(Api.exe.GetPagesDomain());

            _memoryDomains = new MemoryDomainList(mm);
            ((BasicServiceProvider)ServiceProvider).Register(_memoryDomains);
        }
        private void SetupMemoryDomains(bool diskDriveEnabled)
        {
            var domains = new List <MemoryDomain>
            {
                C64MemoryDomainFactory.Create("System Bus", 0x10000, a => _board.Cpu.Peek(a), (a, v) => _board.Cpu.Poke(a, v)),
                C64MemoryDomainFactory.Create("RAM", 0x10000, a => _board.Ram.Peek(a), (a, v) => _board.Ram.Poke(a, v)),
                C64MemoryDomainFactory.Create("CIA0", 0x10, a => _board.Cia0.Peek(a), (a, v) => _board.Cia0.Poke(a, v)),
                C64MemoryDomainFactory.Create("CIA1", 0x10, a => _board.Cia1.Peek(a), (a, v) => _board.Cia1.Poke(a, v)),
                C64MemoryDomainFactory.Create("VIC", 0x40, a => _board.Vic.Peek(a), (a, v) => _board.Vic.Poke(a, v)),
                C64MemoryDomainFactory.Create("SID", 0x20, a => _board.Sid.Peek(a), (a, v) => _board.Sid.Poke(a, v)),
            };

            if (diskDriveEnabled)
            {
                domains.AddRange(new[]
                {
                    C64MemoryDomainFactory.Create("1541 Bus", 0x10000, a => _board.DiskDrive.Peek(a), (a, v) => _board.DiskDrive.Poke(a, v)),
                    C64MemoryDomainFactory.Create("1541 RAM", 0x800, a => _board.DiskDrive.Peek(a), (a, v) => _board.DiskDrive.Poke(a, v)),
                    C64MemoryDomainFactory.Create("1541 VIA0", 0x10, a => _board.DiskDrive.PeekVia0(a), (a, v) => _board.DiskDrive.PokeVia0(a, v)),
                    C64MemoryDomainFactory.Create("1541 VIA1", 0x10, a => _board.DiskDrive.PeekVia1(a), (a, v) => _board.DiskDrive.PokeVia1(a, v))
                });
            }
            _memoryDomains = new MemoryDomainList(domains);
            ((BasicServiceProvider)ServiceProvider).Register(_memoryDomains);
        }
        private void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate("System Bus", 0x10000, MemoryDomain.Endian.Little,
                                         (addr) =>
                {
                    if (addr < 0 || addr >= 65536)
                    {
                        throw new ArgumentOutOfRangeException();
                    }
                    return(_machine.ReadBus((ushort)addr));
                },
                                         (addr, value) =>
                {
                    if (addr < 0 || addr >= 65536)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    _machine.WriteBus((ushort)addr, value);
                }, 1)
            };

            SyncAllByteArrayDomains();

            memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList());
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(memoryDomains);

            _memoryDomainsInit = true;
        }
        private void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>();

            var systemBusDomain = new MemoryDomainDelegate("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);
            }, 1);

            domains.Add(systemBusDomain);

            SyncAllByteArrayDomains();

            _memoryDomains = new MemoryDomainList(_byteArrayDomains.Values.Concat(domains).ToList());
            ((BasicServiceProvider)ServiceProvider).Register(_memoryDomains);

            _memoryDomainsInit = true;
        }
Exemple #6
0
        private void SetupMemoryDomains()
        {
            var domains = new List<MemoryDomain>
            {
                MemoryDomain.FromByteArray("Main RAM", MemoryDomain.Endian.Little, _ram)
            };

            var systemBusDomain = new MemoryDomainDelegate("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);
                }, 1);

            domains.Add(systemBusDomain);

            _memoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
        }
        public InputCollector(IMemoryDomains memoryDomains, IEmulator emulator)
        {
            _memoryBase = new MemoryBase(memoryDomains);
            _wramDump   = new byte[_memoryBase.MemoryDomains["WRAM"].Size];

            NeuronInputs = new Dictionary <InputDetail, short>();
            _tileList    = new Dictionary <InputDetail, uint>();

            short index = 1;

            for (int iy = -INPUT_HEIGHT_WIDTH * 16; iy <= INPUT_HEIGHT_WIDTH * 16; iy += 16)
            {
                for (int ix = -INPUT_HEIGHT_WIDTH * 16; ix <= INPUT_HEIGHT_WIDTH * 16; ix += 16)
                {
                    NeuronInputs.Add(new InputDetail()
                    {
                        Index = index, X = ix, Y = iy
                    }, 0);
                    _tileList.Add(new InputDetail()
                    {
                        Index = index, X = ix, Y = iy
                    }, 0);
                    index++;
                }
            }
        }
		private void SetupMemoryDomains(bool diskDriveEnabled)
		{
		    var domains = new List<MemoryDomain>
		    {
                C64MemoryDomainFactory.Create("System Bus", 0x10000, a => _board.Cpu.Peek(a), (a, v) => _board.Cpu.Poke(a, v)),
                C64MemoryDomainFactory.Create("RAM", 0x10000, a => _board.Ram.Peek(a), (a, v) => _board.Ram.Poke(a, v)),
                C64MemoryDomainFactory.Create("CIA0", 0x10, a => _board.Cia0.Peek(a), (a, v) => _board.Cia0.Poke(a, v)),
                C64MemoryDomainFactory.Create("CIA1", 0x10, a => _board.Cia1.Peek(a), (a, v) => _board.Cia1.Poke(a, v)),
                C64MemoryDomainFactory.Create("VIC", 0x40, a => _board.Vic.Peek(a), (a, v) => _board.Vic.Poke(a, v)),
                C64MemoryDomainFactory.Create("SID", 0x20, a => _board.Sid.Peek(a), (a, v) => _board.Sid.Poke(a, v)),
            };

		    if (diskDriveEnabled)
		    {
		        domains.AddRange(new[]
		        {
                    C64MemoryDomainFactory.Create("1541 Bus", 0x10000, a => _board.DiskDrive.Peek(a), (a, v) => _board.DiskDrive.Poke(a, v)),
                    C64MemoryDomainFactory.Create("1541 RAM", 0x800, a => _board.DiskDrive.Peek(a), (a, v) => _board.DiskDrive.Poke(a, v)),
                    C64MemoryDomainFactory.Create("1541 VIA0", 0x10, a => _board.DiskDrive.PeekVia0(a), (a, v) => _board.DiskDrive.PokeVia0(a, v)),
                    C64MemoryDomainFactory.Create("1541 VIA1", 0x10, a => _board.DiskDrive.PeekVia1(a), (a, v) => _board.DiskDrive.PokeVia1(a, v))
                });
		    }
			_memoryDomains = new MemoryDomainList(domains);
			((BasicServiceProvider) ServiceProvider).Register(_memoryDomains);
		}
        private void SetupMemoryDomains()
        {
            // TODO: is 8bit for byte arrays and 16bit for ushort correct here?
            // If ushort is correct, how about little endian?
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate(
                    "Main RAM",
                    ScratchpadRam.Length,
                    MemoryDomain.Endian.Little,
                    addr => ScratchpadRam[addr],
                    (addr, value) => ScratchpadRam[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "Graphics RAM",
                    GraphicsRam.Length,
                    MemoryDomain.Endian.Little,
                    addr => GraphicsRam[addr],
                    (addr, value) => GraphicsRam[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "Graphics ROM",
                    GraphicsRom.Length,
                    MemoryDomain.Endian.Little,
                    addr => GraphicsRom[addr],
                    (addr, value) => GraphicsRom[addr] = value,
                    1),
            };

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
 public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains, Compare compareTo, long?compareValue, int?differentBy)
     : this(settings, memoryDomains)
 {
     _compareTo   = compareTo;
     DifferentBy  = differentBy;
     CompareValue = compareValue;
 }
        public void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate(
                    "Main RAM",
                    RAM.Length,
                    MemoryDomain.Endian.Little,
                    addr => RAM[addr],
                    (addr, value) => RAM[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "System Bus",
                    0X10000,
                    MemoryDomain.Endian.Little,
                    addr => PeekSystemBus(addr),
                    (addr, value) => PokeSystemBus(addr, value),
                    1),
                new MemoryDomainDelegate(
                    "ROM",
                    _rom.Length,
                    MemoryDomain.Endian.Little,
                    addr => _rom[addr],
                    (addr, value) => _rom[addr] = value,
                    1),
            };

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
Exemple #12
0
        /// <summary>
        /// Generate sa <see cref="Watch"/> from a given string
        /// String is tab separate
        /// </summary>
        /// <param name="line">Entire string, tab separated for each value Order is:
        /// <list type="number">
        /// <item>
        /// <term>0x00</term>
        /// <description>Address in hexadecimal</description>
        /// </item>
        /// <item>
        /// <term>b,w or d</term>
        /// <description>The <see cref="WatchSize"/>, byte, word or double word</description>
        /// <term>s, u, h, b, 1, 2, 3, f</term>
        /// <description>The <see cref="DisplayType"/> signed, unsigned,etc...</description>
        /// </item>
        /// <item>
        /// <term>0 or 1</term>
        /// <description>Big endian or not</description>
        /// </item>
        /// <item>
        /// <term>RDRAM,ROM,...</term>
        /// <description>The <see cref="IMemoryDomains"/></description>
        /// </item>
        /// <item>
        /// <term>Plain text</term>
        /// <description>Notes</description>
        /// </item>
        /// </list>
        /// </param>
        /// <param name="domains"><see cref="Watch"/>'s memory domain</param>
        /// <returns>A brand new <see cref="Watch"/></returns>
        public static Watch FromString(string line, IMemoryDomains domains)
        {
            string[] parts = line.Split(new[] { '\t' }, 6);

            if (parts.Length < 6)
            {
                if (parts.Length >= 3 && parts[2] == "_")
                {
                    return(SeparatorWatch.Instance);
                }

                return(null);
            }

            if (long.TryParse(parts[0], NumberStyles.HexNumber, CultureInfo.CurrentCulture, out var address))
            {
                WatchSize    size      = SizeFromChar(parts[1][0]);
                DisplayType  type      = DisplayTypeFromChar(parts[2][0]);
                bool         bigEndian = parts[3] != "0";
                MemoryDomain domain    = domains[parts[4]];
                string       notes     = parts[5].Trim('\r', '\n');

                return(GenerateWatch(
                           domain,
                           address,
                           size,
                           type,
                           bigEndian,
                           notes));
            }

            return(null);
        }
		private void InitMemoryDomains()
		{
			CreateMemoryDomain(LibGambatte.MemoryAreas.wram, "WRAM");
			CreateMemoryDomain(LibGambatte.MemoryAreas.rom, "ROM");
			CreateMemoryDomain(LibGambatte.MemoryAreas.vram, "VRAM");
			CreateMemoryDomain(LibGambatte.MemoryAreas.cartram, "CartRAM");
			CreateMemoryDomain(LibGambatte.MemoryAreas.oam, "OAM");
			CreateMemoryDomain(LibGambatte.MemoryAreas.hram, "HRAM");

			// also add a special memory domain for the system bus, where calls get sent directly to the core each time

			_memoryDomains.Add(new MemoryDomain("System Bus", 65536, MemoryDomain.Endian.Little,
				delegate(long addr)
				{
					if (addr < 0 || addr >= 65536)
						throw new ArgumentOutOfRangeException();
					return LibGambatte.gambatte_cpuread(GambatteState, (ushort)addr);
				},
				delegate(long addr, byte val)
				{
					if (addr < 0 || addr >= 65536)
						throw new ArgumentOutOfRangeException();
					LibGambatte.gambatte_cpuwrite(GambatteState, (ushort)addr, val);
				}));

			MemoryDomains = new MemoryDomainList(_memoryDomains);
			(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
		}
Exemple #14
0
 public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains, Compare compareTo, long? compareValue, int? differentBy)
     : this(settings, memoryDomains)
 {
     _compareTo = compareTo;
         _differentBy = differentBy;
         _compareValue = compareValue;
 }
Exemple #15
0
        private void InitMemoryDomains()
        {
            var domains = new List <MemoryDomain>();

            _systemBusAddressShift = LibMAME.mame_lua_get_int(MAMELuaCommand.GetSpaceAddressShift);
            var dataWidth    = LibMAME.mame_lua_get_int(MAMELuaCommand.GetSpaceDataWidth) >> 3;          // mame returns in bits
            var size         = (long)LibMAME.mame_lua_get_double(MAMELuaCommand.GetSpaceAddressMask) + dataWidth;
            var endianString = MameGetString(MAMELuaCommand.GetSpaceEndianness);
            var deviceName   = MameGetString(MAMELuaCommand.GetMainCPUName);

            //var addrSize = (size * 2).ToString();

            MemoryDomain.Endian endian = MemoryDomain.Endian.Unknown;

            if (endianString == "little")
            {
                endian = MemoryDomain.Endian.Little;
            }
            else if (endianString == "big")
            {
                endian = MemoryDomain.Endian.Big;
            }

            var mapCount = LibMAME.mame_lua_get_int(MAMELuaCommand.GetSpaceMapCount);

            for (int i = 1; i <= mapCount; i++)
            {
                var read  = MameGetString($"return { MAMELuaCommand.SpaceMap }[{ i }].readtype");
                var write = MameGetString($"return { MAMELuaCommand.SpaceMap }[{ i }].writetype");

                if (read == "ram" && write == "ram" || read == "rom")
                {
                    var firstOffset = LibMAME.mame_lua_get_int($"return { MAMELuaCommand.SpaceMap }[{ i }].offset");
                    var lastOffset  = LibMAME.mame_lua_get_int($"return { MAMELuaCommand.SpaceMap }[{ i }].endoff");
                    var name        = $"{ deviceName } : { read } : 0x{ firstOffset:X}-0x{ lastOffset:X}";

                    domains.Add(new MemoryDomainDelegate(name, lastOffset - firstOffset + 1, endian,
                                                         delegate(long addr)
                    {
                        return(_peek(addr, firstOffset, size));
                    },
                                                         read == "rom" ? (Action <long, byte>) null : delegate(long addr, byte val)
                    {
                        _poke(addr, val, firstOffset, size);
                    },
                                                         dataWidth));
                }
            }

            domains.Add(new MemoryDomainDelegate(deviceName + " : System Bus", size, endian,
                                                 delegate(long addr)
            {
                return(_peek(addr, 0, size));
            },
                                                 null, dataWidth));

            _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);
		}
Exemple #17
0
        public void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate(
                    "Main RAM",
                    RAM.Length,
                    MemoryDomain.Endian.Little,
                    addr => RAM[addr],
                    (addr, value) => RAM[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "TIA Registers",
                    0x20,
                    MemoryDomain.Endian.Little,
                    addr => tia.ReadMemory((ushort)addr, true),
                    (addr, value) => tia.WriteMemory((ushort)addr, value, true),
                    1),
                new MemoryDomainDelegate(
                    "Maria Registers",
                    Maria_regs.Length,
                    MemoryDomain.Endian.Little,
                    addr => Maria_regs[addr],
                    (addr, value) => Maria_regs[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "6532 RAM",
                    RAM_6532.Length,
                    MemoryDomain.Endian.Little,
                    addr => RAM_6532[addr],
                    (addr, value) => RAM_6532[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "Ram Block 0",
                    0xC0,
                    MemoryDomain.Endian.Little,
                    addr => RAM[addr + 0x840],
                    (addr, value) => RAM[addr + 0x840] = value,
                    1),
                new MemoryDomainDelegate(
                    "Ram Block 1",
                    0xC0,
                    MemoryDomain.Endian.Little,
                    addr => RAM[addr + 0x940],
                    (addr, value) => RAM[addr + 0x940] = value,
                    1),
                new MemoryDomainDelegate(
                    "System Bus",
                    0X10000,
                    MemoryDomain.Endian.Little,
                    addr => PeekSystemBus(addr),
                    (addr, value) => PokeSystemBus(addr, value),
                    1)
            };

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
Exemple #18
0
 public WatchList(IMemoryDomains core, MemoryDomain domain, string systemid)
 {
     if (_memoryDomains == null)
     {
         _memoryDomains = core;
     }
     _domain   = domain;
     _systemid = systemid;
 }
        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(MemoryDomain.FromIntPtr("SRAM", s.sram_size, l, s.sram, 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);
        }
        private void SetupMemoryDomains()
        {
            // TODO: is 8bit for byte arrays and 16bit for ushort correct here?
            // If ushort is correct, how about little endian?
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate(
                    "Main RAM",
                    ScratchpadRam.Length,
                    MemoryDomain.Endian.Little,
                    addr => ScratchpadRam[addr],
                    (addr, value) => ScratchpadRam[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "Graphics RAM",
                    GraphicsRam.Length,
                    MemoryDomain.Endian.Little,
                    addr => GraphicsRam[addr],
                    (addr, value) => GraphicsRam[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "Graphics ROM",
                    GraphicsRom.Length,
                    MemoryDomain.Endian.Little,
                    addr => GraphicsRom[addr],
                    (addr, value) => GraphicsRom[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "System Ram",
                    SystemRam.Length * 2,
                    MemoryDomain.Endian.Little,
                    addr => ReadByteFromShortArray(addr, SystemRam),
                    (addr, value) => WriteByteToShortArray(addr, value, SystemRam),
                    1
                    ),
                new MemoryDomainDelegate(
                    "Executive Rom",
                    ExecutiveRom.Length * 2,
                    MemoryDomain.Endian.Little,
                    addr => ReadByteFromShortArray(addr, ExecutiveRom),
                    (addr, value) => WriteByteToShortArray(addr, value, ExecutiveRom),
                    1
                    ),
                new MemoryDomainDelegate(
                    "System Bus",
                    0X20000,
                    MemoryDomain.Endian.Little,
                    addr => PeekSystemBus(addr),
                    (addr, value) => PokeSystemBus(addr, value),
                    1
                    )
            };

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
Exemple #21
0
        private void InitMemoryDomains()
        {
            MakeMemoryDomain("RDRAM", mupen64plusApi.N64_MEMORY.RDRAM, MemoryDomain.Endian.Big, true);

            MakeMemoryDomain("ROM", mupen64plusApi.N64_MEMORY.THE_ROM, MemoryDomain.Endian.Big, true);

            MakeMemoryDomain("PI Register", mupen64plusApi.N64_MEMORY.PI_REG, MemoryDomain.Endian.Big, true);
            MakeMemoryDomain("SI Register", mupen64plusApi.N64_MEMORY.SI_REG, MemoryDomain.Endian.Big, true);
            MakeMemoryDomain("VI Register", mupen64plusApi.N64_MEMORY.VI_REG, MemoryDomain.Endian.Big, true);
            MakeMemoryDomain("RI Register", mupen64plusApi.N64_MEMORY.RI_REG, MemoryDomain.Endian.Big, true);
            MakeMemoryDomain("AI Register", mupen64plusApi.N64_MEMORY.AI_REG, MemoryDomain.Endian.Big, true);

            MakeMemoryDomain("EEPROM", mupen64plusApi.N64_MEMORY.EEPROM, MemoryDomain.Endian.Big, true);
            MakeMemoryDomain("SRAM", mupen64plusApi.N64_MEMORY.SRAM, MemoryDomain.Endian.Big, true);
            MakeMemoryDomain("FlashRAM", mupen64plusApi.N64_MEMORY.FLASHRAM, MemoryDomain.Endian.Big, true);

            if (_syncSettings.Controllers[0].IsConnected &&
                _syncSettings.Controllers[0].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 1", mupen64plusApi.N64_MEMORY.MEMPAK1, MemoryDomain.Endian.Big, true);
            }

            if (_syncSettings.Controllers[1].IsConnected &&
                _syncSettings.Controllers[1].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 2", mupen64plusApi.N64_MEMORY.MEMPAK2, MemoryDomain.Endian.Big, true);
            }

            if (_syncSettings.Controllers[2].IsConnected &&
                _syncSettings.Controllers[2].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 3", mupen64plusApi.N64_MEMORY.MEMPAK3, MemoryDomain.Endian.Big, true);
            }

            if (_syncSettings.Controllers[3].IsConnected &&
                _syncSettings.Controllers[3].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 4", mupen64plusApi.N64_MEMORY.MEMPAK4, MemoryDomain.Endian.Big, true);
            }


            Func <long, byte>   peekByte = addr => api.m64p_read_memory_8((uint)addr);
            Action <long, byte> pokeByte = (addr, val) => api.m64p_write_memory_8((uint)addr, val);

            _memoryDomains.Add(new MemoryDomainDelegate
                               (
                                   "System Bus",
                                   uint.MaxValue,
                                   MemoryDomain.Endian.Big,
                                   peekByte,
                                   pokeByte, 4
                               ));

            MemoryDomains = new MemoryDomainList(_memoryDomains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
Exemple #22
0
 /// <summary>
 /// Initialize a new instance of <see cref="WatchList"/> that will
 /// contains a set of <see cref="Watch"/>
 /// </summary>
 /// <param name="core">All available memomry domains</param>
 /// <param name="domain">Domain you want to watch</param>
 /// <param name="systemid">System identifier (NES, SNES, ...)</param>
 public WatchList(IMemoryDomains core, string systemid)
 {
     if (_memoryDomains == null)
     {
         _memoryDomains = core;
     }
     //TODO: Remove this after tests
     _domain   = core.MainMemory;
     _systemid = systemid;
 }
Exemple #23
0
 public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains)
 {
     _settings = new Settings(memoryDomains);
     _settings.Mode = settings.Mode;
     _settings.Domain = settings.Domain;
     _settings.Size = settings.Size;
     _settings.CheckMisAligned = settings.CheckMisAligned;
     _settings.Type = settings.Type;
     _settings.BigEndian = settings.BigEndian;
     _settings.PreviousType = settings.PreviousType;
 }
Exemple #24
0
            public Settings(IMemoryDomains memoryDomains)
            {
                BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big;
                Size      = (WatchSize)memoryDomains.MainMemory.WordSize;
                Type      = DisplayType.Unsigned;
                Mode      = SearchMode.Fast;

                Domain          = memoryDomains.MainMemory;
                CheckMisAligned = false;
                PreviousType    = PreviousType.LastSearch;
            }
Exemple #25
0
        private bool _isSorted    = true;      // Tracks whether or not the list is sorted by address, if it is, binary search can be used for finding watches

        public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains)
        {
            _settings                 = new Settings(memoryDomains);
            _settings.Mode            = settings.Mode;
            _settings.Domain          = settings.Domain;
            _settings.Size            = settings.Size;
            _settings.CheckMisAligned = settings.CheckMisAligned;
            _settings.Type            = settings.Type;
            _settings.BigEndian       = settings.BigEndian;
            _settings.PreviousType    = settings.PreviousType;
        }
        private void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomain(
                    "Main RAM",
                    128,
                    MemoryDomain.Endian.Little,
                    addr => Ram[addr],
                    (addr, value) => Ram[addr] = value),
                new MemoryDomain(
                    "TIA",
                    16,
                    MemoryDomain.Endian.Little,
                    addr => _tia.ReadMemory((ushort)addr, true),
                    (addr, value) => this._tia.WriteMemory((ushort)addr, value)),
                new MemoryDomain(
                    "PIA",
                    1024,
                    MemoryDomain.Endian.Little,
                    addr => M6532.ReadMemory((ushort)addr, true),
                    (addr, value) => M6532.WriteMemory((ushort)addr, value)),
                new MemoryDomain(
                    "System Bus",
                    65536,
                    MemoryDomain.Endian.Little,
                    addr => _mapper.PeekMemory((ushort)addr),
                    (addr, value) => _mapper.PokeMemory((ushort)addr, value))
            };

            if (_mapper is mDPC)             // TODO: also mDPCPlus
            {
                domains.Add(new MemoryDomain(
                                "DPC",
                                2048,
                                MemoryDomain.Endian.Little,
                                addr => (_mapper as mDPC).DspData[addr],
                                (addr, value) => (_mapper as mDPC).DspData[addr] = value));
            }

            if (_mapper.HasCartRam)
            {
                domains.Add(new MemoryDomain(
                                "Cart Ram",
                                _mapper.CartRam.Len,
                                MemoryDomain.Endian.Little,
                                addr => _mapper.CartRam[(int)addr],
                                (addr, value) => _mapper.CartRam[(int)addr] = value));
            }

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
		private void SetupMemoryDomains()
		{
			var domains = new List<MemoryDomain>
			{
				new MemoryDomain(
					"Main RAM",
					128,
					MemoryDomain.Endian.Little,
					addr => Ram[addr],
					(addr, value) => Ram[addr] = value),
				new MemoryDomain(
					"TIA",
					16,
					MemoryDomain.Endian.Little,
					addr => _tia.ReadMemory((ushort)addr, true),
					(addr, value) => this._tia.WriteMemory((ushort)addr, value)),
				new MemoryDomain(
					"PIA",
					1024,
					MemoryDomain.Endian.Little,
					addr => M6532.ReadMemory((ushort)addr, true),
					(addr, value) => M6532.WriteMemory((ushort)addr, value)),
				new MemoryDomain(
					"System Bus",
					65536,
					MemoryDomain.Endian.Little,
					addr => _mapper.PeekMemory((ushort) addr),
					(addr, value) => _mapper.PokeMemory((ushort) addr, value)) 
			};

			if (_mapper is mDPC) // TODO: also mDPCPlus
			{
				domains.Add(new MemoryDomain(
					"DPC",
					2048,
					MemoryDomain.Endian.Little,
					addr => (_mapper as mDPC).DspData[addr],
					(addr, value) => (_mapper as mDPC).DspData[addr] = value));
			}

			if (_mapper.HasCartRam)
			{
				domains.Add(new MemoryDomain(
					"Cart Ram",
					_mapper.CartRam.Len,
					MemoryDomain.Endian.Little,
					addr => _mapper.CartRam[(int)addr],
					(addr, value) => _mapper.CartRam[(int)addr] = value));
			}

			MemoryDomains = new MemoryDomainList(domains);
			(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
		}
Exemple #28
0
 /// <summary>
 /// Sets WatchList's domain list to a new one
 /// <see cref="Watch"/> domain will also be refreshed
 /// </summary>
 /// <param name="core">New domains</param>
 public void RefreshDomains(IMemoryDomains core)
 {
     _memoryDomains = core;
     Parallel.ForEach <Watch>(_watchList, watch =>
     {
         watch.Domain = core[watch.Domain.Name];
         watch.ResetPrevious();
         watch.Update();
         watch.ClearChangeCount();
     }
                              );
 }
        private void SetupMemoryDomains(byte[] romData, byte[] sgbRomData)
        {
            // lets just do this entirely differently for SGB
            if (IsSGB)
            {
                // NOTE: CGB has 32K of wram, and DMG has 8KB of wram. Not sure how to control this right now.. bsnes might not have any ready way of doign that? I couldnt spot it.
                // You wouldnt expect a DMG game to access excess wram, but what if it tried to? maybe an oversight in bsnes?
                MakeMemoryDomain("SGB WRAM", LibsnesApi.SNES_MEMORY.SGB_WRAM, MemoryDomain.Endian.Little);

                var romDomain = new MemoryDomainByteArray("SGB CARTROM", MemoryDomain.Endian.Little, romData, true, 1);
                _memoryDomainList.Add(romDomain);

                // the last 1 byte of this is special.. its an interrupt enable register, instead of ram. weird. maybe its actually ram and just getting specially used?
                MakeMemoryDomain("SGB HRAM", LibsnesApi.SNES_MEMORY.SGB_HRAM, MemoryDomain.Endian.Little);

                MakeMemoryDomain("SGB CARTRAM", LibsnesApi.SNES_MEMORY.SGB_CARTRAM, MemoryDomain.Endian.Little);

                MakeMemoryDomain("WRAM", LibsnesApi.SNES_MEMORY.WRAM, MemoryDomain.Endian.Little);

                var sgbromDomain = new MemoryDomainByteArray("SGB.SFC ROM", MemoryDomain.Endian.Little, sgbRomData, true, 1);
                _memoryDomainList.Add(sgbromDomain);
            }
            else
            {
                MakeMemoryDomain("WRAM", LibsnesApi.SNES_MEMORY.WRAM, MemoryDomain.Endian.Little);

                MakeMemoryDomain("CARTROM", LibsnesApi.SNES_MEMORY.CARTRIDGE_ROM, MemoryDomain.Endian.Little, byteSize: 2);
                MakeMemoryDomain("CARTRAM", LibsnesApi.SNES_MEMORY.CARTRIDGE_RAM, MemoryDomain.Endian.Little, byteSize: 2);
                MakeMemoryDomain("VRAM", LibsnesApi.SNES_MEMORY.VRAM, MemoryDomain.Endian.Little, byteSize: 2);
                MakeMemoryDomain("OAM", LibsnesApi.SNES_MEMORY.OAM, MemoryDomain.Endian.Little, byteSize: 2);
                MakeMemoryDomain("CGRAM", LibsnesApi.SNES_MEMORY.CGRAM, MemoryDomain.Endian.Little, byteSize: 2);
                MakeMemoryDomain("APURAM", LibsnesApi.SNES_MEMORY.APURAM, MemoryDomain.Endian.Little, byteSize: 2);

                if (!DeterministicEmulation)
                {
                    _memoryDomainList.Add(new MemoryDomainDelegate(
                                              "System Bus",
                                              0x1000000,
                                              MemoryDomain.Endian.Little,
                                              addr => Api.QUERY_peek(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr),
                                              (addr, val) => Api.QUERY_poke(LibsnesApi.SNES_MEMORY.SYSBUS, (uint)addr, val), wordSize: 2));
                }
                else
                {
                    // limited function bus
                    MakeFakeBus();
                }
            }

            _memoryDomains = new MemoryDomainList(_memoryDomainList);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(_memoryDomains);
        }
        private bool _isSorted = true;         // Tracks whether or not the list is sorted by address, if it is, binary search can be used for finding watches

        public RamSearchEngine(Settings settings, IMemoryDomains memoryDomains)
        {
            _settings = new Settings(memoryDomains)
            {
                Mode            = settings.Mode,
                Domain          = settings.Domain,
                Size            = settings.Size,
                CheckMisAligned = settings.CheckMisAligned,
                Type            = settings.Type,
                BigEndian       = settings.BigEndian,
                PreviousType    = settings.PreviousType
            };
        }
Exemple #31
0
            public Settings(IMemoryDomains memoryDomains)
            {
                BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big;
                Size      = (WatchSize)memoryDomains.MainMemory.ByteSize;
                Type      = DisplayType.Unsigned;
                Mode      = memoryDomains.MainMemory.Size > (1024 * 1024) ?
                            SearchMode.Fast :
                            SearchMode.Detailed;

                Domain          = memoryDomains.MainMemory;
                CheckMisAligned = false;
                PreviousType    = PreviousType.LastSearch;
            }
Exemple #32
0
        public void RefreshDomains(IMemoryDomains core, MemoryDomain domain)
        {
            _memoryDomains = core;
            _domain        = domain;

            _watchList.ForEach(w =>
            {
                if (w.Domain != null)
                {
                    w.Domain = _memoryDomains[w.Domain.Name];
                }
            });
        }
Exemple #33
0
        public void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate(
                    "Main RAM",
                    RAM.Length,
                    MemoryDomain.Endian.Little,
                    addr => RAM[addr],
                    (addr, value) => RAM[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "CPU RAM",
                    64,
                    MemoryDomain.Endian.Little,
                    addr => (byte)cpu.Regs[addr],
                    (addr, value) => cpu.Regs[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "System Bus",
                    0X1000,
                    MemoryDomain.Endian.Little,
                    addr => PeekSystemBus(addr),
                    (addr, value) => PokeSystemBus(addr, value),
                    1),
                new MemoryDomainDelegate(
                    "ROM",
                    _rom.Length,
                    MemoryDomain.Endian.Little,
                    addr => _rom[addr],
                    (addr, value) => _rom[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "PPU",
                    256,
                    MemoryDomain.Endian.Little,
                    addr => ppu.PeekReg((int)addr),
                    (addr, value) => ppu.WriteReg((int)addr, value),
                    1)
            };

            if (cart_RAM != null)
            {
                var CartRam = new MemoryDomainByteArray("Cart RAM", MemoryDomain.Endian.Little, cart_RAM, true, 1);
                domains.Add(CartRam);
            }

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
Exemple #34
0
        public void SetupMemoryDomains()
        {
            var domains = new List <MemoryDomain>
            {
                new MemoryDomainDelegate(
                    "Main RAM",
                    RAM.Length,
                    MemoryDomain.Endian.Little,
                    addr => RAM[addr],
                    (addr, value) => RAM[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "Zero Page RAM",
                    ZP_RAM.Length,
                    MemoryDomain.Endian.Little,
                    addr => ZP_RAM[addr],
                    (addr, value) => ZP_RAM[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "System Bus",
                    0X10000,
                    MemoryDomain.Endian.Little,
                    addr => PeekSystemBus(addr),
                    (addr, value) => PokeSystemBus(addr, value),
                    1),
                new MemoryDomainDelegate(
                    "ROM",
                    _rom.Length,
                    MemoryDomain.Endian.Little,
                    addr => _rom[addr],
                    (addr, value) => _rom[addr] = value,
                    1),
                new MemoryDomainDelegate(
                    "VRAM",
                    VRAM.Length,
                    MemoryDomain.Endian.Little,
                    addr => VRAM[addr],
                    (addr, value) => VRAM[addr] = value,
                    1)
            };

            if (cart_RAM != null)
            {
                var CartRam = new MemoryDomainByteArray("Cart RAM", MemoryDomain.Endian.Little, cart_RAM, true, 1);
                domains.Add(CartRam);
            }

            MemoryDomains = new MemoryDomainList(domains);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(MemoryDomains);
        }
Exemple #35
0
        public SearchEngineSettings(IMemoryDomains memoryDomains, bool useUndoHistory)
        {
            BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big;
            Size      = (WatchSize)memoryDomains.MainMemory.WordSize;
            Type      = DisplayType.Unsigned;
            Mode      = memoryDomains.MainMemory.Size > 1024 * 1024
                                ? SearchMode.Fast
                                : SearchMode.Detailed;

            Domain          = memoryDomains.MainMemory;
            CheckMisAligned = false;
            PreviousType    = PreviousType.LastSearch;
            UseUndoHistory  = useUndoHistory;
        }
Exemple #36
0
        /// <summary>
        /// Sets WatchList's domain list to a new one
        /// <see cref="Watch"/> domain will also be refreshed
        /// </summary>
        /// <param name="core">New domains</param>
        public void RefreshDomains(IMemoryDomains core)
        {
            _memoryDomains = core;
            Parallel.ForEach(_watchList, watch =>
            {
                if (watch.IsSeparator)
                {
                    return;
                }

                watch.Domain = core[watch.Domain.Name];
                watch.ResetPrevious();
                watch.Update();
                watch.ClearChangeCount();
            });
        }
Exemple #37
0
        public static IEnumerable <ToolStripItem> MenuItems(this IMemoryDomains domains, Action <string> setCallback, string selected = "", int?maxSize = null)
        {
            foreach (var domain in domains)
            {
                var name = domain.Name;
                var item = new ToolStripMenuItem
                {
                    Text    = name,
                    Enabled = !(maxSize.HasValue && domain.Size > maxSize.Value),
                    Checked = name == selected
                };
                item.Click += (o, ev) => setCallback(name);

                yield return(item);
            }
        }
        /// <summary>
        /// Sets WatchList's domain list to a new one
        /// <see cref="Watch"/> domain will also be refreshed
        /// </summary>
        /// <param name="core">New domains</param>
        public void RefreshDomains(IMemoryDomains core, PreviousType previousType)
        {
            _memoryDomains = core;
            foreach (var watch in _watchList)
            {
                if (watch.IsSeparator)
                {
                    return;
                }

                watch.Domain = core[watch.Domain.Name];
                watch.ResetPrevious();
                watch.Update(previousType);
                watch.ClearChangeCount();
            }
        }
        unsafe void InitMemoryDomains()
        {
            List<MemoryDomain> mm = new List<MemoryDomain>();
            for (int i = 0; ; i++)
            {
                IntPtr data = IntPtr.Zero;
                int size = 0;
                bool writable = false;
                IntPtr name = IntPtr.Zero;

                if (!QN.qn_get_memory_area(Context, i, ref data, ref size, ref writable, ref name))
                    break;

                if (data != IntPtr.Zero && size > 0 && name != IntPtr.Zero)
                {
                    mm.Add(MemoryDomain.FromIntPtr(Marshal.PtrToStringAnsi(name), size, MemoryDomain.Endian.Little, data, writable));
                }
            }
            // add system bus
            mm.Add(new MemoryDomainDelegate
            (
                "System Bus",
                0x10000,
                MemoryDomain.Endian.Unknown,
                delegate(long addr)
                {
                    if (addr < 0 || addr >= 0x10000)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    return QN.qn_peek_prgbus(Context, (int)addr);
                },
                delegate(long addr, byte val)
                {
                    if (addr < 0 || addr >= 0x10000)
                    {
                        throw new ArgumentOutOfRangeException();
                    }

                    QN.qn_poke_prgbus(Context, (int)addr, val);
                }, 1
            ));

            _memoryDomains = new MemoryDomainList(mm);
            (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
        }
		private void SetMemoryDomains()
		{
			var mm = new List<MemoryDomain>();

			foreach (var md in L.MemoryDomains)
			{
				mm.Add(new MemoryDomain("L " + md.Name, md.Size, md.EndianType, md.PeekByte, md.PokeByte));
			}

			foreach (var md in R.MemoryDomains)
			{
				mm.Add(new MemoryDomain("R " + md.Name, md.Size, md.EndianType, md.PeekByte, md.PokeByte));
			}

			_memoryDomains = new MemoryDomainList(mm);
			(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
		}
		private void InitMemoryDomains()
		{
			var ret = new List<MemoryDomain>();
			var nmds = LibYabause.libyabause_getmemoryareas_ex();
			foreach (var nmd in nmds)
			{
				int l = nmd.length;
				IntPtr d = nmd.data;
				ret.Add(MemoryDomain.FromIntPtr(nmd.name, nmd.length, MemoryDomain.Endian.Little, nmd.data, true, 4));
			}

			// main memory is in position 2
			_memoryDomains = new MemoryDomainList(ret);
			_memoryDomains.MainMemory = _memoryDomains["Work Ram Low"];

			(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
		}
        private void SetMemoryDomains()
        {
            var mm = new List<MemoryDomain>();

            foreach (var md in L.MemoryDomains)
            {
                mm.Add(new WrappedMemoryDomain("L " + md.Name, md));
            }

            foreach (var md in R.MemoryDomains)
            {
                mm.Add(new WrappedMemoryDomain("R " + md.Name, md));
            }

            _memoryDomains = new MemoryDomainList(mm);
            (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(_memoryDomains);
        }
Exemple #43
0
		private void SetupMemoryDomains()
		{

			// chips must be initialized before this code runs!
			var domains = new List<MemoryDomain>(1);
			domains.Add(new MemoryDomain("System Bus", 0x10000, MemoryDomain.Endian.Little, board.cpu.Peek, board.cpu.Poke));
			domains.Add(new MemoryDomain("RAM", 0x10000, MemoryDomain.Endian.Little, board.ram.Peek, board.ram.Poke));
			domains.Add(new MemoryDomain("CIA0", 0x10, MemoryDomain.Endian.Little, board.cia0.Peek, board.cia0.Poke));
			domains.Add(new MemoryDomain("CIA1", 0x10, MemoryDomain.Endian.Little, board.cia1.Peek, board.cia1.Poke));
			domains.Add(new MemoryDomain("VIC", 0x40, MemoryDomain.Endian.Little, board.vic.Peek, board.vic.Poke));
			domains.Add(new MemoryDomain("SID", 0x20, MemoryDomain.Endian.Little, board.sid.Peek, board.sid.Poke));
			//domains.Add(new MemoryDomain("1541 Bus", 0x10000, MemoryDomain.Endian.Little, new Func<int, byte>(disk.Peek), new Action<int, byte>(disk.Poke)));
			//domains.Add(new MemoryDomain("1541 VIA0", 0x10, MemoryDomain.Endian.Little, new Func<int, byte>(disk.PeekVia0), new Action<int, byte>(disk.PokeVia0)));
			//domains.Add(new MemoryDomain("1541 VIA1", 0x10, MemoryDomain.Endian.Little, new Func<int, byte>(disk.PeekVia1), new Action<int, byte>(disk.PokeVia1)));
			//domains.Add(new MemoryDomain("1541 RAM", 0x1000, MemoryDomain.Endian.Little, new Func<int, byte>(disk.PeekRam), new Action<int, byte>(disk.PokeRam)));
			memoryDomains = new MemoryDomainList(domains);
			(ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(memoryDomains);
		}
Exemple #44
0
        public CallbackBasedTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler)
        {
            if (!debuggableCore.MemoryCallbacksAvailable())
            {
                throw new InvalidOperationException("Memory callbacks are required");
            }

            try
            {
                debuggableCore.GetCpuFlagsAndRegisters();
            }
            catch (NotImplementedException)
            {
                throw new InvalidOperationException("GetCpuFlagsAndRegisters is required");
            }

            Header = "Instructions";
            DebuggableCore = debuggableCore;
            MemoryDomains = memoryDomains;
            Disassembler = disassembler;
        }
        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);
        }
Exemple #46
0
		public static Watch FromString(string line, IMemoryDomains domains)
		{
			try
			{
				var parts = line.Split(new[] { '\t' }, 6);

				if (parts.Length < 6)
				{
					if (parts.Length >= 3 && parts[2] == "_")
					{
						return SeparatorWatch.Instance;
					}

					return null;
				}

				var address = long.Parse(parts[0], NumberStyles.HexNumber);
				var size = Watch.SizeFromChar(parts[1][0]);
				var type = Watch.DisplayTypeFromChar(parts[2][0]);
				var bigEndian = parts[3] == "0" ? false : true;
				var domain = domains[parts[4]];
				var notes = parts[5].Trim(new[] { '\r', '\n' });

				return Watch.GenerateWatch(
					domain,
					address,
					size,
					type,
					notes,
					bigEndian
					);
			}
			catch
			{
				return null;
			}
		}
Exemple #47
0
	  public void DisassembleCDL(Stream s, CodeDataLog cdl, IMemoryDomains mem)
	  {
	    var w = new StreamWriter(s);
	    w.WriteLine("; Bizhawk CDL Disassembly");
	    w.WriteLine();
	    foreach (var kvp in cdl)
	    {
	      w.WriteLine(".\"{0}\" size=0x{1:x8}", kvp.Key, kvp.Value.Length);

	      byte[] cd = kvp.Value;
	      var md = mem[kvp.Key];

	      for (int i = 0; i < kvp.Value.Length; i++)
	      {
	        if ((kvp.Value[i] & (byte)HuC6280.CDLUsage.Code) != 0)
	        {
	          int unused;
	          string dis = HuC6280.DisassembleExt(
	            0,
	            out unused,
	            delegate(ushort addr)
	            {
	              return md.PeekByte(addr + i);
	            },
	            delegate(ushort addr)
	            {
	              return md.PeekWord(addr + i, false);
	            }
	          );
	          w.WriteLine("0x{0:x8}: {1}", i, dis);
	        }
	      }
	      w.WriteLine();
	    }
	    w.WriteLine("; EOF");
	    w.Flush();
	  }
        public void SetupMemoryDomains(HSC7800 hsc7800)
        {
            // reset memory domains
            if (_MemoryDomains == null)
            {
                _MemoryDomains = new List<MemoryDomain>();
                if (theMachine is Machine7800)
                {
                    _MemoryDomains.Add(new MemoryDomainDelegate(
                        "RAM", 0x1000, MemoryDomain.Endian.Unknown,
                        delegate(long addr)
                        {
                            if (addr < 0 || addr >= 0x1000)
                            {
                                throw new ArgumentOutOfRangeException();
                            }

                            if (addr < 0x800)
                            {
                                return ((Machine7800)theMachine).RAM1[(ushort)addr];
                            }

                            return ((Machine7800)theMachine).RAM2[(ushort)addr];
                        },

                        delegate(long addr, byte val)
                        {
                            if (addr < 0 || addr >= 0x1000)
                            {
                                throw new ArgumentOutOfRangeException();
                            }
                            else if (addr < 0x800)
                            {
                                ((Machine7800)theMachine).RAM1[(ushort)(addr & 0x800)] = val;
                            }
                            else
                            {
                                ((Machine7800)theMachine).RAM2[(ushort)addr] = val;
                            }
                        }, 1));

                    _MemoryDomains.Add(new MemoryDomainByteArray(
                        "BIOS ROM", MemoryDomain.Endian.Unknown,
                        bios, false, 1));

                    if (hsc7800 != null)
                    {
                        _MemoryDomains.Add(new MemoryDomainByteArray(
                            "HSC ROM", MemoryDomain.Endian.Unknown, hsbios, false, 1));

                        _MemoryDomains.Add(new MemoryDomainByteArray(
                            "HSC RAM", MemoryDomain.Endian.Unknown, hsram, true, 1));
                    }

                    _MemoryDomains.Add(new MemoryDomainDelegate(
                        "System Bus", 65536, MemoryDomain.Endian.Unknown,
                        delegate(long addr)
                        {
                            if (addr < 0 || addr >= 0x10000)
                                throw new ArgumentOutOfRangeException();
                            return theMachine.Mem[(ushort)addr];
                        },
                        delegate(long addr, byte val)
                        {
                            if (addr < 0 || addr >= 0x10000)
                                throw new ArgumentOutOfRangeException();
                            theMachine.Mem[(ushort)addr] = val;
                        }, 1));
                }
                else // todo 2600?
                {
                }

                MemoryDomains = new MemoryDomainList(_MemoryDomains);
                (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
            }
        }
Exemple #49
0
            public Settings(IMemoryDomains memoryDomains)
            {
                BigEndian = memoryDomains.MainMemory.EndianType == MemoryDomain.Endian.Big;
                Size = (Watch.WatchSize)memoryDomains.MainMemory.ByteSize;
                Type = Watch.DisplayType.Unsigned;
                Mode = memoryDomains.MainMemory.Size > (1024 * 1024) ?
                    SearchMode.Fast :
                    SearchMode.Detailed;

                Domain = memoryDomains.MainMemory;
                CheckMisAligned = false;
                PreviousType = Watch.PreviousType.LastSearch;
            }
        private void InitMemoryDomains()
        {
            //zero 07-sep-2014 - made RDRAM big endian domain, but none others. others need to be studied individually.
            MakeMemoryDomain("RDRAM", mupen64plusApi.N64_MEMORY.RDRAM, MemoryDomain.Endian.Big, true);

            MakeMemoryDomain("ROM", mupen64plusApi.N64_MEMORY.THE_ROM, MemoryDomain.Endian.Big, true);

            MakeMemoryDomain("PI Register", mupen64plusApi.N64_MEMORY.PI_REG, MemoryDomain.Endian.Little);
            MakeMemoryDomain("SI Register", mupen64plusApi.N64_MEMORY.SI_REG, MemoryDomain.Endian.Little);
            MakeMemoryDomain("VI Register", mupen64plusApi.N64_MEMORY.VI_REG, MemoryDomain.Endian.Little);
            MakeMemoryDomain("RI Register", mupen64plusApi.N64_MEMORY.RI_REG, MemoryDomain.Endian.Little);
            MakeMemoryDomain("AI Register", mupen64plusApi.N64_MEMORY.AI_REG, MemoryDomain.Endian.Little);

            MakeMemoryDomain("EEPROM", mupen64plusApi.N64_MEMORY.EEPROM, MemoryDomain.Endian.Little);

            if (_syncSettings.Controllers[0].IsConnected &&
                _syncSettings.Controllers[0].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 1", mupen64plusApi.N64_MEMORY.MEMPAK1, MemoryDomain.Endian.Little);
            }

            if (_syncSettings.Controllers[1].IsConnected &&
                _syncSettings.Controllers[1].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 2", mupen64plusApi.N64_MEMORY.MEMPAK2, MemoryDomain.Endian.Little);
            }

            if (_syncSettings.Controllers[2].IsConnected &&
                _syncSettings.Controllers[2].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 3", mupen64plusApi.N64_MEMORY.MEMPAK3, MemoryDomain.Endian.Little);
            }

            if (_syncSettings.Controllers[3].IsConnected &&
                _syncSettings.Controllers[3].PakType == N64SyncSettings.N64ControllerSettings.N64ControllerPakType.MEMORY_CARD)
            {
                MakeMemoryDomain("Mempak 4", mupen64plusApi.N64_MEMORY.MEMPAK4, MemoryDomain.Endian.Little);
            }

            Func<long, byte> peekByte;
            Action<long, byte> pokeByte;

            peekByte = delegate(long addr)
            {
                return api.m64p_read_memory_8((uint)addr);
            };

            pokeByte = delegate(long addr, byte val)
            {
                api.m64p_write_memory_8((uint)addr, val);
            };

            _memoryDomains.Add(new MemoryDomainDelegate
                (
                    "System Bus",
                    uint.MaxValue,
                     MemoryDomain.Endian.Big,
                    peekByte,
                    pokeByte, 4
                ));

            MemoryDomains = new MemoryDomainList(_memoryDomains);
            (ServiceProvider as BasicServiceProvider).Register<IMemoryDomains>(MemoryDomains);
        }
		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 = LibGPGX.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();
							LibGPGX.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 LibGPGX.gpgx_peek_m68k_bus(a);
				},
				delegate (long addr, byte val)
				{
					var a = (uint)addr;
					if (a >= 0x1000000)
						throw new ArgumentOutOfRangeException();
					LibGPGX.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 LibGPGX.gpgx_peek_s68k_bus(a);
				},
				delegate (long addr, byte val)
				{
					var a = (uint)addr;
					if (a >= 0x1000000)
						throw new ArgumentOutOfRangeException();
					LibGPGX.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);
		}
Exemple #52
0
 public GPGXTraceBuffer(IDebuggable debuggableCore, IMemoryDomains memoryDomains, IDisassemblable disassembler)
     : base(debuggableCore, memoryDomains, disassembler)
 {
     Header = "M68K: PC, machine code, mnemonic, arguments, registers (D0-D7, A0-A7, SR, USP, status flags)";
 }