Beispiel #1
0
        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));

            _gpumem = new GBAGPUMemoryAreas
            {
                mmio   = s.mmio,
                oam    = s.oam,
                palram = s.palram,
                vram   = s.vram
            };

            return(new MemoryDomainList(mm));
        }
Beispiel #2
0
        private void SetupMemoryDomains()
        {
            var mms = new List <MemoryDomain>();

            mms.Add(MemoryDomain.FromIntPtr("RAM", 65536, MemoryDomain.Endian.Little, LibLynx.GetRamPointer(Core), true, 2));

            IntPtr p;
            int    s;

            if (LibLynx.GetSaveRamPtr(Core, out s, out p))
            {
                mms.Add(MemoryDomain.FromIntPtr("Save RAM", s, MemoryDomain.Endian.Little, p, true, 2));
            }

            IntPtr p0, p1;
            int    s0, s1;

            LibLynx.GetReadOnlyCartPtrs(Core, out s0, out p0, out s1, out p1);
            if (s0 > 0 && p0 != IntPtr.Zero)
            {
                mms.Add(MemoryDomain.FromIntPtr("Cart A", s0, MemoryDomain.Endian.Little, p0, false, 2));
            }
            if (s1 > 0 && p1 != IntPtr.Zero)
            {
                mms.Add(MemoryDomain.FromIntPtr("Cart B", s1, MemoryDomain.Endian.Little, p1, false, 2));
            }

            _memoryDomains = new MemoryDomainList(mms);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(_memoryDomains);
        }
        private void AddMemoryDomain(LibMeteor.MemoryArea which, int size, string name)
        {
            IntPtr data = LibMeteor.libmeteor_getmemoryarea(which);

            if (data == IntPtr.Zero)
            {
                throw new Exception("libmeteor_getmemoryarea() returned NULL??");
            }

            MemoryDomain md = MemoryDomain.FromIntPtr(name, size, MemoryDomain.Endian.Little, data);

            _domainList.Add(md);
        }
Beispiel #4
0
        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 MemoryDomain
                   (
                       "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);
            }
                   ));

            _memoryDomains = new MemoryDomainList(mm);
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(_memoryDomains);
        }
        void CreateMemoryDomain(LibGambatte.MemoryAreas which, string name)
        {
            IntPtr data   = IntPtr.Zero;
            int    length = 0;

            if (!LibGambatte.gambatte_getmemoryarea(GambatteState, which, ref data, ref length))
            {
                throw new Exception("gambatte_getmemoryarea() failed!");
            }

            // if length == 0, it's an empty block; (usually rambank on some carts); that's ok
            if (data != IntPtr.Zero && length > 0)
            {
                _memoryDomains.Add(MemoryDomain.FromIntPtr(name, length, MemoryDomain.Endian.Little, data));
            }
        }
        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);
        }
        void InitIMemoryDomains()
        {
            var mmd = new List <MemoryDomain>();

            for (int i = 0; ; i++)
            {
                IntPtr name;
                int    size;
                IntPtr data;
                if (!BizSwan.bizswan_getmemoryarea(Core, i, out name, out size, out data))
                {
                    break;
                }
                if (size == 0)
                {
                    continue;
                }
                string sname = Marshal.PtrToStringAnsi(name);
                mmd.Add(MemoryDomain.FromIntPtr(sname, size, MemoryDomain.Endian.Little, data));
            }
            (ServiceProvider as BasicServiceProvider).Register <IMemoryDomains>(new MemoryDomainList(mmd));
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        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));
        }