Start adding memory stuff

This commit is contained in:
wheremyfoodat 2022-09-15 13:35:15 +03:00
parent 2057e0c447
commit 905c7ed770
8 changed files with 77 additions and 10 deletions

23
src/core/memory.cpp Normal file
View file

@ -0,0 +1,23 @@
#include "memory.hpp"
Memory::Memory() {
fcram = new uint8_t[128_MB]();
}
void* Memory::getReadPointer(u32 address) {
const auto page = address >> pageShift;
const auto offset = address & pageMask;
uintptr_t pointer = readTable[page];
if (pointer == 0) return nullptr;
return (void*)(pointer + offset);
}
void* Memory::getWritePointer(u32 address) {
const auto page = address >> pageShift;
const auto offset = address & pageMask;
uintptr_t pointer = writeTable[page];
if (pointer == 0) return nullptr;
return (void*)(pointer + offset);
}