示例#1
0
 /// <summary>
 /// Locks a buffer and sets it into libretro. You must pass a delegate to be executed while that buffer is locked.
 /// This is meant to be used for avoiding a memcpy for large roms (which the core is then just going to memcpy again on its own)
 /// The memcpy has to happen at some point (libretro semantics specify [not literally, the docs dont say] that the core should finish using the buffer before its init returns)
 /// but this limits it to once.
 /// Moreover, this keeps the c++ side from having to free strings when they're no longer used (and memory management is trickier there, so we try to avoid it)
 /// </summary>
 public void SetBytes(BufId id, byte[] bytes, Action andThen)
 {
     fixed(byte *bp = bytes)
     {
         _setBuffer(id, bp, (ulong)bytes.Length);
         andThen();
     }
 }
示例#2
0
 /// <summary>
 /// see SetBytes
 /// </summary>
 public void SetAscii(BufId id, string str, Action andThen)
 {
     fixed(byte *cp = System.Text.Encoding.ASCII.GetBytes(str + "\0"))
     {
         _setBuffer(id, cp, (ulong)str.Length + 1);
         andThen();
     }
 }
示例#3
0
 /// <summary>
 /// Copy a buffer into libretro. It keeps the copy.
 /// </summary>
 public void CopyBytes(BufId id, byte[] bytes)
 {
     fixed(byte *bp = bytes)
     _copyBuffer(id, bp, (ulong)bytes.Length);
 }
示例#4
0
 /// <summary>
 /// Copy an ascii string into libretro. It keeps the copy.
 /// </summary>
 public void CopyAscii(BufId id, string str)
 {
     fixed(char *cp = str)
     _copyBuffer(id, cp, (ulong)str.Length + 1);
 }