private void CreateMemoryDomains(int romsize)
        {
            var le = MemoryDomain.Endian.Little;

            var mm = new List <MemoryDomain>();

            mm.Add(_iwram  = new MemoryDomainIntPtr("IWRAM", le, IntPtr.Zero, 32 * 1024, true, 4));
            mm.Add(_ewram  = new MemoryDomainIntPtr("EWRAM", le, IntPtr.Zero, 256 * 1024, true, 4));
            mm.Add(_bios   = new MemoryDomainIntPtr("BIOS", le, IntPtr.Zero, 16 * 1024, false, 4));
            mm.Add(_palram = new MemoryDomainIntPtr("PALRAM", le, IntPtr.Zero, 1024, true, 4));
            mm.Add(_vram   = new MemoryDomainIntPtr("VRAM", le, IntPtr.Zero, 96 * 1024, true, 4));
            mm.Add(_oam    = new MemoryDomainIntPtr("OAM", le, IntPtr.Zero, 1024, true, 4));
            mm.Add(_rom    = new MemoryDomainIntPtr("ROM", le, IntPtr.Zero, romsize, true, 4));
            // 128 KB is the max size for GBA savedata
            // mGBA does not know a game's save type (and as a result actual savedata size) on startup.
            // Instead, BizHawk's savedata buffer will be accessed directly for a consistent interface.
            mm.Add(_sram  = new MemoryDomainIntPtr("SRAM", le, IntPtr.Zero, 128 * 1024, true, 4));
            mm.Add(_cwram = new MemoryDomainDelegate("Combined WRAM", (256 + 32) * 1024, le, null, null, 4));

            mm.Add(new MemoryDomainDelegate("System Bus", 0x10000000, le,
                                            delegate(long addr)
            {
                var a = (uint)addr;
                if (a >= 0x10000000)
                {
                    throw new ArgumentOutOfRangeException();
                }

                return(LibmGBA.BizReadBus(Core, a));
            },
                                            delegate(long addr, byte val)
            {
                var a = (uint)addr;
                if (a >= 0x10000000)
                {
                    throw new ArgumentOutOfRangeException();
                }

                LibmGBA.BizWriteBus(Core, a, val);
            }, 4));

            _memoryDomains = new MemoryDomainList(mm);
            WireMemoryDomainPointers();
        }
Esempio n. 2
0
        private void CreateMemoryDomains(int romsize)
        {
            var le = MemoryDomain.Endian.Little;

            var mm = new List <MemoryDomain>();

            mm.Add(_iwram  = new MemoryDomainIntPtr("IWRAM", le, IntPtr.Zero, 32 * 1024, true, 4));
            mm.Add(_ewram  = new MemoryDomainIntPtr("EWRAM", le, IntPtr.Zero, 256 * 1024, true, 4));
            mm.Add(_bios   = new MemoryDomainIntPtr("BIOS", le, IntPtr.Zero, 16 * 1024, false, 4));
            mm.Add(_palram = new MemoryDomainIntPtr("PALRAM", le, IntPtr.Zero, 1024, true, 4));
            mm.Add(_vram   = new MemoryDomainIntPtr("VRAM", le, IntPtr.Zero, 96 * 1024, true, 4));
            mm.Add(_oam    = new MemoryDomainIntPtr("OAM", le, IntPtr.Zero, 1024, true, 4));
            mm.Add(_rom    = new MemoryDomainIntPtr("ROM", le, IntPtr.Zero, romsize, false, 4));
            mm.Add(_sram   = new MemoryDomainIntPtr("SRAM", le, IntPtr.Zero, 0, true, 4));           // size will be fixed in wireup
            mm.Add(_cwram  = new MemoryDomainDelegate("Combined WRAM", (256 + 32) * 1024, le, null, null, 4));

            mm.Add(new MemoryDomainDelegate("System Bus", 0x10000000, le,
                                            delegate(long addr)
            {
                var a = (uint)addr;
                if (a >= 0x10000000)
                {
                    throw new ArgumentOutOfRangeException();
                }

                return(LibmGBA.BizReadBus(_core, a));
            },
                                            delegate(long addr, byte val)
            {
                var a = (uint)addr;
                if (a >= 0x10000000)
                {
                    throw new ArgumentOutOfRangeException();
                }

                LibmGBA.BizWriteBus(_core, a, val);
            }, 4));

            _memoryDomains = new MemoryDomainList(mm);
            WireMemoryDomainPointers();
        }