Exemplo n.º 1
0
        void WireMemoryDomainPointers()
        {
            var s = new LibmGBA.MemoryAreas();

            LibmGBA.BizGetMemoryAreas(core, s);

            _iwram.Data  = s.iwram;
            _ewram.Data  = s.wram;
            _bios.Data   = s.bios;
            _palram.Data = s.palram;
            _vram.Data   = s.vram;
            _oam.Data    = s.oam;
            _rom.Data    = s.rom;
            _sram.Data   = s.sram;
            _sram.SetSize(s.sram_size);

            // special combined ram memory domain

            _cwram.Peek =
                delegate(long addr)
            {
                LibmGBA.BizGetMemoryAreas(core, s);
                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));
                }
            };
            _cwram.Poke =
                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);
                }
            };

            _gpumem = new GBAGPUMemoryAreas
            {
                mmio   = s.mmio,
                oam    = s.oam,
                palram = s.palram,
                vram   = s.vram
            };
        }
Exemplo n.º 2
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));
        }
Exemplo n.º 3
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));
        }