From 193bf223ec2b8d3eddf5040161afab90684a5546 Mon Sep 17 00:00:00 2001 From: gdkchan Date: Tue, 18 Sep 2018 01:30:35 -0300 Subject: [PATCH] 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 --- Memory/AMemory.cs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/Memory/AMemory.cs b/Memory/AMemory.cs index 566e6b5..806a0b8 100644 --- a/Memory/AMemory.cs +++ b/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);