Ejemplo n.º 1
0
        /// <summary>
        /// Loads memory data of the specified type into the LibRetro core
        /// </summary>
        /// <param name="memoryType">The type of memory to load</param>
        /// <param name="buffer">A byte array containing the memory data</param>
        /// <returns>True if the memory data was successfully loaded</returns>
        public bool SetMemoryData(RETRO_MEMORY memoryType, byte[] buffer)
        {
            int size = (int)_core.GetMemorySize(memoryType);

            if (size > buffer.Length)
            {
                size = buffer.Length;
            }
            IntPtr ptr = _core.GetMemoryData(memoryType);

            if (ptr == IntPtr.Zero)
            {
                return(false);
            }
            Marshal.Copy(buffer, 0, ptr, size);
            return(true);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Convenience method for <see cref="GetMemoryData(RETRO_MEMORY, byte[])"/> that allocates and returns a buffer containing the memory data
        /// </summary>
        /// <param name="memoryType">The type of memory to retrieve</param>
        /// <returns>A byte array containing the memory data</returns>
        public byte[] GetMemoryData(RETRO_MEMORY memoryType)
        {
            uint size = _core.GetMemorySize(memoryType);

            if (size == 0)
            {
                return(null);
            }
            IntPtr ptr = _core.GetMemoryData(memoryType);

            if (ptr == IntPtr.Zero)
            {
                return(null);
            }
            byte[] saveBuffer = new byte[size];
            Marshal.Copy(ptr, saveBuffer, 0, saveBuffer.Length);
            return(saveBuffer);
        }
Ejemplo n.º 3
0
 public abstract long retro_get_memory_size(RETRO_MEMORY id);
Ejemplo n.º 4
0
 public abstract IntPtr retro_get_memory_data(RETRO_MEMORY id);
Ejemplo n.º 5
0
 /// <summary>
 /// Returns the size of the specified memory type
 /// </summary>
 /// <param name="memoryType">The type of memory</param>
 /// <returns>The size of the memory type</returns>
 public int GetMemorySize(RETRO_MEMORY memoryType)
 {
     return((int)_core.GetMemorySize(memoryType));
 }
Ejemplo n.º 6
0
 public Tuple <IntPtr, int> QUERY_GetMemory(RETRO_MEMORY mem)
 {
     comm->value = (uint)mem;
     Message(eMessage.QUERY_GetMemory);
     return(Tuple.Create(new IntPtr(comm->buf[(int)BufId.Param0]), comm->buf_size[(int)BufId.Param0]));
 }
Ejemplo n.º 7
0
 public uint GetMemorySize(RETRO_MEMORY id)
 {
     return(_getMemorySize(id));
 }
Ejemplo n.º 8
0
 public IntPtr GetMemoryData(RETRO_MEMORY id)
 {
     return(_getMemoryData(id));
 }