summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2015-09-10 05:23:44 +0200
committerLioncash <mathew1800@gmail.com>2015-09-10 06:09:55 +0200
commit9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244 (patch)
treede78e9052b63c0e791de8c81bacf9e19f4475dfa
parentMerge pull request #1020 from yuriks/qt-binaries (diff)
downloadyuzu-9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244.tar
yuzu-9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244.tar.gz
yuzu-9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244.tar.bz2
yuzu-9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244.tar.lz
yuzu-9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244.tar.xz
yuzu-9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244.tar.zst
yuzu-9cf1cfe3fdfc6a992b81d04cb2d9420deefc6244.zip
-rw-r--r--src/core/memory.cpp21
1 files changed, 7 insertions, 14 deletions
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index cde390b8a..b80795e0c 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -3,6 +3,7 @@
// Refer to the license.txt file included.
#include <array>
+#include <cstring>
#include "common/assert.h"
#include "common/common_types.h"
@@ -95,7 +96,9 @@ template <typename T>
T Read(const VAddr vaddr) {
const u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
if (page_pointer) {
- return *reinterpret_cast<const T*>(page_pointer + (vaddr & PAGE_MASK));
+ T value;
+ std::memcpy(&value, &page_pointer[vaddr & PAGE_MASK], sizeof(T));
+ return value;
}
PageType type = current_page_table->attributes[vaddr >> PAGE_BITS];
@@ -117,7 +120,7 @@ template <typename T>
void Write(const VAddr vaddr, const T data) {
u8* page_pointer = current_page_table->pointers[vaddr >> PAGE_BITS];
if (page_pointer) {
- *reinterpret_cast<T*>(page_pointer + (vaddr & PAGE_MASK)) = data;
+ std::memcpy(&page_pointer[vaddr & PAGE_MASK], &data, sizeof(T));
return;
}
@@ -183,19 +186,9 @@ void Write64(const VAddr addr, const u64 data) {
}
void WriteBlock(const VAddr addr, const u8* data, const size_t size) {
- u32 offset = 0;
- while (offset < (size & ~3)) {
- Write32(addr + offset, *(u32*)&data[offset]);
- offset += 4;
- }
-
- if (size & 2) {
- Write16(addr + offset, *(u16*)&data[offset]);
- offset += 2;
- }
-
- if (size & 1)
+ for (u32 offset = 0; offset < size; offset++) {
Write8(addr + offset, data[offset]);
+ }
}
PAddr VirtualToPhysicalAddress(const VAddr addr) {