aboutsummaryrefslogtreecommitdiff
path: root/ChocolArm64/Memory
diff options
context:
space:
mode:
authorgdkchan <gab.dark.100@gmail.com>2018-09-18 01:30:35 -0300
committerGitHub <noreply@github.com>2018-09-18 01:30:35 -0300
commitd4187aaa9d7194aa26d04aee838edbc3a38f1862 (patch)
tree06fe725c1067b4aeca21749799b835d85e7d2787 /ChocolArm64/Memory
parentbec95cacc1061f91373a1e3a1411981af7fe2e4e (diff)
Allow "reinterpretation" of framebuffer/zeta formats (#418)
* (Re)Implement format reinterpretation, other changes * Implement writeback to guest memory, some refactoring * More refactoring, implement reinterpretation the old way again * Clean up * Some fixes on M2MF (old Dma engine), added partial support for P2MF, fix conditional ssy, add Z24S8 zeta format, other fixes * nit: Formatting * Address PR feedback
Diffstat (limited to 'ChocolArm64/Memory')
-rw-r--r--ChocolArm64/Memory/AMemory.cs29
1 files changed, 29 insertions, 0 deletions
diff --git a/ChocolArm64/Memory/AMemory.cs b/ChocolArm64/Memory/AMemory.cs
index 566e6b54..806a0b86 100644
--- a/ChocolArm64/Memory/AMemory.cs
+++ b/ChocolArm64/Memory/AMemory.cs
@@ -287,6 +287,14 @@ namespace ChocolArm64.Memory
return Data;
}
+ public void ReadBytes(long Position, byte[] Data, int StartIndex, int Size)
+ {
+ //Note: This will be moved later.
+ EnsureRangeIsValid(Position, (uint)Size);
+
+ Marshal.Copy((IntPtr)Translate(Position), Data, StartIndex, Size);
+ }
+
public void WriteSByte(long Position, sbyte Value)
{
WriteByte(Position, (byte)Value);
@@ -403,6 +411,27 @@ namespace ChocolArm64.Memory
Marshal.Copy(Data, 0, (IntPtr)TranslateWrite(Position), Data.Length);
}
+ public void WriteBytes(long Position, byte[] Data, int StartIndex, int Size)
+ {
+ //Note: This will be moved later.
+ //Using Translate instead of TranslateWrite is on purpose.
+ EnsureRangeIsValid(Position, (uint)Size);
+
+ Marshal.Copy(Data, StartIndex, (IntPtr)Translate(Position), Size);
+ }
+
+ public void CopyBytes(long Src, long Dst, long Size)
+ {
+ //Note: This will be moved later.
+ EnsureRangeIsValid(Src, Size);
+ EnsureRangeIsValid(Dst, Size);
+
+ byte* SrcPtr = Translate(Src);
+ byte* DstPtr = TranslateWrite(Dst);
+
+ Buffer.MemoryCopy(SrcPtr, DstPtr, Size, Size);
+ }
+
public void Map(long VA, long PA, long Size)
{
SetPTEntries(VA, RamPtr + PA, Size);