Split GetPointer into two versions, to help with const correctness

This commit is contained in:
Henrik Rydgård
2022-07-20 12:40:22 +02:00
parent d2a3918f5f
commit e6403d7157
43 changed files with 169 additions and 156 deletions

View File

@@ -28,19 +28,19 @@
namespace Memory {
u8 *GetPointer(const u32 address) {
u8 *GetPointerWrite(const u32 address) {
if ((address & 0x3E000000) == 0x08000000) {
// RAM
return GetPointerUnchecked(address);
return GetPointerWriteUnchecked(address);
} else if ((address & 0x3F800000) == 0x04000000) {
// VRAM
return GetPointerUnchecked(address);
return GetPointerWriteUnchecked(address);
} else if ((address & 0xBFFFC000) == 0x00010000) {
// Scratchpad
return GetPointerUnchecked(address);
return GetPointerWriteUnchecked(address);
} else if ((address & 0x3F000000) >= 0x08000000 && (address & 0x3F000000) < 0x08000000 + g_MemorySize) {
// More RAM (remasters, etc.)
return GetPointerUnchecked(address);
return GetPointerWriteUnchecked(address);
} else {
static bool reported = false;
if (!reported) {
@@ -52,6 +52,10 @@ u8 *GetPointer(const u32 address) {
}
}
const u8 *GetPointer(const u32 address) {
return (const u8 *)GetPointerWrite(address);
}
template <typename T>
inline void ReadFromHardware(T &var, const u32 address) {
// TODO: Figure out the fastest order of tests for both read and write (they are probably different).