/// <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); }
/// <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); }
public abstract long retro_get_memory_size(RETRO_MEMORY id);
public abstract IntPtr retro_get_memory_data(RETRO_MEMORY id);
/// <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)); }
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])); }
public uint GetMemorySize(RETRO_MEMORY id) { return(_getMemorySize(id)); }
public IntPtr GetMemoryData(RETRO_MEMORY id) { return(_getMemoryData(id)); }