diff options
author | gdkchan <gab.dark.100@gmail.com> | 2018-11-17 02:01:31 -0200 |
---|---|---|
committer | Ac_K <Acoustik666@gmail.com> | 2018-11-17 05:01:31 +0100 |
commit | d2bb458b51bbcbc097f8f53ac2a3b8b15a723a45 (patch) | |
tree | 943f74d8edaf99c538eeaeeee01d8c5c55e5eec8 /ChocolArm64/Memory/MemoryManager.cs | |
parent | b833183ef640934e82106cb91f7ced65d81e3b07 (diff) |
Improved GPU command lists decoding (#499)
* Better implementation of the DMA pusher, misc fixes
* Remove some debug code
* Correct RGBX8 format
* Add support for linked Texture Sampler Control
* Attempt to fix upside down screen issue
Diffstat (limited to 'ChocolArm64/Memory/MemoryManager.cs')
-rw-r--r-- | ChocolArm64/Memory/MemoryManager.cs | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/ChocolArm64/Memory/MemoryManager.cs b/ChocolArm64/Memory/MemoryManager.cs index 308dd17e..ef3fb006 100644 --- a/ChocolArm64/Memory/MemoryManager.cs +++ b/ChocolArm64/Memory/MemoryManager.cs @@ -409,9 +409,31 @@ namespace ChocolArm64.Memory public void WriteBytes(long position, byte[] data) { - EnsureRangeIsValid(position, (uint)data.Length); + long endAddr = position + data.Length; - Marshal.Copy(data, 0, (IntPtr)TranslateWrite(position), data.Length); + if ((ulong)endAddr < (ulong)position) + { + throw new ArgumentOutOfRangeException(nameof(position)); + } + + int offset = 0; + + while ((ulong)position < (ulong)endAddr) + { + long pageLimit = (position + PageSize) & ~(long)PageMask; + + if ((ulong)pageLimit > (ulong)endAddr) + { + pageLimit = endAddr; + } + + int copySize = (int)(pageLimit - position); + + Marshal.Copy(data, offset, (IntPtr)TranslateWrite(position), copySize); + + position += copySize; + offset += copySize; + } } public void WriteBytes(long position, byte[] data, int startIndex, int size) |