Пример #1
0
        // ----- Client Debugging API stuff -----
        unsafe MemoryDomain MakeMemoryDomain(string name, LibsnesApi.SNES_MEMORY id, MemoryDomain.Endian endian)
        {
            int  size = api.QUERY_get_memory_size(id);
            int  mask = size - 1;
            bool pow2 = Util.IsPowerOfTwo(size);

            //if this type of memory isnt available, dont make the memory domain (most commonly save ram)
            if (size == 0)
            {
                return(null);
            }

            byte *blockptr = api.QUERY_get_memory_data(id);

            MemoryDomain md;

            if (id == LibsnesApi.SNES_MEMORY.OAM)
            {
                //OAM is actually two differently sized banks of memory which arent truly considered adjacent.
                //maybe a better way to visualize it is with an empty bus and adjacent banks
                //so, we just throw away everything above its size of 544 bytes
                if (size != 544)
                {
                    throw new InvalidOperationException("oam size isnt 544 bytes.. wtf?");
                }
                md = new MemoryDomain(name, size, endian,
                                      (addr) => (addr < 544) ? blockptr[addr] : (byte)0x00,
                                      (addr, value) => { if (addr < 544)
                                                         {
                                                             blockptr[addr] = value;
                                                         }
                                      }
                                      );
            }
            else if (pow2)
            {
                md = new MemoryDomain(name, size, endian,
                                      (addr) => blockptr[addr & mask],
                                      (addr, value) => blockptr[addr & mask] = value);
            }
            else
            {
                md = new MemoryDomain(name, size, endian,
                                      (addr) => blockptr[addr % size],
                                      (addr, value) => blockptr[addr % size] = value);
            }

            _memoryDomains.Add(md);

            return(md);
        }
Пример #2
0
        private unsafe void MakeMemoryDomain(string name, LibsnesApi.SNES_MEMORY id, MemoryDomain.Endian endian, int byteSize = 1)
        {
            int size = Api.QUERY_get_memory_size(id);

            // if this type of memory isn't available, don't make the memory domain (most commonly save ram)
            if (size == 0)
            {
                return;
            }

            byte *blockPtr = Api.QUERY_get_memory_data(id);

            var md = new MemoryDomainIntPtrMonitor(name, MemoryDomain.Endian.Little, (IntPtr)blockPtr, size,
                                                   id != LibsnesApi.SNES_MEMORY.CARTRIDGE_ROM, // hack: for just this one memory area, it will be readonly
                                                   byteSize, Api);

            _memoryDomainList.Add(md);
        }