From 49f59bbceffc7729bf5aee2897de8cf67404500b Mon Sep 17 00:00:00 2001 From: KingLuigi4932 Date: Fri, 22 Dec 2017 06:56:52 +0300 Subject: [PATCH] (Needed) Read and Write Buffer Methods --- source/Cosmos.Core/MemoryBlock.cs | 38 +++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/source/Cosmos.Core/MemoryBlock.cs b/source/Cosmos.Core/MemoryBlock.cs index c9022e8e8..de4a4bf6f 100644 --- a/source/Cosmos.Core/MemoryBlock.cs +++ b/source/Cosmos.Core/MemoryBlock.cs @@ -102,6 +102,44 @@ namespace Cosmos.Core { throw new Exception("TODO"); } + + #region ReadWrite + public unsafe void Read8(Byte[] aBuffer) + { + for (int i = 0; i < aBuffer.Length; i++) + aBuffer[i] = (*(Byte*)(Base + i)); + } + + public unsafe void Write8(Byte[] aBuffer) + { + for (int i = 0; i < aBuffer.Length; i++) + (*(Byte*)(Base + i)) = aBuffer[i]; + } + + public unsafe void Read16(UInt16[] aBuffer) + { + for (int i = 0; i < aBuffer.Length; i++) + aBuffer[i] = (*(UInt16*)(Base + i)); + } + + public unsafe void Write16(UInt16[] aBuffer) + { + for (int i = 0; i < aBuffer.Length; i++) + (*(UInt16*)(Base + i)) = aBuffer[i]; + } + + public unsafe void Read32(UInt32[] aBuffer) + { + for (int i = 0; i < aBuffer.Length; i++) + aBuffer[i] = (*(UInt32*)(Base + i)); + } + + public unsafe void Write32(UInt32[] aBuffer) + { + for (int i = 0; i < aBuffer.Length; i++) + (*(UInt32*)(Base + i)) = aBuffer[i]; + } + #endregion ReadWrite } public class MemoryBlock08