Ejemplo n.º 1
0
        private void AddStream(MemorySection stream)
        {
            Int64 byteCount  = stream.Length;
            Int32 startKey   = (Int32)stream.BasePosition >> 16;
            Int32 endKey     = startKey + ((Int32)(stream.Length - 1) >> 16);
            Int32 sliceCount = (endKey - startKey);

            logger.Debug($"Mapping {sliceCount + 1} slices of {stream} to physical N64 memory -> {stream.BasePosition:X8}");

            for (Int32 i = startKey; i <= endKey; i++)
            {
                if (m_SectionMap[i] != null)
                {
                    throw new InvalidOperationException("Overlay error has occurred!");
                }

                m_SectionMap[i] = stream;
            }
        }
Ejemplo n.º 2
0
        private void Access(Action <Stream, byte[], int, int> op,
                            byte[] buffer, int offset, int count,
                            Int32 key)
        {
            if (count <= 0)
            {
                return;
            }

            /* Pull out the memory section */
            MemorySection section = m_SectionMap[key];

            /* If the section exists, read from its data */
            if (section != null)
            {
                /* Set the position on the stream */
                section.Position = Position - section.BasePosition;

                /* Compute the number of bytes to access */
                Int32 length = (Int32)(Math.Min(section.BasePosition + section.Length, section.Position + count) - section.Position);

                /* Call the access op */
                op(section, buffer, offset, length);

                /* Increment buffer offset, decrement count, and increment position */
                offset   += length;
                count    -= length;
                Position += length;

                /* Access possible section */
                Access(op, buffer, offset, count, (Int32)Position >> 16);
            }
            else
            {
                /* Skip non-existing section */
                Position += 0x10000;
                Access(op, buffer, offset + 0x10000, count -= 0x10000, key + 1);
            }
        }
Ejemplo n.º 3
0
        public void Initialize()
        {
            CheckDispose();
            m_SectionMap        = new MemorySection[0x10000];
            m_RDRam             = new MemorySection(0x100000, 0x00000000);
            m_PifMemory         = new MemorySection(0x800, 0x1FC00000);
            m_PIMem             = new ParallelInterfaceMemory();
            m_RspMemory         = new MemorySection(0x2000, 0x04000000);
            m_RspRegisterMemory = new RspRegisterMemory();
            m_MiIntefaceMemory  = new MipsInterfaceMemory();

            if (m_CartMemory != null)
            {
                AddStream(m_CartMemory);
            }

            /* Setup the region hashtable */
            AddStream(m_RDRam);
            AddStream(m_PIMem);
            AddStream(m_RspMemory);
            AddStream(m_RspRegisterMemory);
            AddStream(m_PifMemory);
        }